From 746e80547ee6b0cb472cfa9561f8a729d68ddd5d Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Sun, 18 Jun 2017 10:08:39 +0300 Subject: [PATCH] ALS - begin infrastructure for moonlight perception filtering --- Effects/agriculture.eff | 1 + Effects/airfield.eff | 1 + Effects/dirt-runway.eff | 1 + Effects/grass.eff | 1 + Effects/rock.eff | 1 + Effects/runway.eff | 1 + Effects/terrain-default.eff | 2 ++ Shaders/filters-ALS.frag | 6 ++++++ Shaders/filters-ALS.vert | 11 +++++++++++ Shaders/model-ALS-ultra.frag | 2 ++ Shaders/space-ALS-ultra.frag | 4 ++++ Shaders/terrain-ALS-detailed.vert | 3 +++ Shaders/terrain-ALS-ultra.vert | 5 ++++- 13 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Shaders/filters-ALS.vert diff --git a/Effects/agriculture.eff b/Effects/agriculture.eff index debd89739..a5a2c9818 100644 --- a/Effects/agriculture.eff +++ b/Effects/agriculture.eff @@ -239,6 +239,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/agriculture-ALS.frag Shaders/cloud-shadowfunc.frag Shaders/noise.frag diff --git a/Effects/airfield.eff b/Effects/airfield.eff index a516d595b..ea34136ab 100644 --- a/Effects/airfield.eff +++ b/Effects/airfield.eff @@ -138,6 +138,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/airfield-ALS.frag Shaders/cloud-shadowfunc.frag Shaders/noise.frag diff --git a/Effects/dirt-runway.eff b/Effects/dirt-runway.eff index 0fa5f3399..5c09702b2 100644 --- a/Effects/dirt-runway.eff +++ b/Effects/dirt-runway.eff @@ -139,6 +139,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/drunway-ALS.frag Shaders/cloud-shadowfunc.frag Shaders/noise.frag diff --git a/Effects/grass.eff b/Effects/grass.eff index ff2ca1843..63e5bf781 100755 --- a/Effects/grass.eff +++ b/Effects/grass.eff @@ -132,6 +132,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/airfield-ALS.frag Shaders/cloud-shadowfunc.frag Shaders/noise.frag diff --git a/Effects/rock.eff b/Effects/rock.eff index 80fe36464..b24f14a70 100644 --- a/Effects/rock.eff +++ b/Effects/rock.eff @@ -88,6 +88,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/rock-ALS.frag Shaders/cloud-shadowfunc.frag Shaders/noise.frag diff --git a/Effects/runway.eff b/Effects/runway.eff index b3dec7a62..e7e2e4af2 100644 --- a/Effects/runway.eff +++ b/Effects/runway.eff @@ -203,6 +203,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/runway-ALS.frag Shaders/cloud-shadowfunc.frag Shaders/noise.frag diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index 2e85cd87d..47f666260 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -311,6 +311,7 @@ Shaders/terrain-ALS-ultra.vert + Shaders/filters-ALS.vert Shaders/terrain-ALS-ultra.frag Shaders/noise.frag Shaders/cloud-shadowfunc.frag @@ -932,6 +933,7 @@ Shaders/terrain-ALS-detailed.vert + Shaders/filters-ALS.vert Shaders/terrain-ALS-detailed.frag Shaders/noise.frag Shaders/hazes.frag diff --git a/Shaders/filters-ALS.frag b/Shaders/filters-ALS.frag index 1bb63a2b3..92302f5ae 100644 --- a/Shaders/filters-ALS.frag +++ b/Shaders/filters-ALS.frag @@ -67,6 +67,12 @@ return vec3 (0.7, 0.7, 0.7) * gain; } +vec3 moonlight_perception (in vec3 light) { + +return light; + +} + vec3 g_force (in vec3 color) { diff --git a/Shaders/filters-ALS.vert b/Shaders/filters-ALS.vert new file mode 100644 index 000000000..5027e7d6c --- /dev/null +++ b/Shaders/filters-ALS.vert @@ -0,0 +1,11 @@ +// -*-C++-*- + +// This is a library of filter functions for the vertex shader + +// Thorsten Renk 2017 + +vec3 moonlight_perception (in vec3 light) { + +return light; + +} diff --git a/Shaders/model-ALS-ultra.frag b/Shaders/model-ALS-ultra.frag index 57c9dc3f6..8173466e3 100644 --- a/Shaders/model-ALS-ultra.frag +++ b/Shaders/model-ALS-ultra.frag @@ -114,6 +114,7 @@ vec3 get_hazeColor(in float lightArg); vec3 searchlight(); vec3 landing_light(in float offset, in float offsetv); vec3 filter_combined (in vec3 color) ; +vec3 moonlight_perception (in vec3 light) ; vec3 addLights(in vec3 color1, in vec3 color2); @@ -147,6 +148,7 @@ void main (void) ///some generic light scattering parameters vec3 shadedFogColor = vec3(0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception(moonLightColor); float alt = eye_alt; float effective_scattering = min(scattering, cloud_self_shading); diff --git a/Shaders/space-ALS-ultra.frag b/Shaders/space-ALS-ultra.frag index 3a6e28c4d..34dcf708d 100644 --- a/Shaders/space-ALS-ultra.frag +++ b/Shaders/space-ALS-ultra.frag @@ -122,6 +122,9 @@ vec3 searchlight(); vec3 landing_light(in float offset, in float offsetv); vec3 addLights(in vec3 color1, in vec3 color2); vec4 color_temperature (in float T); +vec3 filter_combined (in vec3 color) ; +vec3 moonlight_perception (in vec3 light) ; + float light_func (in float x, in float a, in float b, in float c, in float d, in float e) { @@ -151,6 +154,7 @@ void main (void) ///some generic light scattering parameters vec3 shadedFogColor = vec3(0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception(moonLightColor); float alt = eye_alt; float effective_scattering = min(scattering, cloud_self_shading); diff --git a/Shaders/terrain-ALS-detailed.vert b/Shaders/terrain-ALS-detailed.vert index 3a367f57c..660919b35 100644 --- a/Shaders/terrain-ALS-detailed.vert +++ b/Shaders/terrain-ALS-detailed.vert @@ -54,6 +54,8 @@ float yprime_alt; const float EarthRadius = 5800000.0; const float terminator_width = 200000.0; +vec3 moonlight_perception (in vec3 light); + float light_func (in float x, in float a, in float b, in float c, in float d, in float e) { //x = x - 0.5; @@ -72,6 +74,7 @@ void main() vec4 light_ambient; vec3 shadedFogColor = vec3(0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception (moonLightColor); //float yprime_alt; float yprime; diff --git a/Shaders/terrain-ALS-ultra.vert b/Shaders/terrain-ALS-ultra.vert index 75f609a5f..c3dcf9f28 100644 --- a/Shaders/terrain-ALS-ultra.vert +++ b/Shaders/terrain-ALS-ultra.vert @@ -51,7 +51,7 @@ uniform mat4 osg_ViewMatrixInverse; float earthShade; float yprime_alt; - +vec3 moonlight_perception (in vec3 light); // This is the value used in the skydome scattering shader - use the same here for consistency? const float EarthRadius = 5800000.0; @@ -77,6 +77,9 @@ void main() vec3 shadedFogColor = vec3(0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight + vec3 (0.005, 0.005, 0.005); + moonLightColor = moonlight_perception (moonLightColor); + + //float yprime_alt; float yprime; float lightArg;