blob: d250894b59f826036345b526101ad391eafdc38f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#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);
}
|