diff --git a/src/rendering/world-background-renderer.ts b/src/rendering/world-background-renderer.ts index 205c71dc..e75ed1ec 100644 --- a/src/rendering/world-background-renderer.ts +++ b/src/rendering/world-background-renderer.ts @@ -354,11 +354,78 @@ float fbm2(vec2 point) { return value; } -float auroraFilamentPattern(vec2 point, float timeShift) { - float broad = abs(sin(point.x * 18.0 + noise2(point * 0.45) * 4.0 + timeShift)); - float fine = abs(sin(point.x * 54.0 - point.y * 7.0 + noise2(point * 1.35) * 5.5 + timeShift * 1.8)); +float auroraRayPattern(vec2 uv, float timeShift, float phase) { + float field = fbm2( + vec2( + uv.x * 1.35 + phase + timeShift * 0.035, + uv.y * 0.55 - timeShift * 0.018 + ) + ); + float slowFold = + 0.5 + + 0.5 * + sin(uv.x * 10.5 + field * 8.0 + phase + timeShift * 0.45); + float ribbonFold = + 0.5 + + 0.5 * + sin(uv.x * 21.0 + field * 12.0 - uv.y * 2.1 + timeShift * 0.78); + float filament = + 0.5 + + 0.5 * + sin(uv.x * 68.0 + field * 18.0 - uv.y * 5.5 + phase * 1.7 + timeShift * 1.18); + float gaps = smoothstep( + 0.18, + 0.92, + fbm2(vec2(uv.x * 2.5 - timeShift * 0.035 + phase, uv.y * 0.72 + 6.0)) + ); - return mix(pow(broad, 3.4), pow(fine, 5.6), 0.58); + return gaps * + (pow(slowFold, 2.2) * 0.58 + + pow(ribbonFold, 3.8) * 0.62 + + pow(filament, 11.0) * 1.45); +} + +float auroraCurtain( + vec2 uv, + float skyY, + float center, + float width, + float timeShift, + float phase +) { + float wave = fbm2( + vec2( + uv.x * 1.2 + phase + timeShift * 0.026, + uv.y * 0.9 - timeShift * 0.014 + ) + ); + float foldedCenter = + center + + (wave - 0.5) * width * 1.55 + + sin(uv.x * 2.6 + phase + timeShift * 0.16) * width * 0.4; + float distanceToCenter = abs(skyY - foldedCenter); + float core = 1.0 - smoothstep(width * 0.08, width * 0.72, distanceToCenter); + float velvetGlow = + 1.0 - + smoothstep(width * 0.65, width * 4.4, distanceToCenter); + float lowerCurtain = + smoothstep(foldedCenter - width * 5.6, foldedCenter - width * 0.18, skyY); + float upperCurtain = + 1.0 - + smoothstep(foldedCenter + width * 1.45, foldedCenter + width * 3.9, skyY); + float verticalVeil = lowerCurtain * upperCurtain; + float rayPattern = auroraRayPattern(uv, timeShift, phase); + float taper = + 1.0 - + smoothstep( + foldedCenter + width * 0.2, + foldedCenter + width * 3.6, + skyY + ); + + return (core * 1.22 + verticalVeil * 0.48 + velvetGlow * 0.18) * + rayPattern * + mix(0.68, 1.0, taper); } mat3 rotationY(float radians) {