diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff
index 5125c1dca..91cf4cf43 100644
--- a/Effects/model-combined.eff
+++ b/Effects/model-combined.eff
@@ -114,6 +114,8 @@ please see Docs/README.model-combined.eff for documentation
0.0
0.0 0.0 0.0
0.0
+ 0
+ 1.0
0.05
opaque
@@ -758,6 +760,22 @@ please see Docs/README.model-combined.eff for documentation
+
+
+ dirt_modulates_reflection
+ int
+
+
+
+
+
+
+ dirt_reflection_factor
+ float
+
+
+
+
diff --git a/Effects/space-combined.eff b/Effects/space-combined.eff
index 143ac384f..633b1be57 100644
--- a/Effects/space-combined.eff
+++ b/Effects/space-combined.eff
@@ -189,7 +189,7 @@
-
+
refl_enabled
int
@@ -215,6 +215,15 @@
+
+
+ refl_type
+ int
+
+
+
+
+
refl_dynamic
@@ -315,6 +324,22 @@
+
+
+ dirt_modulates_reflection
+ int
+
+
+
+
+
+
+ dirt_reflection_factor
+ float
+
+
+
+
diff --git a/Shaders/model-ALS-ultra.frag b/Shaders/model-ALS-ultra.frag
index 5f8baafc1..57c9dc3f6 100644
--- a/Shaders/model-ALS-ultra.frag
+++ b/Shaders/model-ALS-ultra.frag
@@ -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;
diff --git a/Shaders/space-ALS-ultra.frag b/Shaders/space-ALS-ultra.frag
index 3bb9e9445..3a6e28c4d 100644
--- a/Shaders/space-ALS-ultra.frag
+++ b/Shaders/space-ALS-ultra.frag
@@ -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;
@@ -350,10 +353,24 @@ void main (void)
Diffuse.rgb = addLights(Diffuse.rgb, secondary_light * light_distance_fading(dist));
//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;
}