Fly mostly above the clouds with brief dips
Camera altitude is now driven by pow(sin,5) so the view stays at y=2.6 most of the time and only briefly dips to y=0.9 to skim the top of the cloud deck. Marching also skips the empty gap between camera and cloud ceiling when looking down from above.
This commit is contained in:
1 parent
433d743446
commit
e80d255d58
1 file changed
+13
-14
Vendored
+13
-14
@@ -101,29 +101,28 @@ var FRAG_SRC = [
|
|||||||
'void main() {',
|
'void main() {',
|
||||||
'vec2 uv = (gl_FragCoord.xy / uResolution.xy) * 2.0 - 1.0;',
|
'vec2 uv = (gl_FragCoord.xy / uResolution.xy) * 2.0 - 1.0;',
|
||||||
'uv.x *= uResolution.x / uResolution.y;',
|
'uv.x *= uResolution.x / uResolution.y;',
|
||||||
// Camera path: slow drift in X, sinusoidal altitude.
|
// Camera path: slow drift in X, mostly above the cloud deck.
|
||||||
// The altitude dip drives the "fly through cloud edges" effect.
|
// pow(...,n) shapes the sin into short dips, so the view spends
|
||||||
|
// most of its time at cruising altitude and only briefly skims
|
||||||
|
// the top of the cloud layer.
|
||||||
'float drift = uTime * uSpeed * 0.45;',
|
'float drift = uTime * uSpeed * 0.45;',
|
||||||
'vec3 ro = vec3(',
|
'float diveT = pow(0.5 + 0.5 * sin(uTime * 0.10), 5.0);',
|
||||||
'drift,',
|
'float camY = mix(2.6, 0.9, diveT);',
|
||||||
// Altitude oscillates: above (1.5), at cloud-top (0.6), inside (0.1)
|
'vec3 ro = vec3(drift, camY, drift * 0.7);',
|
||||||
'1.5 - 1.4 * (0.5 + 0.5 * sin(uTime * 0.07)),',
|
// Ray direction: tilt down a bit more so the cloud deck fills
|
||||||
'drift * 0.7',
|
// the lower frame when we're above it.
|
||||||
');',
|
'vec3 rd = normalize(vec3(uv.x * 0.55, -0.35 + uv.y * 0.30, 1.0));',
|
||||||
// Ray direction: gentle downward tilt so we see the cloud deck
|
|
||||||
// and the sky horizon at once.
|
|
||||||
'vec3 rd = normalize(vec3(uv.x * 0.55, -0.18 + uv.y * 0.25, 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);',
|
||||||
// Density threshold: weather 'sunny' -> high (sparse clouds),
|
// Density threshold: weather 'sunny' -> high (sparse clouds),
|
||||||
// 'stormy' -> low (overcast deck).
|
// 'stormy' -> low (overcast deck).
|
||||||
'float baseThresh = mix(0.72, 0.40, uDensity);',
|
'float baseThresh = mix(0.72, 0.40, uDensity);',
|
||||||
// March the cloud layer (bounded in Y).
|
// Skip the gap between camera and cloud top so we don't waste
|
||||||
'float t = 0.0;',
|
// steps marching through clear sky. ray-Y = 2.0 = cloud ceiling.
|
||||||
|
'float t = (ro.y > 2.0 && rd.y < -0.001) ? (ro.y - 2.0) / -rd.y : 0.0;',
|
||||||
'float stepSize = 0.85;',
|
'float stepSize = 0.85;',
|
||||||
'float trans = 1.0;',
|
'float trans = 1.0;',
|
||||||
// Pre-compute ray entry/exit on cloud layer for early out
|
|
||||||
'for (int i = 0; i < 18; i++) {',
|
'for (int i = 0; i < 18; i++) {',
|
||||||
'vec3 p = ro + rd * t;',
|
'vec3 p = ro + rd * t;',
|
||||||
'if (p.y > 2.0 || p.y < -0.4) break;',
|
'if (p.y > 2.0 || p.y < -0.4) break;',
|
||||||
|
|||||||
Reference in new issue
Block a user