From f3b455b6994caf7ca7923ad39304c6d4c714ae07 Mon Sep 17 00:00:00 2001 From: Fahim Imaduddin Dalvi Date: Sat, 2 Apr 2022 21:20:20 +0300 Subject: [PATCH] Bugfix: Terrain quality taken into account in model shaders. Objects like OSM buildings using the `model-combined` effect ignored the Terrain quality. Rayleigh Fog is computed for the terrain only at "Ultra" level, but was computed for models at all quality levels, which led to a visual disparity. The shader now takes into account the terrain quality before computing rayleigh fog for objects. The `road` effect also had the same issue and is fixed now. --- Effects/model-combined.eff | 14 +++++++++++++- Effects/road.eff | 11 +++++++++++ Shaders/model-ALS-ultra.frag | 9 +++++++-- Shaders/road-ALS-ultra.frag | 9 +++++++-- 4 files changed, 38 insertions(+), 5 deletions(-) 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 /local-weather/cloud-shadows/cloudpos-y[19] /local-weather/cloud-shadows/cloud-shadow-flag 0 + /sim/rendering/shaders/landmass + /sim/rendering/shaders/transition @@ -1026,6 +1028,17 @@ please see Docs/README.model-combined.eff for documentation fact_black + + quality_level + int + quality_level + + + tquality_level + int + tquality_level + + cloudpos1_x @@ -1268,7 +1281,6 @@ please see Docs/README.model-combined.eff for documentation building-flag - 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 @@ fact_black + + quality_level + int + quality_level + + + tquality_level + int + tquality_level + + 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