From 662d782f98189d76599e0f8cc109f9aebd37b1ba Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Fri, 3 Mar 2017 19:50:13 +0200 Subject: [PATCH] Groundwork for ALS g-force blackout filter, WIP --- Effects/agriculture.eff | 11 ++++++ Effects/airfield.eff | 10 ++++++ Effects/building.eff | 4 +-- Effects/cloud-static.eff | 12 +++++++ Effects/cloud.eff | 12 +++++++ Effects/dirt-runway.eff | 10 ++++++ Effects/model-combined.eff | 12 +++++++ Effects/model-default.eff | 12 +++++++ Effects/model-interior.eff | 20 +++++++++++ Effects/rain-layer.eff | 12 +++++++ Effects/rock.eff | 10 ++++++ Effects/runway.eff | 10 ++++++ Effects/skydome.eff | 12 +++++++ Effects/terrain-default.eff | 32 ++++++++++++++++++ Effects/tree.eff | 67 +++++++++++++++++++++++++++++++++++++ Effects/urban.eff | 20 +++++++++++ Effects/water-inland.eff | 23 ++++++++++++- Effects/water.eff | 21 ++++++++++++ Shaders/filters-ALS.frag | 38 ++++++++++++++++++++- defaults.xml | 3 ++ gui/dialogs/als-filters.xml | 41 +++++++++++++++++++++-- 21 files changed, 386 insertions(+), 6 deletions(-) diff --git a/Effects/agriculture.eff b/Effects/agriculture.eff index 041f920ea..debd89739 100644 --- a/Effects/agriculture.eff +++ b/Effects/agriculture.eff @@ -457,6 +457,17 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + + cloudpos1_x float diff --git a/Effects/airfield.eff b/Effects/airfield.eff index 0a348fdc8..a516d595b 100644 --- a/Effects/airfield.eff +++ b/Effects/airfield.eff @@ -327,6 +327,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x diff --git a/Effects/building.eff b/Effects/building.eff index 91afa9bee..dcd8062fc 100644 --- a/Effects/building.eff +++ b/Effects/building.eff @@ -98,8 +98,8 @@ /environment/terminator-relative-position-m /sim/rendering/shaders/skydome /environment/mean-terrain-elevation-m - /rendering/scene/overcast - /sim/rendering/eye-altitude-m + /rendering/scene/overcast + /sim/rendering/eye-altitude-m /environment/snow-level-m /environment/surface/dust-cover-factor /sim/rendering/shaders/skydome diff --git a/Effects/cloud-static.eff b/Effects/cloud-static.eff index b7a9f0e9a..d2f6d44c0 100644 --- a/Effects/cloud-static.eff +++ b/Effects/cloud-static.eff @@ -12,6 +12,8 @@ /sim/rendering/als-filters/gamma /sim/rendering/als-filters/brightness /environment/surface/delta-T-cloud + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision /sim/startup/xsize @@ -124,6 +126,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + display_xsize int diff --git a/Effects/cloud.eff b/Effects/cloud.eff index 647d8773b..200e7b93e 100644 --- a/Effects/cloud.eff +++ b/Effects/cloud.eff @@ -21,6 +21,8 @@ /sim/rendering/als-filters/gamma /sim/rendering/als-filters/brightness /environment/surface/delta-T-cloud + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision /sim/startup/xsize @@ -182,6 +184,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + display_xsize int diff --git a/Effects/dirt-runway.eff b/Effects/dirt-runway.eff index 880e04fde..0fa5f3399 100644 --- a/Effects/dirt-runway.eff +++ b/Effects/dirt-runway.eff @@ -362,6 +362,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff index 953e58425..4814d3648 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -972,6 +972,18 @@ please see Docs/README.model-combined.eff for documentation float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + + + cloudpos1_x float diff --git a/Effects/model-default.eff b/Effects/model-default.eff index 86ffb87ea..1ad02e801 100644 --- a/Effects/model-default.eff +++ b/Effects/model-default.eff @@ -30,6 +30,8 @@ /sim/rendering/als-filters/gamma /sim/rendering/als-filters/brightness /environment/surface/delta-T-structure + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision /sim/startup/xsize @@ -221,6 +223,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + view_pitch_offset float diff --git a/Effects/model-interior.eff b/Effects/model-interior.eff index bddc8f2b6..1001e77c9 100644 --- a/Effects/model-interior.eff +++ b/Effects/model-interior.eff @@ -387,6 +387,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + texture sampler-2d @@ -694,6 +704,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + texture sampler-2d diff --git a/Effects/rain-layer.eff b/Effects/rain-layer.eff index cef0f27ed..b33b69834 100644 --- a/Effects/rain-layer.eff +++ b/Effects/rain-layer.eff @@ -16,6 +16,8 @@ /sim/rendering/als-filters/gamma /sim/rendering/als-filters/brightness /environment/surface/delta-T-cloud + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision /sim/startup/xsize @@ -147,6 +149,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + display_xsize int diff --git a/Effects/rock.eff b/Effects/rock.eff index 1cfbb5ec4..80fe36464 100644 --- a/Effects/rock.eff +++ b/Effects/rock.eff @@ -325,6 +325,16 @@ delta_T float delta_T + + + fact_grey + float + fact_grey + + + fact_black + float + fact_black diff --git a/Effects/runway.eff b/Effects/runway.eff index 4cad33165..b3dec7a62 100644 --- a/Effects/runway.eff +++ b/Effects/runway.eff @@ -569,6 +569,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x diff --git a/Effects/skydome.eff b/Effects/skydome.eff index 90859d566..412288cfc 100644 --- a/Effects/skydome.eff +++ b/Effects/skydome.eff @@ -38,6 +38,8 @@ /sim/rendering/als-filters/brightness /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor -50.0 /environment/air-pollution-norm @@ -191,6 +193,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + use_filtering bool diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index 64fe4d57e..2e85cd87d 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -134,6 +134,8 @@ /sim/rendering/als-filters/use-filtering /sim/rendering/als-filters/gamma /sim/rendering/als-filters/brightness + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision /local-weather/cloud-shadows/cloudpos-x[0] @@ -518,6 +520,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x @@ -1061,6 +1073,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + display_xsize int @@ -1292,6 +1314,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + display_xsize int diff --git a/Effects/tree.eff b/Effects/tree.eff index 691b65b6d..2488ba9e6 100644 --- a/Effects/tree.eff +++ b/Effects/tree.eff @@ -60,6 +60,8 @@ /sim/rendering/als-filters/use-filtering /sim/rendering/als-filters/gamma /sim/rendering/als-filters/brightness + /sim/rendering/als-filters/grey-factor + /sim/rendering/als-filters/black-factor /sim/rendering/als-filters/use-night-vision /sim/rendering/als-filters/use-IR-vision /environment/surface/delta-T-vegetation @@ -304,6 +306,16 @@ delta_T float delta_T + + + fact_grey + float + fact_grey + + + fact_black + float + fact_black @@ -794,6 +806,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x @@ -1242,6 +1264,51 @@ float landing_light3_offset + + + + gamma + float + gamma + + + brightness + float + brightness + + + use_night_vision + bool + use_night_vision + + + use_IR_vision + bool + use_IR_vision + + + use_filtering + bool + use_filtering + + + delta_T + float + delta_T + + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + + + + cloudpos1_x float diff --git a/Effects/urban.eff b/Effects/urban.eff index 41da34776..d3229238b 100644 --- a/Effects/urban.eff +++ b/Effects/urban.eff @@ -508,6 +508,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x @@ -1064,6 +1074,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + cloudpos1_x diff --git a/Effects/water-inland.eff b/Effects/water-inland.eff index 684594e13..79343c11c 100644 --- a/Effects/water-inland.eff +++ b/Effects/water-inland.eff @@ -647,6 +647,17 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + + cloudpos1_x float @@ -1305,7 +1316,17 @@ delta_T float delta_T - + + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + sea_r diff --git a/Effects/water.eff b/Effects/water.eff index afe517c11..03a96084c 100644 --- a/Effects/water.eff +++ b/Effects/water.eff @@ -641,6 +641,17 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + + cloudpos1_x float @@ -1304,6 +1315,16 @@ float delta_T + + fact_grey + float + fact_grey + + + fact_black + float + fact_black + sea_r diff --git a/Shaders/filters-ALS.frag b/Shaders/filters-ALS.frag index 812f4deed..1bb63a2b3 100644 --- a/Shaders/filters-ALS.frag +++ b/Shaders/filters-ALS.frag @@ -10,6 +10,8 @@ uniform float gamma; uniform float brightness; uniform float delta_T; uniform float osg_SimulationTime; +uniform float fact_grey; +uniform float fact_black; uniform bool use_filtering; uniform bool use_night_vision; @@ -64,6 +66,40 @@ return vec3 (0.7, 0.7, 0.7) * gain; } + + +vec3 g_force (in vec3 color) { + +vec2 center = vec2 (float(display_xsize) * 0.5, float(display_ysize) * 0.5); + +float greyout_band_width = 0.2; +float blackout_band_width = 0.3; + +float f_grey = 1.0 - fact_grey; + +float greyout = smoothstep( f_grey * display_ysize, (f_grey + greyout_band_width) * display_ysize, length(gl_FragCoord.xy -center)); + +float tgt_brightness = (1.0 - 0.5 * greyout); + +float noise = Noise2D( vec2 (gl_FragCoord.x + 100.0 * osg_SimulationTime, +gl_FragCoord.y + 300.0 * osg_SimulationTime), 8.0); + +float f_black = 1.0 - fact_black; + +noise *= (1.0 - smoothstep(0.0, 0.5, f_black)); + +color = mix(color, vec3 (1.0, 1.0, 1.0) * mix(length(color), +tgt_brightness, greyout) , 0.9* greyout + 0.6 * noise); +color *= tgt_brightness; + +float blackout = 1.0 - smoothstep( f_black * display_ysize, (f_black + blackout_band_width) * display_ysize, length(gl_FragCoord.xy -center)); + +color *= blackout; + +return color; + +} + vec3 filter_combined (in vec3 color) { if (use_filtering == false) @@ -71,7 +107,7 @@ if (use_filtering == false) return color; } - +color = g_force(color); if (use_night_vision) diff --git a/defaults.xml b/defaults.xml index f2af7f5e6..b6173319a 100644 --- a/defaults.xml +++ b/defaults.xml @@ -363,6 +363,9 @@ Started September 2000 by David Megginson, david@megginson.com 1.0 false false + true + 0.0 + 0.0 diff --git a/gui/dialogs/als-filters.xml b/gui/dialogs/als-filters.xml index 74448bcc7..ad71544f1 100644 --- a/gui/dialogs/als-filters.xml +++ b/gui/dialogs/als-filters.xml @@ -85,6 +85,33 @@ hbox + + left + + true + /sim/rendering/als-filters/use-normal-filters + + /sim/rendering/shaders/skydome + /sim/rendering/als-filters/use-filtering + + + property-assign + /sim/rendering/als-filters/use-night-vision + false + + + property-assign + /sim/rendering/als-filters/use-IR-vision + false + + + property-assign + /sim/rendering/als-filters/use-normal-filters + true + + + + left @@ -95,10 +122,15 @@ /sim/rendering/als-filters/use-filtering - property-toggle + property-assign /sim/rendering/als-filters/use-night-vision true + + property-assign + /sim/rendering/als-filters/use-normal-filters + false + property-assign /sim/rendering/als-filters/use-IR-vision @@ -116,7 +148,7 @@ /sim/rendering/als-filters/use-filtering - property-toggle + property-assign /sim/rendering/als-filters/use-IR-vision true @@ -125,6 +157,11 @@ /sim/rendering/als-filters/use-night-vision false + + property-assign + /sim/rendering/als-filters/use-normal-filters + false +