clouds: clip only against curved horizon, not detailed terrain

This commit is contained in:
Richard Zink committed 2026-10-12 14:57:32 +02:00
1 parent cb847df3f5
commit 20b47f5460
1 file changed
+3 -10
+3 -10
View File
@@ -446,16 +446,9 @@ var FRAG_SRC = [
'float tTerrain = -1.0;', 'float tTerrain = -1.0;',
'if (terrRoots.x > 0.0) tTerrain = terrRoots.x;', 'if (terrRoots.x > 0.0) tTerrain = terrRoots.x;',
'else if (terrRoots.y > 0.0) tTerrain = terrRoots.y;', 'else if (terrRoots.y > 0.0) tTerrain = terrRoots.y;',
'if (tTerrain > 0.0 && uElevOn > 0.5 && rd.y < -0.01) {', // Keep cloud occlusion on the curved Earth horizon only. Detailed
'for (int ti = 0; ti < 4; ti++) {', // terrain-height clipping made the deck boil and cut holes.
'vec3 hp = ro + rd * tTerrain;', 'if (tTerrain < 0.1) tTerrain = -1.0;',
'float terrainY = terrElev(hp.xz) * uElevScale - earthDrop(hp.xz);',
'float dh = terrainY - hp.y;',
'if (abs(dh) < 0.02) break;',
'tTerrain -= dh / -rd.y;',
'if (tTerrain < 0.1 || tTerrain > 90.0) { tTerrain = -1.0; break; }',
'}',
'}',
// Cloud march. The output is the cloud's effective colour and // Cloud march. The output is the cloud's effective colour and
// coverage (alpha); the render pass uses alpha-blend so the // coverage (alpha); the render pass uses alpha-blend so the
// terrain mesh from the previous pass shows through transparent // terrain mesh from the previous pass shows through transparent