getShadowRenderObjectFunction
An internal factory function that creates and caches a specialized, high-performance function for rendering objects into a shadow map based on settings like shadow type.
Core Advantages
Its core value is performance optimization through caching (memoization). It encapsulates all the complex logic for rendering an object to a shadow map (like handling VSM specifics or motion velocity) and provides `onBefore/AfterShadow` hooks for deep customization.
Common Uses
Generating render logic that only checks `castShadow` for standard shadows.
Generating special logic for VSM shadows that checks both `castShadow` and `receiveShadow`.
Ensuring an object's motion velocity data is correctly prepared during the shadow pass when TAA is enabled.
Executing the `onBeforeShadow` hook, allowing temporary material swaps for performance optimization during shadow rendering.
How to adjust
This function cannot be adjusted directly, but its behavior is influenced by scene properties. For example, changing a light's `shadow.type` from `BasicShadowMap` to `PCFSoftShadowMap` will change shadow edges from sharp to soft. Alternatively, using the `onBeforeShadow` hook can make a detailed wireframe model cast a simple, semi-transparent plane shadow in exchange for performance.
Code Examples
1// Use hooks to cast a simplified shadow from a detailed model
2myComplexObject.onBeforeShadow = function ( renderer, object, camera ) {
3 // Swap in a simpler material
4 object.material = mySimpleShadowMaterial;
5};