atmosphere: disable haze for rays that do not hit the Earth sphere

This commit is contained in:
Richard Zink committed 2026-10-12 17:07:03 +02:00
1 parent 83bec11d61
commit 97c78ceca3
1 file changed
+4 -3
+4 -3
View File
@@ -345,12 +345,13 @@ var FRAG_SRC = [
'float cIn = dot(oc, oc) - R * R;', 'float cIn = dot(oc, oc) - R * R;',
'float discIn = b * b - cIn;', 'float discIn = b * b - cIn;',
'float tInner = 100000.0;', 'float tInner = 100000.0;',
'float hitsInner = 0.0;',
'if (discIn > 0.0) {', 'if (discIn > 0.0) {',
'float sq = sqrt(discIn);', 'float sq = sqrt(discIn);',
'float t1 = -b - sq;', 'float t1 = -b - sq;',
'float t2 = -b + sq;', 'float t2 = -b + sq;',
'if (t1 > 0.0) tInner = t1;', 'if (t1 > 0.0) { tInner = t1; hitsInner = 1.0; }',
'else if (t2 > 0.0) tInner = t2;', 'else if (t2 > 0.0) { tInner = t2; hitsInner = 1.0; }',
'}', '}',
'if (tInner < 100000.0) tEnd = min(tEnd, tInner);', 'if (tInner < 100000.0) tEnd = min(tEnd, tInner);',
'if (tEnd <= tStart) { gl_FragColor = vec4(0.0); return; }', 'if (tEnd <= tStart) { gl_FragColor = vec4(0.0); return; }',
@@ -375,7 +376,7 @@ var FRAG_SRC = [
't += step;', 't += step;',
'}', '}',
'float rawAlpha = clamp(1.0 - exp(-tau), 0.0, 1.0);', '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);', 'vec3 col = scatter / max(rawAlpha, 1e-4);',
'gl_FragColor = vec4(col, alpha);', 'gl_FragColor = vec4(col, alpha);',
'return;', 'return;',