Class ScriptableRenderPass
ScriptableRenderPass
implements a logical rendering pass that can be used to extend Universal RP renderer.
Inherited Members
Namespace: UnityEngine.Rendering.Universal
Assembly: Unity.RenderPipelines.Universal.Runtime.dll
Syntax
public abstract class ScriptableRenderPass
Constructors
ScriptableRenderPass()
Creates a new ScriptableRenderPass"
instance.
Declaration
public ScriptableRenderPass()
Fields
k_CameraTarget
RTHandle alias for BuiltinRenderTextureType.CameraTarget which is the backbuffer.
Declaration
public static RTHandle k_CameraTarget
Field Value
Type | Description |
---|---|
RTHandle |
Properties
clearColor
The color value to use when clearing.
Declaration
public Color clearColor { get; }
Property Value
Type | Description |
---|---|
Color |
clearFlag
The flag to use when clearing.
Declaration
public ClearFlag clearFlag { get; }
Property Value
Type | Description |
---|---|
ClearFlag |
See Also
colorAttachmentHandle
The main color attachment handle.
Declaration
public RTHandle colorAttachmentHandle { get; }
Property Value
Type | Description |
---|---|
RTHandle |
colorAttachmentHandles
List for the g-buffer attachment handles.
Declaration
public RTHandle[] colorAttachmentHandles { get; }
Property Value
Type | Description |
---|---|
RTHandle[] |
colorStoreActions
The store actions for Color.
Declaration
public RenderBufferStoreAction[] colorStoreActions { get; }
Property Value
Type | Description |
---|---|
RenderBufferStoreAction[] |
depthAttachmentHandle
The depth attachment handle.
Declaration
public RTHandle depthAttachmentHandle { get; }
Property Value
Type | Description |
---|---|
RTHandle |
depthStoreAction
The store actions for Depth.
Declaration
public RenderBufferStoreAction depthStoreAction { get; }
Property Value
Type | Description |
---|---|
RenderBufferStoreAction |
input
The input requirements for the ScriptableRenderPass
, which has been set using ConfigureInput
Declaration
public ScriptableRenderPassInput input { get; }
Property Value
Type | Description |
---|---|
ScriptableRenderPassInput |
See Also
profilingSampler
A ProfilingSampler for the entire render pass. Used as a profiling name by ScriptableRenderer
when executing the pass.
Default is Unnamed_ScriptableRenderPass
.
Set base.profilingSampler
from the sub-class constructor to set a profiling name for a custom ScriptableRenderPass
.
Declaration
protected ProfilingSampler profilingSampler { get; set; }
Property Value
Type | Description |
---|---|
ProfilingSampler |
renderPassEvent
The event when the render pass executes.
Declaration
public RenderPassEvent renderPassEvent { get; set; }
Property Value
Type | Description |
---|---|
RenderPassEvent |
Methods
Blit(CommandBuffer, RTHandle, RTHandle, Material, int)
Add a blit command to the context for execution. This changes the active render target in the ScriptableRenderer to destination.
Declaration
public void Blit(CommandBuffer cmd, RTHandle source, RTHandle destination, Material material = null, int passIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer to record command for execution. |
RTHandle | source | Source texture or target handle to blit from. |
RTHandle | destination | Destination texture or target handle to blit into. This becomes the renderer active render target. |
Material | material | Material to use. |
int | passIndex | Shader pass to use. Default is 0. |
See Also
Blit(CommandBuffer, ref RenderingData, Material, int)
Add a blit command to the context for execution. This applies the material to the color target.
Declaration
public void Blit(CommandBuffer cmd, ref RenderingData data, Material material, int passIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer to record command for execution. |
RenderingData | data | RenderingData to access the active renderer. |
Material | material | Material to use. |
int | passIndex | Shader pass to use. Default is 0. |
Blit(CommandBuffer, ref RenderingData, RTHandle, Material, int)
Add a blit command to the context for execution. This applies the material to the color target.
Declaration
public void Blit(CommandBuffer cmd, ref RenderingData data, RTHandle source, Material material, int passIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer to record command for execution. |
RenderingData | data | RenderingData to access the active renderer. |
RTHandle | source | Source texture or target identifier to blit from. |
Material | material | Material to use. |
int | passIndex | Shader pass to use. Default is 0. |
Configure(CommandBuffer, RenderTextureDescriptor)
This method is called by the renderer before executing the render pass.
Override this method if you need to to configure render targets and their clear state, and to create temporary render target textures.
If a render pass doesn't override this method, this render pass renders to the active Camera's render target.
You should never call CommandBuffer.SetRenderTarget. Instead call ConfigureTarget
and ConfigureClear
.
Declaration
public virtual void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | CommandBuffer to enqueue rendering commands. This will be executed by the pipeline. |
RenderTextureDescriptor | cameraTextureDescriptor | Render texture descriptor of the camera render target. |
See Also
ConfigureClear(ClearFlag, Color)
Configures clearing for the render targets for this render pass. Call this inside Configure.
Declaration
public void ConfigureClear(ClearFlag clearFlag, Color clearColor)
Parameters
Type | Name | Description |
---|---|---|
ClearFlag | clearFlag | ClearFlag containing information about what targets to clear. |
Color | clearColor | Clear color. |
See Also
ConfigureColorStoreAction(RenderBufferStoreAction, uint)
Configures the Store Action for a color attachment of this render pass.
Declaration
public void ConfigureColorStoreAction(RenderBufferStoreAction storeAction, uint attachmentIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
RenderBufferStoreAction | storeAction | RenderBufferStoreAction to use |
uint | attachmentIndex | Index of the color attachment |
ConfigureColorStoreActions(RenderBufferStoreAction[])
Configures the Store Actions for all the color attachments of this render pass.
Declaration
public void ConfigureColorStoreActions(RenderBufferStoreAction[] storeActions)
Parameters
Type | Name | Description |
---|---|---|
RenderBufferStoreAction[] | storeActions | Array of RenderBufferStoreActions to use |
ConfigureDepthStoreAction(RenderBufferStoreAction)
Configures the Store Action for the depth attachment of this render pass.
Declaration
public void ConfigureDepthStoreAction(RenderBufferStoreAction storeAction)
Parameters
Type | Name | Description |
---|---|---|
RenderBufferStoreAction | storeAction | RenderBufferStoreAction to use |
ConfigureInput(ScriptableRenderPassInput)
Configures Input Requirements for this render pass.
This method should be called inside ScriptableRendererFeature.AddRenderPasses
.
Declaration
public void ConfigureInput(ScriptableRenderPassInput passInput)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderPassInput | passInput | ScriptableRenderPassInput containing information about what requirements the pass needs. |
See Also
ConfigureTarget(RTHandle)
Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget. This method should be called inside Configure.
Declaration
public void ConfigureTarget(RTHandle colorAttachment)
Parameters
Type | Name | Description |
---|---|---|
RTHandle | colorAttachment | Color attachment handle. |
See Also
ConfigureTarget(RTHandle, RTHandle)
Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget. This method should be called inside Configure.
Declaration
public void ConfigureTarget(RTHandle colorAttachment, RTHandle depthAttachment)
Parameters
Type | Name | Description |
---|---|---|
RTHandle | colorAttachment | Color attachment handle. |
RTHandle | depthAttachment | Depth attachment handle. |
See Also
ConfigureTarget(RTHandle[])
Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget. This method should be called inside Configure.
Declaration
public void ConfigureTarget(RTHandle[] colorAttachments)
Parameters
Type | Name | Description |
---|---|---|
RTHandle[] | colorAttachments | Color attachment handle. |
See Also
ConfigureTarget(RTHandle[], RTHandle)
Configures render targets for this render pass. Call this instead of CommandBuffer.SetRenderTarget. This method should be called inside Configure.
Declaration
public void ConfigureTarget(RTHandle[] colorAttachments, RTHandle depthAttachment)
Parameters
Type | Name | Description |
---|---|---|
RTHandle[] | colorAttachments | Color attachment handle. |
RTHandle | depthAttachment | Depth attachment handle. |
See Also
CreateDrawingSettings(List<ShaderTagId>, ref RenderingData, SortingCriteria)
Creates DrawingSettings
based on current rendering state.
Declaration
public DrawingSettings CreateDrawingSettings(List<ShaderTagId> shaderTagIdList, ref RenderingData renderingData, SortingCriteria sortingCriteria)
Parameters
Type | Name | Description |
---|---|---|
List<ShaderTagId> | shaderTagIdList | List of shader pass tag to render. |
RenderingData | renderingData | Current rendering state. |
SortingCriteria | sortingCriteria | Criteria to sort objects being rendered. |
Returns
Type | Description |
---|---|
DrawingSettings |
See Also
CreateDrawingSettings(ShaderTagId, ref RenderingData, SortingCriteria)
Creates DrawingSettings
based on current the rendering state.
Declaration
public DrawingSettings CreateDrawingSettings(ShaderTagId shaderTagId, ref RenderingData renderingData, SortingCriteria sortingCriteria)
Parameters
Type | Name | Description |
---|---|---|
ShaderTagId | shaderTagId | Shader pass tag to render. |
RenderingData | renderingData | Current rendering state. |
SortingCriteria | sortingCriteria | Criteria to sort objects being rendered. |
Returns
Type | Description |
---|---|
DrawingSettings |
See Also
Execute(ScriptableRenderContext, ref RenderingData)
Execute the pass. This is where custom rendering occurs. Specific details are left to the implementation
Declaration
public virtual void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderContext | context | Use this render context to issue any draw commands during execution |
RenderingData | renderingData | Current rendering state information |
OnCameraCleanup(CommandBuffer)
Called upon finish rendering a camera. You can use this callback to release any resources created by this render pass that need to be cleanup once camera has finished rendering. This method be called for all cameras in a camera stack.
Declaration
public virtual void OnCameraCleanup(CommandBuffer cmd)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Use this CommandBuffer to cleanup any generated data |
OnCameraSetup(CommandBuffer, ref RenderingData)
This method is called by the renderer before rendering a camera
Override this method if you need to to configure render targets and their clear state, and to create temporary render target textures.
If a render pass doesn't override this method, this render pass renders to the active Camera's render target.
You should never call CommandBuffer.SetRenderTarget. Instead call ConfigureTarget
and ConfigureClear
.
Declaration
public virtual void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | CommandBuffer to enqueue rendering commands. This will be executed by the pipeline. |
RenderingData | renderingData | Current rendering state information |
See Also
OnFinishCameraStackRendering(CommandBuffer)
Called upon finish rendering a camera stack. You can use this callback to release any resources created by this render pass that need to be cleanup once all cameras in the stack have finished rendering. This method will be called once after rendering the last camera in the camera stack. Cameras that don't have an explicit camera stack are also considered stacked rendering. In that case the Base camera is the first and last camera in the stack.
Declaration
public virtual void OnFinishCameraStackRendering(CommandBuffer cmd)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Use this CommandBuffer to cleanup any generated data |
RecordRenderGraph(RenderGraph, FrameResources, ref RenderingData)
Record the render graph pass. This is where custom rendering occurs. Specific details are left to the implementation
Declaration
public virtual void RecordRenderGraph(RenderGraph renderGraph, FrameResources frameResources, ref RenderingData renderingData)
Parameters
Type | Name | Description |
---|---|---|
RenderGraph | renderGraph | |
FrameResources | frameResources | |
RenderingData | renderingData |
ResetTarget()
Resets render targets to default. This method effectively reset changes done by ConfigureTarget.
Declaration
public void ResetTarget()
See Also
Operators
operator >(ScriptableRenderPass, ScriptableRenderPass)
Compares two instances of ScriptableRenderPass
by their RenderPassEvent
and returns if lhs
is executed after rhs
.
Declaration
public static bool operator >(ScriptableRenderPass lhs, ScriptableRenderPass rhs)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderPass | lhs | |
ScriptableRenderPass | rhs |
Returns
Type | Description |
---|---|
bool |
operator <(ScriptableRenderPass, ScriptableRenderPass)
Compares two instances of ScriptableRenderPass
by their RenderPassEvent
and returns if lhs
is executed before rhs
.
Declaration
public static bool operator <(ScriptableRenderPass lhs, ScriptableRenderPass rhs)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderPass | lhs | |
ScriptableRenderPass | rhs |
Returns
Type | Description |
---|---|
bool |