UnityRef is currently in early development. Some features may be incomplete and/or not functioning.

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

graphics

[HDRP] Fix Unable to add Renderer Error during Custom Pass Culling

Solution

hdrpgraphicsrenderingoptimization

Unity 2021.3.x - Unity 6.3.x

Published 2 days ago

Issue

 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.

Explanation

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.

  1. Open your custom pass class.
  2. Locate and remove any calls to ScriptableRenderContext.Cull() within the Execute method.
  3. Override the AggregateCullingParameters method to define how your pass should handle visibility.
  4. Use the CustomPassContext inside the Execute method to retrieve the computed cullingResults instead of generating them manually.

Additional Tips

  • The ctx.cameraCullingResults can 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 Terrain components 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.