Skip to content

TSL Helpers

createEnvironmentMap() creates an equirectangular texture. Use equirectUVFromDir to convert a world-space direction into texture coordinates.

typescript
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.

ParamTypeRequiredDescription
dirNode<vec3>requiredWorld-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:

typescript
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):

typescript
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.

See Also

Commercial License - All Rights Reserved.