5.9 KiB
uid |
---|
urp-accessing-frame-data |
Get data from the current frame
You can fetch the textures that the Universal Render Pipeline (URP) creates for the current frame, for example the active color buffer or a G-buffer texture, and use them in your render passes.
These textures are called frame data, resource data, or frame resources. This documentation refers to these textures as frame data.
Some textures might not exist in the frame data, depending on which injection point you use to insert your custom render pass into the URP frame rendering loop. For more information about which textures exist when, refer to Injection points reference.
Get frame data
The frame data is in the ContextContainer
object that URP provides when you override the RecordRenderGraph
method.
Follow these steps to get a handle to a texture in the frame data:
-
Get all the frame data as a
UniversalResourceData
object, using theGet
method of theContextContainer
object.For example:
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext) { using (var builder = renderGraph.AddRasterRenderPass<PassData>("Get frame data", out var passData)) { UniversalResourceData frameData = frameContext.Get<UniversalResourceData>(); } }
-
Get the handle to a texture in the frame data.
For example, the following gets a handle to the active color texture:
```csharp
TextureHandle activeColorTexture = frameData.activeColorTexture;
```
You can then read from and write to the texture. Refer to Use a texture in a render pass.
The texture handle is valid only for the current render graph in the current frame.
You can use the ConfigureInput API to make sure URP generates the texture you need in the frame data.
Textures in the frame data
You can fetch the following textures from the frame data.
Property | Texture | URP shader pass that writes to the texture |
---|---|---|
additionalShadowsTexture |
The additional shadow map. | ShadowCaster |
activeColorTexture |
The color texture the camera currently targets. | Any pass, depending on your settings |
activeDepthTexture |
The depth texture the camera is currently targets. | Any pass, depending on your settings |
afterPostProcessColor |
The main color texture after URP's post processing passes. | UberPost |
backBufferColor |
The color texture of the screen back buffer. If you use post-processing, URP writes to this texture at the end of rendering, unless you enable HDR Debug Views. Refer to debugScreenTexture for more information. |
Any pass, depending on your settings |
backBufferDepth |
The depth texture of the screen back buffer. | Any pass, depending on your settings |
cameraColor |
The main color texture for the camera. You can store multiple samples in this texture if you enable Multisample Anti-aliasing (MSAA). | Any pass, depending on your settings |
cameraDepth |
The main depth texture for the camera. You can store multiple samples in this texture if you enable Multisample Anti-aliasing (MSAA). | Any pass, depending on your settings |
cameraDepthTexture |
A copy of the depth texture, if you enable Depth Priming Mode in the renderer or Depth Texture in the active URP Asset. | CopyDepth or DepthPrepass |
cameraNormalsTexture |
The scene normals texture. Contains the scene depth for objects with shaders that have a DepthNormals pass. |
DepthNormals prepass |
cameraOpaqueTexture |
A texture with the opaque objects in the scene, if you enable Opaque Texture in the URP Asset. | CopyColor |
dBuffer |
The Decals texture. For more information about the decals texture, refer to DBuffer. | Decals |
dBufferDepth |
The Decals depth texture. Refer to DBuffer. | Decals |
debugScreenTexture |
If you enable HDR Debug Views, URP writes the output of post-processing to this texture instead of backBufferColor . |
uberPost and finalPost |
gBuffer |
The G-buffer textures. Refer to G-buffer. | GBuffer |
internalColorLut |
The internal look-up textures (LUT) texture. | InternalLut |
mainShadowsTexture |
The main shadow map. | ShadowCaster |
motionVectorColor |
The motion vectors color texture. Refer to motion vectors. | Camera Motion Vectors and MotionVectors |
motionVectorDepth |
The motion vectors depth texture. Refer to motion vectors. | Camera Motion Vectors and MotionVectors |
overlayUITexture |
The overlay UI texture. | DrawScreenSpaceUI |
renderingLayersTexture |
The Rendering Layers texture. Refer to Rendering layers | DrawOpaques or the DepthNormals prepass, depending on your settings. |
ssaoTexture |
The Screen Space Ambient Occlusion (SSAO) texture. Refer to Ambient occlusion. | SSAO |
Example
For a full example, refer to the example called TextureReference w. FrameData in the Universal Render Pipeline (URP) package samples.