1
0
Fork 0

ALS model shader: allow dirt overlay to change surface reflectivity, add grain merge reflection type to space shader

This commit is contained in:
Thorsten Renk 2017-06-18 09:35:32 +03:00
parent 0df35c2516
commit 79244fd5e4
4 changed files with 86 additions and 4 deletions

View file

@ -114,6 +114,8 @@ please see Docs/README.model-combined.eff for documentation
<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>
<dirt-modulates-reflection type="int">0</dirt-modulates-reflection>
<dirt-reflection-factor type="double">1.0</dirt-reflection-factor>
<!-- ambient correction -->
<ambient-correction type="float">0.05</ambient-correction>
<rendering-hint>opaque</rendering-hint>
@ -759,6 +761,22 @@ please see Docs/README.model-combined.eff for documentation
</value>
</uniform>
<uniform>
<name>dirt_modulates_reflection</name>
<type>int</type>
<value>
<use>dirt-modulates-reflection</use>
</value>
</uniform>
<uniform>
<name>dirt_reflection_factor</name>
<type>float</type>
<value>
<use>dirt-reflection-factor</use>
</value>
</uniform>
<!-- use a grain texture map-->
<uniform>

View file

@ -215,6 +215,15 @@
</value>
</uniform>
<!-- how are colors merged in a reflection-->
<uniform>
<name>refl_type</name>
<type>int</type>
<value>
<use>reflection-type</use>
</value>
</uniform>
<!-- reflection is dynamic -->
<uniform>
<name>refl_dynamic</name>
@ -316,6 +325,22 @@
</value>
</uniform>
<uniform>
<name>dirt_modulates_reflection</name>
<type>int</type>
<value>
<use>dirt-modulates-reflection</use>
</value>
</uniform>
<uniform>
<name>dirt_reflection_factor</name>
<type>float</type>
<value>
<use>dirt-reflection-factor</use>
</value>
</uniform>
<!-- use a grain texture map-->
<uniform>

View file

@ -28,6 +28,7 @@ uniform sampler2D GrainTex;
uniform int dirt_enabled;
uniform int dirt_multi;
uniform int dirt_modulates_reflection;
uniform int lightmap_enabled;
uniform int lightmap_multi;
uniform int nmap_dds;
@ -47,6 +48,7 @@ uniform float amb_correction;
uniform float dirt_b_factor;
uniform float dirt_g_factor;
uniform float dirt_r_factor;
uniform float dirt_reflection_factor;
uniform float lightmap_a_factor;
uniform float lightmap_b_factor;
uniform float lightmap_g_factor;
@ -355,9 +357,24 @@ void main (void)
{
Diffuse.rgb = max(Diffuse.rgb, vec3 (0.5, 0.5, 0.5));
}
///BEGIN reflection correction by dirt
float refl_d = 1.0;
if ((dirt_enabled == 1) && (dirt_modulates_reflection == 1))
{
refl_d = 1.0 - (reflmap.r * dirt_r_factor * (1.0 - dirt_reflection_factor));
}
///END reflection correction by dirt
vec4 Specular = gl_FrontMaterial.specular * light_diffuse * pf + gl_FrontMaterial.specular * light_ambient * pf1;
Specular+= gl_FrontMaterial.specular * pow(max(0.0,-dot(N,normalize(vertVec))),gl_FrontMaterial.shininess) * vec4(secondary_light,1.0);
Specular *= refl_d;
vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse;
color = clamp( color, 0.0, 1.0 );
@ -397,9 +414,9 @@ void main (void)
raincolor *= light_diffuse;
if (refl_type == 1)
{mixedcolor = mix(texel, raincolor, reflFactor).rgb;}
{mixedcolor = mix(texel, raincolor, reflFactor * refl_d).rgb;}
else if (refl_type == 2)
{mixedcolor = ((texel +(reflcolor * reflFactor))-(0.5*reflFactor)).rgb;}
{mixedcolor = ((texel +(reflcolor * reflFactor * refl_d))-(0.5*reflFactor * refl_d)).rgb;}
} else {
mixedcolor = texel.rgb;

View file

@ -28,11 +28,13 @@ uniform sampler2D GrainTex;
uniform int dirt_enabled;
uniform int dirt_multi;
uniform int dirt_modulates_reflection;
uniform int lightmap_enabled;
uniform int lightmap_multi;
uniform int nmap_dds;
uniform int nmap_enabled;
uniform int refl_enabled;
uniform int refl_type;
uniform int refl_map;
uniform int grain_texture_enabled;
uniform int darkmap_enabled;
@ -47,6 +49,7 @@ uniform float amb_correction;
uniform float dirt_b_factor;
uniform float dirt_g_factor;
uniform float dirt_r_factor;
uniform float dirt_reflection_factor;
uniform float lightmap_a_factor;
uniform float lightmap_b_factor;
uniform float lightmap_g_factor;
@ -351,9 +354,23 @@ void main (void)
//if (use_geo_light == 1)
{Diffuse.rgb = addLights(Diffuse.rgb, geo_light * diffuse_reduction );}
///BEGIN reflection correction by dirt
float refl_d = 1.0;
if ((dirt_enabled == 1) && (dirt_modulates_reflection == 1))
{
refl_d = 1.0 - (reflmap.r * dirt_r_factor * (1.0 - dirt_reflection_factor));
}
///END reflection correction by dirt
vec4 Specular = gl_FrontMaterial.specular * light_diffuse * pf + gl_FrontMaterial.specular * light_ambient * pf1;
Specular+= gl_FrontMaterial.specular * pow(max(0.0,-dot(N,normalize(vertVec))),gl_FrontMaterial.shininess) * vec4(secondary_light,1.0);
Specular *= refl_d;
vec4 color = gl_Color * light_ambient + gl_FrontMaterial.emission;
color = color + Diffuse * gl_FrontMaterial.diffuse;
@ -386,7 +403,12 @@ void main (void)
vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0);
raincolor += Specular;
raincolor *= light_diffuse;
mixedcolor = mix(texel, raincolor, reflFactor).rgb;
if (refl_type == 1)
{mixedcolor = mix(texel, raincolor, reflFactor * refl_d).rgb;}
else if (refl_type == 2)
{mixedcolor = ((texel +(reflcolor * reflFactor * refl_d))-(0.5*reflFactor * refl_d)).rgb;}
} else {
mixedcolor = texel.rgb;
}