1
0
Fork 0

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.
This commit is contained in:
Fahim Imaduddin Dalvi 2022-04-02 21:20:20 +03:00
parent 6fd8a92b2f
commit f3b455b699
4 changed files with 38 additions and 5 deletions

View file

@ -194,6 +194,8 @@ please see Docs/README.model-combined.eff for documentation
<cloudpos20_y><use>/local-weather/cloud-shadows/cloudpos-y[19]</use></cloudpos20_y>
<cloud_shadow_flag><use>/local-weather/cloud-shadows/cloud-shadow-flag</use></cloud_shadow_flag>
<building-flag type="int">0</building-flag>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
<!-- END fog include -->
</parameters>
@ -1026,6 +1028,17 @@ please see Docs/README.model-combined.eff for documentation
<value><use>fact_black</use></value>
</uniform>
<uniform>
<name>quality_level</name>
<type>int</type>
<value><use>quality_level</use></value>
</uniform>
<uniform>
<name>tquality_level</name>
<type>int</type>
<value><use>tquality_level</use></value>
</uniform>
<!-- cloud shadows -->
<uniform>
<name>cloudpos1_x</name>
@ -1268,7 +1281,6 @@ please see Docs/README.model-combined.eff for documentation
<value><use>building-flag</use></value>
</uniform>
<!-- END fog include -->
<!-- BEGIN shadows include -->
<uniform>

View file

@ -840,6 +840,17 @@
<value><use>fact_black</use></value>
</uniform>
<uniform>
<name>quality_level</name>
<type>int</type>
<value><use>quality_level</use></value>
</uniform>
<uniform>
<name>tquality_level</name>
<type>int</type>
<value><use>tquality_level</use></value>
</uniform>
<!-- cloud shadows -->
<uniform>
<name>cloudpos1_x</name>

View file

@ -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

View file

@ -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