lightProjectionUV
Computes projected UV coordinates for a light (vec3: xy are sampling UVs, z is depth). Defaults to positionWorld. Intended for spot lights with maps.
Core Advantages
Maps surface points into a spotlight’s projection space without authoring a projection matrix. Ideal for GOBO / light cookies.
Common Uses
Spotlight projected textures (GOBO / light cookie)
Light-driven decals / logo projection
Projection frustum or shadow visualization
Local texturing inside the light cone
How to adjust
light: pass the target SpotLight instance; enabling castShadow ensures a valid projection/shadow matrix. position: override with a custom position node to offset/scale/rotate the projection. Sampling: use .xy for texture UV; use .z as a visibility/attenuation mask. Region limit: use step/clamp so it applies only when uv∈[0,1] and z∈[0,1]. Multiple lights: call per light and blend as needed.
Code Examples
1<meshStandardNodeMaterial
2 // Sample a projector texture using spotlight-projected UVs
3 colorNode={ texture( projectorMap, lightProjectionUV( projLight ).xy ) }
4 // Optional: show only within the valid projection region (uv and z in [0,1])
5 opacityNode={ step(0.0, lightProjectionUV( projLight ).x) * step(lightProjectionUV( projLight ).x, 1.0) * step(0.0, lightProjectionUV( projLight ).y) * step(lightProjectionUV( projLight ).y, 1.0) * step(0.0, lightProjectionUV( projLight ).z) * step(lightProjectionUV( projLight ).z, 1.0) }
6 transparent
7/>