builtinShadowContext
builtinShadowContext defines a built-in shadow context for a node so that, during the standard lighting pass, the shadow term of a given light is multiplied by a custom ShadowNode instead of using only the raw built-in shadow value.
Core Advantages
It lets you target the shadow contribution of a single light and modulate it (noise, masks, distance falloff, etc.) while still relying on three.js' built-in shadow maps and light configuration, without reimplementing the entire shadow pipeline.
Common Uses
Adding noise, soft edges, or masks to the shadow of one specific directional or spot light
Applying additional attenuation or clipping to the shadow of a light inside fog, volumetric regions, or special areas
Letting multiple lights share the same material while having different shadow behavior (for example: a main light with full shadow, a fill light with very weak or masked shadow)
How to adjust
The node itself has no adjustable properties; it only wires the given shadowNode and light into the built-in shadow pipeline. To tune the effect: (1) modify the shadowNode before passing it in (for example multiply it by noise, distance factors, or mask textures) to change shadow strength and shape; (2) make sure the second argument is always the same THREE.Light instance that should be affected, otherwise the context will not match that light; (3) keep using regular light.shadow settings (bias, radius, mapSize, etc.) to control the base shadow quality, and then layer additional control via the shadowNode.
Code Examples
1// 1. Build a base shadow node for this light (usually from shadow())
2const shadowNode = shadow( dirLight );
3
4// 2. Inject this as a built-in shadow context, affecting only dirLight
5material.colorNode = baseColor.builtinShadowContext( shadowNode, dirLight );