From d9e55dc2e5c18bd5c9d4be239c7aded3fa34efed Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Mon, 29 Jan 2018 09:25:38 +0200 Subject: [PATCH] Improvements to Earthview: enable changing cloud density, fix aurora z-ordering issue, let moonlight give a relief effect to clouds --- Effects/planet-cloudlayer.eff | 22 ++++++++++++-------- Shaders/planet-cloudlayer.frag | 25 ++++++++++++++--------- Shaders/planet-high.frag | 7 +++---- defaults.xml | 1 + gui/dialogs/earthview.xml | 37 ++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 21 deletions(-) diff --git a/Effects/planet-cloudlayer.eff b/Effects/planet-cloudlayer.eff index b1d495f22..58ce137c6 100644 --- a/Effects/planet-cloudlayer.eff +++ b/Effects/planet-cloudlayer.eff @@ -22,6 +22,7 @@ /earthview/overlay-texture-flag /earthview/cloud-normal-flag /earthview/shade-effect + /earthview/cloudcover-bias /sim/time/sun-angle-rad /environment/moonlight /environment/air-pollution-norm @@ -95,10 +96,10 @@ cull-face transparent - - 111 + + 110 DepthSortedBin - + @@ -188,11 +189,16 @@ shade-effect - - air_pollution - float - air_pollution - + + cloudcover_bias + float + cloudcover-bias + + + air_pollution + float + air_pollution + sun_angle float diff --git a/Shaders/planet-cloudlayer.frag b/Shaders/planet-cloudlayer.frag index fc702e69e..a50a73919 100644 --- a/Shaders/planet-cloudlayer.frag +++ b/Shaders/planet-cloudlayer.frag @@ -16,6 +16,7 @@ uniform float moonlight; uniform float roi_x1; uniform float roi_y1; uniform float lightning; +uniform float cloudcover_bias; uniform bool use_overlay; uniform bool use_cloud_normals; @@ -27,7 +28,6 @@ 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) { @@ -86,11 +86,15 @@ void main() vec3 tangent = normalize(VTangent); vec3 binormal = cross(n, tangent); - float NdotL2 = 0.0; + float NdotL2 = 1.0; texel = texture2D(texture, gl_TexCoord[0].st); ref_texel = texel; + float sign = -1.0; + float ml_fact = 1.0; + + if (use_cloud_normals) { vec2 sun2d = vec2 (0.0, 1.0); @@ -114,7 +118,6 @@ void main() // relief shading based on gradient and parallax lookup float slope = shade_effect * (comp_texel.a - ref_texel.a) * texel.a; - float sign = -1.0; if (slope < 0.0) {sign = 1.0;} vec2 snormal = normalize(vec2 (slope, 1.0)); @@ -122,10 +125,14 @@ void main() NdotL2 = dot (snormal, sun2d); NdotL = add_cosines(NdotL, NdotL2, sign ); - + ml_fact = 0.5 + 1.0 * add_cosines(0.0, NdotL2, sign); } + + ref_texel = texel; + texel.a = pow(texel.a,1.0/cloudcover_bias); + texel.a = clamp(texel.a, 0.0, 1.0); color += diff_term * max(NdotL, 0.15) ; @@ -141,9 +148,8 @@ 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; + moonLightColor = moonlight_perception (moonLightColor); + color.rgb += moonLightColor * ml_fact; color.a = 1.0;//diffuse_term.a; color = clamp(color, 0.0, 1.0); @@ -158,15 +164,16 @@ void main() vec4 noiseTexel = vec4 (1.0,1.0,1.0, 0.5* noise * texel.a); structureTexel = mix(structureTexel, noiseTexel,noiseTexel.a); - + structureTexel = mix(structureTexel, texel, clamp(1.5 * ref_texel.a * (cloudcover_bias - 1.0), 0.0, 1.0)); if (use_overlay) { texel = vec4(structureTexel.rgb, smoothstep(0.0, 0.5,texel.a) * structureTexel.a); + //texel.a = pow(texel.a,1.0/cloudcover_bias); + } - texel.a = clamp((1.0 + darkness_fact) * texel.a, 0.0, 1.0); diff --git a/Shaders/planet-high.frag b/Shaders/planet-high.frag index afd99a241..9852493d9 100644 --- a/Shaders/planet-high.frag +++ b/Shaders/planet-high.frag @@ -24,7 +24,6 @@ float Noise2D(in vec2 coord, in float wavelength); vec3 filter_combined (in vec3 color) ; vec3 moonlight_perception (in vec3 light); - void main() { vec3 n; @@ -136,9 +135,9 @@ void main() * pow(NdotHV, gl_FrontMaterial.shininess)); } - vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; - moonLightColor = moonlight_perception (moonLightColor); - 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/defaults.xml b/defaults.xml index f0848619f..680541d67 100644 --- a/defaults.xml +++ b/defaults.xml @@ -1349,6 +1349,7 @@ Started September 2000 by David Megginson, david@megginson.com true true + 1.0 true true 0.0 diff --git a/gui/dialogs/earthview.xml b/gui/dialogs/earthview.xml index 63ee65042..c44f4d329 100644 --- a/gui/dialogs/earthview.xml +++ b/gui/dialogs/earthview.xml @@ -432,6 +432,43 @@ /environment/air-pollution-norm + + + + + + + + + hbox + right + + + + + + + + + + + cloudcover + 0.5 + 2.0 + /earthview/cloudcover-bias + + dialog-apply + cloudcover + + true + + + + %.1f + true + /earthview/cloudcover-bias + +