1
0
Fork 0

Bugfix - prevent emissive dirt

Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
Vivian Meazza 2011-12-24 15:47:09 +00:00
parent 8f6fabe120
commit 609a3a196d
2 changed files with 56 additions and 53 deletions

View file

@ -7,11 +7,11 @@ please see Docs/README.model-combined.eff for documentation
<inherits-from>Effects/model-default</inherits-from> <inherits-from>Effects/model-default</inherits-from>
<parameters> <parameters>
<!-- Diffuse Texture --> <!-- Diffuse Texture -->
<texture n ="0"> <texture n ="0">
<type>white</type> <type>white</type>
</texture> </texture>
<!-- Normal Map --> <!-- Normal Map -->
<normalmap-enabled type="int">0</normalmap-enabled> <normalmap-enabled type="int">0</normalmap-enabled>
<normalmap-dds type="int">0</normalmap-dds> <normalmap-dds type="int">0</normalmap-dds>
<normalmap-tiling type="float">1.0</normalmap-tiling> <normalmap-tiling type="float">1.0</normalmap-tiling>
@ -22,7 +22,7 @@ please see Docs/README.model-combined.eff for documentation
<wrap-t>clamp</wrap-t> <wrap-t>clamp</wrap-t>
<internal-format>normalized</internal-format> <internal-format>normalized</internal-format>
</texture> </texture>
<!-- Light Map --> <!-- Light Map -->
<lightmap-enabled type="int">0</lightmap-enabled> <lightmap-enabled type="int">0</lightmap-enabled>
<lightmap-multi type="int">0</lightmap-multi> <lightmap-multi type="int">0</lightmap-multi>
<lightmap-factor type="float" n="0">1.0</lightmap-factor> <lightmap-factor type="float" n="0">1.0</lightmap-factor>
@ -40,7 +40,7 @@ please see Docs/README.model-combined.eff for documentation
<wrap-t>clamp</wrap-t> <wrap-t>clamp</wrap-t>
<internal-format>normalized</internal-format> <internal-format>normalized</internal-format>
</texture> </texture>
<!-- Reflection --> <!-- Reflection -->
<reflection-enabled type="int">0</reflection-enabled> <reflection-enabled type="int">0</reflection-enabled>
<reflection-correction type="float">0.0</reflection-correction> <reflection-correction type="float">0.0</reflection-correction>
<reflect-map-enabled type="int">0</reflect-map-enabled> <reflect-map-enabled type="int">0</reflect-map-enabled>
@ -52,7 +52,7 @@ please see Docs/README.model-combined.eff for documentation
<wrap-t>clamp</wrap-t> <wrap-t>clamp</wrap-t>
<internal-format>normalized</internal-format> <internal-format>normalized</internal-format>
</texture> </texture>
<!-- Reflection environment --> <!-- Reflection environment -->
<texture n="5"> <texture n="5">
<type>cubemap</type> <type>cubemap</type>
<!-- use this form for a cube cross --> <!-- use this form for a cube cross -->
@ -88,7 +88,7 @@ please see Docs/README.model-combined.eff for documentation
<internal-format>normalized</internal-format> <internal-format>normalized</internal-format>
</texture> </texture>
<reflection-noise type="float">0.25</reflection-noise> <reflection-noise type="float">0.25</reflection-noise>
<!-- END Reflection --> <!-- END Reflection -->
<!-- Dirt --> <!-- Dirt -->
<dirt-enabled type="int">0</dirt-enabled> <dirt-enabled type="int">0</dirt-enabled>
<dirt-multi type="int">0</dirt-multi> <dirt-multi type="int">0</dirt-multi>
@ -100,7 +100,7 @@ please see Docs/README.model-combined.eff for documentation
<dirt-factor type="float" n="2">0.0</dirt-factor> <dirt-factor type="float" n="2">0.0</dirt-factor>
<!-- ambient correction --> <!-- ambient correction -->
<ambient-correction type="float">0.05</ambient-correction> <ambient-correction type="float">0.05</ambient-correction>
<!-- quality slider --> <!-- quality slider -->
<shader-quality type="int"> <shader-quality type="int">
<use>/sim/rendering/shaders/model</use> <use>/sim/rendering/shaders/model</use>
</shader-quality> </shader-quality>
@ -110,8 +110,8 @@ please see Docs/README.model-combined.eff for documentation
<bin-number>1</bin-number> <bin-number>1</bin-number>
<bin-name>RenderBin</bin-name> <bin-name>RenderBin</bin-name>
</render-bin> </render-bin>
<!-- INTERNAL USE --> <!-- INTERNAL USE -->
<shade-model>smooth</shade-model> <shade-model>smooth</shade-model>
<model-hdg> <model-hdg>
<use>orientation/model/heading-deg</use> <use>orientation/model/heading-deg</use>
</model-hdg> </model-hdg>
@ -121,7 +121,7 @@ please see Docs/README.model-combined.eff for documentation
<model-roll> <model-roll>
<use>orientation/model/roll-deg</use> <use>orientation/model/roll-deg</use>
</model-roll> </model-roll>
<!-- fog include --> <!-- fog include -->
<visibility> <visibility>
<use>/environment/ground-visibility-m</use> <use>/environment/ground-visibility-m</use>
</visibility> </visibility>
@ -140,7 +140,7 @@ please see Docs/README.model-combined.eff for documentation
<fogtype> <fogtype>
<use>/sim/rendering/shaders/skydome</use> <use>/sim/rendering/shaders/skydome</use>
</fogtype> </fogtype>
<!-- END fog include --> <!-- END fog include -->
</parameters> </parameters>
<!--<generate> <!--<generate>
@ -218,13 +218,13 @@ please see Docs/README.model-combined.eff for documentation
<use>transparent</use> <use>transparent</use>
</alpha-test> </alpha-test>
<render-bin> <render-bin>
<bin-number> <bin-number>
<use>render-bin/bin-number</use> <use>render-bin/bin-number</use>
</bin-number> </bin-number>
<bin-name> <bin-name>
<use>render-bin/bin-name</use> <use>render-bin/bin-name</use>
</bin-name> </bin-name>
</render-bin> </render-bin>
<!-- Diffuse texture unit--> <!-- Diffuse texture unit-->
<texture-unit> <texture-unit>
<unit>0</unit> <unit>0</unit>
@ -355,7 +355,7 @@ please see Docs/README.model-combined.eff for documentation
</internal-format> </internal-format>
</texture-unit> </texture-unit>
<!-- Reflection Noise texture unit--> <!-- Reflection Noise texture unit-->
<texture-unit> <texture-unit>
<unit>9</unit> <unit>9</unit>
<type>noise</type> <type>noise</type>
</texture-unit> </texture-unit>
@ -427,7 +427,7 @@ please see Docs/README.model-combined.eff for documentation
<value type="int">9</value> <value type="int">9</value>
</uniform> </uniform>
<!-- NORMAL MAP --> <!-- NORMAL MAP -->
<!-- normalmap is used--> <!-- normalmap is used-->
<uniform> <uniform>
<name>nmap_enabled</name> <name>nmap_enabled</name>
@ -454,8 +454,8 @@ please see Docs/README.model-combined.eff for documentation
</value> </value>
</uniform> </uniform>
<!-- LIGHTMAP --> <!-- LIGHTMAP -->
<!-- lightmap is used --> <!-- lightmap is used -->
<uniform> <uniform>
<name>lightmap_enabled</name> <name>lightmap_enabled</name>
<type>int</type> <type>int</type>
@ -463,7 +463,7 @@ please see Docs/README.model-combined.eff for documentation
<use>lightmap-enabled</use> <use>lightmap-enabled</use>
</value> </value>
</uniform> </uniform>
<!-- lightmap is multichannel --> <!-- lightmap is multichannel -->
<uniform> <uniform>
<name>lightmap_multi</name> <name>lightmap_multi</name>
<type>int</type> <type>int</type>
@ -498,7 +498,7 @@ please see Docs/README.model-combined.eff for documentation
<uniform> <uniform>
<name>lightmap_g_color</name> <name>lightmap_g_color</name>
<type>float-vec3</type> <type>float-vec3</type>
<value> <value>
<use>lightmap-color[1]</use> <use>lightmap-color[1]</use>
</value> </value>
@ -514,7 +514,7 @@ please see Docs/README.model-combined.eff for documentation
<uniform> <uniform>
<name>lightmap_b_color</name> <name>lightmap_b_color</name>
<type>float-vec3</type> <type>float-vec3</type>
<value> <value>
<use>lightmap-color[2]</use> <use>lightmap-color[2]</use>
</value> </value>
@ -536,7 +536,7 @@ please see Docs/README.model-combined.eff for documentation
</value> </value>
</uniform> </uniform>
<!-- reflection is used --> <!-- reflection is used -->
<uniform> <uniform>
<name>refl_enabled</name> <name>refl_enabled</name>
<type>int</type> <type>int</type>
@ -544,7 +544,7 @@ please see Docs/README.model-combined.eff for documentation
<use>reflection-enabled</use> <use>reflection-enabled</use>
</value> </value>
</uniform> </uniform>
<!-- reflection correction --> <!-- reflection correction -->
<uniform> <uniform>
<name>refl_correction</name> <name>refl_correction</name>
<type>float</type> <type>float</type>
@ -561,7 +561,7 @@ please see Docs/README.model-combined.eff for documentation
<use>reflect-map-enabled</use> <use>reflect-map-enabled</use>
</value> </value>
</uniform> </uniform>
<!-- reflection is dynamic --> <!-- reflection is dynamic -->
<uniform> <uniform>
<name>refl_dynamic</name> <name>refl_dynamic</name>
<type>int</type> <type>int</type>
@ -670,7 +670,7 @@ please see Docs/README.model-combined.eff for documentation
<use>ambient-correction</use> <use>ambient-correction</use>
</value> </value>
</uniform> </uniform>
<!-- shader quality --> <!-- shader quality -->
<uniform> <uniform>
<name>shader_qual</name> <name>shader_qual</name>
<type>int</type> <type>int</type>
@ -703,7 +703,7 @@ please see Docs/README.model-combined.eff for documentation
</value> </value>
</uniform> </uniform>
<!-- BEGIN fog include --> <!-- BEGIN fog include -->
<uniform> <uniform>
<name>visibility</name> <name>visibility</name>
<type>float</type> <type>float</type>
@ -746,7 +746,7 @@ please see Docs/README.model-combined.eff for documentation
<use>fogtype</use> <use>fogtype</use>
</value> </value>
</uniform> </uniform>
<!-- END fog include --> <!-- END fog include -->
</pass> </pass>
</technique> </technique>

View file

@ -140,9 +140,30 @@ void main (void)
} else { } else {
mixedcolor = texel.rgb; mixedcolor = texel.rgb;
} }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
//END reflect //END reflect
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//begin DIRT
//////////////////////////////////////////////////////////////////////
if (dirt_enabled > 0.0){
float dirtFactorR = reflmap.r * dirt_r_factor;
dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, dirtFactorR);
if (dirt_multi > 0) {
float dirtFactorG = reflmap.g * dirt_g_factor;
float dirtFactorB = reflmap.b * dirt_b_factor;
dirtFactorG = smoothstep(0.0, 1.0, dirtFactorG);
dirtFactorB = smoothstep(0.0, 1.0, dirtFactorB);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, dirtFactorG);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, dirtFactorB);
}
}
//////////////////////////////////////////////////////////////////////
//END Dirt
//////////////////////////////////////////////////////////////////////
// set ambient adjustment to remove bluiness with user input // set ambient adjustment to remove bluiness with user input
float ambient_offset = clamp(amb_correction, -1.0, 1.0); float ambient_offset = clamp(amb_correction, -1.0, 1.0);
@ -152,25 +173,7 @@ void main (void)
color.a = texel.a * alpha; color.a = texel.a * alpha;
vec4 fragColor = vec4(color.rgb * mixedcolor + ambient_Correction.rgb, color.a); vec4 fragColor = vec4(color.rgb * mixedcolor + ambient_Correction.rgb, color.a);
//////////////////////////////////////////////////////////////////////
//begin DIRT
//////////////////////////////////////////////////////////////////////
if (dirt_enabled > 0.0){
float dirtFactorR = reflmap.r * dirt_r_factor;
dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR);
fragColor.rgb = mix(fragColor.rgb, dirt_r_color, dirtFactorR);
if (dirt_multi > 0) {
float dirtFactorG = reflmap.g * dirt_g_factor;
float dirtFactorB = reflmap.b * dirt_b_factor;
dirtFactorG = smoothstep(0.0, 1.0, dirtFactorG);
dirtFactorB = smoothstep(0.0, 1.0, dirtFactorB);
fragColor.rgb = mix(fragColor.rgb, dirt_g_color, dirtFactorG);
fragColor.rgb = mix(fragColor.rgb, dirt_b_color, dirtFactorB);
}
}
//////////////////////////////////////////////////////////////////////
//END Dirt
//////////////////////////////////////////////////////////////////////
fragColor += Specular * nmap.a; fragColor += Specular * nmap.a;