ALS secondary lights, Rayleigh haze and cloud shadows for dirt runway effect
This commit is contained in:
parent
afaac563db
commit
67867d8a32
3 changed files with 336 additions and 85 deletions
|
@ -116,8 +116,12 @@
|
|||
<internal-format><use>texture[11]/internal-format</use></internal-format>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/terrain-ALS-ultra.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/drunway-lightfield.frag</fragment-shader>
|
||||
<vertex-shader n="1">Shaders/terrain-ALS-ultra.vert</vertex-shader>
|
||||
<fragment-shader n="1">Shaders/drunway-ALS.frag</fragment-shader>
|
||||
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
|
||||
<fragment-shader n="3">Shaders/noise.frag</fragment-shader>
|
||||
<fragment-shader n="4">Shaders/hazes.frag</fragment-shader>
|
||||
<fragment-shader n="5">Shaders/secondary_lights.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>visibility</name>
|
||||
|
@ -204,6 +208,241 @@
|
|||
<type>float</type>
|
||||
<value><use>moonlight</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>
|
||||
<value><use>cloudpos1_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos1_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos1_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos2_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos2_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos2_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos2_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos3_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos3_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos3_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos3_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos4_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos4_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos4_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos4_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos5_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos5_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos5_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos5_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos6_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos6_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos6_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos6_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos7_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos7_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos7_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos7_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos8_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos8_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos8_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos8_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos9_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos9_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos9_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos9_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos10_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos10_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos10_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos10_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos11_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos11_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos11_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos11_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos12_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos12_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos12_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos12_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos13_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos13_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos13_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos13_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos14_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos14_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos14_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos14_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos15_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos15_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos15_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos15_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos16_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos16_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos16_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos16_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos17_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos17_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos17_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos17_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos18_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos18_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos18_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos18_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos19_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos19_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos19_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos19_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos20_x</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos20_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloudpos20_y</name>
|
||||
<type>float</type>
|
||||
<value><use>cloudpos20_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>cloud_shadow_flag</name>
|
||||
<type>int</type>
|
||||
<value><use>cloud_shadow_flag</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>quality_level</name>
|
||||
<type>int</type>
|
||||
|
@ -214,6 +453,36 @@
|
|||
<type>int</type>
|
||||
<value><use>tquality_level</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>
|
||||
|
|
|
@ -160,12 +160,12 @@
|
|||
<internal-format><use>texture[4]/internal-format</use></internal-format>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/terrain-ALS-ultra.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/runway-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>
|
||||
<vertex-shader n="1">Shaders/terrain-ALS-ultra.vert</vertex-shader>
|
||||
<fragment-shader n="1">Shaders/runway-ALS.frag</fragment-shader>
|
||||
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
|
||||
<fragment-shader n="3">Shaders/noise.frag</fragment-shader>
|
||||
<fragment-shader n="4">Shaders/hazes.frag</fragment-shader>
|
||||
<fragment-shader n="5">Shaders/secondary_lights.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>visibility</name>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
// Ambient term comes in gl_Color.rgb.
|
||||
varying vec4 diffuse_term;
|
||||
varying vec3 normal;
|
||||
//varying vec2 nvec;
|
||||
varying vec3 relPos;
|
||||
varying vec2 rawPos;
|
||||
varying vec3 ecViewdir;
|
||||
|
@ -12,13 +11,8 @@ varying vec3 ecViewdir;
|
|||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D NormalTex;
|
||||
//uniform sampler3D NoiseTex;
|
||||
//uniform sampler2D snow_texture;
|
||||
//uniform sampler2D detail_texture;
|
||||
uniform sampler2D mix_texture;
|
||||
|
||||
//varying float yprime_alt;
|
||||
//varying float mie_angle;
|
||||
varying float steepness;
|
||||
|
||||
|
||||
|
@ -37,8 +31,17 @@ uniform float wetness;
|
|||
uniform float fogstructure;
|
||||
uniform float snow_thickness_factor;
|
||||
uniform float cloud_self_shading;
|
||||
uniform float landing_light1_offset;
|
||||
uniform float landing_light2_offset;
|
||||
uniform float air_pollution;
|
||||
|
||||
|
||||
uniform int quality_level;
|
||||
uniform int tquality_level;
|
||||
uniform int cloud_shadow_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;
|
||||
|
@ -49,51 +52,15 @@ float yprime_alt;
|
|||
float mie_angle;
|
||||
|
||||
|
||||
float shadow_func (in float x, in float y, in float noise, in float dist);
|
||||
float Noise2D(in vec2 coord, in float wavelength);
|
||||
float fog_func (in float targ, in float alt);
|
||||
float light_distance_fading(in float dist);
|
||||
float fog_backscatter(in float avisibility);
|
||||
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
|
||||
|
||||
float rand2D(in vec2 co){
|
||||
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
float cosine_interpolate(in float a, in float b, in float x)
|
||||
{
|
||||
float ft = x * 3.1415927;
|
||||
float f = (1.0 - cos(ft)) * .5;
|
||||
|
||||
return a*(1.0-f) + b*f;
|
||||
}
|
||||
|
||||
float simple_interpolate(in float a, in float b, in float x)
|
||||
{
|
||||
return a + smoothstep(0.0,1.0,x) * (b-a);
|
||||
//return mix(a,b,x);
|
||||
}
|
||||
|
||||
float interpolatedNoise2D(in float x, in float y)
|
||||
{
|
||||
float integer_x = x - fract(x);
|
||||
float fractional_x = x - integer_x;
|
||||
|
||||
float integer_y = y - fract(y);
|
||||
float fractional_y = y - integer_y;
|
||||
|
||||
float v1 = rand2D(vec2(integer_x, integer_y));
|
||||
float v2 = rand2D(vec2(integer_x+1.0, integer_y));
|
||||
float v3 = rand2D(vec2(integer_x, integer_y+1.0));
|
||||
float v4 = rand2D(vec2(integer_x+1.0, integer_y +1.0));
|
||||
|
||||
float i1 = simple_interpolate(v1 , v2 , fractional_x);
|
||||
float i2 = simple_interpolate(v3 , v4 , fractional_x);
|
||||
|
||||
return simple_interpolate(i1 , i2 , fractional_y);
|
||||
}
|
||||
|
||||
|
||||
float Noise2D(in vec2 coord, in float wavelength)
|
||||
{
|
||||
return interpolatedNoise2D(coord.x/wavelength, coord.y/wavelength);
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -111,31 +78,6 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
|
|||
// 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()
|
||||
{
|
||||
|
@ -305,6 +247,8 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
|
|||
//NdotL = NdotL + 3.0 * N.r + 0.1 * (noise_01m-0.5) ;
|
||||
}
|
||||
if (NdotL > 0.0) {
|
||||
if (cloud_shadow_flag == 1)
|
||||
{NdotL = NdotL * shadow_func(relPos.x, relPos.y, 1.0, dist);}
|
||||
color += diffuse_term * NdotL;
|
||||
NdotHV = max(dot(n, halfVector), 0.0);
|
||||
//if (gl_FrontMaterial.shininess > 0.0)
|
||||
|
@ -318,7 +262,21 @@ if ((dist < 5000.0)&& (quality_level > 3) && (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.rgb += 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;
|
||||
|
@ -425,7 +383,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;
|
||||
|
@ -481,10 +439,21 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
|
|||
hazeColor = mix(shadow * hazeColor, hazeColor, 0.3 + 0.7* smoothstep(250000.0, 400000.0, terminator));
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
if ((quality_level>5) && (tquality_level>5))
|
||||
{
|
||||
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;
|
||||
|
@ -493,6 +462,19 @@ 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);
|
||||
|
||||
if ((quality_level>5) && (tquality_level>5))
|
||||
{
|
||||
fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
|
||||
}
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue