Class RenderingUtils
Contains properties and helper functions that you can use when rendering.
Inherited Members
Namespace: UnityEngine.Rendering.Universal
Assembly: Unity.RenderPipelines.Universal.Runtime.dll
Syntax
public static class RenderingUtils
Methods
CreateDrawingSettings(List<ShaderTagId>, ref RenderingData, SortingCriteria)
Creates DrawingSettings
based on current rendering state.
Declaration
public static DrawingSettings CreateDrawingSettings(List<ShaderTagId> shaderTagIdList, ref RenderingData renderingData, SortingCriteria sortingCriteria)
Parameters
Type | Name | Description |
---|---|---|
List<ShaderTagId> | shaderTagIdList | List of shader pass tag to render. |
RenderingData | renderingData | Current rendering state. |
SortingCriteria | sortingCriteria | Criteria to sort objects being rendered. |
Returns
Type | Description |
---|---|
DrawingSettings |
See Also
CreateDrawingSettings(List<ShaderTagId>, UniversalRenderingData, UniversalCameraData, UniversalLightData, SortingCriteria)
Creates DrawingSettings
based on current rendering state.
Declaration
public static DrawingSettings CreateDrawingSettings(List<ShaderTagId> shaderTagIdList, UniversalRenderingData renderingData, UniversalCameraData cameraData, UniversalLightData lightData, SortingCriteria sortingCriteria)
Parameters
Type | Name | Description |
---|---|---|
List<ShaderTagId> | shaderTagIdList | List of shader pass tag to render. |
UniversalRenderingData | renderingData | Current rendering state. |
UniversalCameraData | cameraData | Current camera state. |
UniversalLightData | lightData | Current light state. |
SortingCriteria | sortingCriteria | Criteria to sort objects being rendered. |
Returns
Type | Description |
---|---|
DrawingSettings |
See Also
CreateDrawingSettings(ShaderTagId, ref RenderingData, SortingCriteria)
Creates DrawingSettings
based on current the rendering state.
Declaration
public static DrawingSettings CreateDrawingSettings(ShaderTagId shaderTagId, ref RenderingData renderingData, SortingCriteria sortingCriteria)
Parameters
Type | Name | Description |
---|---|---|
ShaderTagId | shaderTagId | Shader pass tag to render. |
RenderingData | renderingData | Current rendering state. |
SortingCriteria | sortingCriteria | Criteria to sort objects being rendered. |
Returns
Type | Description |
---|---|
DrawingSettings |
See Also
CreateDrawingSettings(ShaderTagId, UniversalRenderingData, UniversalCameraData, UniversalLightData, SortingCriteria)
Creates DrawingSettings
based on current the rendering state.
Declaration
public static DrawingSettings CreateDrawingSettings(ShaderTagId shaderTagId, UniversalRenderingData renderingData, UniversalCameraData cameraData, UniversalLightData lightData, SortingCriteria sortingCriteria)
Parameters
Type | Name | Description |
---|---|---|
ShaderTagId | shaderTagId | Shader pass tag to render. |
UniversalRenderingData | renderingData | Current rendering state. |
UniversalCameraData | cameraData | Current camera state. |
UniversalLightData | lightData | Current light state. |
SortingCriteria | sortingCriteria | Criteria to sort objects being rendered. |
Returns
Type | Description |
---|---|
DrawingSettings |
See Also
ReAllocateHandleIfNeeded(ref RTHandle, in RenderTextureDescriptor, FilterMode, TextureWrapMode, int, float, string)
Re-allocate fixed-size RTHandle if it is not allocated or doesn't match the descriptor
Declaration
public static bool ReAllocateHandleIfNeeded(ref RTHandle handle, in RenderTextureDescriptor descriptor, FilterMode filterMode = FilterMode.Point, TextureWrapMode wrapMode = TextureWrapMode.Repeat, int anisoLevel = 1, float mipMapBias = 0, string name = "")
Parameters
Type | Name | Description |
---|---|---|
RTHandle | handle | RTHandle to check (can be null) |
RenderTextureDescriptor | descriptor | Descriptor for the RTHandle to match |
FilterMode | filterMode | Filtering mode of the RTHandle. |
TextureWrapMode | wrapMode | Addressing mode of the RTHandle. |
int | anisoLevel | Anisotropic filtering level. |
float | mipMapBias | Bias applied to mipmaps during filtering. |
string | name | Name of the RTHandle. |
Returns
Type | Description |
---|---|
bool | If an allocation was done. |
ReAllocateHandleIfNeeded(ref RTHandle, ScaleFunc, in RenderTextureDescriptor, FilterMode, TextureWrapMode, int, float, string)
Re-allocate dynamically resized RTHandle if it is not allocated or doesn't match the descriptor
Declaration
public static bool ReAllocateHandleIfNeeded(ref RTHandle handle, ScaleFunc scaleFunc, in RenderTextureDescriptor descriptor, FilterMode filterMode = FilterMode.Point, TextureWrapMode wrapMode = TextureWrapMode.Repeat, int anisoLevel = 1, float mipMapBias = 0, string name = "")
Parameters
Type | Name | Description |
---|---|---|
RTHandle | handle | RTHandle to check (can be null) |
ScaleFunc | scaleFunc | Function used for the RTHandle size computation. |
RenderTextureDescriptor | descriptor | Descriptor for the RTHandle to match |
FilterMode | filterMode | Filtering mode of the RTHandle. |
TextureWrapMode | wrapMode | Addressing mode of the RTHandle. |
int | anisoLevel | Anisotropic filtering level. |
float | mipMapBias | Bias applied to mipmaps during filtering. |
string | name | Name of the RTHandle. |
Returns
Type | Description |
---|---|
bool | If an allocation was done. |
ReAllocateHandleIfNeeded(ref RTHandle, Vector2, in RenderTextureDescriptor, FilterMode, TextureWrapMode, int, float, string)
Re-allocate dynamically resized RTHandle if it is not allocated or doesn't match the descriptor
Declaration
public static bool ReAllocateHandleIfNeeded(ref RTHandle handle, Vector2 scaleFactor, in RenderTextureDescriptor descriptor, FilterMode filterMode = FilterMode.Point, TextureWrapMode wrapMode = TextureWrapMode.Repeat, int anisoLevel = 1, float mipMapBias = 0, string name = "")
Parameters
Type | Name | Description |
---|---|---|
RTHandle | handle | RTHandle to check (can be null) |
Vector2 | scaleFactor | Constant scale for the RTHandle size computation. |
RenderTextureDescriptor | descriptor | Descriptor for the RTHandle to match |
FilterMode | filterMode | Filtering mode of the RTHandle. |
TextureWrapMode | wrapMode | Addressing mode of the RTHandle. |
int | anisoLevel | Anisotropic filtering level. |
float | mipMapBias | Bias applied to mipmaps during filtering. |
string | name | Name of the RTHandle. |
Returns
Type | Description |
---|---|
bool | If an allocation was done. |
SetMaxRTHandlePoolCapacity(int)
Resize the rthandle pool's max stale resource capacity. The default value is 32. Increasing the capacity may have a negative impact on the memory usage(dued to staled resources in pool). Increasing the capacity may improve runtime performance (by reducing the runtime RTHandle realloc count in multi view/multi camera setup). Setting capacity will purge the current pool. It is recommended to setup the capacity upfront and not changing it during the runtime.
Declaration
public static bool SetMaxRTHandlePoolCapacity(int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | capacity | Max capacity to set |
Returns
Type | Description |
---|---|
bool | Return true if set successfully. Return false if URP is not initialized and pool does not exist yet. |
SetViewAndProjectionMatrices(CommandBuffer, Matrix4x4, Matrix4x4, bool)
Set view and projection matrices.
This function will set UNITY_MATRIX_V
, UNITY_MATRIX_P
, UNITY_MATRIX_VP
to given view and projection matrices.
If setInverseMatrices
is set to true this function will also set UNITY_MATRIX_I_V
and UNITY_MATRIX_I_VP
.
Declaration
public static void SetViewAndProjectionMatrices(CommandBuffer cmd, Matrix4x4 viewMatrix, Matrix4x4 projectionMatrix, bool setInverseMatrices)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | CommandBuffer to submit data to GPU. |
Matrix4x4 | viewMatrix | View matrix to be set. |
Matrix4x4 | projectionMatrix | Projection matrix to be set. |
bool | setInverseMatrices | Set this to true if you also need to set inverse camera matrices. |
SupportsRenderTextureFormat(RenderTextureFormat)
Checks if a render texture format is supported by the run-time system. Similar to SupportsRenderTextureFormat(RenderTextureFormat), but doesn't allocate memory.
Declaration
public static bool SupportsRenderTextureFormat(RenderTextureFormat format)
Parameters
Type | Name | Description |
---|---|---|
RenderTextureFormat | format | The format to look up. |
Returns
Type | Description |
---|---|
bool | Returns true if the graphics card supports the given |