From e5f4b0a51138a0b3941a13b93705990f5e259640 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Mon, 13 Nov 2017 10:27:25 +0200 Subject: [PATCH] More infrastructure for perception filtering of moonlight --- Effects/cloud-impostor.eff | 1 + Effects/cloud-noctilucent.eff | 1 + Effects/cloud-static.eff | 1 + Effects/cloud.eff | 1 + Shaders/3dcloud-ALS.vert | 4 ++++ Shaders/cloud-impostor-ALS.vert | 3 +++ Shaders/cloud-noctilucent-ALS.vert | 3 +++ Shaders/cloud-static-ALS.vert | 3 +++ Shaders/planet-cloudlayer.frag | 2 ++ Shaders/planet-high.frag | 6 ++++-- Shaders/road-ALS-ultra.frag | 2 ++ 11 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Effects/cloud-impostor.eff b/Effects/cloud-impostor.eff index 5dc04b36e..2f6a36f54 100644 --- a/Effects/cloud-impostor.eff +++ b/Effects/cloud-impostor.eff @@ -70,6 +70,7 @@ Shaders/cloud-impostor-ALS.vert + Shaders/filters-ALS.vert Shaders/cloud-static-ALS.frag Shaders/noise.frag Shaders/filters-ALS.frag diff --git a/Effects/cloud-noctilucent.eff b/Effects/cloud-noctilucent.eff index 730097f02..116135a0e 100644 --- a/Effects/cloud-noctilucent.eff +++ b/Effects/cloud-noctilucent.eff @@ -57,6 +57,7 @@ Shaders/cloud-noctilucent-ALS.vert + Shaders/filters-ALS.vert Shaders/cloud-static-ALS.frag diff --git a/Effects/cloud-static.eff b/Effects/cloud-static.eff index d2f6d44c0..38d916c37 100644 --- a/Effects/cloud-static.eff +++ b/Effects/cloud-static.eff @@ -67,6 +67,7 @@ Shaders/cloud-static-ALS.vert + Shaders/filters-ALS.vert Shaders/cloud-static-ALS.frag Shaders/noise.frag Shaders/filters-ALS.frag diff --git a/Effects/cloud.eff b/Effects/cloud.eff index 200e7b93e..ae8a04c7f 100644 --- a/Effects/cloud.eff +++ b/Effects/cloud.eff @@ -72,6 +72,7 @@ Shaders/3dcloud-ALS.vert + Shaders/filters-ALS.vert Shaders/3dcloud-ALS.frag Shaders/filters-ALS.frag Shaders/noise.frag diff --git a/Shaders/3dcloud-ALS.vert b/Shaders/3dcloud-ALS.vert index a1b3d28ea..e698f4f90 100644 --- a/Shaders/3dcloud-ALS.vert +++ b/Shaders/3dcloud-ALS.vert @@ -30,6 +30,8 @@ float top_factor = usrAttr2.b; const float EarthRadius = 5800000.0; +vec3 moonlight_perception (in vec3 light); + // light_func is a generalized logistic function fit to the light intensity as a function // of scaled terminator position obtained from Flightgear core @@ -68,6 +70,8 @@ void main(void) vec3 shadedFogColor = vec3(0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight * scattering; + moonLightColor = moonlight_perception (moonLightColor); + gl_TexCoord[0] = gl_MultiTexCoord0; vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0); vec4 l = gl_ModelViewMatrixInverse * vec4(0.0,0.0,1.0,1.0); diff --git a/Shaders/cloud-impostor-ALS.vert b/Shaders/cloud-impostor-ALS.vert index ae41398ac..0fbfc2236 100644 --- a/Shaders/cloud-impostor-ALS.vert +++ b/Shaders/cloud-impostor-ALS.vert @@ -16,6 +16,8 @@ const float shade = 1.0; const float cloud_height = 1000.0; const float EarthRadius = 5800000.0; +vec3 moonlight_perception (in vec3 light); + // light_func is a generalized logistic function fit to the light intensity as a function // of scaled terminator position obtained from Flightgear core @@ -36,6 +38,7 @@ void main(void) vec3 shadedFogColor = vec3 (0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception (moonLightColor); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; //gl_TexCoord[0] = gl_MultiTexCoord0 + vec4(textureIndexX, textureIndexY, 0.0, 0.0); diff --git a/Shaders/cloud-noctilucent-ALS.vert b/Shaders/cloud-noctilucent-ALS.vert index d95051844..2b1f0617b 100644 --- a/Shaders/cloud-noctilucent-ALS.vert +++ b/Shaders/cloud-noctilucent-ALS.vert @@ -13,6 +13,8 @@ const float shade = 1.0; const float cloud_height = 1000.0; const float EarthRadius = 5800000.0; +vec3 moonlight_perception (in vec3 light); + // light_func is a generalized logistic function fit to the light intensity as a function // of scaled terminator position obtained from Flightgear core @@ -33,6 +35,7 @@ void main(void) vec3 shadedFogColor = vec3 (0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception (moonLightColor); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; //gl_TexCoord[0] = gl_MultiTexCoord0 + vec4(textureIndexX, textureIndexY, 0.0, 0.0); diff --git a/Shaders/cloud-static-ALS.vert b/Shaders/cloud-static-ALS.vert index 0250413e8..150357fb5 100644 --- a/Shaders/cloud-static-ALS.vert +++ b/Shaders/cloud-static-ALS.vert @@ -13,6 +13,8 @@ const float shade = 1.0; const float cloud_height = 1000.0; const float EarthRadius = 5800000.0; +vec3 moonlight_perception (in vec3 light); + // light_func is a generalized logistic function fit to the light intensity as a function // of scaled terminator position obtained from Flightgear core @@ -33,6 +35,7 @@ void main(void) vec3 shadedFogColor = vec3 (0.55, 0.67, 0.88); vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception (moonLightColor); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; //gl_TexCoord[0] = gl_MultiTexCoord0 + vec4(textureIndexX, textureIndexY, 0.0, 0.0); diff --git a/Shaders/planet-cloudlayer.frag b/Shaders/planet-cloudlayer.frag index 9e1f62930..fc702e69e 100644 --- a/Shaders/planet-cloudlayer.frag +++ b/Shaders/planet-cloudlayer.frag @@ -25,6 +25,7 @@ uniform sampler2D structure_texture; float Noise2D(in vec2 coord, in float wavelength); vec3 filter_combined (in vec3 color) ; +vec3 moonlight_perception (in vec3 light); float add_cosines (in float cos1, in float cos2, in float sign) @@ -140,6 +141,7 @@ void main() color.rgb += lightning_color(gl_TexCoord[0].st) * (1.0 - texel.a) * lightning * darkness_fact; vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception (moonLightColor); color.rgb += moonLightColor; diff --git a/Shaders/planet-high.frag b/Shaders/planet-high.frag index 5d7a839db..afd99a241 100644 --- a/Shaders/planet-high.frag +++ b/Shaders/planet-high.frag @@ -22,6 +22,7 @@ uniform sampler2D normal_texture; float Noise2D(in vec2 coord, in float wavelength); vec3 filter_combined (in vec3 color) ; +vec3 moonlight_perception (in vec3 light); void main() @@ -135,8 +136,9 @@ void main() * pow(NdotHV, gl_FrontMaterial.shininess)); } - vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; - color.rgb += moonLightColor; + vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; + moonLightColor = moonlight_perception (moonLightColor); + color.rgb += moonLightColor; color.a = diffuse_term.a; diff --git a/Shaders/road-ALS-ultra.frag b/Shaders/road-ALS-ultra.frag index 9255196fd..eac34371d 100644 --- a/Shaders/road-ALS-ultra.frag +++ b/Shaders/road-ALS-ultra.frag @@ -112,6 +112,7 @@ vec3 searchlight(); vec3 landing_light(in float offset, in float offsetv); vec3 filter_combined (in vec3 color) ; vec3 addLights(in vec3 color1, in vec3 color2); +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) @@ -216,6 +217,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);