Injection Points
To determine when Unity executes a Custom Pass Volume, select an Injection Point in the Custom Pass Volume component.
Each injection point affects the way Custom Passes appear in your scene. There are six injection points in the High Definition Render Pipeline (HDRP). If there are multiple Custom Pass volumes assigned to one Injection Point, HDRP executes them in order of priority. For more information see Custom Pass Volume workflow
Injection points give a Custom Pass Volume component access to a selection of buffers. Each available buffer has different read or write access at each injection point. Each buffer contains a subset of objects rendered before your pass. HDRP creates a color pyramid and depth pyramid at specific points in the rendering pipeline. For more information, see Custom Pass buffers and pyramids.
In a DrawRenderers Custom Pass you can only use certain materials at specific injection points. For a full list of compatible materials, see Material and injection point compatibility.
To analyse the actions Unity performs in a render loop and see where Unity executes your Custom Pass, use the frame debugger.
Unity triggers the following injection points in a frame, in order from top to bottom:
Injection point | Available buffers | Description |
---|---|---|
BeforeRendering | Depth (Write) | Unity clears the depth buffer immediately before this injection point. In this injection point you can write to the depth buffer so that Unity doesn’t render depth-tested, opaque objects. You can also clear the buffer you allocated or the Custom Buffer .When you select this Injection point for a FullscreenCustom Pass, Unity assigns the camera color buffer as the target by default. |
AfterOpaqueDepthAndNormal | Depth (Read | Write), Normal and roughness (Read | Write), Motion Vectors (Write) | The available buffers for this injection point contain all opaque objects. In this injection point you can modify the normal, roughness, depth, and motion vectors buffers. HDRP takes this into account in the lighting and the depth pyramid. Normals and roughness are in the same buffer. You can use DecodeFromNormalBuffer and EncodeIntoNormalBuffer methods to read/write normal and roughness data. The Motion Vectors buffer only includes object motion vector data when you use forward rendering. To include object motion vector data in the Motion Vectors buffer when using deferred rendering, go to Frame Settings and enable Depth Prepass within Deferred. |
BeforePreRefraction | Color (no pyramid | Read | Write), Depth (Read | Write), Normal and roughness (Read), Motion Vectors (Read | Write) | The available buffers for this injection point contain all opaque objects, the camera and object motion vectors, and the sky. From this point, the motion vectors buffer is complete. In this injection point you can render any transparent objects that require refraction. These objects are then included in the color pyramid that Unity uses for refraction when it renders transparent objects. |
BeforeTransparent | Color (Pyramid | Read | Write), Depth (Read | Write), Normal and roughness (Read), Motion Vectors (Read) | The available buffers for this injection point contain: - All opaque objects. - Transparent PreRefraction objects. - Transparent objects with depth-prepass and screen space reflections (SSR) enabled. In this Injection Point you can sample the color pyramid that Unity uses for transparent refraction. You can use this to create a blur effect. All objects Unity renders in this injection point will not be in the color pyramid. You can also use this injection point to draw some transparent objects that refract the whole scene, like water. |
BeforePostProcess | Color (Pyramid | Read | Write), Depth (Read | Write), Normal and roughness (Read), Motion Vectors (Read) | The available buffers for this injection point contain all geometry in the frame that uses High Dynamic Range (HDR). |
AfterPostProcess | Color (Read | Write), Depth (Read) | The available buffers for this injection point contain the final render of the scene, including post-process effects. This injection point executes the available buffers after Unity applies any post-processing effects. If you select this injection point, objects that use the depth buffer display jittering artifacts. When you select this injection point for a FullscreenCustom Pass, Unity assigns the camera color buffer as the target by default. |
The following diagram describes where Unity injects Custom Passes into an HDRP frame: