medfall

A super great game engine
Log | Files | Refs

debug_render_shadow_map.glsl (570B)


      1 uniform sampler2D tex;
      2 
      3 #ifdef VERTEX_SHADER
      4 
      5 in vec2 position;
      6 out vec2 uv;
      7 
      8 void main() {
      9 	gl_Position = vec4( position, 0.0, 1.0 );
     10 	uv.x = ( position.x + 1.0 ) / 0.2;
     11 	uv.y = ( position.y + 1.0 ) / 0.3;
     12 }
     13 
     14 #else
     15 
     16 in vec2 uv;
     17 out vec4 screen_colour;
     18 
     19 float LinearizeDepth(float depth)
     20 {
     21 	float z = depth * 2.0 - 1.0; // Back to NDC
     22 	return (2.0 * 0.1 * 50000.0) / (50000.0 + 0.1 - z * (50000.0 - 0.1));
     23 }
     24 
     25 void main() {
     26 	float Depth = texture( tex, uv ).x;
     27 	Depth = 1.0 - (1.0 - Depth) * 25.0;
     28 	screen_colour = vec4( vec3( LinearizeDepth( Depth ) ), 1.0 );
     29 }
     30 
     31 #endif