Night vision post processing effect in Rembrandt
This commit is contained in:
parent
46b6ab02af
commit
6013f3360e
6 changed files with 161 additions and 19 deletions
|
@ -2,11 +2,17 @@
|
|||
<PropertyList>
|
||||
<name>Effects/display</name>
|
||||
<parameters>
|
||||
<exposure type="float"><use>/sim/rendering/rembrandt/exposure</use></exposure>
|
||||
<show-buffers type="bool"><use>/sim/rendering/rembrandt/show-buffers</use></show-buffers>
|
||||
<bloom type="bool"><use>/sim/rendering/rembrandt/bloom</use></bloom>
|
||||
<bloom-strength type="float"><use>/sim/rendering/rembrandt/bloom-strength</use></bloom-strength>
|
||||
<bloom-buffers type="bool"><use>/sim/rendering/rembrandt/bloom-buffers</use></bloom-buffers>
|
||||
<texture n="0">
|
||||
<image>Textures\noise_tex.jpg</image>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>repeat</wrap-s>
|
||||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
|
||||
<buffer-nw-enabled><use>/sim/rendering/rembrandt/debug-buffer[0]/enabled</use></buffer-nw-enabled>
|
||||
<buffer-nw-name><use>/sim/rendering/rembrandt/debug-buffer[0]/name</use></buffer-nw-name>
|
||||
|
@ -17,6 +23,97 @@
|
|||
<buffer-se-enabled><use>/sim/rendering/rembrandt/debug-buffer[3]/enabled</use></buffer-se-enabled>
|
||||
<buffer-se-name><use>/sim/rendering/rembrandt/debug-buffer[3]/name</use></buffer-se-name>
|
||||
</parameters>
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/rembrandt/night-vision</property>
|
||||
<equal>
|
||||
<value type="float">0.0</value>
|
||||
<float-property>/sim/rendering/rembrandt/show-buffers</float-property>
|
||||
</equal>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass>
|
||||
<render-bin>
|
||||
<bin-number>99999</bin-number>
|
||||
<bin-name>RenderBin</bin-name>
|
||||
</render-bin>
|
||||
<texture-unit>
|
||||
<unit>0</unit>
|
||||
<type>buffer</type>
|
||||
<name>lighting</name>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>1</unit>
|
||||
<type>buffer</type>
|
||||
<name>bloom-3</name>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>2</unit>
|
||||
<type>buffer</type>
|
||||
<name>spec-emis</name>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>3</unit>
|
||||
<type>buffer</type>
|
||||
<name>diffuse</name>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>4</unit>
|
||||
<image><use>texture[0]/image</use></image>
|
||||
<filter><use>texture[0]/filter</use></filter>
|
||||
<wrap-s><use>texture[0]/wrap-s</use></wrap-s>
|
||||
<wrap-t><use>texture[0]/wrap-t</use></wrap-t>
|
||||
<internal-format><use>texture[0]/internal-format</use></internal-format>
|
||||
</texture-unit>
|
||||
|
||||
<program>
|
||||
<vertex-shader>Shaders/fullscreen.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/night-vision.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>lighting_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>bloom_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">1</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>spec_emis_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">2</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>color_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">3</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>noise_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">4</value>
|
||||
</uniform>
|
||||
|
||||
<uniform>
|
||||
<name>bloomEnabled</name>
|
||||
<type>bool</type>
|
||||
<value type="bool"><use>bloom</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>bloomStrength</name>
|
||||
<type>float</type>
|
||||
<value><use>bloom-strength</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>bloomBuffers</name>
|
||||
<type>bool</type>
|
||||
<value><use>bloom-buffers</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
<technique n="11">
|
||||
<pass>
|
||||
<render-bin>
|
||||
|
@ -89,11 +186,6 @@
|
|||
<type>sampler-2d</type>
|
||||
<value type="int">5</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>exposure</name>
|
||||
<type>float</type>
|
||||
<value type="float"><use>exposure</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>showBuffers</name>
|
||||
<type>bool</type>
|
||||
|
|
|
@ -6,7 +6,6 @@ uniform sampler2D bufferNE_tex;
|
|||
uniform sampler2D bufferSW_tex;
|
||||
uniform sampler2D bufferSE_tex;
|
||||
|
||||
uniform float exposure;
|
||||
uniform bool showBuffers;
|
||||
|
||||
uniform bool bloomEnabled;
|
||||
|
@ -18,14 +17,6 @@ uniform bool bufferNE_enabled;
|
|||
uniform bool bufferSW_enabled;
|
||||
uniform bool bufferSE_enabled;
|
||||
|
||||
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;
|
||||
|
@ -42,13 +33,11 @@ void main() {
|
|||
color = texture2D( lighting_tex, coords );
|
||||
if (bloomEnabled && bloomBuffers)
|
||||
color = color + bloomStrength * texture2D( bloom_tex, coords );
|
||||
//color = vec4( HDR( color.rgb ), 1.0 );
|
||||
}
|
||||
} else {
|
||||
color = texture2D( lighting_tex, coords );
|
||||
if (bloomEnabled && bloomBuffers)
|
||||
color = color + bloomStrength * texture2D( bloom_tex, coords );
|
||||
//color = vec4( HDR( color.rgb ), 1.0 );
|
||||
}
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
|
42
Shaders/night-vision.frag
Normal file
42
Shaders/night-vision.frag
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Night vision effect inspired by http://www.geeks3d.com/20091009/shader-library-night-vision-post-processing-filter-glsl/
|
||||
|
||||
uniform sampler2D color_tex;
|
||||
uniform sampler2D lighting_tex;
|
||||
uniform sampler2D bloom_tex;
|
||||
uniform sampler2D spec_emis_tex;
|
||||
uniform sampler2D noise_tex;
|
||||
|
||||
uniform bool bloomEnabled;
|
||||
uniform float bloomStrength;
|
||||
uniform bool bloomBuffers;
|
||||
|
||||
uniform vec2 fg_BufferSize;
|
||||
uniform float osg_SimulationTime;
|
||||
|
||||
void main() {
|
||||
vec2 coords = gl_TexCoord[0].xy;
|
||||
vec4 color;
|
||||
vec2 uv;
|
||||
uv.x = 0.4*sin(osg_SimulationTime*50.0);
|
||||
uv.y = 0.4*cos(osg_SimulationTime*50.0);
|
||||
vec3 n = texture2D(noise_tex, (coords*3.5) + uv).rgb;
|
||||
|
||||
vec2 c1 = coords + (n.xy*0.005);
|
||||
color = texture2D( lighting_tex, c1 );
|
||||
if (bloomEnabled && bloomBuffers)
|
||||
color = color + bloomStrength * texture2D( bloom_tex, c1 );
|
||||
|
||||
float lum = dot(color.rgb, vec3(.3, .59, .11));
|
||||
color.rgb *= (4.0 - 3.0*smoothstep(0.2, 0.3, lum));
|
||||
|
||||
// color.rgb += texture2D( spec_emis_tex, c1 ).b;
|
||||
// color.rgb += texture2D( bloom_tex, c1 ).rgb;
|
||||
color.rgb = (color.rgb + (n*0.2)) * vec3(0.1, 0.95, 0.2);
|
||||
|
||||
vec2 c = 2.0 * coords - vec2(1.,1.);
|
||||
c = c * vec2( 1.0, fg_BufferSize.y / fg_BufferSize.x );
|
||||
float l = length(c);
|
||||
float f = smoothstep( 0.7, 1.1, l );
|
||||
color.rgb = (1 - f) * color.rgb;
|
||||
gl_FragColor = color;
|
||||
}
|
BIN
Textures/noise_tex.jpg
Normal file
BIN
Textures/noise_tex.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
|
@ -152,9 +152,9 @@
|
|||
</enable>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
|
||||
<hrule/>
|
||||
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>left</halign>
|
||||
|
@ -377,6 +377,24 @@
|
|||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>left</halign>
|
||||
|
||||
<checkbox>
|
||||
<halign>left</halign>
|
||||
<label>Night vision</label>
|
||||
<name>night-vision</name>
|
||||
<property>/sim/rendering/rembrandt/night-vision</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>night-vision</object-name>
|
||||
</binding>
|
||||
</checkbox>
|
||||
</group>
|
||||
|
||||
<hrule/>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<bloom type="bool" userarchive="y">true</bloom>
|
||||
<bloom-strength type="float" userarchive="y">1.0</bloom-strength>
|
||||
<bloom-buffers type="bool">true</bloom-buffers>
|
||||
<night-vision type="bool">false</night-vision>
|
||||
<exposure type="float" userarchive="y">1.0</exposure>
|
||||
<use-color-for-depth type="bool">false</use-color-for-depth>
|
||||
<no-16bit-buffer type="bool">true</no-16bit-buffer>
|
||||
|
|
Loading…
Reference in a new issue