ALS secondary lights illuminate fog, work in progress
This commit is contained in:
parent
1e0d4f83dc
commit
63bfbcbb4a
10 changed files with 317 additions and 78 deletions
|
@ -15,6 +15,16 @@
|
|||
<terrain_alt><use>/environment/mean-terrain-elevation-m</use></terrain_alt>
|
||||
<cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading>
|
||||
<horizon_roughness><use>/local-weather/config/small-scale-persistence</use></horizon_roughness>
|
||||
<display_xsize><use>/sim/startup/xsize</use></display_xsize>
|
||||
<display_ysize><use>/sim/startup/ysize</use></display_ysize>
|
||||
<view_pitch_offset><use>/sim/current-view/pitch-offset-deg</use></view_pitch_offset>
|
||||
<view_heading_offset><use>/sim/current-view/heading-offset-deg</use></view_heading_offset>
|
||||
<view_fov><use>/sim/current-view/field-of-view</use></view_fov>
|
||||
<use_searchlight><use>/sim/rendering/als-secondary-lights/use-searchlight</use></use_searchlight>
|
||||
<use_landing_light><use>/sim/rendering/als-secondary-lights/use-landing-light</use></use_landing_light>
|
||||
<use_alt_landing_light><use>/sim/rendering/als-secondary-lights/use-alt-landing-light</use></use_alt_landing_light>
|
||||
<landing_light1_offset><use>/sim/rendering/als-secondary-lights/landing-light1-offset-deg</use></landing_light1_offset>
|
||||
<landing_light2_offset><use>/sim/rendering/als-secondary-lights/landing-light2-offset-deg</use></landing_light2_offset>
|
||||
</parameters>
|
||||
<technique n="8">
|
||||
<predicate>
|
||||
|
@ -40,8 +50,10 @@
|
|||
<shade-model>smooth</shade-model>
|
||||
<cull-face>back</cull-face>
|
||||
<program>
|
||||
<vertex-shader>Shaders/skydome.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/skydome.frag</fragment-shader>
|
||||
<vertex-shader>Shaders/skydome-ALS.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/skydome-ALS.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/noise.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>mK</name>
|
||||
|
@ -108,6 +120,56 @@
|
|||
<type>float</type>
|
||||
<value><use>horizon_roughness</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>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>
|
||||
</pass>
|
||||
</technique>
|
||||
|
||||
|
|
130
Effects/tree.eff
130
Effects/tree.eff
|
@ -39,6 +39,16 @@
|
|||
<forest_effects><use>/sim/rendering/shaders/forest</use></forest_effects>
|
||||
<windE><use>/environment/sea/surface/wind-from-east-fps</use></windE>
|
||||
<windN><use>/environment/sea/surface/wind-from-north-fps</use></windN>
|
||||
<display_xsize><use>/sim/startup/xsize</use></display_xsize>
|
||||
<display_ysize><use>/sim/startup/ysize</use></display_ysize>
|
||||
<view_pitch_offset><use>/sim/current-view/pitch-offset-deg</use></view_pitch_offset>
|
||||
<view_heading_offset><use>/sim/current-view/heading-offset-deg</use></view_heading_offset>
|
||||
<view_fov><use>/sim/current-view/field-of-view</use></view_fov>
|
||||
<use_searchlight><use>/sim/rendering/als-secondary-lights/use-searchlight</use></use_searchlight>
|
||||
<use_landing_light><use>/sim/rendering/als-secondary-lights/use-landing-light</use></use_landing_light>
|
||||
<use_alt_landing_light><use>/sim/rendering/als-secondary-lights/use-alt-landing-light</use></use_alt_landing_light>
|
||||
<landing_light1_offset><use>/sim/rendering/als-secondary-lights/landing-light1-offset-deg</use></landing_light1_offset>
|
||||
<landing_light2_offset><use>/sim/rendering/als-secondary-lights/landing-light2-offset-deg</use></landing_light2_offset>
|
||||
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
|
||||
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
|
||||
<cloudpos2_x><use>/local-weather/cloud-shadows/cloudpos-x[1]</use></cloudpos2_x>
|
||||
|
@ -119,10 +129,11 @@
|
|||
</texture-unit>
|
||||
<alpha-to-coverage>true</alpha-to-coverage>
|
||||
<program>
|
||||
<vertex-shader>Shaders/tree-haze.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/tree-ALS.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/noise.frag</vertex-shader>
|
||||
<vertex-shader>Shaders/cloud-shadowfunc.frag</vertex-shader>
|
||||
<fragment-shader>Shaders/tree-haze.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/tree-ALS.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>visibility</name>
|
||||
|
@ -199,6 +210,36 @@
|
|||
<type>float</type>
|
||||
<value><use>windN</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>
|
||||
|
@ -404,6 +445,31 @@
|
|||
<type>int</type>
|
||||
<value><use>cloud_shadow_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>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
|
@ -478,10 +544,11 @@
|
|||
<reference type="float">0.1</reference>
|
||||
</alpha-test>
|
||||
<program>
|
||||
<vertex-shader>Shaders/tree-haze.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/tree-ALS.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/noise.frag</vertex-shader>
|
||||
<vertex-shader>Shaders/cloud-shadowfunc.frag</vertex-shader>
|
||||
<fragment-shader>Shaders/tree-haze.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/tree-ALS.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>visibility</name>
|
||||
|
@ -558,6 +625,36 @@
|
|||
<type>float</type>
|
||||
<value><use>windN</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>
|
||||
|
@ -763,6 +860,31 @@
|
|||
<type>int</type>
|
||||
<value><use>cloud_shadow_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>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
|
|
|
@ -58,9 +58,12 @@ float Noise2D(in vec2 coord, in float wavelength);
|
|||
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(in float dist);
|
||||
vec3 landing_light(in float dist, in float offset);
|
||||
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)
|
||||
{
|
||||
|
@ -270,20 +273,21 @@ if (quality_level > 3)
|
|||
|
||||
|
||||
|
||||
|
||||
vec3 secondary_light = vec3 (0.0,0.0,0.0);
|
||||
|
||||
if (use_searchlight == 1)
|
||||
{
|
||||
color.rgb += searchlight(dist);
|
||||
secondary_light += searchlight();
|
||||
}
|
||||
if (use_landing_light == 1)
|
||||
{
|
||||
color.rgb += landing_light(dist, landing_light1_offset);
|
||||
secondary_light += landing_light(landing_light1_offset);
|
||||
}
|
||||
if (use_alt_landing_light == 1)
|
||||
{
|
||||
color.rgb += landing_light(dist, landing_light2_offset);
|
||||
secondary_light += landing_light(landing_light2_offset);
|
||||
}
|
||||
color.rgb +=secondary_light * light_distance_fading(dist);
|
||||
|
||||
fragColor = color * texel + specular;
|
||||
|
||||
|
@ -464,7 +468,8 @@ 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;
|
||||
|
|
|
@ -52,8 +52,11 @@ 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);
|
||||
vec3 searchlight(in float dist);
|
||||
vec3 landing_light(in float dist, in float offset);
|
||||
float light_distance_fading(in float dist);
|
||||
float fog_backscatter(in float avisibility);
|
||||
|
||||
vec3 searchlight();
|
||||
vec3 landing_light(in float offset);
|
||||
|
||||
|
||||
|
||||
|
@ -248,19 +251,22 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
|
|||
// saturated. Clamping the color before modulating by the texture
|
||||
// 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)
|
||||
{
|
||||
color.rgb += searchlight(dist);
|
||||
secondary_light.rgb += searchlight();
|
||||
}
|
||||
if (use_landing_light == 1)
|
||||
{
|
||||
color.rgb += landing_light(dist, landing_light1_offset);
|
||||
secondary_light += landing_light(landing_light1_offset);
|
||||
}
|
||||
if (use_alt_landing_light == 1)
|
||||
{
|
||||
color.rgb += landing_light(dist, landing_light2_offset);
|
||||
secondary_light += landing_light(landing_light2_offset);
|
||||
}
|
||||
color.rgb +=secondary_light * light_distance_fading(dist);
|
||||
|
||||
fragColor = color * texel + specular;
|
||||
|
||||
|
@ -418,11 +424,11 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
|
|||
float shadow = mix( min(1.0 + dot(n,lightDir),1.0), 1.0, 1.0-smoothstep(0.1, 0.4, transmission));
|
||||
hazeColor = mix(shadow * hazeColor, hazeColor, 0.3 + 0.7* smoothstep(250000.0, 400000.0, terminator));
|
||||
}
|
||||
hazeColor = clamp(hazeColor, 0.0, 1.0);
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -6,7 +6,19 @@ uniform float field_of_view;
|
|||
uniform float view_pitch_offset;
|
||||
uniform float view_heading_offset;
|
||||
|
||||
vec3 searchlight(in float dist)
|
||||
float light_distance_fading(in float dist)
|
||||
{
|
||||
return min(1.0, 10000.0/(dist*dist));
|
||||
}
|
||||
|
||||
float fog_backscatter(in float avisibility)
|
||||
{
|
||||
return 0.5* min(1.0,10000.0/(avisibility*avisibility));
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 searchlight()
|
||||
{
|
||||
|
||||
vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.4);
|
||||
|
@ -18,14 +30,14 @@ float angularDist = length(gl_FragCoord.xy -center);
|
|||
if (angularDist < lightRadius)
|
||||
{
|
||||
headlightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0);
|
||||
headlightIntensity = headlightIntensity * min(1.0, 10000.0/(dist*dist));
|
||||
//headlightIntensity = headlightIntensity *
|
||||
//headlightIntensity*= clamp(1.0 + 0.15 * log(1000.0/(dist*dist)),0.0,1.0);
|
||||
return headlightIntensity * vec3 (0.5,0.5, 0.5);
|
||||
}
|
||||
else return vec3 (0.0,0.0,0.0);
|
||||
}
|
||||
|
||||
vec3 landing_light(in float dist, in float offset)
|
||||
vec3 landing_light(in float offset)
|
||||
{
|
||||
|
||||
float fov_h = field_of_view;
|
||||
|
@ -52,7 +64,7 @@ float angularDist = length(gl_FragCoord.xy -center);
|
|||
if (angularDist < lightRadius)
|
||||
{
|
||||
landingLightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0);
|
||||
landingLightIntensity *= min(1.0, 10000.0/(dist*dist));
|
||||
//landingLightIntensity *= min(1.0, 10000.0/(dist*dist));
|
||||
return landingLightIntensity * vec3 (0.5,0.5, 0.5);
|
||||
}
|
||||
else return vec3 (0.0,0.0,0.0);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// -*-C++-*-
|
||||
|
||||
#version 120
|
||||
|
||||
// Atmospheric scattering shader for flightgear
|
||||
|
@ -22,9 +24,21 @@ uniform float avisibility;
|
|||
uniform float scattering;
|
||||
uniform float cloud_self_shading;
|
||||
uniform float horizon_roughness;
|
||||
uniform float landing_light1_offset;
|
||||
uniform float landing_light2_offset;
|
||||
|
||||
uniform int use_searchlight;
|
||||
uniform int use_landing_light;
|
||||
uniform int use_alt_landing_light;
|
||||
|
||||
const float EarthRadius = 5800000.0;
|
||||
|
||||
float Noise2D(in vec2 coord, in float wavelength);
|
||||
float fog_backscatter(in float avisibility);
|
||||
|
||||
vec3 searchlight();
|
||||
vec3 landing_light(in float offset);
|
||||
|
||||
float miePhase(in float cosTheta, in float g)
|
||||
{
|
||||
float g2 = g*g;
|
||||
|
@ -42,40 +56,7 @@ float rayleighPhase(in float cosTheta)
|
|||
return 1.5 * (2.0 + 0.5*cosTheta*cosTheta);
|
||||
}
|
||||
|
||||
float rand2D(in vec2 co){
|
||||
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
float simple_interpolate(in float a, in float b, in float x)
|
||||
{
|
||||
return a + smoothstep(0.0,1.0,x) * (b-a);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
|
@ -225,14 +206,34 @@ terrainHazeColor = clamp(terrainHazeColor,0.0,1.0);
|
|||
color = mix(color, terrainHazeColor ,smoothstep(hazeBlendAngle + ctterrain, 0.0+ctterrain, ct));
|
||||
|
||||
|
||||
// add the brightening of fog by lights
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// mix fog the skydome with the right amount of haze
|
||||
|
||||
hColor = clamp(hColor,0.0,1.0);
|
||||
color = transmission * color + (1.0-transmission) * eqColorFactor * hColor;
|
||||
//color = transmission * color + (1.0-transmission) * eqColorFactor * hColor ;
|
||||
color = mix((eqColorFactor * hColor)+secondary_light * fog_backscatter(avisibility),color, transmission);
|
||||
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
gl_FragDepth = 0.1;
|
||||
|
||||
}
|
||||
|
|
@ -82,9 +82,12 @@ float Strata3D(in vec3 coord, in float wavelength, in float variation);
|
|||
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(in float dist);
|
||||
vec3 landing_light(in float dist, in float offset);
|
||||
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)
|
||||
{
|
||||
|
@ -463,18 +466,22 @@ 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)
|
||||
{
|
||||
color.rgb += searchlight(dist);
|
||||
secondary_light += searchlight();
|
||||
}
|
||||
if (use_landing_light == 1)
|
||||
{
|
||||
color.rgb += landing_light(dist, landing_light1_offset);
|
||||
secondary_light += landing_light(landing_light1_offset);
|
||||
}
|
||||
if (use_alt_landing_light == 1)
|
||||
if (use_alt_landing_light == 1)
|
||||
{
|
||||
color.rgb += landing_light(dist, landing_light2_offset);
|
||||
secondary_light += landing_light(landing_light2_offset);
|
||||
}
|
||||
color.rgb +=secondary_light * light_distance_fading(dist);
|
||||
|
||||
|
||||
fragColor = color * texel + specular;
|
||||
|
@ -668,7 +675,7 @@ fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
|
|||
// finally, mix fog in
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
@ -22,9 +22,12 @@ uniform float hazeLayerAltitude;
|
|||
uniform float overcast;
|
||||
uniform float eye_alt;
|
||||
uniform float dust_cover_factor;
|
||||
uniform float landing_light1_offset;
|
||||
uniform float landing_light2_offset;
|
||||
|
||||
|
||||
|
||||
uniform int use_searchlight;
|
||||
uniform int use_landing_light;
|
||||
uniform int use_alt_landing_light;
|
||||
uniform int quality_level;
|
||||
uniform int tquality_level;
|
||||
|
||||
|
@ -36,6 +39,12 @@ float alt;
|
|||
float mie_angle;
|
||||
|
||||
|
||||
float light_distance_fading(in float dist);
|
||||
float fog_backscatter(in float avisibility);
|
||||
|
||||
vec3 searchlight();
|
||||
vec3 landing_light(in float offset);
|
||||
|
||||
float luminance(vec3 color)
|
||||
{
|
||||
return dot(vec3(0.212671, 0.715160, 0.072169), color);
|
||||
|
@ -145,7 +154,28 @@ void main()
|
|||
texel = mix(texel, dust_color, clamp(0.6 * dust_cover_factor ,0.0, 1.0) );
|
||||
}
|
||||
|
||||
vec4 fragColor = vec4 (gl_Color.xyz,1.0) * texel;
|
||||
|
||||
// ALS secondary light sources
|
||||
|
||||
vec3 secondary_light = vec3 (0.0,0.0,0.0);
|
||||
|
||||
if ((quality_level>5) && (tquality_level>5))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 fragColor = vec4 (gl_Color.rgb +secondary_light * light_distance_fading(dist),1.0) * texel;
|
||||
|
||||
|
||||
|
||||
|
@ -299,21 +329,15 @@ intensity = length(hazeColor);
|
|||
hazeColor = intensity * normalize(mix(hazeColor, 1.5* shadedFogColor, 1.0 -smoothstep(0.25, fade_out,eShade) ));
|
||||
|
||||
// change haze color to blue hue for strong fogging
|
||||
//intensity = length(hazeColor);
|
||||
|
||||
hazeColor = intensity * normalize(mix(hazeColor, shadedFogColor, (1.0-smoothstep(0.5,0.9,eqColorFactor))));
|
||||
|
||||
|
||||
// reduce haze intensity when looking at shaded surfaces, only in terminator region
|
||||
|
||||
//float shadow = mix( min(1.0 + dot(normal,lightDir),1.0), 1.0, 1.0-smoothstep(0.1, 0.4, transmission));
|
||||
//hazeColor = mix(shadow * hazeColor, hazeColor, 0.3 + 0.7* smoothstep(250000.0, 400000.0, terminator));
|
||||
|
||||
|
||||
// determine the right mix of transmission and haze
|
||||
|
||||
//fragColor.xyz = transmission * fragColor.xyz + (1.0-transmission) * eqColorFactor * hazeColor * earthShade;
|
||||
|
||||
fragColor.rgb = mix(eqColorFactor * hazeColor * eShade, fragColor.rgb,transmission);
|
||||
hazeColor = clamp(hazeColor,0.0,1.0);
|
||||
fragColor.rgb = mix(eqColorFactor * hazeColor * eShade + secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
|
Loading…
Reference in a new issue