Class CustomPassUtils
A set of custom pass utility function to help you build your effects
Namespace: UnityEngine.Rendering.HighDefinition
Syntax
public static class CustomPassUtils
Fields
fullScreenScaleBias
Fullscreen scale and bias values, it is the default for functions that have scale and bias overloads.
Declaration
public static Vector4 fullScreenScaleBias
Field Value
Type | Description |
---|---|
Vector4 | x: scaleX, y: scaleY, z: biasX, w: biasY |
Methods
Copy(CustomPassContext, RTHandle, RTHandle, Int32, Int32)
Copy an RTHandle content to another
Declaration
public static void Copy(in CustomPassContext ctx, RTHandle source, RTHandle destination, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the copy |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the copy |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
Copy(CustomPassContext, RTHandle, RTHandle, Vector4, Vector4, Int32, Int32)
Copy a region of an RTHandle to another
Declaration
public static void Copy(in CustomPassContext ctx, RTHandle source, RTHandle destination, Vector4 sourceScaleBias, Vector4 destScaleBias, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the copy |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the copy |
Vector4 | sourceScaleBias | Scale and bias to apply when sampling the source buffer |
Vector4 | destScaleBias | Scale and bias to apply when writing into the destination buffer. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
DownSample(CustomPassContext, RTHandle, RTHandle, Int32, Int32)
Convert the source buffer to an half resolution buffer and output it to the destination buffer.
Declaration
public static void DownSample(in CustomPassContext ctx, RTHandle source, RTHandle destination, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the downsample |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the downsample |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
DownSample(CustomPassContext, RTHandle, RTHandle, Vector4, Vector4, Int32, Int32)
Convert the source buffer to an half resolution buffer and output it to the destination buffer.
Declaration
public static void DownSample(in CustomPassContext ctx, RTHandle source, RTHandle destination, Vector4 sourceScaleBias, Vector4 destScaleBias, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the downsample |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the downsample |
Vector4 | sourceScaleBias | Scale and bias to apply when sampling the source buffer |
Vector4 | destScaleBias | Scale and bias to apply when writing into the destination buffer. It's scale is relative to the destination buffer, so if you want an half res downsampling into a fullres buffer you need to specify a scale of 0.5;0,5. If your buffer is already half res Then 1;1 scale works. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
DrawRenderers(CustomPassContext, LayerMask, CustomPass.RenderQueueType, Material, Int32, RenderStateBlock)
Simpler version of ScriptableRenderContext.DrawRenderers to draw HDRP materials.
Declaration
public static void DrawRenderers(in CustomPassContext ctx, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, Material overrideMaterial = null, int overrideMaterialIndex = 0, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
Material | overrideMaterial | Optional material that will be used to render the objects. |
Int32 | overrideMaterialIndex | Pass index to use for the override material. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
GaussianBlur(CustomPassContext, RTHandle, RTHandle, RTHandle, Int32, Single, Int32, Int32, Boolean)
Gaussian Blur pass.
Declaration
public static void GaussianBlur(in CustomPassContext ctx, RTHandle source, RTHandle destination, RTHandle tempTarget, int sampleCount = 9, float radius = 5F, int sourceMip = 0, int destMip = 0, bool downSample = true)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the gaussian blur. |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the gaussian blur. |
UnityEngine.Rendering.RTHandle | tempTarget | Temporary render target to provide used internally to swap the result between blur passes. Can be half res if downsample is true. |
Int32 | sampleCount | Number of samples to use for the gaussian blur. A high number will impact performances. |
Single | radius | Radius in pixel of the gaussian blur. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
Boolean | downSample | If true, will execute a downsample pass before the blur. It increases the performances of the blur. |
GaussianBlur(CustomPassContext, RTHandle, RTHandle, RTHandle, Vector4, Vector4, Int32, Single, Int32, Int32, Boolean)
Gaussian Blur pass.
Declaration
public static void GaussianBlur(in CustomPassContext ctx, RTHandle source, RTHandle destination, RTHandle tempTarget, Vector4 sourceScaleBias, Vector4 destScaleBias, int sampleCount = 9, float radius = 5F, int sourceMip = 0, int destMip = 0, bool downSample = true)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the gaussian blur. |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the gaussian blur. |
UnityEngine.Rendering.RTHandle | tempTarget | Temporary render target to provide used internally to swap the result between blur passes. Can be half res if downsample is true. |
Vector4 | sourceScaleBias | Scale and bias to apply when sampling the source buffer. |
Vector4 | destScaleBias | Scale and bias to apply when writing into the destination buffer. |
Int32 | sampleCount | Number of samples to use for the gaussian blur. A high number will impact performances. |
Single | radius | Radius in pixel of the gaussian blur. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
Boolean | downSample | If true, will execute a downsample pass before the blur. It increases the performances of the blur. |
GetRenderQueueRangeFromRenderQueueType(CustomPass.RenderQueueType)
Convert a Custom Pass render queue type to a RenderQueueRange that can be used in DrawRenderers
Declaration
public static RenderQueueRange GetRenderQueueRangeFromRenderQueueType(CustomPass.RenderQueueType type)
Parameters
Type | Name | Description |
---|---|---|
CustomPass.RenderQueueType | type | The type of render queue |
Returns
Type | Description |
---|---|
RenderQueueRange | The converted render queue range |
HorizontalGaussianBlur(CustomPassContext, RTHandle, RTHandle, Int32, Single, Int32, Int32)
Horizontal gaussian blur pass.
Declaration
public static void HorizontalGaussianBlur(in CustomPassContext ctx, RTHandle source, RTHandle destination, int sampleCount = 8, float radius = 5F, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the gaussian blur. |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the gaussian blur. |
Int32 | sampleCount | Number of samples to use for the gaussian blur. A high number will impact performances. |
Single | radius | Radius in pixel of the gaussian blur. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
HorizontalGaussianBlur(CustomPassContext, RTHandle, RTHandle, Vector4, Vector4, Int32, Single, Int32, Int32)
Horizontal gaussian blur pass.
Declaration
public static void HorizontalGaussianBlur(in CustomPassContext ctx, RTHandle source, RTHandle destination, Vector4 sourceScaleBias, Vector4 destScaleBias, int sampleCount = 8, float radius = 5F, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the gaussian blur. |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the gaussian blur. |
Vector4 | sourceScaleBias | Scale and bias to apply when sampling the source buffer. |
Vector4 | destScaleBias | Scale and bias to apply when writing into the destination buffer. |
Int32 | sampleCount | Number of samples to use for the gaussian blur. A high number will impact performances. |
Single | radius | Radius in pixel of the gaussian blur. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
RenderDepthFromCamera(CustomPassContext, Camera, LayerMask, CustomPass.RenderQueueType, RenderStateBlock)
Render eye space depth of objects from the view point of a camera into the color buffer.
Declaration
public static void RenderDepthFromCamera(in CustomPassContext ctx, Camera view, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderDepthFromCamera(CustomPassContext, Camera, RTHandle, RTHandle, ClearFlag, LayerMask, CustomPass.RenderQueueType, RenderStateBlock)
Render eye space depth of objects from the view point of a camera into the color and depth buffers.
Declaration
public static void RenderDepthFromCamera(in CustomPassContext ctx, Camera view, RTHandle targetColor, RTHandle targetDepth, ClearFlag clearFlag, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
UnityEngine.Rendering.RTHandle | targetColor | The render target that will be bound to the color buffer before rendering |
UnityEngine.Rendering.RTHandle | targetDepth | The render target that will be bound to the depth buffer before rendering |
UnityEngine.Rendering.ClearFlag | clearFlag | The type of clear to do before binding the render targets. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderFromCamera(CustomPassContext, Camera, LayerMask, CustomPass.RenderQueueType, Material, Int32, RenderStateBlock)
Render a list of objects from another camera point of view.
Declaration
public static void RenderFromCamera(in CustomPassContext ctx, Camera view, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, Material overrideMaterial = null, int overrideMaterialIndex = 0, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
Material | overrideMaterial | Optional material that will be used to render the objects. |
Int32 | overrideMaterialIndex | Pass index to use for the override material. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderFromCamera(CustomPassContext, Camera, RTHandle, RTHandle, ClearFlag, LayerMask, CustomPass.RenderQueueType, Material, Int32, RenderStateBlock)
Render a list of objects from another camera point of view.
Declaration
public static void RenderFromCamera(in CustomPassContext ctx, Camera view, RTHandle targetColor, RTHandle targetDepth, ClearFlag clearFlag, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, Material overrideMaterial = null, int overrideMaterialIndex = 0, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
UnityEngine.Rendering.RTHandle | targetColor | The render target that will be bound to the color buffer before rendering |
UnityEngine.Rendering.RTHandle | targetDepth | The render target that will be bound to the depth buffer before rendering |
UnityEngine.Rendering.ClearFlag | clearFlag | The type of clear to do before binding the render targets. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
Material | overrideMaterial | Optional material that will be used to render the objects. |
Int32 | overrideMaterialIndex | Pass index to use for the override material. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderNormalFromCamera(CustomPassContext, Camera, LayerMask, CustomPass.RenderQueueType, RenderStateBlock)
Render world space normal of objects from the view point of a camera into the color buffer.
Declaration
public static void RenderNormalFromCamera(in CustomPassContext ctx, Camera view, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderNormalFromCamera(CustomPassContext, Camera, RTHandle, RTHandle, ClearFlag, LayerMask, CustomPass.RenderQueueType, RenderStateBlock)
Render world space normal of objects from the view point of a camera into the color buffer.
Declaration
public static void RenderNormalFromCamera(in CustomPassContext ctx, Camera view, RTHandle targetColor, RTHandle targetDepth, ClearFlag clearFlag, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
UnityEngine.Rendering.RTHandle | targetColor | The render target that will be bound to the color buffer before rendering |
UnityEngine.Rendering.RTHandle | targetDepth | The render target that will be bound to the depth buffer before rendering |
UnityEngine.Rendering.ClearFlag | clearFlag | The type of clear to do before binding the render targets. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderTangentFromCamera(CustomPassContext, Camera, LayerMask, CustomPass.RenderQueueType, RenderStateBlock)
Render world space tangent of objects from the view point of a camera into the color buffer.
Declaration
public static void RenderTangentFromCamera(in CustomPassContext ctx, Camera view, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
RenderTangentFromCamera(CustomPassContext, Camera, RTHandle, RTHandle, ClearFlag, LayerMask, CustomPass.RenderQueueType, RenderStateBlock)
Render world space tangent of objects from the view point of a camera into the color buffer
Declaration
public static void RenderTangentFromCamera(in CustomPassContext ctx, Camera view, RTHandle targetColor, RTHandle targetDepth, ClearFlag clearFlag, LayerMask layerMask, CustomPass.RenderQueueType renderQueueFilter = CustomPass.RenderQueueType.All, RenderStateBlock overrideRenderState = default(RenderStateBlock))
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
Camera | view | The camera from where you want the objects to be rendered. |
UnityEngine.Rendering.RTHandle | targetColor | The render target that will be bound to the color buffer before rendering |
UnityEngine.Rendering.RTHandle | targetDepth | The render target that will be bound to the depth buffer before rendering |
UnityEngine.Rendering.ClearFlag | clearFlag | The type of clear to do before binding the render targets. |
LayerMask | layerMask | LayerMask to filter the objects to render. |
CustomPass.RenderQueueType | renderQueueFilter | Render Queue to filter the type of objects you want to render. |
RenderStateBlock | overrideRenderState | The render states to override when rendering the objects. |
VerticalGaussianBlur(CustomPassContext, RTHandle, RTHandle, Int32, Single, Int32, Int32)
Vertical gaussian blur pass
Declaration
public static void VerticalGaussianBlur(in CustomPassContext ctx, RTHandle source, RTHandle destination, int sampleCount = 8, float radius = 5F, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the gaussian blur. |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the gaussian blur. |
Int32 | sampleCount | Number of samples to use for the gaussian blur. A high number will impact performances. |
Single | radius | Radius in pixel of the gaussian blur. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |
VerticalGaussianBlur(CustomPassContext, RTHandle, RTHandle, Vector4, Vector4, Int32, Single, Int32, Int32)
Vertical gaussian blur pass
Declaration
public static void VerticalGaussianBlur(in CustomPassContext ctx, RTHandle source, RTHandle destination, Vector4 sourceScaleBias, Vector4 destScaleBias, int sampleCount = 8, float radius = 5F, int sourceMip = 0, int destMip = 0)
Parameters
Type | Name | Description |
---|---|---|
CustomPassContext | ctx | Custom Pass Context. |
UnityEngine.Rendering.RTHandle | source | Source to use for the gaussian blur. |
UnityEngine.Rendering.RTHandle | destination | Destination buffer of the gaussian blur. |
Vector4 | sourceScaleBias | Scale and bias to apply when sampling the source buffer |
Vector4 | destScaleBias | Scale and bias to apply when writing into the destination buffer. |
Int32 | sampleCount | Number of samples to use for the gaussian blur. A high number will impact performances. |
Single | radius | Radius in pixel of the gaussian blur. |
Int32 | sourceMip | Source mip level to sample from. |
Int32 | destMip | Destination mip level to write to. |