diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff
index ecff7df57..6572d17b7 100644
--- a/Effects/model-combined.eff
+++ b/Effects/model-combined.eff
@@ -194,6 +194,8 @@ please see Docs/README.model-combined.eff for documentation
0
+
+
@@ -1026,6 +1028,17 @@ please see Docs/README.model-combined.eff for documentation
+
+ quality_level
+ int
+
+
+
+ tquality_level
+ int
+
+
+
cloudpos1_x
@@ -1268,7 +1281,6 @@ please see Docs/README.model-combined.eff for documentation
-
diff --git a/Effects/road.eff b/Effects/road.eff
index bab0e77a4..6b1f1870f 100644
--- a/Effects/road.eff
+++ b/Effects/road.eff
@@ -840,6 +840,17 @@
+
+ quality_level
+ int
+
+
+
+ tquality_level
+ int
+
+
+
cloudpos1_x
diff --git a/Shaders/model-ALS-ultra.frag b/Shaders/model-ALS-ultra.frag
index 9435a13a6..3bef194ff 100644
--- a/Shaders/model-ALS-ultra.frag
+++ b/Shaders/model-ALS-ultra.frag
@@ -79,6 +79,9 @@ uniform float air_pollution;
uniform float snowlevel;
uniform float snow_thickness_factor;
+uniform int quality_level;
+uniform int tquality_level;
+
uniform float osg_SimulationTime;
uniform mat4 osg_ViewMatrix;
@@ -660,7 +663,9 @@ void main (void)
//hazeColor = clamp(hazeColor, 0.0, 1.0);
///BEGIN Rayleigh fog ///
-
+ // Only compute fog if terrain level is 'Ultra'
+ if ((quality_level > 5) && (tquality_level > 5))
+ {
// Rayleigh color shift due to out-scattering
float rayleigh_length = 0.5 * avisibility * (2.5 - 1.9 * air_pollution)/alt_factor(eye_alt, eye_alt+relPos.z);
float outscatter = 1.0-exp(-dist/rayleigh_length);
@@ -669,7 +674,7 @@ void main (void)
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
-
+ }
/// END Rayleigh fog
// don't let the light fade out too rapidly
diff --git a/Shaders/road-ALS-ultra.frag b/Shaders/road-ALS-ultra.frag
index 7296d5dbd..0f4565195 100644
--- a/Shaders/road-ALS-ultra.frag
+++ b/Shaders/road-ALS-ultra.frag
@@ -76,6 +76,9 @@ uniform float air_pollution;
uniform float snowlevel;
uniform float snow_thickness_factor;
+uniform int quality_level;
+uniform int tquality_level;
+
uniform float osg_SimulationTime;
uniform float landing_light1_offset;
@@ -842,7 +845,9 @@ void main (void)
hazeColor = clamp(hazeColor, 0.0, 1.0);
///BEGIN Rayleigh fog ///
-
+ // Only compute fog if terrain level is 'Ultra'
+ if ((quality_level > 5) && (tquality_level > 5))
+ {
// Rayleigh color shift due to out-scattering
float rayleigh_length = 0.5 * avisibility * (2.5 - 1.9 * air_pollution)/alt_factor(eye_alt, eye_alt+relPos.z);
float outscatter = 1.0-exp(-dist/rayleigh_length);
@@ -851,7 +856,7 @@ void main (void)
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
-
+ }
/// END Rayleigh fog
// don't let the light fade out too rapidly