Class Blitter
Various blit (texture copy) utilities for the Scriptable Render Pipelines.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public static class Blitter
Methods
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, float, bool)
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 = 0, bool bilinear = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Material, int)
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 |
int | pass | pass to use of the provided material |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Rect, float, bool)
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 = 0, 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. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, RenderBufferLoadAction, RenderBufferStoreAction, Material, int)
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, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
RenderBufferLoadAction | loadAction | Load action. |
RenderBufferStoreAction | storeAction | Store action. |
Material | material | The material to use when blitting |
int | pass | pass to use of the provided material |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, Vector4, float, bool)
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 = 0, 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. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitCameraTexture2D(CommandBuffer, RTHandle, RTHandle, float, bool)
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 = 0, bool bilinear = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitColorAndDepth(RasterCommandBuffer, Texture, RenderTexture, Vector4, float, bool)
Blit a 2D texture and depth buffer.
Declaration
public static void BlitColorAndDepth(RasterCommandBuffer cmd, Texture sourceColor, RenderTexture sourceDepth, Vector4 scaleBias, float mipLevel, bool blitDepth)
Parameters
Type | Name | Description |
---|---|---|
RasterCommandBuffer | cmd | Command Buffer used for rendering. |
Texture | sourceColor | Source Texture for color. |
RenderTexture | sourceDepth | Source RenderTexture for depth. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
float | mipLevel | Mip level to blit. |
bool | blitDepth | Enable depth blit. |
BlitColorAndDepth(CommandBuffer, Texture, RenderTexture, Vector4, float, bool)
Blit a 2D texture and depth buffer.
Declaration
public static void BlitColorAndDepth(CommandBuffer cmd, Texture sourceColor, RenderTexture sourceDepth, Vector4 scaleBias, float mipLevel, bool blitDepth)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
Texture | sourceColor | Source Texture for color. |
RenderTexture | sourceDepth | Source RenderTexture for depth. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
float | mipLevel | Mip level to blit. |
bool | blitDepth | Enable depth blit. |
BlitCubeToOctahedral2DQuad(CommandBuffer, Texture, Vector4, int)
Blit a cube texture into 2d texture as octahedral quad. (projection)
Declaration
public static void BlitCubeToOctahedral2DQuad(CommandBuffer cmd, Texture source, Vector4 scaleBiasRT, int mipLevelTex)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source cube texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
int | mipLevelTex | Mip level to sample. |
BlitCubeToOctahedral2DQuadSingleChannel(CommandBuffer, Texture, Vector4, int)
Blit a cube texture into 2d texture as octahedral quad. (projection) Conversion between single and multi channel formats. RGB(A) to YYYY (luminance). R to RRRR. A to AAAA.
Declaration
public static void BlitCubeToOctahedral2DQuadSingleChannel(CommandBuffer cmd, Texture source, Vector4 scaleBiasRT, int mipLevelTex)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source texture. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
int | mipLevelTex | Mip level to blit. |
BlitCubeToOctahedral2DQuadWithPadding(CommandBuffer, Texture, Vector2, Vector4, int, bool, int, Vector4?)
Blit a cube texture into 2d texture as octahedral quad with padding. (projection)
Declaration
public static void BlitCubeToOctahedral2DQuadWithPadding(CommandBuffer cmd, Texture source, Vector2 textureSize, Vector4 scaleBiasRT, int mipLevelTex, bool bilinear, int paddingInPixels, Vector4? decodeInstructions = null)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
Texture | source | Source cube texture. |
Vector2 | textureSize | Source texture size. |
Vector4 | scaleBiasRT | Scale and bias for the output texture. |
int | mipLevelTex | Mip level to sample. |
bool | bilinear | Enable bilinear filtering. |
int | paddingInPixels | Padding in pixels. |
Vector4? | decodeInstructions | The purpose of this parameter is to blit HDR-encoded values to a non HDR texture. Use values from API that produce HDR-encoded values, for example textureHDRDecodeValues. If this parameter is null, HDR decoding is disabled. |
BlitOctahedralWithPadding(CommandBuffer, Texture, Vector2, Vector4, Vector4, int, bool, int)
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. |
int | mipLevelTex | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
int | paddingInPixels | Padding in pixels. |
BlitOctahedralWithPaddingMultiply(CommandBuffer, Texture, Vector2, Vector4, Vector4, int, bool, int)
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. |
int | mipLevelTex | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
int | paddingInPixels | Padding in pixels. |
BlitQuad(CommandBuffer, Texture, Vector4, Vector4, int, bool)
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. |
int | mipLevelTex | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitQuadSingleChannel(CommandBuffer, Texture, Vector4, Vector4, int)
Bilinear Blit a texture using a quad in the current render target. Conversion between single and multi channel formats. RGB(A) to YYYY (luminance). R to RRRR. A to AAAA.
Declaration
public static void BlitQuadSingleChannel(CommandBuffer cmd, Texture source, Vector4 scaleBiasTex, Vector4 scaleBiasRT, int mipLevelTex)
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. |
int | mipLevelTex | Mip level to blit. |
BlitQuadWithPadding(CommandBuffer, Texture, Vector2, Vector4, Vector4, int, bool, int)
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. |
int | mipLevelTex | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
int | paddingInPixels | Padding in pixels. |
BlitQuadWithPaddingMultiply(CommandBuffer, Texture, Vector2, Vector4, Vector4, int, bool, int)
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. |
int | mipLevelTex | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
int | paddingInPixels | Padding in pixels. |
BlitTexture(RasterCommandBuffer, RTHandle, Vector4, float, bool)
Blit a RTHandle texture.
Declaration
public static void BlitTexture(RasterCommandBuffer cmd, RTHandle source, Vector4 scaleBias, float mipLevel, bool bilinear)
Parameters
Type | Name | Description |
---|---|---|
RasterCommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitTexture(RasterCommandBuffer, RTHandle, Vector4, Material, int)
Blit a RTHandle texture
Declaration
public static void BlitTexture(RasterCommandBuffer cmd, RTHandle source, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
RasterCommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Material | material | Material to invoke when blitting. |
int | pass | Pass idx within the material to invoke. |
BlitTexture(RasterCommandBuffer, RenderTargetIdentifier, Vector4, Material, int)
Blit a RTHandle texture
Declaration
public static void BlitTexture(RasterCommandBuffer cmd, RenderTargetIdentifier source, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
RasterCommandBuffer | cmd | Command Buffer used for rendering. |
RenderTargetIdentifier | source | Source render target. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Material | material | Material to invoke when blitting. |
int | pass | Pass idx within the material to invoke. |
BlitTexture(RasterCommandBuffer, Vector4, Material, int)
Blit a quad with a given Material. Set the destination parameter before using this method.
Declaration
public static void BlitTexture(RasterCommandBuffer cmd, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
RasterCommandBuffer | cmd | Command Buffer used for rendering. |
Vector4 | scaleBias | Scale and bias values for sampling the input texture. |
Material | material | Material to invoke when blitting. |
int | pass | Pass index within the Material to invoke. |
BlitTexture(CommandBuffer, RTHandle, Vector4, float, bool)
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. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitTexture(CommandBuffer, RTHandle, Vector4, Material, int)
Blit a RTHandle texture
Declaration
public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, Material material, int pass)
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. |
Material | material | Material to invoke when blitting. |
int | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, Material, int)
Blit a Texture with a specified material. The reference name "_BlitTexture" will be used to bind the input texture.
Declaration
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RenderTargetIdentifier | source | Source render target. |
RenderTargetIdentifier | destination | Destination render target. |
Material | material | Material to invoke when blitting. |
int | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, RenderBufferLoadAction, RenderBufferStoreAction, Material, int)
Blit a Texture with a specified material. The reference name "_BlitTexture" will be used to bind the input texture.
Declaration
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RenderTargetIdentifier | source | Source render target. |
RenderTargetIdentifier | destination | Destination render target. |
RenderBufferLoadAction | loadAction | Load action. |
RenderBufferStoreAction | storeAction | Store action. |
Material | material | Material to invoke when blitting. |
int | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, RenderTargetIdentifier, Vector4, Material, int)
Blit a RTHandle texture
Declaration
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
RenderTargetIdentifier | source | Source render target. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Material | material | Material to invoke when blitting. |
int | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, Vector4, Material, int)
Blit a quad with a given Material. Set the destination parameter before using this method.
Declaration
public static void BlitTexture(CommandBuffer cmd, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command Buffer used for rendering. |
Vector4 | scaleBias | Scale and bias values for sampling the input texture. |
Material | material | Material to invoke when blitting. |
int | pass | Pass index within the Material to invoke. |
BlitTexture2D(RasterCommandBuffer, RTHandle, Vector4, float, bool)
Blit a RTHandle texture 2D.
Declaration
public static void BlitTexture2D(RasterCommandBuffer cmd, RTHandle source, Vector4 scaleBias, float mipLevel, bool bilinear)
Parameters
Type | Name | Description |
---|---|---|
RasterCommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
Vector4 | scaleBias | Scale and bias for sampling the input texture. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
BlitTexture2D(CommandBuffer, RTHandle, Vector4, float, bool)
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. |
float | mipLevel | Mip level to blit. |
bool | bilinear | Enable bilinear filtering. |
Cleanup()
Release Blitter resources.
Declaration
public static void Cleanup()
GetBlitMaterial(TextureDimension, bool)
Returns the 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. |
bool | singleSlice | Blit only a single slice of the array if applicable. |
Returns
Type | Description |
---|---|
Material |
Initialize(Shader, Shader)
Initialize Blitter resources. Must be called once before any use
Declaration
public static void Initialize(Shader blitPS, Shader blitColorAndDepthPS)
Parameters
Type | Name | Description |
---|---|---|
Shader | blitPS | |
Shader | blitColorAndDepthPS |