photo-sky
Photo Sky
Target: Three.js 0.187.0, three/webgpu and TSL node materials from three/tsl; WebGPU only, no WebGL fallback, no GLSL strings.
Companion files in this folder:
scripts/photo-sky.tsl.js: the sky. Copy it into the project; it imports only fromthree/webgpuandthree/tsl.scripts/convert-sky.mjs+scripts/convert-sky.html: turn 2:1 sky photos into dome textures and measure each photo's sun. Node 22+ and Chrome, no packages.
What it is
A back-faced sphere around the camera with one texture slot per sky photo. Every frame, update() turns the sun direction, the weather and the night into one weight per slot. The shader blends the weighted photos with a cloud-aware crossfade, inverts three's ACES tone map (so the renderer's ACES gives the photo back unchanged), and then runs a grade: horizon haze, a night or overcast wash, and a storm fold toward the fog colour. The dome turns so each photo's sun column follows the clock's azimuth. A per-slot elevation warp moves each photo's sun row toward the clock's elevation. The clipped sun comes back as HDR (about 8), so a PMREM baked from the dome lights the scene from the right direction.
A photo sky costs a fraction of a procedural sky: one to three texture fetches per pixel and no ray march. A procedural dome with a cloud march measured 2.3 to 5 ms; this one is well under 1 ms. Its limits: clouds do not move, and you can only show the light conditions you have photos of.
When to use it
- driving, flying or walking scenes with a day/night clock where the sky should look photographed
- when realistic clouds matter more than clouds that move
- when the sky is also the environment map (PMREM) for the scene