TSL Helpers
createEnvironmentMap() creates an equirectangular texture. Use equirectUVFromDir to convert a world-space direction into texture coordinates.
import { equirectUVFromDir } from "threejs-sky-pro";equirectUVFromDir(dir)
Maps a world direction to a UV on the equirect bake — the same convention createEnvironmentMap() bakes in. Right-handed, Y-up: +X at u=0.5, +Z at u=0.75, zenith at v=1.
| Param | Type | Required | Description |
|---|---|---|---|
dir | Node<vec3> | required | World-space direction. Normalized internally, so an unnormalized reflection vector is fine. |
Returns: Node<vec2> — UV in [0,1]².
Sample the env map along a reflection direction:
import { texture } from "three/tsl";
const envMap = sky.createEnvironmentMap();
const reflection = texture(envMap.texture, equirectUVFromDir(reflectDir));For a full material that reflects the live sky, see Reflections.
Shading Under The Clouds
Use sky.cloudShadow(worldPos) to apply cloud shadows to custom materials. It returns sun transmittance from 0 (fully shadowed) to 1 (full sun):
import { positionWorld } from "three/tsl";
const litColor = albedo.mul(sunColor).mul(sky.cloudShadow(positionWorld));Positions outside the shadow footprint, or with the bake disabled, return 1. For a DirectionalLight-based recipe that shadows standard materials automatically, see Shadows.
