1
0
Fork 0

Lightspot effect for ALS runway shader

This commit is contained in:
Thorsten Renk 2016-08-01 12:32:57 +03:00
parent 5fc5e8263f
commit 12f4129a0d
4 changed files with 329 additions and 5 deletions

View file

@ -78,6 +78,46 @@
<snow_thickness_factor><use>/environment/surface/snow-thickness-factor</use></snow_thickness_factor>
<wetness><use>/environment/surface/wetness</use></wetness>
<uvstretch>1.0</uvstretch>
<num_lightspots><use>/sim/rendering/als-secondary-lights/num-lightspots</use></num_lightspots>
<eyerel_x1><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m</use></eyerel_x1>
<eyerel_y1><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m</use></eyerel_y1>
<eyerel_z1><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m</use></eyerel_z1>
<lightspot_project1><use>/sim/rendering/als-secondary-lights/lightspot/stretch</use></lightspot_project1>
<lightspot_dir1><use>/sim/rendering/als-secondary-lights/lightspot/dir</use></lightspot_dir1>
<lightspot_size1><use>/sim/rendering/als-secondary-lights/lightspot/size</use></lightspot_size1>
<lightspot_r1><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-r</use></lightspot_r1>
<lightspot_g1><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-g</use></lightspot_g1>
<lightspot_b1><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-b</use></lightspot_b1>
<eyerel_x2><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[1]</use></eyerel_x2>
<eyerel_y2><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[1]</use></eyerel_y2>
<eyerel_z2><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[1]</use></eyerel_z2>
<lightspot_project2><use>/sim/rendering/als-secondary-lights/lightspot/stretch[1]</use></lightspot_project2>
<lightspot_dir2><use>/sim/rendering/als-secondary-lights/lightspot/dir[1]</use></lightspot_dir2>
<lightspot_size2><use>/sim/rendering/als-secondary-lights/lightspot/size[1]</use></lightspot_size2>
<lightspot_r2><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-r[1]</use></lightspot_r2>
<lightspot_g2><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-g[1]</use></lightspot_g2>
<lightspot_b2><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-b[1]</use></lightspot_b2>
<eyerel_x3><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[2]</use></eyerel_x3>
<eyerel_y3><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[2]</use></eyerel_y3>
<eyerel_z3><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[2]</use></eyerel_z3>
<lightspot_size3><use>/sim/rendering/als-secondary-lights/lightspot/size[2]</use></lightspot_size3>
<lightspot_r3><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-r[2]</use></lightspot_r3>
<lightspot_g3><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-g[2]</use></lightspot_g3>
<lightspot_b3><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-b[2]</use></lightspot_b3>
<eyerel_x4><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[3]</use></eyerel_x4>
<eyerel_y4><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[3]</use></eyerel_y4>
<eyerel_z4><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[3]</use></eyerel_z4>
<lightspot_size4><use>/sim/rendering/als-secondary-lights/lightspot/size[3]</use></lightspot_size4>
<lightspot_r4><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-r[3]</use></lightspot_r4>
<lightspot_g4><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-g[3]</use></lightspot_g4>
<lightspot_b4><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-b[3]</use></lightspot_b4>
<eyerel_x5><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[4]</use></eyerel_x5>
<eyerel_y5><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[4]</use></eyerel_y5>
<eyerel_z5><use>/sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[4]</use></eyerel_z5>
<lightspot_size5><use>/sim/rendering/als-secondary-lights/lightspot/size[4]</use></lightspot_size5>
<lightspot_r5><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-r[4]</use></lightspot_r5>
<lightspot_g5><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-g[4]</use></lightspot_g5>
<lightspot_b5><use>/sim/rendering/als-secondary-lights/lightspot/lightspot-b[4]</use></lightspot_b5>
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
<fogstructure><use>/environment/fog-structure</use></fogstructure>
<cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading>
@ -169,6 +209,7 @@
<fragment-shader n="3">Shaders/hazes.frag</fragment-shader>
<fragment-shader n="4">Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader n="5">Shaders/filters-ALS.frag</fragment-shader>
<fragment-shader n="6">Shaders/lightspot-ALS.frag</fragment-shader>
</program>
<uniform>
<name>visibility</name>
@ -270,6 +311,7 @@
<type>float</type>
<value><use>air_pollution</use></value>
</uniform>
<!-- secondary lights -->
<uniform>
<name>view_pitch_offset</name>
@ -301,6 +343,201 @@
<type>float</type>
<value><use>landing_light3_offset</use></value>
</uniform>
<uniform>
<name>eyerel_x1</name>
<type>float</type>
<value><use>eyerel_x1</use></value>
</uniform>
<uniform>
<name>eyerel_y1</name>
<type>float</type>
<value><use>eyerel_y1</use></value>
</uniform>
<uniform>
<name>eyerel_z1</name>
<type>float</type>
<value><use>eyerel_z1</use></value>
</uniform>
<uniform>
<name>lightspot_project1</name>
<type>float</type>
<value><use>lightspot_project1</use></value>
</uniform>
<uniform>
<name>lightspot_dir1</name>
<type>float</type>
<value><use>lightspot_dir1</use></value>
</uniform>
<uniform>
<name>lightspot_size1</name>
<type>float</type>
<value><use>lightspot_size1</use></value>
</uniform>
<uniform>
<name>lightspot_r1</name>
<type>float</type>
<value><use>lightspot_r1</use></value>
</uniform>
<uniform>
<name>lightspot_g1</name>
<type>float</type>
<value><use>lightspot_g1</use></value>
</uniform>
<uniform>
<name>lightspot_b1</name>
<type>float</type>
<value><use>lightspot_b1</use></value>
</uniform>
<uniform>
<name>eyerel_x2</name>
<type>float</type>
<value><use>eyerel_x2</use></value>
</uniform>
<uniform>
<name>eyerel_y2</name>
<type>float</type>
<value><use>eyerel_y2</use></value>
</uniform>
<uniform>
<name>eyerel_z2</name>
<type>float</type>
<value><use>eyerel_z2</use></value>
</uniform>
<uniform>
<name>lightspot_project2</name>
<type>float</type>
<value><use>lightspot_project2</use></value>
</uniform>
<uniform>
<name>lightspot_dir2</name>
<type>float</type>
<value><use>lightspot_dir2</use></value>
</uniform>
<uniform>
<name>lightspot_size2</name>
<type>float</type>
<value><use>lightspot_size2</use></value>
</uniform>
<uniform>
<name>lightspot_r2</name>
<type>float</type>
<value><use>lightspot_r2</use></value>
</uniform>
<uniform>
<name>lightspot_g2</name>
<type>float</type>
<value><use>lightspot_g2</use></value>
</uniform>
<uniform>
<name>lightspot_b2</name>
<type>float</type>
<value><use>lightspot_b2</use></value>
</uniform>
<uniform>
<name>eyerel_x3</name>
<type>float</type>
<value><use>eyerel_x3</use></value>
</uniform>
<uniform>
<name>eyerel_y3</name>
<type>float</type>
<value><use>eyerel_y3</use></value>
</uniform>
<uniform>
<name>eyerel_z3</name>
<type>float</type>
<value><use>eyerel_z3</use></value>
</uniform>
<uniform>
<name>lightspot_size3</name>
<type>float</type>
<value><use>lightspot_size3</use></value>
</uniform>
<uniform>
<name>lightspot_r3</name>
<type>float</type>
<value><use>lightspot_r3</use></value>
</uniform>
<uniform>
<name>lightspot_g3</name>
<type>float</type>
<value><use>lightspot_g3</use></value>
</uniform>
<uniform>
<name>lightspot_b3</name>
<type>float</type>
<value><use>lightspot_b3</use></value>
</uniform>
<uniform>
<name>eyerel_x4</name>
<type>float</type>
<value><use>eyerel_x4</use></value>
</uniform>
<uniform>
<name>eyerel_y4</name>
<type>float</type>
<value><use>eyerel_y4</use></value>
</uniform>
<uniform>
<name>eyerel_z4</name>
<type>float</type>
<value><use>eyerel_z4</use></value>
</uniform>
<uniform>
<name>lightspot_size4</name>
<type>float</type>
<value><use>lightspot_size4</use></value>
</uniform>
<uniform>
<name>lightspot_r4</name>
<type>float</type>
<value><use>lightspot_r4</use></value>
</uniform>
<uniform>
<name>lightspot_g4</name>
<type>float</type>
<value><use>lightspot_g4</use></value>
</uniform>
<uniform>
<name>lightspot_b4</name>
<type>float</type>
<value><use>lightspot_b4</use></value>
</uniform>
<uniform>
<name>eyerel_x5</name>
<type>float</type>
<value><use>eyerel_x5</use></value>
</uniform>
<uniform>
<name>eyerel_y5</name>
<type>float</type>
<value><use>eyerel_y5</use></value>
</uniform>
<uniform>
<name>eyerel_z5</name>
<type>float</type>
<value><use>eyerel_z5</use></value>
</uniform>
<uniform>
<name>lightspot_size5</name>
<type>float</type>
<value><use>lightspot_size5</use></value>
</uniform>
<uniform>
<name>lightspot_r5</name>
<type>float</type>
<value><use>lightspot_r5</use></value>
</uniform>
<uniform>
<name>lightspot_g5</name>
<type>float</type>
<value><use>lightspot_g5</use></value>
</uniform>
<uniform>
<name>lightspot_b5</name>
<type>float</type>
<value><use>lightspot_b5</use></value>
</uniform>
<!-- filtering -->
<uniform>
<name>gamma</name>
@ -573,6 +810,11 @@
<type>int</type>
<value><use>display_ysize</use></value>
</uniform>
<uniform>
<name>num_lightspots</name>
<type>int</type>
<value><use>num_lightspots</use></value>
</uniform>
<uniform>
<name>overlay_flag</name>
<type>int</type>

View file

@ -40,10 +40,19 @@ uniform float lightspot_size3;
uniform float lightspot_size4;
uniform float lightspot_size5;
uniform int num_lightspots;
vec3 lightspot(vec3 relPos)
{
if (num_lightspots == 0)
{
return vec3 (0.0, 0.0, 0.0);
}
// first projectable spot
vec3 eye_rel = vec3 (eyerel_x1, eyerel_y1, eyerel_z1);
vec3 difference_vec = relPos - eye_rel;
@ -52,19 +61,47 @@ mat2 rotMat = mat2 (cos(lightspot_dir1), sin(lightspot_dir1), -sin(lightspot_dir
difference_vec.xy = rotMat * difference_vec.xy;
difference_vec.x/= (1.0 + lightspot_project1);
float lightspot_arg = (1.0 - smoothstep(5.0, 15.0, length(difference_vec))) * (1.0 - 0.5* smoothstep(5.0, 15.0/(1.0+lightspot_project1), difference_vec.x));
float lightspot_arg = (1.0 - smoothstep(lightspot_size1/3.0, lightspot_size1, length(difference_vec))) * (1.0 - 0.5* smoothstep(lightspot_size1/3.0, lightspot_size1/(1.0+lightspot_project1), difference_vec.x));
vec3 lightspot_color = vec3 (lightspot_r1,lightspot_g1, lightspot_b1 ) * lightspot_arg;
// second projectable spot
eye_rel = vec3 (eyerel_x2, eyerel_y2, eyerel_z2);
lightspot_arg = (1.0 - smoothstep(0.0, 5.0, length(relPos - eye_rel)));
difference_vec = relPos - eye_rel;
rotMat = mat2 (cos(lightspot_dir2), sin(lightspot_dir2), -sin(lightspot_dir2), cos(lightspot_dir2));
difference_vec.xy = rotMat * difference_vec.xy;
difference_vec.x/= (1.0 + lightspot_project2);
lightspot_arg = (1.0 - smoothstep(lightspot_size2/3.0, lightspot_size2, length(relPos - eye_rel)));
lightspot_color += vec3 (lightspot_r2,lightspot_g2, lightspot_b2 ) * lightspot_arg;
if (num_lightspots < 3)
{
return lightspot_color ;
}
// spherical spot
eye_rel = vec3 (eyerel_x3, eyerel_y3, eyerel_z3);
lightspot_arg = (1.0 - smoothstep(0.0, 5.0, length(relPos - eye_rel)));
lightspot_arg = (1.0 - smoothstep(lightspot_size3/3.0, lightspot_size3, length(relPos - eye_rel)));
lightspot_color += vec3 (lightspot_r3,lightspot_g3, lightspot_b3 ) * lightspot_arg;
// spherical spot
eye_rel = vec3 (eyerel_x4, eyerel_y4, eyerel_z4);
lightspot_arg = (1.0 - smoothstep(lightspot_size4/3.0, lightspot_size4, length(relPos - eye_rel)));
lightspot_color += vec3 (lightspot_r4,lightspot_g4, lightspot_b4 ) * lightspot_arg;
// spherical spot
eye_rel = vec3 (eyerel_x5, eyerel_y5, eyerel_z5);
lightspot_arg = (1.0 - smoothstep(lightspot_size5/3.0, lightspot_size5, length(relPos - eye_rel)));
lightspot_color += vec3 (lightspot_r5,lightspot_g5, lightspot_b5 ) * lightspot_arg;
return lightspot_color;
}

View file

@ -67,6 +67,7 @@ float rayleigh_in_func(in float dist, in float air_pollution, in float avisibili
vec3 searchlight();
vec3 landing_light(in float offset, in float offsetv);
vec3 lightspot(in vec3 relPos);
vec3 rayleigh_out_shift(in vec3 color, in float outscatter);
vec3 get_hazeColor(in float light_arg);
vec3 filter_combined (in vec3 color) ;
@ -333,7 +334,8 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
{
secondary_light += landing_light(landing_light2_offset, landing_light3_offset);
}
color.rgb +=secondary_light * light_distance_fading(dist);
color.rgb +=secondary_light * light_distance_fading(dist) + lightspot(relPos);
fragColor = color * texel + specular;

View file

@ -293,6 +293,49 @@ Started September 2000 by David Megginson, david@megginson.com
<landing-light2-offset-deg type="float">0.0</landing-light2-offset-deg>
<landing-light3-offset-deg type="float">0.0</landing-light3-offset-deg>
<use-flashlight type="int">0</use-flashlight>
<num-lightspots type="int">0</num-lightspots>
<lightspot>
<eyerel-x-m type="float">0.0</eyerel-x-m>
<eyerel-x-m n="1" type="float">0.0</eyerel-x-m>
<eyerel-x-m n="2" type="float">0.0</eyerel-x-m>
<eyerel-x-m n="3" type="float">0.0</eyerel-x-m>
<eyerel-x-m n="4" type="float">0.0</eyerel-x-m>
<eyerel-y-m type="float">0.0</eyerel-y-m>
<eyerel-y-m n="1" type="float">0.0</eyerel-y-m>
<eyerel-y-m n="2" type="float">0.0</eyerel-y-m>
<eyerel-y-m n="3" type="float">0.0</eyerel-y-m>
<eyerel-y-m n="4" type="float">0.0</eyerel-y-m>
<eyerel-z-m type="float">0.0</eyerel-z-m>
<eyerel-z-m n="1" type="float">0.0</eyerel-z-m>
<eyerel-z-m n="2" type="float">0.0</eyerel-z-m>
<eyerel-z-m n="3" type="float">0.0</eyerel-z-m>
<eyerel-z-m n="4" type="float">0.0</eyerel-z-m>
<lightspot-r type="float">0.0</lightspot-r>
<lightspot-g type="float">0.0</lightspot-g>
<lightspot-b type="float">0.0</lightspot-b>
<lightspot-r n="1" type="float">0.0</lightspot-r>
<lightspot-g n="1" type="float">0.0</lightspot-g>
<lightspot-b n="1" type="float">0.0</lightspot-b>
<lightspot-r n="2" type="float">0.0</lightspot-r>
<lightspot-g n="2" type="float">0.0</lightspot-g>
<lightspot-b n="2" type="float">0.0</lightspot-b>
<lightspot-r n="3" type="float">0.0</lightspot-r>
<lightspot-g n="3" type="float">0.0</lightspot-g>
<lightspot-b n="3" type="float">0.0</lightspot-b>
<lightspot-r n="4" type="float">0.0</lightspot-r>
<lightspot-g n="4" type="float">0.0</lightspot-g>
<lightspot-b n="4" type="float">0.0</lightspot-b>
<size type="float">0.0</size>
<size n="1" type="float">0.0</size>
<size n="2" type="float">0.0</size>
<size n="3" type="float">0.0</size>
<size n="4" type="float">0.0</size>
<dir type="float">0.0</dir>
<dir n="1" type="float">0.0</dir>
<stretch type="float">0.0</stretch>
<stretch n="1" type="float">0.0</stretch>
</lightspot>
</als-secondary-lights>
<als-filters>
<use-filtering type="bool">false</use-filtering>