From 97c78ceca38e1311f015966adf34627e6825623b Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Mon, 12 Oct 2026 17:07:03 +0200 Subject: [PATCH] atmosphere: disable haze for rays that do not hit the Earth sphere --- vendor/clouds3d.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vendor/clouds3d.js b/vendor/clouds3d.js index f773b30..bef930a 100644 --- a/vendor/clouds3d.js +++ b/vendor/clouds3d.js @@ -345,12 +345,13 @@ var FRAG_SRC = [ 'float cIn = dot(oc, oc) - R * R;', 'float discIn = b * b - cIn;', 'float tInner = 100000.0;', + 'float hitsInner = 0.0;', 'if (discIn > 0.0) {', 'float sq = sqrt(discIn);', 'float t1 = -b - sq;', 'float t2 = -b + sq;', - 'if (t1 > 0.0) tInner = t1;', - 'else if (t2 > 0.0) tInner = t2;', + 'if (t1 > 0.0) { tInner = t1; hitsInner = 1.0; }', + 'else if (t2 > 0.0) { tInner = t2; hitsInner = 1.0; }', '}', 'if (tInner < 100000.0) tEnd = min(tEnd, tInner);', 'if (tEnd <= tStart) { gl_FragColor = vec4(0.0); return; }', @@ -375,7 +376,7 @@ var FRAG_SRC = [ 't += step;', '}', 'float rawAlpha = clamp(1.0 - exp(-tau), 0.0, 1.0);', - 'float alpha = clamp(rawAlpha * uAtmoGain, 0.0, uAtmoMaxAlpha);', + 'float alpha = clamp(rawAlpha * uAtmoGain * hitsInner, 0.0, uAtmoMaxAlpha);', 'vec3 col = scatter / max(rawAlpha, 1e-4);', 'gl_FragColor = vec4(col, alpha);', 'return;',