Class Blitter
Various blit (texture copy) utilities for the Scriptable Render Pipelines.
Namespace: UnityEngine.Rendering
Syntax
public static class Blitter
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 |
---|---|---|
UnityEngine.Rendering.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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
UnityEngine.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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
UnityEngine.Rect | destViewport | Viewport of the destination RTHandle. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitCameraTexture(CommandBuffer, RTHandle, RTHandle, RenderBufferLoadAction, RenderBufferStoreAction, 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, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
UnityEngine.Rendering.RenderBufferLoadAction | loadAction | Load action. |
UnityEngine.Rendering.RenderBufferStoreAction | storeAction | Store action. |
UnityEngine.Material | material | The material to use when blitting |
Int32 | pass | pass to use of the provided material |
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
RTHandle | destination | Destination RTHandle. |
UnityEngine.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 |
---|---|---|
UnityEngine.Rendering.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. |
BlitColorAndDepth(CommandBuffer, Texture, RenderTexture, Vector4, Single, Boolean)
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
UnityEngine.Texture | sourceColor | Source Texture for color. |
UnityEngine.RenderTexture | sourceDepth | Source RenderTexture for depth. |
UnityEngine.Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Single | mipLevel | Mip level to blit. |
Boolean | blitDepth | Enable depth blit. |
BlitCubeToOctahedral2DQuad(CommandBuffer, Texture, Vector4, Int32)
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source cube texture. |
UnityEngine.Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to sample. |
BlitCubeToOctahedral2DQuadSingleChannel(CommandBuffer, Texture, Vector4, Int32)
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
BlitCubeToOctahedral2DQuadWithPadding(CommandBuffer, Texture, Vector2, Vector4, Int32, Boolean, Int32, Nullable<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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source cube texture. |
UnityEngine.Vector2 | textureSize | Source texture size. |
UnityEngine.Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to sample. |
Boolean | bilinear | Enable bilinear filtering. |
Int32 | paddingInPixels | Padding in pixels. |
Nullable<UnityEngine.Vector4> | decodeInstructions | Decode instruction. |
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector2 | textureSize | Source texture size. |
UnityEngine.Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
UnityEngine.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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector2 | textureSize | Source texture size. |
UnityEngine.Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
UnityEngine.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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector4 | scaleBiasTex | Scale and bias for the input texture. |
UnityEngine.Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitQuadSingleChannel(CommandBuffer, Texture, Vector4, Vector4, Int32)
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector4 | scaleBiasTex | Scale and bias for the input texture. |
UnityEngine.Vector4 | scaleBiasRT | Scale and bias for the output texture. |
Int32 | mipLevelTex | Mip level to blit. |
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector2 | textureSize | Source texture size. |
UnityEngine.Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
UnityEngine.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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command buffer used for rendering. |
UnityEngine.Texture | source | Source texture. |
UnityEngine.Vector2 | textureSize | Source texture size. |
UnityEngine.Vector4 | scaleBiasTex | Scale and bias for sampling the input texture. |
UnityEngine.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, RenderTargetIdentifier, RenderTargetIdentifier, Material, Int32)
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
UnityEngine.Rendering.RenderTargetIdentifier | source | Source render target. |
UnityEngine.Rendering.RenderTargetIdentifier | destination | Destination render target. |
UnityEngine.Material | material | Material to invoke when blitting. |
Int32 | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, RenderBufferLoadAction, RenderBufferStoreAction, Material, Int32)
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
UnityEngine.Rendering.RenderTargetIdentifier | source | Source render target. |
UnityEngine.Rendering.RenderTargetIdentifier | destination | Destination render target. |
UnityEngine.Rendering.RenderBufferLoadAction | loadAction | Load action. |
UnityEngine.Rendering.RenderBufferStoreAction | storeAction | Store action. |
UnityEngine.Material | material | Material to invoke when blitting. |
Int32 | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, RenderTargetIdentifier, Vector4, Material, Int32)
Blit a RTHandle texture
Declaration
public static void BlitTexture(CommandBuffer cmd, RenderTargetIdentifier source, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
UnityEngine.Rendering.RenderTargetIdentifier | source | Source render target. |
UnityEngine.Vector4 | scaleBias | Scale and bias for sampling the input texture. |
UnityEngine.Material | material | Material to invoke when blitting. |
Int32 | pass | Pass idx within the material to invoke. |
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
UnityEngine.Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
BlitTexture(CommandBuffer, RTHandle, Vector4, Material, Int32)
Blit a RTHandle texture
Declaration
public static void BlitTexture(CommandBuffer cmd, RTHandle source, Vector4 scaleBias, Material material, int pass)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
UnityEngine.Vector4 | scaleBias | Scale and bias for sampling the input texture. |
UnityEngine.Material | material | Material to invoke when blitting. |
Int32 | pass | Pass idx within the material to invoke. |
BlitTexture(CommandBuffer, Vector4, Material, Int32)
Blit a Texture with a given Material. Unity uses the reference name _BlitTexture
to bind the input texture. 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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
UnityEngine.Vector4 | scaleBias | Scale and bias values for sampling the input texture. |
UnityEngine.Material | material | Material to invoke when blitting. |
Int32 | pass | Pass index within the Material to invoke. |
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 |
---|---|---|
UnityEngine.Rendering.CommandBuffer | cmd | Command Buffer used for rendering. |
RTHandle | source | Source RTHandle. |
UnityEngine.Vector4 | scaleBias | Scale and bias for sampling the input texture. |
Single | mipLevel | Mip level to blit. |
Boolean | bilinear | Enable bilinear filtering. |
Cleanup()
Release Blitter resources.
Declaration
public static void Cleanup()
GetBlitMaterial(TextureDimension, Boolean)
Returns the default blit material.
Declaration
public static Material GetBlitMaterial(TextureDimension dimension, bool singleSlice = false)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Rendering.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 |
---|---|
UnityEngine.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 |
---|---|---|
UnityEngine.Shader | blitPS | |
UnityEngine.Shader | blitColorAndDepthPS |