From 6775ecdfd261dbbe28ede07e01a593f992304491 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier <fredfgfs01@free.fr> Date: Tue, 1 May 2012 09:34:14 +0200 Subject: [PATCH] Display the depth buffer when stored in a color texture --- Shaders/display.frag | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Shaders/display.frag b/Shaders/display.frag index 038369bc7..acb54c65e 100644 --- a/Shaders/display.frag +++ b/Shaders/display.frag @@ -7,6 +7,7 @@ uniform sampler2D lighting_tex; //uniform sampler2D ao_tex; uniform float exposure; uniform bool showBuffers; +uniform bool fg_DepthInColor; vec3 HDR(vec3 L) { L = L * exposure; @@ -19,22 +20,22 @@ vec3 HDR(vec3 L) { void main() { vec2 coords = gl_TexCoord[0].xy; vec4 color; - if (showBuffers) { - if (coords.x < 0.2 && coords.y < 0.2) { - color = texture2D( normal_tex, coords * 5.0 ); - } else if (coords.x >= 0.8 && coords.y >= 0.8) { - color = texture2D( specular_tex, (coords - vec2( 0.8, 0.8 )) * 5.0 ); - } else if (coords.x >= 0.8 && coords.y < 0.2) { - color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 ); -// } else if (coords.x < 0.2 && coords.y >= 0.8) { -// color = texture2D( ao_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 ); - } else { - color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; - //color = vec4( HDR( color.rgb ), 1.0 ); - } - } else { - color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; - //color = vec4( HDR( color.rgb ), 1.0 ); - } + if (showBuffers) { + if (coords.x < 0.2 && coords.y < 0.2) { + color = texture2D( normal_tex, coords * 5.0 ); + } else if (coords.x >= 0.8 && coords.y >= 0.8) { + color = texture2D( specular_tex, (coords - vec2( 0.8, 0.8 )) * 5.0 ); + } else if (coords.x >= 0.8 && coords.y < 0.2) { + color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 ); + } else if (coords.x < 0.2 && coords.y >= 0.8 && fg_DepthInColor) { + color = texture2D( depth_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 ); + } else { + color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; + //color = vec4( HDR( color.rgb ), 1.0 ); + } + } else { + color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; + //color = vec4( HDR( color.rgb ), 1.0 ); + } gl_FragColor = color; }