shadow2D
shadow2D(
position,lightPos,occluderTex,occluderSize,shadowStrength?):Node<"float">
Defined in: packages/nodes/src/lighting/shadows.ts:115
Calculate hard 2D shadow from a light source. Checks if a point is in shadow by sampling an occluder texture.
Parameters
Section titled “Parameters”position
Section titled “position”World/screen position of the surface
lightPos
Section titled “lightPos”Position of the light source
occluderTex
Section titled “occluderTex”Texture containing occluder data (alpha channel)
occluderSize
Section titled “occluderSize”Size of the occluder texture in world units
shadowStrength?
Section titled “shadowStrength?”FloatInput = 0.7
Shadow intensity (default: 0.7)
Returns
Section titled “Returns”Node <"float">
Shadow factor (0 = full shadow, 1 = no shadow)
Example
Section titled “Example”const shadow = shadow2D(fragPos, lightPos, occluderMap, [512, 512])finalColor = finalColor.mul(shadow)