diff options
Diffstat (limited to 'res/shaders/line.fs')
| -rw-r--r-- | res/shaders/line.fs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/res/shaders/line.fs b/res/shaders/line.fs new file mode 100644 index 0000000..04cba86 --- /dev/null +++ b/res/shaders/line.fs @@ -0,0 +1,55 @@ +#version 420 core + +uniform vec4 _u_colour; + +layout(std140, binding = 0) uniform _u_globals { + mat4 proj; + mat4 view; + vec4 frustum[6]; + float znear; + float zfar; + float xfov; + float yfov; + int time; + float xwindow; + float ywindow; +}; +layout(binding = 2) uniform sampler2D main_colour; +layout(binding = 3) uniform sampler2D main_depth; + +out vec4 _o_colour; + +vec4 texture_sample(const sampler2D sampler, const vec2 coord) { + return texture(sampler, coord); +} + +float depth_sample(const sampler2D sampler, const vec2 coord) { + return texture(sampler, coord).r; +} + +void main() { + const vec2 coords = vec2(gl_FragCoord.x / xwindow, gl_FragCoord.y / ywindow); + + const float cur_depth = depth_sample(main_depth, coords); + gl_FragDepth = gl_FragCoord.z * 0.9999f; + if (gl_FragDepth > cur_depth) { + discard; + } + + _o_colour = vec4(0.0f, 0.0f, 0.0f, 1.0f); + + // This is for dynamically choosing a higher contrast colour, but it's not + // that nice of an effect so it's commented out. + /* + const vec2 coords = vec2(gl_FragCoord.x / xwindow, gl_FragCoord.y / ywindow); + const float cur_depth = depth_sample(main_depth, coords); + gl_FragDepth = gl_FragCoord.z * 0.9999f; + if (gl_FragDepth > cur_depth) { + discard; + } + + const vec4 cur_tex = texture_sample(main_colour, coords); + const float clr = (1.0f - (cur_tex.r + cur_tex.g + cur_tex.b) / 3.0f) > 0.5f ? 1.0f : 0.0f; + _o_colour = vec4(clr, clr, clr, 1.0f); + */ +} |
