From f3cc0ac539b1b308ca23509e36afc065d7b0a3a9 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Mon, 6 Oct 2014 09:43:51 +0300 Subject: [PATCH] Optional second landing light and light offset control for ALS --- Effects/airfield.eff | 15 ++++++++++++++ Effects/runway.eff | 15 ++++++++++++++ Effects/terrain-default.eff | 20 ++++++++++++++++++- Shaders/airfield-ALS.frag | 12 +++++++++-- Shaders/runway-ALS.frag | 11 ++++++++-- Shaders/secondary_lights.frag | 18 ++++++++--------- ...haze-ultra.frag => terrain-ALS-ultra.frag} | 11 ++++++++-- preferences.xml | 3 +++ 8 files changed, 89 insertions(+), 16 deletions(-) rename Shaders/{terrain-haze-ultra.frag => terrain-ALS-ultra.frag} (98%) diff --git a/Effects/airfield.eff b/Effects/airfield.eff index 7efbc8d14..1e0202d84 100644 --- a/Effects/airfield.eff +++ b/Effects/airfield.eff @@ -235,6 +235,16 @@ float view_fov + + landing_light1_offset + float + landing_light1_offset + + + landing_light2_offset + float + landing_light2_offset + cloudpos1_x float @@ -465,6 +475,11 @@ int use_landing_light + + use_alt_landing_light + int + use_alt_landing_light + display_xsize int diff --git a/Effects/runway.eff b/Effects/runway.eff index 692bc6bb0..ea2dbfc5f 100644 --- a/Effects/runway.eff +++ b/Effects/runway.eff @@ -276,6 +276,16 @@ float view_fov + + landing_light1_offset + float + landing_light1_offset + + + landing_light2_offset + float + landing_light2_offset + cloudpos1_x float @@ -501,6 +511,11 @@ int use_landing_light + + use_alt_landing_light + int + use_alt_landing_light + display_xsize int diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index 3d0b44996..c4915d23b 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -123,6 +123,9 @@ /sim/current-view/field-of-view /sim/rendering/als-secondary-lights/use-searchlight /sim/rendering/als-secondary-lights/use-landing-light + /sim/rendering/als-secondary-lights/use-alt-landing-light + /sim/rendering/als-secondary-lights/landing-light1-offset-deg + /sim/rendering/als-secondary-lights/landing-light2-offset-deg /sim/rendering/shaders/landmass /sim/rendering/shaders/transition /local-weather/cloud-shadows/cloudpos-x[0] @@ -298,7 +301,7 @@ Shaders/terrain-haze-ultra.vert - Shaders/terrain-haze-ultra.frag + Shaders/terrain-ALS-ultra.frag Shaders/noise.frag Shaders/cloud-shadowfunc.frag Shaders/hazes.frag @@ -459,6 +462,16 @@ float view_fov + + landing_light1_offset + float + landing_light1_offset + + + landing_light2_offset + float + landing_light2_offset + cloudpos1_x float @@ -679,6 +692,11 @@ int use_landing_light + + use_alt_landing_light + int + use_alt_landing_light + display_xsize int diff --git a/Shaders/airfield-ALS.frag b/Shaders/airfield-ALS.frag index 07f72d3ae..407545b5f 100644 --- a/Shaders/airfield-ALS.frag +++ b/Shaders/airfield-ALS.frag @@ -34,12 +34,16 @@ uniform float overlay_bias; uniform float overlay_alpha; uniform float wetness; uniform float air_pollution; +uniform float landing_light1_offset; +uniform float landing_light2_offset; + uniform int quality_level; uniform int tquality_level; uniform int cloud_shadow_flag; uniform int use_overlay; 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; @@ -56,7 +60,7 @@ float rayleigh_in_func(in float dist, in float air_pollution, in float avisibili float alt_factor(in float eye_alt, in float vertex_alt); vec3 rayleigh_out_shift(in vec3 color, in float outscatter); vec3 searchlight(in float dist); -vec3 landing_light(in float dist); +vec3 landing_light(in float dist, in float offset); float light_func (in float x, in float a, in float b, in float c, in float d, in float e) { @@ -274,7 +278,11 @@ if (quality_level > 3) } if (use_landing_light == 1) { - color.rgb += landing_light(dist); + color.rgb += landing_light(dist, landing_light1_offset); + } + if (use_alt_landing_light == 1) + { + color.rgb += landing_light(dist, landing_light2_offset); } fragColor = color * texel + specular; diff --git a/Shaders/runway-ALS.frag b/Shaders/runway-ALS.frag index 21099b7a9..884afc672 100644 --- a/Shaders/runway-ALS.frag +++ b/Shaders/runway-ALS.frag @@ -31,12 +31,15 @@ uniform float fogstructure; uniform float snow_thickness_factor; uniform float cloud_self_shading; uniform float uvstretch; +uniform float landing_light1_offset; +uniform float landing_light2_offset; 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; @@ -50,7 +53,7 @@ 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); +vec3 landing_light(in float dist, in float offset); @@ -252,7 +255,11 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0)) } if (use_landing_light == 1) { - color.rgb += landing_light(dist); + color.rgb += landing_light(dist, landing_light1_offset); + } + if (use_alt_landing_light == 1) + { + color.rgb += landing_light(dist, landing_light2_offset); } fragColor = color * texel + specular; diff --git a/Shaders/secondary_lights.frag b/Shaders/secondary_lights.frag index 3329c0584..051e5e157 100644 --- a/Shaders/secondary_lights.frag +++ b/Shaders/secondary_lights.frag @@ -12,12 +12,12 @@ vec3 searchlight(in float dist) vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.4); float headlightIntensity; -float lightRadius = (200.0 * 55.0/field_of_view); +float lightRadius = (float(display_xsize) *9.16 /field_of_view); float angularDist = length(gl_FragCoord.xy -center); if (angularDist < lightRadius) { - headlightIntensity = pow(cos(angularDist/lightRadius * 3.1415/2.0),2.0); + headlightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0); headlightIntensity = headlightIntensity * min(1.0, 10000.0/(dist*dist)); //headlightIntensity*= clamp(1.0 + 0.15 * log(1000.0/(dist*dist)),0.0,1.0); return headlightIntensity * vec3 (0.5,0.5, 0.5); @@ -25,7 +25,7 @@ if (angularDist < lightRadius) else return vec3 (0.0,0.0,0.0); } -vec3 landing_light(in float dist) +vec3 landing_light(in float dist, in float offset) { float fov_h = field_of_view; @@ -38,22 +38,22 @@ if (view_heading_offset > 180.0) else {yaw_offset = view_heading_offset;} -float x_offset = (float(display_xsize) / fov_h * yaw_offset); +float x_offset = (float(display_xsize) / fov_h * (yaw_offset + offset)); float y_offset = -(float(display_ysize) / fov_v * view_pitch_offset); vec2 center = vec2 (float(display_xsize) * 0.5 + x_offset, float(display_ysize) * 0.4 + y_offset); -float headlightIntensity; -float lightRadius = (200.0 * 55.0/field_of_view); +float landingLightIntensity; +float lightRadius = (float(display_xsize) *9.16 /field_of_view); float angularDist = length(gl_FragCoord.xy -center); if (angularDist < lightRadius) { - headlightIntensity = pow(cos(angularDist/lightRadius * 3.1415/2.0),2.0); - headlightIntensity = headlightIntensity * min(1.0, 10000.0/(dist*dist)); - return headlightIntensity * vec3 (0.5,0.5, 0.5); + landingLightIntensity = pow(cos(angularDist/lightRadius * 1.57075),2.0); + 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); } diff --git a/Shaders/terrain-haze-ultra.frag b/Shaders/terrain-ALS-ultra.frag similarity index 98% rename from Shaders/terrain-haze-ultra.frag rename to Shaders/terrain-ALS-ultra.frag index 8c1d273e7..bdcfa4e4b 100644 --- a/Shaders/terrain-haze-ultra.frag +++ b/Shaders/terrain-ALS-ultra.frag @@ -52,6 +52,8 @@ uniform float dot_size; uniform float dust_resistance; uniform float WindE; uniform float WindN; +uniform float landing_light1_offset; +uniform float landing_light2_offset; uniform float osg_SimulationTime; uniform int quality_level; @@ -61,6 +63,7 @@ uniform int cloud_shadow_flag; uniform int rock_strata; 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; @@ -81,7 +84,7 @@ float rayleigh_in_func(in float dist, in float air_pollution, in float avisibili float alt_factor(in float eye_alt, in float vertex_alt); vec3 rayleigh_out_shift(in vec3 color, in float outscatter); vec3 searchlight(in float dist); -vec3 landing_light(in float dist); +vec3 landing_light(in float dist, in float offset); float light_func (in float x, in float a, in float b, in float c, in float d, in float e) { @@ -466,7 +469,11 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0)) } if (use_landing_light == 1) { - color.rgb += landing_light(dist); + color.rgb += landing_light(dist, landing_light1_offset); + } + if (use_alt_landing_light == 1) + { + color.rgb += landing_light(dist, landing_light2_offset); } diff --git a/preferences.xml b/preferences.xml index d6562259a..a96554cd7 100644 --- a/preferences.xml +++ b/preferences.xml @@ -290,6 +290,9 @@ Started September 2000 by David Megginson, david@megginson.com false false + false + 0.0 + 0.0 120