Class HDUtils
Various utility functions for HDRP.
Namespace: UnityEngine.Rendering.HighDefinition
Syntax
public class HDUtils
Properties
clearTexture3D
Default 1x1x1 3D texture initialized with Color.clear.
Declaration
public static Texture3D clearTexture3D { get; }
Property Value
Type | Description |
---|---|
Texture3D |
clearTexture3DRTH
Default 1x1x1 3D RTHandle initialized with Color.clear.
Declaration
public static RTHandle clearTexture3DRTH { get; }
Property Value
Type | Description |
---|---|
RTHandle |
hdrpSettings
Current HDRP settings.
Declaration
public static RenderPipelineSettings hdrpSettings { get; }
Property Value
Type | Description |
---|---|
RenderPipelineSettings |
Methods
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Single, Boolean)
Blit a RTHandle to another RTHandle. This will properly account for partial usage (in term of resolution) of the texture for the current viewport.
Declaration
public static void BlitCameraTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, float mipLevel = 0F, bool bilinear = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Material, Int32)
Blit a RTHandle to another RTHandle. This will properly account for partial usage (in term of resolution) of the texture for the current viewport. This overloads allows the user to override the default blit shader
Declaration
public static void BlitCameraTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
Material | material | The material to use when blitting |
Int32 | pass | pass to use of the provided material |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Rect, Single, Boolean)
Blit a RTHandle to another RTHandle. This will properly account for partial usage (in term of resolution) of the texture for the current viewport. This overload allows user to override the viewport of the destination RTHandle.
Declaration
public static void BlitCameraTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Rect destViewport, float mipLevel = 0F, bool bilinear = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
Rect | destViewport | Viewport of the destination RTHandle. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Vector4, Single, Boolean)
Blit a RTHandle to another RTHandle. This will properly account for partial usage (in term of resolution) of the texture for the current viewport. This overload allows user to override the scale and bias used when sampling the input RTHandle.
Declaration
public static void BlitCameraTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Vector4 scaleBias, float mipLevel = 0F, bool bilinear = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
Vector4 | scaleBias | Scale and bias used to sample the input RTHandle. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitCameraTexture2D(CommandBuffer, RTHandle, RTHandle, Single, Boolean)
Blit a RThandle Texture2D RTHandle to another RTHandle. This will properly account for partial usage (in term of resolution) of the texture for the current viewport.
Declaration
public static void BlitCameraTexture2D(CommandBuffer cmd, RTHandle source, RTHandle destination, float mipLevel = 0F, bool bilinear = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitOctahedralWithPadding(CommandBuffer, Texture, Vector2, Vector4, Vector4, Int32, Boolean, Int32)
Blit a texture (which is a Octahedral projection) using a quad in the current render target.
Declaration
public static void BlitOctahedralWithPadding(CommandBuffer cmd, Texture source, Vector2 textureSize, Vector4 scaleBiasTex, Vector4 scaleBiasRT, int mipLevelTex, bool bilinear, int paddingInPixels)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source texture. |
Vector2 | textureSize | Source texture size. |
Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
Int32 | paddingInPixels | Padding in pixels. |
BlitOctahedralWithPaddingMultiply(CommandBuffer, Texture, Vector2, Vector4, Vector4, Int32, Boolean, Int32)
Blit a texture (which is a Octahedral projection) using a quad in the current render target, by performing an alpha blend with the existing content on the render target.
Declaration
public static void BlitOctahedralWithPaddingMultiply(CommandBuffer cmd, Texture source, Vector2 textureSize, Vector4 scaleBiasTex, Vector4 scaleBiasRT, int mipLevelTex, bool bilinear, int paddingInPixels)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source texture. |
Vector2 | textureSize | Source texture size. |
Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
Int32 | paddingInPixels | Padding in pixels. |
BlitQuad(CommandBuffer, Texture, Vector4, Vector4, Int32, Boolean)
Blit a texture using a quad in the current render target.
Declaration
public static void BlitQuad(CommandBuffer cmd, Texture source, Vector4 scaleBiasTex, Vector4 scaleBiasRT, int mipLevelTex, bool bilinear)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source texture. |
Vector4 | scaleBiasTex | Scale and bias for the input texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitQuadWithPadding(CommandBuffer, Texture, Vector2, Vector4, Vector4, Int32, Boolean, Int32)
Blit a texture using a quad in the current render target.
Declaration
public static void BlitQuadWithPadding(CommandBuffer cmd, Texture source, Vector2 textureSize, Vector4 scaleBiasTex, Vector4 scaleBiasRT, int mipLevelTex, bool bilinear, int paddingInPixels)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source texture. |
Vector2 | textureSize | Source texture size. |
Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
Int32 | paddingInPixels | Padding in pixels. |
BlitQuadWithPaddingMultiply(CommandBuffer, Texture, Vector2, Vector4, Vector4, Int32, Boolean, Int32)
Blit a texture using a quad in the current render target, by performing an alpha blend with the existing content on the render target.
Declaration
public static void BlitQuadWithPaddingMultiply(CommandBuffer cmd, Texture source, Vector2 textureSize, Vector4 scaleBiasTex, Vector4 scaleBiasRT, int mipLevelTex, bool bilinear, int paddingInPixels)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source texture. |
Vector2 | textureSize | Source texture size. |
Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
Int32 | paddingInPixels | Padding in pixels. |
BlitTexture(CommandBuffer, RTHandle, Vector4, Single, Boolean)
Blit a RTHandle texture.
Declaration
public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, float mipLevel, bool bilinear)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitTexture2D(CommandBuffer, RTHandle, Vector4, Single, Boolean)
Blit a RTHandle texture 2D.
Declaration
public static void BlitTexture2D(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, float mipLevel, bool bilinear)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
DrawFullScreen(CommandBuffer, Material, RenderTargetIdentifier[], RTHandle, MaterialPropertyBlock, Int32)
Draw a full screen triangle with a material. This will automatically set the viewport of the destination RTHandle based on the current camera parameters.
Declaration
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, RenderTargetIdentifier[] colorBuffers, RTHandle depthStencilBuffer, MaterialPropertyBlock properties = null, int shaderPassId = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | commandBuffer | Command Buffer used for rendering. |
Material | material | Material used for rendering. |
RenderTargetIdentifier[] | colorBuffers | Array of RenderTargetIdentifier for multiple render target rendering. |
RTHandle | depthStencilBuffer | Destination Depth Stencil RTHandle. |
MaterialPropertyBlock | properties | Optional material property block. |
Int32 | shaderPassId | Optional pass index to use. |
DrawFullScreen(CommandBuffer, Material, RTHandle, MaterialPropertyBlock, Int32)
Draw a full screen triangle with a material. This will automatically set the viewport of the destination RTHandle based on the current camera parameters.
Declaration
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, RTHandle colorBuffer, MaterialPropertyBlock properties = null, int shaderPassId = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | commandBuffer | Command Buffer used for rendering. |
Material | material | Material used for rendering. |
RTHandle | colorBuffer | Destination RTHandle. |
MaterialPropertyBlock | properties | Optional material property block. |
Int32 | shaderPassId | Optional pass index to use. |
DrawFullScreen(CommandBuffer, Material, RTHandle, RTHandle, MaterialPropertyBlock, Int32)
Draw a full screen triangle with a material. This will automatically set the viewport of the destination RTHandle based on the current camera parameters.
Declaration
public static void DrawFullScreen(CommandBuffer commandBuffer, Material material, RTHandle colorBuffer, RTHandle depthStencilBuffer, MaterialPropertyBlock properties = null, int shaderPassId = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | commandBuffer | Command Buffer used for rendering. |
Material | material | Material used for rendering. |
RTHandle | colorBuffer | Destination RTHandle. |
RTHandle | depthStencilBuffer | Destination Depth Stencil RTHandle. |
MaterialPropertyBlock | properties | Optional material property block. |
Int32 | shaderPassId | Optional pass index to use. |
DrawFullScreen(CommandBuffer, Rect, Material, RenderTargetIdentifier, MaterialPropertyBlock, Int32, Int32)
Draw a full screen triangle with a material. This will render into the destination texture with the specified viewport.
Declaration
public static void DrawFullScreen(CommandBuffer commandBuffer, Rect viewport, Material material, RenderTargetIdentifier destination, MaterialPropertyBlock properties = null, int shaderPassId = 0, int depthSlice = -1)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | commandBuffer | Command Buffer used for rendering. |
Rect | viewport | Destination viewport. |
Material | material | Material used for rendering. |
RenderTargetIdentifier | destination | Destination RenderTargetIdentifier. |
MaterialPropertyBlock | properties | Optional Material Property block. |
Int32 | shaderPassId | Optional pass index to use. |
Int32 | depthSlice | Optional depth slice to render to. |
DrawFullScreen(CommandBuffer, Rect, Material, RenderTargetIdentifier, RTHandle, MaterialPropertyBlock, Int32)
Draw a full screen triangle with a material. This will render into the destination texture with the specified viewport.
Declaration
public static void DrawFullScreen(CommandBuffer commandBuffer, Rect viewport, Material material, RenderTargetIdentifier destination, RTHandle depthStencilBuffer, MaterialPropertyBlock properties = null, int shaderPassId = 0)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | commandBuffer | Command Buffer used for rendering. |
Rect | viewport | Destination viewport. |
Material | material | Material used for rendering. |
RenderTargetIdentifier | destination | Destination RenderTargetIdentifier. |
RTHandle | depthStencilBuffer | Destination Depth Stencil RTHandle. |
MaterialPropertyBlock | properties | Optional Material Property block. |
Int32 | shaderPassId | Optional pass index to use. |
DrawRendererList(ScriptableRenderContext, CommandBuffer, RendererList)
Draw a renderer list.
Declaration
[Obsolete("Please use CoreUtils.DrawRendererList instead.")]
public static void DrawRendererList(ScriptableRenderContext renderContext, CommandBuffer cmd, RendererList rendererList)
Parameters
Type | Name | Description |
---|---|---|
ScriptableRenderContext | renderContext | Current Scriptable Render Context. |
CommandBuffer | cmd | Command Buffer used for rendering. |
UnityEngine.Rendering.RendererUtils.RendererList | rendererList | Renderer List to render. |
GetBakedLightingRenderConfig()
Returns the render configuration for baked static lighting, this value can be used in a RendererListDesc call to render Lit objects.
Declaration
public static PerObjectData GetBakedLightingRenderConfig()
Returns
Type | Description |
---|---|
PerObjectData |
GetBakedLightingWithShadowMaskRenderConfig()
Returns the render configuration for baked static lighting with shadow masks, this value can be used in a RendererListDesc call to render Lit objects when shadow masks are enabled.
Declaration
public static PerObjectData GetBakedLightingWithShadowMaskRenderConfig()
Returns
Type | Description |
---|---|
PerObjectData |
GetBlitMaterial(TextureDimension, Boolean)
Returns the HDRP default blit material.
Declaration
public static Material GetBlitMaterial(TextureDimension dimension, bool singleSlice = false)
Parameters
Type | Name | Description |
---|---|---|
TextureDimension | dimension | Dimension of the texture to blit, either 2D or 2D Array. |
Boolean | singleSlice | Blit only a single slice of the array if applicable. |
Returns
Type | Description |
---|---|
Material |
NormalizeColor(Color)
Normalize the input color.
Declaration
public static Color NormalizeColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Input color. |
Returns
Type | Description |
---|---|
Color | Normalized color. |