Class RTHandle
A RTHandle is a RenderTexture that scales automatically with the camera size. This allows proper reutilization of RenderTexture memory when different cameras with various sizes are used during rendering. RTHandleSystem
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public class RTHandle
Properties
externalTexture
Texture associated with the RTHandle when constructed from an external Texture or RenderTexture
Declaration
public Texture externalTexture { get; }
Property Value
Type | Description |
---|---|
Texture |
isMSAAEnabled
Returns true is MSAA is enabled, false otherwise.
Declaration
public bool isMSAAEnabled { get; }
Property Value
Type | Description |
---|---|
bool |
name
Name of the RTHandle
Declaration
public string name { get; }
Property Value
Type | Description |
---|---|
string |
nameID
RenderTargetIdentifier associated with the RTHandle
Declaration
public RenderTargetIdentifier nameID { get; }
Property Value
Type | Description |
---|---|
RenderTargetIdentifier |
referenceSize
Reference size of the RTHandle System associated with the RTHandle
Declaration
public Vector2Int referenceSize { get; }
Property Value
Type | Description |
---|---|
Vector2Int |
rt
RenderTexture associated with the RTHandle
Declaration
public RenderTexture rt { get; }
Property Value
Type | Description |
---|---|
RenderTexture |
rtHandleProperties
Current properties of the RTHandle System. If a custom property has been set through SetCustomHandleProperties method, it will be used that one instead.
Declaration
public RTHandleProperties rtHandleProperties { get; }
Property Value
Type | Description |
---|---|
RTHandleProperties |
scaleFactor
Scale factor applied to the RTHandle reference size.
Declaration
public Vector2 scaleFactor { get; }
Property Value
Type | Description |
---|---|
Vector2 |
useScaling
Returns true if the RTHandle uses automatic scaling.
Declaration
public bool useScaling { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
ClearCustomHandleProperties()
Method that clears any custom handle property being set.
Declaration
public void ClearCustomHandleProperties()
CopyToFastMemory(CommandBuffer, float, FastMemoryFlags)
Switch the render target to fast memory on platform that have it and copies the content.
Declaration
public void CopyToFastMemory(CommandBuffer cmd, float residencyFraction = 1, FastMemoryFlags flags = FastMemoryFlags.SpillTop)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
float | residencyFraction | How much of the render target is to be switched into fast memory (between 0 and 1). |
FastMemoryFlags | flags | Flag to determine what parts of the render target is spilled if not fully resident in fast memory. |
GetInstanceID()
Get the Instance ID of the RTHandle.
Declaration
public int GetInstanceID()
Returns
Type | Description |
---|---|
int | The RTHandle Instance ID. |
GetScaledSize()
Return the scaled size of the RTHandle.
Declaration
public Vector2Int GetScaledSize()
Returns
Type | Description |
---|---|
Vector2Int | The scaled size of the RTHandle. |
GetScaledSize(Vector2Int)
Return the input size, scaled by the RTHandle scale factor.
Declaration
public Vector2Int GetScaledSize(Vector2Int refSize)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | refSize | Input size |
Returns
Type | Description |
---|---|
Vector2Int | Input size scaled by the RTHandle scale factor. |
Release()
Release the RTHandle
Declaration
public void Release()
SetCustomHandleProperties(in RTHandleProperties)
By default, rtHandleProperties gets the global state of scalers against the global reference mode. This method lets the current RTHandle use a local custom RTHandleProperties. This function is being used by scalers such as TAAU and DLSS, which require to have a different resolution for color (independent of the RTHandleSystem).
Declaration
public void SetCustomHandleProperties(in RTHandleProperties properties)
Parameters
Type | Name | Description |
---|---|---|
RTHandleProperties | properties | Properties to set. |
SwitchOutFastMemory(CommandBuffer, bool)
Switch out the render target from fast memory back to main memory on platforms that have fast memory.
Declaration
public void SwitchOutFastMemory(CommandBuffer cmd, bool copyContents = true)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
bool | copyContents | Whether the content of render target are copied or not when switching out fast memory. |
SwitchToFastMemory(CommandBuffer, float, FastMemoryFlags, bool)
Switch the render target to fast memory on platform that have it.
Declaration
public void SwitchToFastMemory(CommandBuffer cmd, float residencyFraction = 1, FastMemoryFlags flags = FastMemoryFlags.SpillTop, bool copyContents = false)
Parameters
Type | Name | Description |
---|---|---|
CommandBuffer | cmd | Command buffer used for rendering. |
float | residencyFraction | How much of the render target is to be switched into fast memory (between 0 and 1). |
FastMemoryFlags | flags | Flag to determine what parts of the render target is spilled if not fully resident in fast memory. |
bool | copyContents | Whether the content of render target are copied or not when switching to fast memory. |
Operators
implicit operator RenderTexture(RTHandle)
Implicit conversion operator to RenderTexture
Declaration
public static implicit operator RenderTexture(RTHandle handle)
Parameters
Type | Name | Description |
---|---|---|
RTHandle | handle | Input RTHandle |
Returns
Type | Description |
---|---|
RenderTexture | RenderTexture representation of the RTHandle. |
implicit operator RenderTargetIdentifier(RTHandle)
Implicit conversion operator to RenderTargetIdentifier
Declaration
public static implicit operator RenderTargetIdentifier(RTHandle handle)
Parameters
Type | Name | Description |
---|---|---|
RTHandle | handle | Input RTHandle |
Returns
Type | Description |
---|---|
RenderTargetIdentifier | RenderTargetIdentifier representation of the RTHandle. |
implicit operator Texture(RTHandle)
Implicit conversion operator to Texture
Declaration
public static implicit operator Texture(RTHandle handle)
Parameters
Type | Name | Description |
---|---|---|
RTHandle | handle | Input RTHandle |
Returns
Type | Description |
---|---|
Texture | Texture representation of the RTHandle. |