ALS secondary lights and Rayleigh haze for agriculture effect
This commit is contained in:
parent
52dc0e9e69
commit
afaac563db
2 changed files with 116 additions and 31 deletions
|
@ -79,6 +79,7 @@
|
|||
<uv_yoffset>0.0</uv_yoffset>
|
||||
<intrinsic_wetness>0.0</intrinsic_wetness>
|
||||
<dust_resistance>1.0</dust_resistance>
|
||||
<raise_vertex type="bool">false</raise_vertex>
|
||||
<visibility><use>/environment/ground-visibility-m</use></visibility>
|
||||
<avisibility><use>/environment/visibility-m</use></avisibility>
|
||||
<lthickness><use>/environment/ground-haze-thickness-m</use></lthickness>
|
||||
|
@ -238,9 +239,11 @@
|
|||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/terrain-ALS-ultra.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/agriculture.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/agriculture-ALS.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/noise.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/hazes.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>grain_strength</name>
|
||||
|
@ -387,6 +390,36 @@
|
|||
<type>float</type>
|
||||
<value><use>season</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>air_pollution</name>
|
||||
<type>float</type>
|
||||
<value><use>air_pollution</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>view_pitch_offset</name>
|
||||
<type>float</type>
|
||||
<value><use>view_pitch_offset</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>view_heading_offset</name>
|
||||
<type>float</type>
|
||||
<value><use>view_heading_offset</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>field_of_view</name>
|
||||
<type>float</type>
|
||||
<value><use>view_fov</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>landing_light1_offset</name>
|
||||
<type>float</type>
|
||||
<value><use>landing_light1_offset</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>landing_light2_offset</name>
|
||||
<type>float</type>
|
||||
<value><use>landing_light2_offset</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos1_x</name>
|
||||
<type>float</type>
|
||||
|
@ -622,6 +655,36 @@
|
|||
<type>int</type>
|
||||
<value><use>rotation_flag</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>use_searchlight</name>
|
||||
<type>int</type>
|
||||
<value> <use>use_searchlight</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>use_landing_light</name>
|
||||
<type>int</type>
|
||||
<value> <use>use_landing_light</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>use_alt_landing_light</name>
|
||||
<type>int</type>
|
||||
<value> <use>use_alt_landing_light</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>display_xsize</name>
|
||||
<type>int</type>
|
||||
<value><use>display_xsize</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>display_ysize</name>
|
||||
<type>int</type>
|
||||
<value><use>display_ysize</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>raise_vertex</name>
|
||||
<type>bool</type>
|
||||
<value> <use>raise_vertex</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
|
|
|
@ -38,6 +38,7 @@ uniform float fogstructure;
|
|||
uniform float snow_thickness_factor;
|
||||
uniform float cloud_self_shading;
|
||||
uniform float season;
|
||||
uniform float air_pollution;
|
||||
uniform float grain_strength;
|
||||
uniform float intrinsic_wetness;
|
||||
uniform float overlay_fraction;
|
||||
|
@ -46,6 +47,8 @@ uniform float rotation_scale;
|
|||
uniform float distortion_factor;
|
||||
uniform float uv_xoffset;
|
||||
uniform float uv_yoffset;
|
||||
uniform float landing_light1_offset;
|
||||
uniform float landing_light2_offset;
|
||||
|
||||
uniform float dust_resistance;
|
||||
uniform float WindE;
|
||||
|
@ -57,6 +60,10 @@ uniform int tquality_level;
|
|||
uniform int wind_effects;
|
||||
uniform int cloud_shadow_flag;
|
||||
uniform int rotation_flag;
|
||||
uniform int use_searchlight;
|
||||
uniform int use_landing_light;
|
||||
uniform int use_alt_landing_light;
|
||||
|
||||
|
||||
const float EarthRadius = 5800000.0;
|
||||
const float terminator_width = 200000.0;
|
||||
|
@ -71,7 +78,15 @@ float Noise2D(in vec2 coord, in float wavelength);
|
|||
float Noise3D(in vec3 coord, in float wavelength);
|
||||
float VoronoiNoise2D(in vec2 coord, in float wavelength, in float xrand, in float yrand);
|
||||
float SlopeLines2D(in vec2 coord, in vec2 gradDir, in float wavelength, in float steepness);
|
||||
float fog_func (in float targ, in float alt);
|
||||
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
|
||||
float alt_factor(in float eye_alt, in float vertex_alt);
|
||||
float light_distance_fading(in float dist);
|
||||
float fog_backscatter(in float avisibility);
|
||||
|
||||
vec3 rayleigh_out_shift(in vec3 color, in float outscatter);
|
||||
vec3 searchlight();
|
||||
vec3 landing_light(in float offset);
|
||||
|
||||
|
||||
float light_func (in float x, in float a, in float b, in float c, in float d, in float e)
|
||||
|
@ -96,35 +111,8 @@ return 1.0 - smoothstep(0.5 * fade_dist, fade_dist, dist);
|
|||
}
|
||||
|
||||
|
||||
// this determines how light is attenuated in the distance
|
||||
// physically this should be exp(-arg) but for technical reasons we use a sharper cutoff
|
||||
// for distance > visibility
|
||||
|
||||
float fog_func (in float targ)
|
||||
{
|
||||
|
||||
|
||||
float fade_mix;
|
||||
|
||||
// for large altitude > 30 km, we switch to some component of quadratic distance fading to
|
||||
// create the illusion of improved visibility range
|
||||
|
||||
targ = 1.25 * targ * smoothstep(0.04,0.06,targ); // need to sync with the distance to which terrain is drawn
|
||||
|
||||
|
||||
if (alt < 30000.0)
|
||||
{return exp(-targ - targ * targ * targ * targ);}
|
||||
else if (alt < 50000.0)
|
||||
{
|
||||
fade_mix = (alt - 30000.0)/20000.0;
|
||||
return fade_mix * exp(-targ*targ - pow(targ,4.0)) + (1.0 - fade_mix) * exp(-targ - pow(targ,4.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
return exp(- targ * targ - pow(targ,4.0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -451,11 +439,30 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0))
|
|||
// is closer to what the OpenGL fixed function pipeline does.
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
vec3 secondary_light = vec3 (0.0,0.0,0.0);
|
||||
|
||||
if (use_searchlight == 1)
|
||||
{
|
||||
secondary_light += searchlight();
|
||||
}
|
||||
if (use_landing_light == 1)
|
||||
{
|
||||
secondary_light += landing_light(landing_light1_offset);
|
||||
}
|
||||
if (use_alt_landing_light == 1)
|
||||
{
|
||||
secondary_light += landing_light(landing_light2_offset);
|
||||
}
|
||||
color.rgb +=secondary_light * light_distance_fading(dist);
|
||||
|
||||
|
||||
fragColor = color * texel + specular;
|
||||
|
||||
// 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);
|
||||
fragColor.rgb = rayleigh_out_shift(fragColor.rgb,outscatter);
|
||||
|
||||
// here comes the terrain haze model
|
||||
|
||||
|
||||
|
@ -574,7 +581,7 @@ else
|
|||
|
||||
|
||||
|
||||
transmission = fog_func(transmission_arg);
|
||||
transmission = fog_func(transmission_arg, alt);
|
||||
|
||||
// there's always residual intensity, we should never be driven to zero
|
||||
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
|
||||
|
@ -631,9 +638,15 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
|
|||
}
|
||||
|
||||
|
||||
// blue Rayleigh scattering with distance
|
||||
|
||||
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
|
||||
float lightIntensity = length(diffuse_term.rgb)/1.73 * rShade;
|
||||
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);
|
||||
|
||||
fragColor.rgb = mix(eqColorFactor * hazeColor * eShade , fragColor.rgb,transmission);
|
||||
fragColor.rgb = mix((eqColorFactor * hazeColor * eShade) +secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
|
||||
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
|
@ -642,6 +655,15 @@ gl_FragColor = fragColor;
|
|||
}
|
||||
else // if dist < threshold no fogging at all
|
||||
{
|
||||
|
||||
// blue Rayleigh scattering with distance
|
||||
|
||||
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
|
||||
float lightIntensity = length(diffuse_term.rgb)/1.73 * rShade;
|
||||
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);
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
}
|
||||
|
Loading…
Reference in a new issue