Add an effect for the final display stage of the Rembrandt renderer
This commit is contained in:
parent
874c1223fb
commit
4334e98e1d
3 changed files with 119 additions and 0 deletions
75
Effects/display.eff
Normal file
75
Effects/display.eff
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PropertyList>
|
||||
<name>Effects/display</name>
|
||||
<parameters>
|
||||
<exposure type="float"><use>/sim/rendering/exposure</use></exposure>
|
||||
<show-buffers type="bool"><use>/sim/rendering/show-buffers</use></show-buffers>
|
||||
</parameters>
|
||||
<technique n="11">
|
||||
<pass>
|
||||
<render-bin>
|
||||
<bin-number>99999</bin-number>
|
||||
<bin-name>RenderBin</bin-name>
|
||||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<type>depth-buffer</type>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>1</unit>
|
||||
<type>normal-buffer</type>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>2</unit>
|
||||
<type>diffuse-buffer</type>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>3</unit>
|
||||
<type>spec-emis-buffer</type>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>4</unit>
|
||||
<type>lighting-buffer</type>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/display.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/display.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>depth_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>normal_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">1</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>color_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">2</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>specular_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">3</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>lighting_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">4</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>exposure</name>
|
||||
<type>float</type>
|
||||
<value type="float"><use>exposure</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>showBuffers</name>
|
||||
<type>bool</type>
|
||||
<value type="bool"><use>show-buffers</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
40
Shaders/display.frag
Normal file
40
Shaders/display.frag
Normal file
|
@ -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;
|
||||
}
|
4
Shaders/display.vert
Normal file
4
Shaders/display.vert
Normal file
|
@ -0,0 +1,4 @@
|
|||
void main() {
|
||||
gl_Position = gl_Vertex;
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
}
|
Loading…
Reference in a new issue