diff --git a/Effects/display.eff b/Effects/display.eff index 1b82c6f4d..1fbf93ddf 100644 --- a/Effects/display.eff +++ b/Effects/display.eff @@ -2,11 +2,17 @@ Effects/display - /sim/rendering/rembrandt/exposure /sim/rendering/rembrandt/show-buffers /sim/rendering/rembrandt/bloom /sim/rendering/rembrandt/bloom-strength /sim/rendering/rembrandt/bloom-buffers + + Textures\noise_tex.jpg + linear-mipmap-linear + repeat + repeat + normalized + /sim/rendering/rembrandt/debug-buffer[0]/enabled /sim/rendering/rembrandt/debug-buffer[0]/name @@ -17,6 +23,97 @@ /sim/rendering/rembrandt/debug-buffer[3]/enabled /sim/rendering/rembrandt/debug-buffer[3]/name + + + + /sim/rendering/rembrandt/night-vision + + 0.0 + /sim/rendering/rembrandt/show-buffers + + + + + + 99999 + RenderBin + + + 0 + buffer + lighting + + + 1 + buffer + bloom-3 + + + 2 + buffer + spec-emis + + + 3 + buffer + diffuse + + + 4 + texture[0]/image + texture[0]/filter + texture[0]/wrap-s + texture[0]/wrap-t + texture[0]/internal-format + + + + Shaders/fullscreen.vert + Shaders/night-vision.frag + + + lighting_tex + sampler-2d + 0 + + + bloom_tex + sampler-2d + 1 + + + spec_emis_tex + sampler-2d + 2 + + + color_tex + sampler-2d + 3 + + + noise_tex + sampler-2d + 4 + + + + bloomEnabled + bool + bloom + + + bloomStrength + float + bloom-strength + + + bloomBuffers + bool + bloom-buffers + + + @@ -89,11 +186,6 @@ sampler-2d 5 - - exposure - float - exposure - showBuffers bool diff --git a/Shaders/display.frag b/Shaders/display.frag index 66205cd1b..3c07b9ec8 100644 --- a/Shaders/display.frag +++ b/Shaders/display.frag @@ -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; } diff --git a/Shaders/night-vision.frag b/Shaders/night-vision.frag new file mode 100644 index 000000000..86488b0d6 --- /dev/null +++ b/Shaders/night-vision.frag @@ -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; +} diff --git a/Textures/noise_tex.jpg b/Textures/noise_tex.jpg new file mode 100644 index 000000000..bad5ffd74 Binary files /dev/null and b/Textures/noise_tex.jpg differ diff --git a/gui/dialogs/rembrandt.xml b/gui/dialogs/rembrandt.xml index 7a6a2ed6b..65b1716bd 100644 --- a/gui/dialogs/rembrandt.xml +++ b/gui/dialogs/rembrandt.xml @@ -152,9 +152,9 @@ - + - + hbox left @@ -377,6 +377,24 @@ + + hbox + left + + + left + + night-vision + /sim/rendering/rembrandt/night-vision + + dialog-apply + night-vision + + + + + + hbox diff --git a/preferences.xml b/preferences.xml index da199b548..b115350ad 100644 --- a/preferences.xml +++ b/preferences.xml @@ -72,6 +72,7 @@ Started September 2000 by David Megginson, david@megginson.com true 1.0 true + false 1.0 false true