Class CustomPass
Class that holds data and logic for the pass to be executed
Namespace: UnityEngine.Rendering.HighDefinition
Syntax
public abstract class CustomPass : object, IVersionable<CustomPass.Version>
Fields
clearFlags
What clear to apply when the color and depth buffer are bound
Declaration
public ClearFlag clearFlags
Field Value
| Type | Description |
|---|---|
| ClearFlag |
enabled
Is the custom pass enabled or not
Declaration
public bool enabled
Field Value
| Type | Description |
|---|---|
| Boolean |
targetColorBuffer
Target color buffer (Camera or Custom)
Declaration
public CustomPass.TargetBuffer targetColorBuffer
Field Value
| Type | Description |
|---|---|
| CustomPass.TargetBuffer |
targetDepthBuffer
Target depth buffer (camera or custom)
Declaration
public CustomPass.TargetBuffer targetDepthBuffer
Field Value
| Type | Description |
|---|---|
| CustomPass.TargetBuffer |
Properties
executeInSceneView
True if you want your custom pass to be executed in the scene view. False for game cameras only.
Declaration
protected virtual bool executeInSceneView { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
fadeValue
Mirror of the value in the CustomPassVolume where this custom pass is listed
Declaration
protected float fadeValue { get; }
Property Value
| Type | Description |
|---|---|
| Single | The blend value that should be applied to the custom pass effect |
injectionPoint
Get the injection point in HDRP where this pass will be executed
Declaration
protected CustomPassInjectionPoint injectionPoint { get; }
Property Value
| Type | Description |
|---|---|
| CustomPassInjectionPoint |
name
Name of the custom pass
Declaration
public string name { get; set; }
Property Value
| Type | Description |
|---|---|
| String |
Methods
AggregateCullingParameters(ref ScriptableCullingParameters, HDCamera)
Use this method if you want to draw objects that are not visible in the camera. For example if you disable a layer in the camera and add it in the culling parameters, then the culling result will contains your layer.
Declaration
protected virtual void AggregateCullingParameters(ref ScriptableCullingParameters cullingParameters, HDCamera hdCamera)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptableCullingParameters | cullingParameters | Aggregate the parameters in this property (use |= for masks fields, etc.) |
| HDCamera | hdCamera | The camera where the culling is being done |
Cleanup()
Called when HDRP is destroyed. Allow you to free custom buffers.
Declaration
protected virtual void Cleanup()
CreateDrawRenderersPass(CustomPass.RenderQueueType, LayerMask, Material, String, SortingCriteria, ClearFlag, CustomPass.TargetBuffer, CustomPass.TargetBuffer)
Create a Custom Pass to render objects
Declaration
public static CustomPass CreateDrawRenderersPass(CustomPass.RenderQueueType queue, LayerMask mask, Material overrideMaterial, string overrideMaterialPassName = "Forward", SortingCriteria sorting = null, ClearFlag clearFlags = null, CustomPass.TargetBuffer targetColorBuffer = CustomPass.TargetBuffer.Camera, CustomPass.TargetBuffer targetDepthBuffer = CustomPass.TargetBuffer.Camera)
Parameters
| Type | Name | Description |
|---|---|---|
| CustomPass.RenderQueueType | queue | The render queue filter to select which object will be rendered |
| LayerMask | mask | The layer mask to select which layer(s) will be rendered |
| Material | overrideMaterial | The replacement material to use when renering objects |
| String | overrideMaterialPassName | The pass name to use in the override material |
| SortingCriteria | sorting | Sorting options when rendering objects |
| ClearFlag | clearFlags | Clear options when the target buffers are bound. Before executing the pass |
| CustomPass.TargetBuffer | targetColorBuffer | Target Color buffer |
| CustomPass.TargetBuffer | targetDepthBuffer | Target Depth buffer. Note: It's also the buffer which will do the Depth Test |
Returns
| Type | Description |
|---|---|
| CustomPass |
CreateFullScreenPass(Material, CustomPass.TargetBuffer, CustomPass.TargetBuffer)
Create a custom pass to execute a fullscreen pass
Declaration
public static CustomPass CreateFullScreenPass(Material fullScreenMaterial, CustomPass.TargetBuffer targetColorBuffer = CustomPass.TargetBuffer.Camera, CustomPass.TargetBuffer targetDepthBuffer = CustomPass.TargetBuffer.Camera)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | fullScreenMaterial | The material to use for your fullscreen pass. It must have a shader based on the Custom Pass Fullscreen shader or equivalent |
| CustomPass.TargetBuffer | targetColorBuffer | |
| CustomPass.TargetBuffer | targetDepthBuffer |
Returns
| Type | Description |
|---|---|
| CustomPass |
Execute(ScriptableRenderContext, CommandBuffer, HDCamera, CullingResults)
Called when your pass needs to be executed by a camera
Declaration
protected abstract void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera hdCamera, CullingResults cullingResult)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptableRenderContext | renderContext | |
| CommandBuffer | cmd | |
| HDCamera | hdCamera | |
| CullingResults | cullingResult |
Finalize()
Cleans up the custom pass when Unity destroys it unexpectedly. Currently, this happens every time you edit the UI because of a bug with the SerializeReference attribute.
Declaration
protected void Finalize()
GetCameraBuffers(out RTHandle, out RTHandle)
Get the current camera buffers (can be MSAA)
Declaration
protected void GetCameraBuffers(out RTHandle colorBuffer, out RTHandle depthBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| RTHandle | colorBuffer | outputs the camera color buffer |
| RTHandle | depthBuffer | outputs the camera depth buffer |
GetCustomBuffers(out RTHandle, out RTHandle)
Get the current custom buffers
Declaration
protected void GetCustomBuffers(out RTHandle colorBuffer, out RTHandle depthBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| RTHandle | colorBuffer | outputs the custom color buffer |
| RTHandle | depthBuffer | outputs the custom depth buffer |
GetNormalBuffer()
Get the current normal buffer (can be MSAA)
Declaration
protected RTHandle GetNormalBuffer()
Returns
| Type | Description |
|---|---|
| RTHandle |
GetRenderQueueRange(CustomPass.RenderQueueType)
Returns the render queue range associated with the custom render queue type
Declaration
protected RenderQueueRange GetRenderQueueRange(CustomPass.RenderQueueType type)
Parameters
| Type | Name | Description |
|---|---|---|
| CustomPass.RenderQueueType | type | The custom pass render queue type. |
Returns
| Type | Description |
|---|---|
| RenderQueueRange | Returns a render queue range compatible with a ScriptableRenderContext.DrawRenderers. |
RegisterMaterialForInspector()
List all the materials that need to be displayed at the bottom of the component. All the materials gathered by this method will be used to create a Material Editor and then can be edited directly on the custom pass.
Declaration
public virtual IEnumerable<Material> RegisterMaterialForInspector()
Returns
| Type | Description |
|---|---|
| IEnumerable<Material> | An enumerable of materials to show in the inspector. These materials can be null, the list is cleaned afterwards |
ResolveMSAAColorBuffer(CommandBuffer, HDCamera)
Resolve the camera color buffer only if the MSAA is enabled and the pass is executed in before transparent.
Declaration
protected void ResolveMSAAColorBuffer(CommandBuffer cmd, HDCamera hdCamera)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | |
| HDCamera | hdCamera |
SetCameraRenderTarget(CommandBuffer, Boolean, ClearFlag)
Bind the camera color buffer as the current render target
Declaration
protected void SetCameraRenderTarget(CommandBuffer cmd, bool bindDepth = true, ClearFlag clearFlags = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | |
| Boolean | bindDepth | if true we bind the camera depth buffer in addition to the color |
| ClearFlag | clearFlags |
SetCustomRenderTarget(CommandBuffer, Boolean, ClearFlag)
Bind the custom color buffer as the current render target
Declaration
protected void SetCustomRenderTarget(CommandBuffer cmd, bool bindDepth = true, ClearFlag clearFlags = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | |
| Boolean | bindDepth | if true we bind the custom depth buffer in addition to the color |
| ClearFlag | clearFlags |
SetRenderTargetAuto(CommandBuffer)
Bind the render targets according to the parameters of the UI (targetColorBuffer, targetDepthBuffer and clearFlags)
Declaration
protected void SetRenderTargetAuto(CommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd |
Setup(ScriptableRenderContext, CommandBuffer)
Called before the first execution of the pass occurs. Allow you to allocate custom buffers.
Declaration
protected virtual void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptableRenderContext | renderContext | |
| CommandBuffer | cmd |
Explicit Interface Implementations
IVersionable<CustomPass.Version>.version
Declaration
CustomPass.Version IVersionable<CustomPass.Version>.version { get; set; }
Returns
| Type | Description |
|---|---|
| UnityEngine.Rendering.HighDefinition.CustomPass.Version |