From 12f4129a0da4316d53d71a0f81d1024bbaa76a55 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Mon, 1 Aug 2016 12:32:57 +0300 Subject: [PATCH] Lightspot effect for ALS runway shader --- Effects/runway.eff | 242 +++++++++++++++++++++++++++++++++++++ Shaders/lightspot-ALS.frag | 45 ++++++- Shaders/runway-ALS.frag | 4 +- preferences.xml | 43 +++++++ 4 files changed, 329 insertions(+), 5 deletions(-) diff --git a/Effects/runway.eff b/Effects/runway.eff index 7664f71e6..4cad33165 100644 --- a/Effects/runway.eff +++ b/Effects/runway.eff @@ -78,6 +78,46 @@ /environment/surface/snow-thickness-factor /environment/surface/wetness 1.0 + /sim/rendering/als-secondary-lights/num-lightspots + /sim/rendering/als-secondary-lights/lightspot/eyerel-x-m + /sim/rendering/als-secondary-lights/lightspot/eyerel-y-m + /sim/rendering/als-secondary-lights/lightspot/eyerel-z-m + /sim/rendering/als-secondary-lights/lightspot/stretch + /sim/rendering/als-secondary-lights/lightspot/dir + /sim/rendering/als-secondary-lights/lightspot/size + /sim/rendering/als-secondary-lights/lightspot/lightspot-r + /sim/rendering/als-secondary-lights/lightspot/lightspot-g + /sim/rendering/als-secondary-lights/lightspot/lightspot-b + /sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[1] + /sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[1] + /sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[1] + /sim/rendering/als-secondary-lights/lightspot/stretch[1] + /sim/rendering/als-secondary-lights/lightspot/dir[1] + /sim/rendering/als-secondary-lights/lightspot/size[1] + /sim/rendering/als-secondary-lights/lightspot/lightspot-r[1] + /sim/rendering/als-secondary-lights/lightspot/lightspot-g[1] + /sim/rendering/als-secondary-lights/lightspot/lightspot-b[1] + /sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[2] + /sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[2] + /sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[2] + /sim/rendering/als-secondary-lights/lightspot/size[2] + /sim/rendering/als-secondary-lights/lightspot/lightspot-r[2] + /sim/rendering/als-secondary-lights/lightspot/lightspot-g[2] + /sim/rendering/als-secondary-lights/lightspot/lightspot-b[2] + /sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[3] + /sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[3] + /sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[3] + /sim/rendering/als-secondary-lights/lightspot/size[3] + /sim/rendering/als-secondary-lights/lightspot/lightspot-r[3] + /sim/rendering/als-secondary-lights/lightspot/lightspot-g[3] + /sim/rendering/als-secondary-lights/lightspot/lightspot-b[3] + /sim/rendering/als-secondary-lights/lightspot/eyerel-x-m[4] + /sim/rendering/als-secondary-lights/lightspot/eyerel-y-m[4] + /sim/rendering/als-secondary-lights/lightspot/eyerel-z-m[4] + /sim/rendering/als-secondary-lights/lightspot/size[4] + /sim/rendering/als-secondary-lights/lightspot/lightspot-r[4] + /sim/rendering/als-secondary-lights/lightspot/lightspot-g[4] + /sim/rendering/als-secondary-lights/lightspot/lightspot-b[4] /sim/rendering/shaders/skydome /environment/fog-structure /environment/cloud-self-shading @@ -169,6 +209,7 @@ Shaders/hazes.frag Shaders/secondary_lights.frag Shaders/filters-ALS.frag + Shaders/lightspot-ALS.frag visibility @@ -270,6 +311,7 @@ float air_pollution + view_pitch_offset @@ -301,6 +343,201 @@ float landing_light3_offset + + eyerel_x1 + float + eyerel_x1 + + + eyerel_y1 + float + eyerel_y1 + + + eyerel_z1 + float + eyerel_z1 + + + lightspot_project1 + float + lightspot_project1 + + + lightspot_dir1 + float + lightspot_dir1 + + + lightspot_size1 + float + lightspot_size1 + + + lightspot_r1 + float + lightspot_r1 + + + lightspot_g1 + float + lightspot_g1 + + + lightspot_b1 + float + lightspot_b1 + + + eyerel_x2 + float + eyerel_x2 + + + eyerel_y2 + float + eyerel_y2 + + + eyerel_z2 + float + eyerel_z2 + + + lightspot_project2 + float + lightspot_project2 + + + lightspot_dir2 + float + lightspot_dir2 + + + lightspot_size2 + float + lightspot_size2 + + + lightspot_r2 + float + lightspot_r2 + + + lightspot_g2 + float + lightspot_g2 + + + lightspot_b2 + float + lightspot_b2 + + + eyerel_x3 + float + eyerel_x3 + + + eyerel_y3 + float + eyerel_y3 + + + eyerel_z3 + float + eyerel_z3 + + + lightspot_size3 + float + lightspot_size3 + + + lightspot_r3 + float + lightspot_r3 + + + lightspot_g3 + float + lightspot_g3 + + + lightspot_b3 + float + lightspot_b3 + + + eyerel_x4 + float + eyerel_x4 + + + eyerel_y4 + float + eyerel_y4 + + + eyerel_z4 + float + eyerel_z4 + + + lightspot_size4 + float + lightspot_size4 + + + lightspot_r4 + float + lightspot_r4 + + + lightspot_g4 + float + lightspot_g4 + + + lightspot_b4 + float + lightspot_b4 + + + eyerel_x5 + float + eyerel_x5 + + + eyerel_y5 + float + eyerel_y5 + + + eyerel_z5 + float + eyerel_z5 + + + lightspot_size5 + float + lightspot_size5 + + + lightspot_r5 + float + lightspot_r5 + + + lightspot_g5 + float + lightspot_g5 + + + lightspot_b5 + float + lightspot_b5 + gamma @@ -573,6 +810,11 @@ int display_ysize + + num_lightspots + int + num_lightspots + overlay_flag int diff --git a/Shaders/lightspot-ALS.frag b/Shaders/lightspot-ALS.frag index cfdae95fb..5862eff32 100644 --- a/Shaders/lightspot-ALS.frag +++ b/Shaders/lightspot-ALS.frag @@ -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; } diff --git a/Shaders/runway-ALS.frag b/Shaders/runway-ALS.frag index 51d952aba..3728c31f2 100644 --- a/Shaders/runway-ALS.frag +++ b/Shaders/runway-ALS.frag @@ -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; diff --git a/preferences.xml b/preferences.xml index bf4db1ec6..f09f63466 100644 --- a/preferences.xml +++ b/preferences.xml @@ -293,6 +293,49 @@ Started September 2000 by David Megginson, david@megginson.com 0.0 0.0 0 + 0 + + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + + false