1
0
Fork 0

Add condition on ambient occlusion and a menu item to switch it on and off if the stage is enabled in the pipeline

This commit is contained in:
Frederic Bouvier 2012-05-12 00:29:40 +02:00
parent 7d573e3292
commit 1a5cc682a9
9 changed files with 76 additions and 5 deletions

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>Effects/ambient</name>
<parameters>
<ambient-occlusion type="bool"><use>/sim/rendering/rembrandt/ambient-occlusion</use></ambient-occlusion>
</parameters>
<technique n="11">
<pass>
<lighting>false</lighting>
@ -65,6 +68,11 @@
<type>sampler-2d</type>
<value type="int">4</value>
</uniform>
<uniform>
<name>ambientOcclusion</name>
<type>bool</type>
<value type="bool"><use>ambient-occlusion</use></value>
</uniform>
<!-- The following uniforms are automatically defined and initialized :
- fg_SunAmbientColor
- fg_SunDiffuseColor

View file

@ -12,6 +12,12 @@
</buffer>
<buffer>
<name>normal</name>
<condition>
<equal>
<value type="bool">true</value>
<property>/sim/rendering/rembrandt/no-16bit-buffer</property>
</equal>
</condition>
<internal-format>rgba8</internal-format>
<source-format>rgba</source-format>
<source-type>unsigned-byte</source-type>
@ -20,6 +26,22 @@
<scale-factor>1.0</scale-factor>
<wrap-mode>clamp-to-border</wrap-mode>
</buffer>
<buffer>
<name>normal</name>
<condition>
<equal>
<value type="bool">false</value>
<property>/sim/rendering/rembrandt/no-16bit-buffer</property>
</equal>
</condition>
<internal-format>rg16</internal-format>
<source-format>rg</source-format>
<source-type>unsigned-short</source-type>
<width>screen</width>
<height>screen</height>
<scale-factor>1.0</scale-factor>
<wrap-mode>clamp-to-border</wrap-mode>
</buffer>
<buffer>
<name>shadow</name>
<internal-format>depth-component32</internal-format>
@ -55,6 +77,9 @@
</buffer>
<buffer>
<name>ao-1</name>
<condition>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</condition>
<internal-format>rgba8</internal-format>
<source-format>rgba</source-format>
<source-type>unsigned-byte</source-type>
@ -65,6 +90,9 @@
</buffer>
<buffer>
<name>ao-2</name>
<condition>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</condition>
<internal-format>rgba8</internal-format>
<source-format>rgba</source-format>
<source-type>unsigned-byte</source-type>
@ -75,6 +103,9 @@
</buffer>
<buffer>
<name>ao-3</name>
<condition>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</condition>
<internal-format>rgba8</internal-format>
<source-format>rgba</source-format>
<source-type>unsigned-byte</source-type>
@ -126,6 +157,9 @@
<stage>
<name>ssao-1</name>
<type>fullscreen</type>
<condition>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</condition>
<order-num>2</order-num>
<effect>Effects/ssao</effect>
<needs-du-dv>true</needs-du-dv>
@ -138,6 +172,9 @@
<stage>
<name>ssao-2</name>
<type>fullscreen</type>
<condition>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</condition>
<order-num>3</order-num>
<effect>Effects/ssao-blur-1</effect>
<scale-factor>0.25</scale-factor>
@ -149,6 +186,9 @@
<stage>
<name>ssao-3</name>
<type>fullscreen</type>
<condition>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</condition>
<order-num>4</order-num>
<effect>Effects/ssao-blur-2</effect>
<scale-factor>0.25</scale-factor>

View file

@ -4,6 +4,7 @@
<parameters>
<exposure type="float"><use>/sim/rendering/rembrandt/exposure</use></exposure>
<show-buffers type="bool"><use>/sim/rendering/rembrandt/show-buffers</use></show-buffers>
<ambient-occlusion type="bool"><use>/sim/rendering/rembrandt/ambient-occlusion-buffers</use></ambient-occlusion>
</parameters>
<technique n="11">
<pass>
@ -85,6 +86,11 @@
<type>bool</type>
<value type="bool"><use>show-buffers</use></value>
</uniform>
<uniform>
<name>ambientOcclusion</name>
<type>bool</type>
<value type="bool"><use>ambient-occlusion</use></value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -155,7 +155,8 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
}
menuEnable("autopilot", isAutopilotMenuEnabled() );
menuEnable("joystick-info", size(props.globals.getNode("/input/joysticks").getChildren("js")));
menuEnable("rendering-buffers", getprop("/sim/rendering/rembrandt"));
menuEnable("ambient-occlusion", getprop("/sim/rendering/rembrandt/enabled") and getprop("/sim/rendering/rembrandt/ambient-occlusion-buffers"));
menuEnable("rendering-buffers", getprop("/sim/rendering/rembrandt/enabled"));
# frame-per-second display
var fps = props.globals.getNode("/sim/rendering/fps-display", 1);

View file

@ -3,13 +3,16 @@ uniform sampler2D ao_tex;
uniform sampler2D normal_tex;
uniform sampler2D spec_emis_tex;
uniform vec4 fg_SunAmbientColor;
uniform bool ambientOcclusion;
void main() {
vec2 coords = gl_TexCoord[0].xy;
float initialized = texture2D( spec_emis_tex, coords ).a;
if ( initialized < 0.1 )
discard;
vec3 tcolor = texture2D( color_tex, coords ).rgb;
float ao = texture2D( ao_tex, coords ).r;
float ao = 1.0;
if (ambientOcclusion) {
ao = texture2D( ao_tex, coords ).r;
}
gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb*ao, 1.0);
// gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb, 1.0);
}

View file

@ -8,6 +8,7 @@ uniform sampler2D ao_tex;
uniform float exposure;
uniform bool showBuffers;
uniform bool fg_DepthInColor;
uniform bool ambientOcclusion;
vec3 HDR(vec3 L) {
L = L * exposure;
@ -29,7 +30,7 @@ void main() {
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 if (coords.x < 0.2 && coords.y >= 0.8) {
} else if (coords.x < 0.2 && coords.y >= 0.8 && ambientOcclusion) {
color = texture2D( ao_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 );
} else {
color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */;

View file

@ -99,6 +99,7 @@
<logging>Logging</logging>
<local_weather>Local Weather (Test)</local_weather>
<print-scene-info>Print Visible Scene Info</print-scene-info>
<ambient-occlusion>Hide/Show Ambient occlusion</ambient-occlusion>
<rendering-buffers>Hide/Show Rendering Buffers</rendering-buffers>
<!-- Help menu -->

View file

@ -658,6 +658,15 @@
</binding>
</item>
<item>
<name>ambient-occlusion</name>
<binding>
<command>property-toggle</command>
<property>/sim/rendering/rembrandt/ambient-occlusion</property>
</binding>
<enabled>false</enabled>
</item>
<item>
<name>rendering-buffers</name>
<binding>

View file

@ -67,10 +67,12 @@ Started September 2000 by David Megginson, david@megginson.com
<rembrandt>
<enabled type="bool">false</enabled>
<renderer>default-pipeline</renderer>
<show-buffers type="bool" userarchive="y">true</show-buffers>
<show-buffers type="bool" userarchive="y">false</show-buffers>
<ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion>
<ambient-occlusion-buffers type="bool">true</ambient-occlusion-buffers>
<exposure type="float" userarchive="y">1.0</exposure>
<use-color-for-depth type="bool">false</use-color-for-depth>
<no-16bit-buffer type="bool">false</no-16bit-buffer>
</rembrandt>
<debug type="bool">false</debug>
<realism type="int">5</realism>