Fix stripes: tilt camera more downward so visible ground fits in mosaic

Previous look direction had rd.y from -0.05 to -0.40 across
the screen, so most rays hit ground at tGround in [9, 44] — way
beyond the 16-unit mosaic. Those OOB pixels came back as solid
edge colour, creating the striped band of texture-then-edge
transitions.

New look: rd.y from -1.10 (bottom) to 0.20 (top). At uv.y=0
rd.y=-0.45 (26° below horizon) so the visible ground sits at
tGround < 6 — all within the 16-unit mosaic. Ground mask
threshold also tightened from -0.30 to -0.10 so the ground
fades to sky higher in the image (looks like atmospheric haze).
Fog distance 14 → matches the new closer-ground regime.
This commit is contained in:
Richard Zink committed 2026-10-07 20:56:08 +02:00
1 parent 043d2b689e
commit 9c17682aed
1 file changed
+8 -6
+8 -6
View File
@@ -140,9 +140,11 @@ var FRAG_SRC = [
// Fixed altitude well above the cloud ceiling (y=1.5). // Fixed altitude well above the cloud ceiling (y=1.5).
'float camY = 2.2;', 'float camY = 2.2;',
'vec3 ro = vec3(drift, camY, drift * 0.7);', 'vec3 ro = vec3(drift, camY, drift * 0.7);',
// Ray direction: nearly level, like looking out a cockpit // Ray direction: tilt more downward so the visible ground fits
// window. Horizon sits around the middle of the frame. // within the mosaic. At uv.y = 0 the ray goes ~26° below
'vec3 rd = normalize(vec3(uv.x * 0.55, -0.05 + uv.y * 0.35, 1.0));', // horizontal, putting the visible ground at tGround < 5
// (well inside the 16x16 mosaic at most camera altitudes).
'vec3 rd = normalize(vec3(uv.x * 0.55, -0.45 + uv.y * 0.65, 1.0));',
// Sky gradient based on ray Y (background). // Sky gradient based on ray Y (background).
'float skyT = clamp(rd.y * 0.7 + 0.5, 0.0, 1.0);', 'float skyT = clamp(rd.y * 0.7 + 0.5, 0.0, 1.0);',
'vec3 col = mix(uBg, uSky, skyT);', 'vec3 col = mix(uBg, uSky, skyT);',
@@ -197,7 +199,7 @@ var FRAG_SRC = [
// remain visible against a deep but not void-black sky. // remain visible against a deep but not void-black sky.
'float skyDarkness = nightFactor * 0.55;', 'float skyDarkness = nightFactor * 0.55;',
'col = mix(col, col * (1.0 - skyDarkness), 1.0 - cloud);', 'col = mix(col, col * (1.0 - skyDarkness), 1.0 - cloud);',
'// Horizon: cast the ray onto the ground plane (y=0) and sample the satellite image at that world (x,z) coordinate. As the camera drifts forward over time the texture scrolls past, giving the illusion of flying over real terrain. Distant ground fades toward sky colour (atmospheric perspective).', '// Horizon: cast the ray onto the ground plane (y=0) and sample the satellite image at that world (x,z) coordinate. As the camera drifts forward over time the texture scrolls past, giving the illusion of flying over real terrain. Distant ground fades toward sky colour (atmospheric perspective).
'float tGround = (ro.y > 0.0 && rd.y < -0.001) ? -ro.y / rd.y : -1.0;', 'float tGround = (ro.y > 0.0 && rd.y < -0.001) ? -ro.y / rd.y : -1.0;',
'vec3 hitPoint = ro + rd * tGround;', 'vec3 hitPoint = ro + rd * tGround;',
// UV from world (hitPoint - centre) / size + 0.5 — the // UV from world (hitPoint - centre) / size + 0.5 — the
@@ -205,10 +207,10 @@ var FRAG_SRC = [
'vec2 gUv = vec2(hitPoint.x, hitPoint.z);', 'vec2 gUv = vec2(hitPoint.x, hitPoint.z);',
'gUv = (gUv - uGroundCenter) / uGroundSize + 0.5;', 'gUv = (gUv - uGroundCenter) / uGroundSize + 0.5;',
'vec3 groundCol = texture2D(uGround, gUv).rgb;', 'vec3 groundCol = texture2D(uGround, gUv).rgb;',
'float fogAmount = clamp(tGround / 12.0, 0.0, 1.0);', 'float fogAmount = clamp(tGround / 14.0, 0.0, 1.0);',
'groundCol = mix(groundCol, uBg, fogAmount);', 'groundCol = mix(groundCol, uBg, fogAmount);',
// Ground mask: full ground when looking down, none when up. // Ground mask: full ground when looking down, none when up.
'float gmask = (tGround > 0.0) ? smoothstep(0.0, -0.30, rd.y) : 0.0;', 'float gmask = (tGround > 0.0) ? smoothstep(0.0, -0.10, rd.y) : 0.0;',
'col = mix(col, groundCol, gmask);', 'col = mix(col, groundCol, gmask);',
'gl_FragColor = vec4(col, 1.0);', 'gl_FragColor = vec4(col, 1.0);',
'}' '}'