diff --git a/Effects/display.eff b/Effects/display.eff new file mode 100644 index 000000000..d403eb68e --- /dev/null +++ b/Effects/display.eff @@ -0,0 +1,75 @@ + + + Effects/display + + /sim/rendering/exposure + /sim/rendering/show-buffers + + + + + 99999 + RenderBin + + + 0 + depth-buffer + + + 1 + normal-buffer + + + 2 + diffuse-buffer + + + 3 + spec-emis-buffer + + + 4 + lighting-buffer + + + Shaders/display.vert + Shaders/display.frag + + + depth_tex + sampler-2d + 0 + + + normal_tex + sampler-2d + 1 + + + color_tex + sampler-2d + 2 + + + specular_tex + sampler-2d + 3 + + + lighting_tex + sampler-2d + 4 + + + exposure + float + exposure + + + showBuffers + bool + show-buffers + + + + diff --git a/Shaders/display.frag b/Shaders/display.frag new file mode 100644 index 000000000..038369bc7 --- /dev/null +++ b/Shaders/display.frag @@ -0,0 +1,40 @@ +uniform sampler2D depth_tex; +uniform sampler2D normal_tex; +uniform sampler2D color_tex; +uniform sampler2D specular_tex; +uniform sampler2D lighting_tex; +//uniform sampler2D bloom_tex; +//uniform sampler2D ao_tex; +uniform float exposure; +uniform bool showBuffers; + +vec3 HDR(vec3 L) { + L = L * exposure; + L.r = L.r < 1.413 ? pow(L.r * 0.38317, 1.0 / 2.2) : 1.0 - exp(-L.r); + L.g = L.g < 1.413 ? pow(L.g * 0.38317, 1.0 / 2.2) : 1.0 - exp(-L.g); + L.b = L.b < 1.413 ? pow(L.b * 0.38317, 1.0 / 2.2) : 1.0 - exp(-L.b); + return 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 ); + } + gl_FragColor = color; +} diff --git a/Shaders/display.vert b/Shaders/display.vert new file mode 100644 index 000000000..f01ebba78 --- /dev/null +++ b/Shaders/display.vert @@ -0,0 +1,4 @@ +void main() { + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +}