Struct RenderGraphUtils.BlitMaterialParameters
This struct specifies all the arugments to the blit-with-material function. As there are many parameters with some of them only rarely used moving them to a struct makes it easier to use the function.
Use one of the constructor overloads for common use cases.
The shader properties defined in the struct or constructors is used for most common usecases but they are not required to be used in the shader.
By using the MaterialPropertyBlock
can you add your shader properties with custom values.
Inherited Members
Namespace: UnityEngine.Rendering.RenderGraphModule.Util
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public struct RenderGraphUtils.BlitMaterialParameters
Constructors
BlitMaterialParameters(TextureHandle, TextureHandle, Material, int)
Simple constructor to set a few amount of parameters to blit.
Declaration
public BlitMaterialParameters(TextureHandle source, TextureHandle destination, Material material, int shaderPass)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | source | The texture the data is copied from. |
TextureHandle | destination | The texture the data is copied to. |
Material | material | Material used for blitting. |
int | shaderPass | The shader pass index to use for the material. |
BlitMaterialParameters(TextureHandle, TextureHandle, Material, int, MaterialPropertyBlock, int, int, int, int, int, int, FullScreenGeometryType, int, int, int)
Constructor to set the source and destination mip and slices as well as material property and IDs to interact with it.
Declaration
public BlitMaterialParameters(TextureHandle source, TextureHandle destination, Material material, int shaderPass, MaterialPropertyBlock mpb, int destinationSlice, int destinationMip, int numSlices = 1, int numMips = 1, int sourceSlice = -1, int sourceMip = -1, RenderGraphUtils.FullScreenGeometryType geometry = FullScreenGeometryType.Mesh, int sourceTexturePropertyID = -1, int sourceSlicePropertyID = -1, int sourceMipPropertyID = -1)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | source | The texture the data is copied from. |
TextureHandle | destination | The texture the data is copied to. |
Material | material | Material used for blitting. |
int | shaderPass | The shader pass index to use for the material. |
MaterialPropertyBlock | mpb | Material property block to use to render the blit. This property should contain all data the shader needs. |
int | destinationSlice | The first slice to copy to if the texture is an 3D or array texture. Must be zero for regular textures. |
int | destinationMip | The first mipmap level to copy to. Must be zero for non-mipmapped textures. Must be a valid index for mipmapped textures. |
int | numSlices | The number of slices to copy. -1 to copy all slices until the end of the texture. Arguments that copy invalid slices to be copied will lead to an error. |
int | numMips | The number of mipmaps to copy. -1 to copy all mipmaps. Arguments that copy invalid mips to be copied will lead to an error. |
int | sourceSlice | The first slice to copy from if the texture is an 3D or array texture. Must be zero for regular textures. Default is set to -1 to ignore source slices and set it to 0 without looping for each destination slice |
int | sourceMip | The first mipmap level to copy from. Must be zero for non-mipmapped textures. Must be a valid index for mipmapped textures. Defaults to -1 to ignore source mips and set it to 0 without looping for each destination mip. |
RenderGraphUtils.FullScreenGeometryType | geometry | Geometry used for blitting the source texture. |
int | sourceTexturePropertyID | The texture property to set with the source texture. If -1 the default "_BlitTexture" texture property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If propertyBlock is null the texture will be applied directly to the material. |
int | sourceSlicePropertyID | The scalar property to set with the source slice index. If -1 the default "_BlitTexArraySlice" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one slice is rendered using the blit function (numSlices>1) several full screen quads will be rendered for each slice with different sourceSlicePropertyID values set. |
int | sourceMipPropertyID | The scalar property to set with the source mip index. If -1 the default "_BlitMipLevel" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one mip is rendered using the blit function (numMips>1) several full screen quads will be rendered for each slice with different sourceMipPropertyID values set. |
BlitMaterialParameters(TextureHandle, TextureHandle, Material, int, MaterialPropertyBlock, FullScreenGeometryType, int, int, int)
Constructor to set textures, material, shader pass and material property block.
Declaration
public BlitMaterialParameters(TextureHandle source, TextureHandle destination, Material material, int shaderPass, MaterialPropertyBlock mpb, RenderGraphUtils.FullScreenGeometryType geometry = FullScreenGeometryType.Mesh, int sourceTexturePropertyID = -1, int sourceSlicePropertyID = -1, int sourceMipPropertyID = -1)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | source | The texture the data is copied from. |
TextureHandle | destination | The texture the data is copied to. |
Material | material | Material used for blitting. |
int | shaderPass | The shader pass index to use for the material. |
MaterialPropertyBlock | mpb | Material property block to use to render the blit. This property should contain all data the shader needs. |
RenderGraphUtils.FullScreenGeometryType | geometry | Geometry used for blitting the source texture. |
int | sourceTexturePropertyID | The texture property to set with the source texture. If -1 the default "_BlitTexture" texture property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If propertyBlock is null the texture will be applied directly to the material. |
int | sourceSlicePropertyID | The scalar property to set with the source slice index. If -1 the default "_BlitTexArraySlice" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one slice is rendered using the blit function (numSlices>1) several full screen quads will be rendered for each slice with different sourceSlicePropertyID values set. |
int | sourceMipPropertyID | The scalar property to set with the source mip index. If -1 the default "_BlitMipLevel" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one mip is rendered using the blit function (numMips>1) several full screen quads will be rendered for each slice with different sourceMipPropertyID values set. |
BlitMaterialParameters(TextureHandle, TextureHandle, Vector2, Vector2, Material, int)
Simple constructor to set a few amount of parameters to blit.
Declaration
public BlitMaterialParameters(TextureHandle source, TextureHandle destination, Vector2 scale, Vector2 offset, Material material, int shaderPass)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | source | The texture the data is copied from. |
TextureHandle | destination | The texture the data is copied to. |
Vector2 | scale | Scale for sampling the input texture. |
Vector2 | offset | Offset also known as bias for sampling the input texture |
Material | material | Material used for blitting. |
int | shaderPass | The shader pass index to use for the material. |
BlitMaterialParameters(TextureHandle, TextureHandle, Vector2, Vector2, Material, int, MaterialPropertyBlock, int, int, int, int, int, int, FullScreenGeometryType, int, int, int, int)
Constructor to set the source and destination mip and slices as well as material property and IDs to interact with it.
Declaration
public BlitMaterialParameters(TextureHandle source, TextureHandle destination, Vector2 scale, Vector2 offset, Material material, int shaderPass, MaterialPropertyBlock mpb, int destinationSlice, int destinationMip, int numSlices = 1, int numMips = 1, int sourceSlice = -1, int sourceMip = -1, RenderGraphUtils.FullScreenGeometryType geometry = FullScreenGeometryType.Mesh, int sourceTexturePropertyID = -1, int sourceSlicePropertyID = -1, int sourceMipPropertyID = -1, int scaleBiasPropertyID = -1)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | source | The texture the data is copied from. |
TextureHandle | destination | The texture the data is copied to. |
Vector2 | scale | Scale for sampling the input texture. |
Vector2 | offset | Offset also known as bias for sampling the input texture |
Material | material | Material used for blitting. |
int | shaderPass | The shader pass index to use for the material. |
MaterialPropertyBlock | mpb | Material property block to use to render the blit. This property should contain all data the shader needs. |
int | destinationSlice | The first slice to copy to if the texture is an 3D or array texture. Must be zero for regular textures. |
int | destinationMip | The first mipmap level to copy to. Must be zero for non-mipmapped textures. Must be a valid index for mipmapped textures. |
int | numSlices | The number of slices to copy. -1 to copy all slices until the end of the texture. Arguments that copy invalid slices to be copied will lead to an error. |
int | numMips | The number of mipmaps to copy. -1 to copy all mipmaps. Arguments that copy invalid mips to be copied will lead to an error. |
int | sourceSlice | The first slice to copy from if the texture is an 3D or array texture. Must be zero for regular textures. Default is set to -1 to ignore source slices and set it to 0 without looping for each destination slice |
int | sourceMip | The first mipmap level to copy from. Must be zero for non-mipmapped textures. Must be a valid index for mipmapped textures. Defaults to -1 to ignore source mips and set it to 0 without looping for each destination mip. |
RenderGraphUtils.FullScreenGeometryType | geometry | Geometry used for blitting the source texture. |
int | sourceTexturePropertyID | The texture property to set with the source texture. If -1 the default "_BlitTexture" texture property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If propertyBlock is null the texture will be applied directly to the material. |
int | sourceSlicePropertyID | The scalar property to set with the source slice index. If -1 the default "_BlitTexArraySlice" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one slice is rendered using the blit function (numSlices>1) several full screen quads will be rendered for each slice with different sourceSlicePropertyID values set. |
int | sourceMipPropertyID | The scalar property to set with the source mip index. If -1 the default "_BlitMipLevel" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one mip is rendered using the blit function (numMips>1) several full screen quads will be rendered for each slice with different sourceMipPropertyID values set. |
int | scaleBiasPropertyID | The scalar property to set with the scale and bias known as offset. If -1 the default "_BlitScaleBias" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. |
BlitMaterialParameters(TextureHandle, TextureHandle, Vector2, Vector2, Material, int, MaterialPropertyBlock, FullScreenGeometryType, int, int, int, int)
Constructor to set textures, material, shader pass and material property block.
Declaration
public BlitMaterialParameters(TextureHandle source, TextureHandle destination, Vector2 scale, Vector2 offset, Material material, int shaderPass, MaterialPropertyBlock mpb, RenderGraphUtils.FullScreenGeometryType geometry = FullScreenGeometryType.Mesh, int sourceTexturePropertyID = -1, int sourceSlicePropertyID = -1, int sourceMipPropertyID = -1, int scaleBiasPropertyID = -1)
Parameters
Type | Name | Description |
---|---|---|
TextureHandle | source | The texture the data is copied from. |
TextureHandle | destination | The texture the data is copied to. |
Vector2 | scale | Scale for sampling the input texture. |
Vector2 | offset | Offset also known as bias for sampling the input texture |
Material | material | Material used for blitting. |
int | shaderPass | The shader pass index to use for the material. |
MaterialPropertyBlock | mpb | Material property block to use to render the blit. This property should contain all data the shader needs. |
RenderGraphUtils.FullScreenGeometryType | geometry | Geometry used for blitting the source texture. |
int | sourceTexturePropertyID | The texture property to set with the source texture. If -1 the default "_BlitTexture" texture property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If propertyBlock is null the texture will be applied directly to the material. |
int | sourceSlicePropertyID | The scalar property to set with the source slice index. If -1 the default "_BlitSlice" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one slice is rendered using the blit function (numSlices>1) several full screen quads will be rendered for each slice with different sourceSlicePropertyID values set. |
int | sourceMipPropertyID | The scalar property to set with the source mip index. If -1 the default "_BlitMipLevel" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one mip is rendered using the blit function (numMips>1) several full screen quads will be rendered for each slice with different sourceMipPropertyID values set. |
int | scaleBiasPropertyID | The scalar property to set with the scale and bias known as offset. If -1 the default "_BlitScaleBias" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. |
Fields
destination
The texture to blit into. This subresources (mips,slices) of this texture texture will be set-up as a render attachment based on the destination argumments.
Declaration
public TextureHandle destination
Field Value
Type | Description |
---|---|
TextureHandle |
destinationMip
The first destination mipmap to blit into.
Declaration
public int destinationMip
Field Value
Type | Description |
---|---|
int |
destinationSlice
The first slice of the destination texture to blit into.
Declaration
public int destinationSlice
Field Value
Type | Description |
---|---|
int |
geometry
The type of full-screen geometry to use when rendering the blit material. See FullScreenGeometryType for details.
Declaration
public RenderGraphUtils.FullScreenGeometryType geometry
Field Value
Type | Description |
---|---|
RenderGraphUtils.FullScreenGeometryType |
material
The material to use, cannot be null. The blit functions will not modify this material in any way.
Declaration
public Material material
Field Value
Type | Description |
---|---|
Material |
numMips
The number of mipmaps to blit. -1 to blit all mipmaps until the end of the texture starting from destinationMip. Arguments that copy invalid slices (e.g. out of range or zero) will lead to an error.
Declaration
public int numMips
Field Value
Type | Description |
---|---|
int |
numSlices
The number of slices to blit. -1 to blit all slices until the end of the texture starting from destinationSlice. Arguments that copy invalid slices (e.g. out of range or zero) will lead to an error.
Declaration
public int numSlices
Field Value
Type | Description |
---|---|
int |
offset
The offset of the blit destination.
Declaration
public Vector2 offset
Field Value
Type | Description |
---|---|
Vector2 |
propertyBlock
The material propery block to use, can be null. The blit functions will modify the sourceTexturePropertyID, sourceSliceProperty, and sourceMipPropertyID of this material poperty block as part of the blit. Calling propertyBlock's SetTexture(...) function used by BlitMaterialParameters should be avoid since it will cause untracked textures when using RenderGraph. This can cause unexpected behaviours.
Declaration
public MaterialPropertyBlock propertyBlock
Field Value
Type | Description |
---|---|
MaterialPropertyBlock |
scale
The scale used for the blit operation.
Declaration
public Vector2 scale
Field Value
Type | Description |
---|---|
Vector2 |
scaleBiasPropertyID
The scalar property to set with the scale and bias also known as offset from the source to distination. If -1 the default "_BlitScaleBias" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID.
Declaration
public int scaleBiasPropertyID
Field Value
Type | Description |
---|---|
int |
shaderPass
The shader pass index to use.
Declaration
public int shaderPass
Field Value
Type | Description |
---|---|
int |
source
The source texture. This texture will be set on the specified material property block property with the name specified sourceTexturePropertyID. If the property block is null, a temp property block will be allocated by the blit function.
Declaration
public TextureHandle source
Field Value
Type | Description |
---|---|
TextureHandle |
sourceMip
The first source mipmap to blit from. -1 to ignore source mips and set it to 0 without looping for each destination mip.
Declaration
public int sourceMip
Field Value
Type | Description |
---|---|
int |
sourceMipPropertyID
The scalar property to set with the source mip index. If -1 the default "_BlitMipLevel" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one mip is rendered using the blit function (numMips>1) several full screen quads will be rendered for each slice with different sourceMipPropertyID values set.///
Declaration
public int sourceMipPropertyID
Field Value
Type | Description |
---|---|
int |
sourceSlice
The first slice of the source texture to blit from. -1 to ignore source slices and set it to 0 without looping for each destination slice.
Declaration
public int sourceSlice
Field Value
Type | Description |
---|---|
int |
sourceSlicePropertyID
The scalar property to set with the source slice index. If -1 the default "_BlitTexArraySlice" property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If more than one slice is rendered using the blit function (numSlices>1) several full screen quads will be rendered for each slice with different sourceSlicePropertyID values set.
Declaration
public int sourceSlicePropertyID
Field Value
Type | Description |
---|---|
int |
sourceTexturePropertyID
The texture property to set with the source texture. If -1 the default "_BlitTexture" texture property will be used. Note: Use Shader.PropertyToID to convert a string property name to an ID. If propertyBlock is null the texture will be applied directly to the material.
Declaration
public int sourceTexturePropertyID
Field Value
Type | Description |
---|---|
int |