Function onCsmReceiverUpdate
-
Parameters
- sg: ShadowGenerator
A cascaded-shadow generator from createCsmDirectionalShadowGenerator.
- cb: (data: Float32Array) => void
Receiver-sync callback.
Returns () => void
A disposer that unregisters this callback.
- sg: ShadowGenerator
Register a callback invoked on every frame the receiver UBO is republished (right after it is uploaded, before the shadow map renders) and on every frame the active camera's change key moves while the generator is enabled (
setShadowGeneratorEnabled), always with the currently published UBO and before the main pass renders. With the static cache'scascadeCoveragePadding, a camera move that redraws no cascade still invokes it, with unchanged data.Custom
ShaderMaterialreceivers that mirror the cascade transforms into their own uniforms (rather than binding the generator's receiver UBO directly, as the built-in standard/PBR/node receivers do) MUST sync from inside this callback. Syncing from anonBeforeRendercallback reads the previous frame's transforms — a one-frame lag that makes those shadows visibly swim while the camera moves (the cascade window can slide many texels per frame during a zoom).Multiple receivers may register on the same generator; every registered callback is invoked on each of those frames. The callback receives the 80-float receiver UBO (layout: four
mat4x4cascade transforms,viewFrustumZ,frustumLengths,shadowsInfo,csmParams— see the cascaded-shadow architecture doc). The array is reused across frames; copy what you need.