[HDRP] Fix Unable to add Renderer Error during Custom Pass Culling
Solution
Unity 2021.3.x - Unity 6.3.x
Published 2 days ago
In Unity 6, calling ScriptableRenderContext.Cull() within the Execute function of an HDRP custom pass triggers a runtime error: Unable to add Renderer to the Scene after Culling. This specific issue occurs most frequently when a Terrain object is present in the hierarchy, causing the rendering pipeline to fail during scene validation due to late-frame culling requests.
Unity 6 implements strict validation to prevent rendering crashes caused by late renderer registration. Invoking ScriptableRenderContext.Cull() inside the Execute phase is no longer supported because the execution point occurs after the pipeline has finalized the list of visible objects for the frame.
To resolve this, culling logic must be moved to the AggregateCullingParameters method. This provides the correct injection point for the HDRP to aggregate culling requirements before processing the render list.
- Open your custom pass class.
- Locate and remove any calls to
ScriptableRenderContext.Cull()within theExecutemethod. - Override the AggregateCullingParameters method to define how your pass should handle visibility.
- Use the
CustomPassContextinside theExecutemethod to retrieve the computedcullingResultsinstead of generating them manually.
Additional Tips
- The
ctx.cameraCullingResultscan be used if your pass depends on the main camera’s visibility set rather than a custom one. - Ensure you call
base.AggregateCullingParameters(ref cullingParameters, ctx)within your override to maintain default pipeline behavior. - This shift to AggregateCullingParameters is mandatory for stability when using
Terraincomponents in Unity 6.
TL;DR
In Unity 6, manual culling inside the Execute loop is prohibited. You must override AggregateCullingParameters to calculate culling results early in the frame pipeline.
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
Content inspired by a Unity discussion post.