Skip to content

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.

Vec2Input

World/screen position of the surface

Vec2Input

Position of the light source

Texture 

Texture containing occluder data (alpha channel)

Vec2Input

Size of the occluder texture in world units

FloatInput = 0.7

Shadow intensity (default: 0.7)

Node <"float">

Shadow factor (0 = full shadow, 1 = no shadow)

const shadow = shadow2D(fragPos, lightPos, occluderMap, [512, 512])
finalColor = finalColor.mul(shadow)