From 379dd17b3dc888cef2335909e0af534ed0e60c1b Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Sun, 12 Jun 2016 15:22:11 +0300 Subject: [PATCH] ALS maintenance: bugfix for cloud impostors, 'inverse' Mie for cloud shader, glare for translucent objects proportional to 1-alpha rather than on-off --- Effects/cloud-impostor.eff | 42 ++++++++++++++++++++++++++++++++++++ Shaders/3dcloud-ALS.vert | 26 ++++++++++++++++++---- Shaders/model-ALS-ultra.frag | 4 ++-- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/Effects/cloud-impostor.eff b/Effects/cloud-impostor.eff index 6540e0025..9ef756587 100644 --- a/Effects/cloud-impostor.eff +++ b/Effects/cloud-impostor.eff @@ -60,6 +60,8 @@ Shaders/cloud-impostor-ALS.vert Shaders/cloud-static-ALS.frag + Shaders/noise.frag + Shaders/filters-ALS.frag baseTexture @@ -96,6 +98,46 @@ float air_pollution + + gamma + float + gamma + + + brightness + float + brightness + + + use_filtering + bool + use_filtering + + + use_night_vision + bool + use_night_vision + + + use_IR_vision + bool + use_IR_vision + + + delta_T + float + delta_T + + + display_xsize + int + display_xsize + + + display_ysize + int + display_ysize + true diff --git a/Shaders/3dcloud-ALS.vert b/Shaders/3dcloud-ALS.vert index 6c273e14d..c729bf0e0 100644 --- a/Shaders/3dcloud-ALS.vert +++ b/Shaders/3dcloud-ALS.vert @@ -209,15 +209,16 @@ void main(void) // Mie correction - float Mie; - float MieFactor; + float Mie = 0.0; + float MieFactor = 0.0; - if (bottom_factor > 0.6) + if (bottom_factor > 0.4) { MieFactor = dot(normalize(lightFull), normalize(relVector)); Mie = 1.5 * smoothstep(0.9,1.0, MieFactor) * smoothstep(0.6, 0.8, bottom_factor) * (1.0-earthShadeFactor) ; + //if (MieFactor < 0.0) {Mie = - Mie;} } - else {Mie = 0.0;} + //else {Mie = 0.0;} if (Mie > 0.0) { @@ -229,6 +230,23 @@ void main(void) gl_FrontColor.g = mie_func(gl_FrontColor.g, 0.8* Mie); gl_FrontColor.b = mie_func(gl_FrontColor.b, 0.5*Mie); } + else if (MieFactor < 0.0) + { + float thickness_reduction = smoothstep(0.4, 0.8, bottom_factor) ; + float light_reduction = dot (lightFull, lightHorizon); + light_reduction *= light_reduction; + + float factor_b = 0.8 + 0.2 * (1.0 - smoothstep(0.0, 0.7, -MieFactor) * thickness_reduction * light_reduction) ; + float factor_r = 0.6 + 0.4 * (1.0 - smoothstep(0.0, 0.7, -MieFactor) * thickness_reduction * light_reduction) ; + float factor_g = 0.65 + 0.35 * (1.0 - smoothstep(0.0, 0.7, -MieFactor) * thickness_reduction * light_reduction) ; + hazeColor.r *= factor_r; + hazeColor.g *= factor_g; + hazeColor.b *= factor_b; + + gl_FrontColor.r *= factor_r; + gl_FrontColor.g *= factor_g; + gl_FrontColor.b *= factor_b; + } gl_FrontColor.rgb = gl_FrontColor.rgb + moonLightColor * earthShadeFactor; hazeColor.rgb = hazeColor.rgb + moonLightColor * earthShadeFactor; diff --git a/Shaders/model-ALS-ultra.frag b/Shaders/model-ALS-ultra.frag index 04aa8dbd8..a57fdbbd5 100644 --- a/Shaders/model-ALS-ultra.frag +++ b/Shaders/model-ALS-ultra.frag @@ -253,8 +253,8 @@ void main (void) //glare on the backside of tranparent objects if ((gl_FrontMaterial.diffuse.a < 1.0 || texel.a < 1.0) && dot(N, normalize(gl_LightSource[0].position.xyz)) < 0.0) { - nDotVP = max(0.0, dot(-N, normalize(gl_LightSource[0].position.xyz))); - nDotHV = max(0.0, dot(-N, normalize(gl_LightSource[0].halfVector.xyz))); + nDotVP = max(0.0, dot(-N, normalize(gl_LightSource[0].position.xyz)) * (1.0 -texel.a) ); + nDotHV = max(0.0, dot(-N, normalize(gl_LightSource[0].halfVector.xyz)) * (1.0 -texel.a) ); } float nDotVP1 = 0.0;