From f9ad6fa902c1167d7622ee7af2617d14b62bee21 Mon Sep 17 00:00:00 2001 From: pryazha Date: Wed, 19 Feb 2025 22:26:48 +0500 Subject: quite a lot of changes that I, of course, are not going to describe;) --- .../3.1.shadow_mapping/shaders/debug_quad.frag | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 advanced_lighting/3.1.shadow_mapping/shaders/debug_quad.frag (limited to 'advanced_lighting/3.1.shadow_mapping/shaders/debug_quad.frag') diff --git a/advanced_lighting/3.1.shadow_mapping/shaders/debug_quad.frag b/advanced_lighting/3.1.shadow_mapping/shaders/debug_quad.frag new file mode 100644 index 0000000..4cb6df1 --- /dev/null +++ b/advanced_lighting/3.1.shadow_mapping/shaders/debug_quad.frag @@ -0,0 +1,25 @@ +#version 330 core + +in vec2 tex_coords; + +out vec4 frag_color; + +uniform sampler2D depth_map; +uniform float near; +uniform float far; + +float linearize_depth(float depth) +{ + float z = (depth+1.0)*0.5; + return((2.0*near*far)/(far+near-z*(far-near))); +} + +void main(void) +{ + float depth = texture(depth_map, tex_coords).r; + + /* frag_color = vec4(vec3(depth), 1.0); */ + + /* NOTE(pryazha): For visual debugging of perspective projection light */ + frag_color = vec4(vec3(linearize_depth(depth)/far), 1.0); +} -- cgit v1.2.3