1
0
Fork 0

Allow to adjust ambient occlusion strength

This commit is contained in:
Frederic Bouvier 2012-05-18 09:00:48 +02:00
parent e21807bb33
commit 58c5a389ce
5 changed files with 65 additions and 19 deletions

View file

@ -3,6 +3,7 @@
<name>Effects/ambient</name> <name>Effects/ambient</name>
<parameters> <parameters>
<ambient-occlusion type="bool"><use>/sim/rendering/rembrandt/ambient-occlusion</use></ambient-occlusion> <ambient-occlusion type="bool"><use>/sim/rendering/rembrandt/ambient-occlusion</use></ambient-occlusion>
<ambient-occlusion-strength type="float"><use>/sim/rendering/rembrandt/ambient-occlusion-strength</use></ambient-occlusion-strength>
</parameters> </parameters>
<technique n="11"> <technique n="11">
<pass> <pass>
@ -71,7 +72,12 @@
<uniform> <uniform>
<name>ambientOcclusion</name> <name>ambientOcclusion</name>
<type>bool</type> <type>bool</type>
<value type="bool"><use>ambient-occlusion</use></value> <value><use>ambient-occlusion</use></value>
</uniform>
<uniform>
<name>ambientOcclusionStrength</name>
<type>float</type>
<value><use>ambient-occlusion-strength</use></value>
</uniform> </uniform>
<!-- The following uniforms are automatically defined and initialized : <!-- The following uniforms are automatically defined and initialized :
- fg_SunAmbientColor - fg_SunAmbientColor

View file

@ -4,6 +4,8 @@ uniform sampler2D normal_tex;
uniform sampler2D spec_emis_tex; uniform sampler2D spec_emis_tex;
uniform vec4 fg_SunAmbientColor; uniform vec4 fg_SunAmbientColor;
uniform bool ambientOcclusion; uniform bool ambientOcclusion;
uniform float ambientOcclusionStrength;
void main() { void main() {
vec2 coords = gl_TexCoord[0].xy; vec2 coords = gl_TexCoord[0].xy;
float initialized = texture2D( spec_emis_tex, coords ).a; float initialized = texture2D( spec_emis_tex, coords ).a;
@ -12,7 +14,7 @@ void main() {
vec3 tcolor = texture2D( color_tex, coords ).rgb; vec3 tcolor = texture2D( color_tex, coords ).rgb;
float ao = 1.0; float ao = 1.0;
if (ambientOcclusion) { if (ambientOcclusion) {
ao = texture2D( ao_tex, coords ).r; ao = 1.0 - ambientOcclusionStrength * (1.0 - texture2D( ao_tex, coords ).r);
} }
gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb*ao, 1.0); gl_FragColor = vec4(tcolor * fg_SunAmbientColor.rgb * ao, 1.0);
} }

View file

@ -222,7 +222,7 @@
<command>dialog-apply</command> <command>dialog-apply</command>
<object-name>random-objects</object-name> <object-name>random-objects</object-name>
</binding> </binding>
</checkbox> </checkbox>
<checkbox> <checkbox>
<halign>left</halign> <halign>left</halign>
@ -306,13 +306,13 @@
</text> </text>
</group> </group>
<button> <button>
<legend>Reload Scenery</legend> <legend>Reload Scenery</legend>
<binding> <binding>
<command>reinit</command> <command>reinit</command>
<subsystem>tile-manager</subsystem> <subsystem>tile-manager</subsystem>
</binding> </binding>
</button> </button>
<group> <group>
<layout>vbox</layout> <layout>vbox</layout>
@ -568,7 +568,10 @@
<object-name>bloom</object-name> <object-name>bloom</object-name>
</binding> </binding>
<visible> <visible>
<property>/sim/rendering/rembrandt/enabled</property> <and>
<property>/sim/rendering/rembrandt/enabled</property>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</and>
</visible> </visible>
</checkbox> </checkbox>
@ -582,10 +585,53 @@
<object-name>occlusion</object-name> <object-name>occlusion</object-name>
</binding> </binding>
<visible> <visible>
<property>/sim/rendering/rembrandt/enabled</property> <and>
<property>/sim/rendering/rembrandt/enabled</property>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</and>
</visible> </visible>
</checkbox> </checkbox>
<group>
<layout>hbox</layout>
<halign>right</halign>
<visible>
<and>
<property>/sim/rendering/rembrandt/enabled</property>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</and>
</visible>
<text>
<label>Ambient occlusion strength</label>
<enable>
<property>/sim/rendering/rembrandt/ambient-occlusion</property>
</enable>
</text>
<slider>
<name>ambient-occlusion-strength</name>
<enable>
<property>/sim/rendering/rembrandt/ambient-occlusion</property>
</enable>
<min>0.0</min>
<max>1.0</max>
<step>0.05</step>
<property>/sim/rendering/rembrandt/ambient-occlusion-strength</property>
<binding>
<command>dialog-apply</command>
<object-name>ambient-occlusion-strength</object-name>
</binding>
</slider>
<text>
<enable>
<property>/sim/rendering/rembrandt/ambient-occlusion</property>
</enable>
<label>12345678</label>
<format>%.1f</format>
<live>true</live>
<property>/sim/rendering/rembrandt/ambient-occlusion-strength</property>
</text>
</group>
<checkbox> <checkbox>
<halign>left</halign> <halign>left</halign>
<label>Shadows</label> <label>Shadows</label>

View file

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

View file

@ -69,6 +69,7 @@ Started September 2000 by David Megginson, david@megginson.com
<renderer>default-pipeline</renderer> <renderer>default-pipeline</renderer>
<show-buffers type="bool" userarchive="y">false</show-buffers> <show-buffers type="bool" userarchive="y">false</show-buffers>
<ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion> <ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion>
<ambient-occlusion-strength type="float" userarchive="y">1.0</ambient-occlusion-strength>
<ambient-occlusion-buffers type="bool">true</ambient-occlusion-buffers> <ambient-occlusion-buffers type="bool">true</ambient-occlusion-buffers>
<bloom type="bool" userarchive="y">true</bloom> <bloom type="bool" userarchive="y">true</bloom>
<bloom-buffers type="bool">true</bloom-buffers> <bloom-buffers type="bool">true</bloom-buffers>