1
0
Fork 0

Add 2 more dirt channels - "green" and "blue"

Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
Vivian Meazza 2011-12-17 17:07:41 +00:00
parent a51cb4a280
commit cfb86efb84
2 changed files with 72 additions and 14 deletions

View file

@ -91,8 +91,13 @@ please see Docs/README.model-combined.eff for documentation
<!-- END Reflection --> <!-- END Reflection -->
<!-- Dirt --> <!-- Dirt -->
<dirt-enabled type="int">0</dirt-enabled> <dirt-enabled type="int">0</dirt-enabled>
<dirt-color type="vec3d">0.0 0.0 0.0</dirt-color> <dirt-multi type="int">0</dirt-multi>
<dirt-factor type="float">0.0</dirt-factor> <dirt-color type="vec3d" n="0">0.0 0.0 0.0</dirt-color>
<dirt-factor type="float" n="0">0.0</dirt-factor>
<dirt-color type="vec3d" n="1">0.0 0.0 0.0</dirt-color>
<dirt-factor type="float" n="1">0.0</dirt-factor>
<dirt-color type="vec3d" n="2">0.0 0.0 0.0</dirt-color>
<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 -->
@ -602,20 +607,61 @@ please see Docs/README.model-combined.eff for documentation
</uniform> </uniform>
<uniform> <uniform>
<name>dirt_color</name> <name>dirt_multi</name>
<type>float-vec3</type> <type>int</type>
<value> <value>
<use>dirt-color</use> <use>dirt-multi</use>
</value> </value>
</uniform> </uniform>
<uniform> <uniform>
<name>dirt_factor</name> <name>dirt_r_color</name>
<type>float</type> <type>float-vec3</type>
<value> <value>
<use>dirt-factor</use> <use>dirt-color[0]</use>
</value> </value>
</uniform> </uniform>
<uniform>
<name>dirt_r_factor</name>
<type>float</type>
<value>
<use>dirt-factor[0]</use>
</value>
</uniform>
<uniform>
<name>dirt_g_color</name>
<type>float-vec3</type>
<value>
<use>dirt-color[1]</use>
</value>
</uniform>
<uniform>
<name>dirt_g_factor</name>
<type>float</type>
<value>
<use>dirt-factor[1]</use>
</value>
</uniform>
<uniform>
<name>dirt_b_color</name>
<type>float-vec3</type>
<value>
<use>dirt-color[2]</use>
</value>
</uniform>
<uniform>
<name>dirt_b_factor</name>
<type>float</type>
<value>
<use>dirt-factor[2]</use>
</value>
</uniform>
<!-- set the amount of ambient light correction 0.0 - 1.0 --> <!-- set the amount of ambient light correction 0.0 - 1.0 -->
<uniform> <uniform>
<name>amb_correction</name> <name>amb_correction</name>

View file

@ -32,6 +32,7 @@ uniform int lightmap_enabled;
uniform int lightmap_multi; uniform int lightmap_multi;
uniform int shader_qual; uniform int shader_qual;
uniform int dirt_enabled; uniform int dirt_enabled;
uniform int dirt_multi;
uniform float lightmap_r_factor; uniform float lightmap_r_factor;
uniform float lightmap_g_factor; uniform float lightmap_g_factor;
@ -42,14 +43,18 @@ uniform float refl_fresnel;
uniform float refl_rainbow; uniform float refl_rainbow;
uniform float refl_noise; uniform float refl_noise;
uniform float amb_correction; uniform float amb_correction;
uniform float dirt_factor; uniform float dirt_r_factor;
uniform float dirt_g_factor;
uniform float dirt_b_factor;
uniform vec3 lightmap_r_color; uniform vec3 lightmap_r_color;
uniform vec3 lightmap_g_color; uniform vec3 lightmap_g_color;
uniform vec3 lightmap_b_color; uniform vec3 lightmap_b_color;
uniform vec3 lightmap_a_color; uniform vec3 lightmap_a_color;
uniform vec3 dirt_color; uniform vec3 dirt_r_color;
uniform vec3 dirt_g_color;
uniform vec3 dirt_b_color;
///fog include////////////////////// ///fog include//////////////////////
uniform int fogType; uniform int fogType;
@ -151,10 +156,17 @@ void main (void)
//begin DIRT //begin DIRT
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
if (dirt_enabled > 0.0){ if (dirt_enabled > 0.0){
vec3 dirtColor = dirt_color * noisevec.rgb; float dirtFactorR = reflmap.r * dirt_r_factor;
float dirtFactor = reflmap.r * dirt_factor; dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR);
dirtFactor = smoothstep(0.0, 1.0, dirtFactor); fragColor.rgb = mix(fragColor.rgb, dirt_r_color, dirtFactorR);
fragColor.rgb = mix(fragColor.rgb, dirtColor, dirtFactor); 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 //END Dirt