Custom Pass buffers and pyramids
This section describes how depth and color buffers work with custom passes in HDRP.
When HDRP renders a scene, it stores some data to a render target or buffer, and uses this data to create a series of mipmaps. This series of mipmaps is called a pyramid. Custom passes in HDRP use depth pyramids and color pyramids. You can reference a pyramid in a shader.
HDRP creates depth and color pyramids at given points in the render pipeline. For more information, see Depth pyramid and color pyramid generation in HDRP.
Custom pass buffers
HDRP custom passes use the following buffers:
You can set each of these buffers to use:
- The camera’s color or depth buffer.
- A custom buffer under your control.
- No buffer to disable color or depth outputs.
Depth buffer
During rendering, HDRP uses a depth buffer to perform depth tests. By default, only opaque objects write to the depth buffer up to and including the BeforePreRefraction injection point.
However, you can also make HDRP write transparent objects to the depth buffer. To do this, go to Surface options and either enable Depth Write, Transparent Depth Prepass or Transparent Depth Postpass depending on when you want them to write to the depth buffer.
You can only read the current depth buffer from a rendering shader if you bind it in a C# custom pass script.
HDRP uses this data to generate a depth pyramid.
Color buffer
During rendering, HDRP writes color data from visible objects (renderers) in the scene to the color buffer. You cannot read the current color buffer from a rendering shader.
Custom pass pyramids
During a custom pass, HDRP creates the following pyramids:
The term pyramid comes from the fact that each pyramid is a texture with a full chain of mipmaps.
Depth pyramid
A depth pyramid is a series of mipmaps that HDRP creates from data in the depth buffer at a given point in the rendering pipeline. HDRP builds each successive mipmap level of the depth pyramid by downscaling the previous level’s depth values using the minimum (closest) depth value of each 4x4 block of pixels.
This pyramid reduces the time HDRP takes to render effects that need depth information like SSAO by providing a hierarchical depth buffer.
Color pyramid
A color pyramid is a series of mipmaps that HDRP creates from the color buffer at a given point in the rendering pipeline. HDRP builds each successive mipmap level of the color pyramid by downscaling and blurring the previous level’s color values.
To access the color pyramid in shader graph, use the Scene Color node.
Depth pyramid and color pyramid generation in HDRP
HDRP creates a color pyramid and a depth pyramid at specific points in the rendering pipeline to capture a snapshot of the scene’s color and depth buffers for use as input to shaders in subsequent passes.
HDRP generates a single depth pyramid after the AfterOpaqueDepthAndNormal injection point. This depth pyramid therefore contains only opaque objects. For more information, see Depth pyramid.
HDRP generates color pyramids at these points in the rendering pipeline:
- After the BeforePreRefraction injection point (in Color Pyramid PreRefraction). This contains opaque objects and objects rendered in BeforePreRefraction and is used for Screen space reflections next frame and the refraction effect in the current frame.
- If Distortion is enabled in the Frame Settings, after the BeforeTransparent injection point and all the Transparent rendering passes. This is used for distortion and contains all opaque and transparent objects.
- As part of the bloom post-processing effect. This contains all opaque and transparent objects and the distortion effect.
Note: The term color pyramid usually refers to the first pyramid in this list.