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>
<parameters>
<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>
<technique n="11">
<pass>
@ -71,7 +72,12 @@
<uniform>
<name>ambientOcclusion</name>
<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>
<!-- The following uniforms are automatically defined and initialized :
- fg_SunAmbientColor

View file

@ -4,6 +4,8 @@ uniform sampler2D normal_tex;
uniform sampler2D spec_emis_tex;
uniform vec4 fg_SunAmbientColor;
uniform bool ambientOcclusion;
uniform float ambientOcclusionStrength;
void main() {
vec2 coords = gl_TexCoord[0].xy;
float initialized = texture2D( spec_emis_tex, coords ).a;
@ -12,7 +14,7 @@ void main() {
vec3 tcolor = texture2D( color_tex, coords ).rgb;
float ao = 1.0;
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>
<object-name>random-objects</object-name>
</binding>
</checkbox>
</checkbox>
<checkbox>
<halign>left</halign>
@ -306,13 +306,13 @@
</text>
</group>
<button>
<legend>Reload Scenery</legend>
<button>
<legend>Reload Scenery</legend>
<binding>
<command>reinit</command>
<subsystem>tile-manager</subsystem>
</binding>
</button>
</button>
<group>
<layout>vbox</layout>
@ -568,7 +568,10 @@
<object-name>bloom</object-name>
</binding>
<visible>
<property>/sim/rendering/rembrandt/enabled</property>
<and>
<property>/sim/rendering/rembrandt/enabled</property>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</and>
</visible>
</checkbox>
@ -582,10 +585,53 @@
<object-name>occlusion</object-name>
</binding>
<visible>
<property>/sim/rendering/rembrandt/enabled</property>
<and>
<property>/sim/rendering/rembrandt/enabled</property>
<property>/sim/rendering/rembrandt/ambient-occlusion-buffers</property>
</and>
</visible>
</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>
<halign>left</halign>
<label>Shadows</label>

View file

@ -658,15 +658,6 @@
</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

@ -69,6 +69,7 @@ Started September 2000 by David Megginson, david@megginson.com
<renderer>default-pipeline</renderer>
<show-buffers type="bool" userarchive="y">false</show-buffers>
<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>
<bloom type="bool" userarchive="y">true</bloom>
<bloom-buffers type="bool">true</bloom-buffers>