Class RuntimeUtilities | Post Processing | 2.3.0
docs.unity3d.com
    Show / Hide Table of Contents

    Class RuntimeUtilities

    A set of runtime utilities used by the post-processing stack.

    Inheritance
    Object
    RuntimeUtilities
    Namespace: UnityEngine.Rendering.PostProcessing
    Syntax
    public static class RuntimeUtilities

    Properties

    blackTexture

    A 1x1 black texture.

    Declaration
    public static Texture2D blackTexture { get; }
    Property Value
    Type Description
    Texture2D
    Remarks

    This texture is only created once and recycled afterward. You shouldn't modify it.

    blackTexture3D

    A 1x1x1 black texture.

    Declaration
    public static Texture3D blackTexture3D { get; }
    Property Value
    Type Description
    Texture3D
    Remarks

    This texture is only created once and recycled afterward. You shouldn't modify it.

    copyFromTexArrayMaterial

    A copy material with a texture array slice as a source for the builtin pipelines.

    Declaration
    public static Material copyFromTexArrayMaterial { get; }
    Property Value
    Type Description
    Material

    copyFromTexArraySheet

    A pre-configured PropertySheet for copyFromTexArrayMaterial.

    Declaration
    public static PropertySheet copyFromTexArraySheet { get; }
    Property Value
    Type Description
    PropertySheet

    copyMaterial

    A simple copy material independent from the rendering pipeline.

    Declaration
    public static Material copyMaterial { get; }
    Property Value
    Type Description
    Material

    copySheet

    A pre-configured PropertySheet for copyMaterial.

    Declaration
    public static PropertySheet copySheet { get; }
    Property Value
    Type Description
    PropertySheet

    copyStdFromDoubleWideMaterial

    A double-wide copy material to use with VR and the builtin pipelines.

    Declaration
    public static Material copyStdFromDoubleWideMaterial { get; }
    Property Value
    Type Description
    Material

    copyStdMaterial

    A simple copy material to use with the builtin pipelines.

    Declaration
    public static Material copyStdMaterial { get; }
    Property Value
    Type Description
    Material

    defaultHDRRenderTextureFormat

    Gets the default HDR render texture format for the current target platform.

    Declaration
    public static RenderTextureFormat defaultHDRRenderTextureFormat { get; }
    Property Value
    Type Description
    RenderTextureFormat

    fullscreenTriangle

    A fullscreen triangle mesh.

    Declaration
    public static Mesh fullscreenTriangle { get; }
    Property Value
    Type Description
    Mesh

    isAndroidOpenGL

    Returns true if the target platform is Android and the selected API is OpenGL, false otherwise.

    Declaration
    public static bool isAndroidOpenGL { get; }
    Property Value
    Type Description
    Boolean

    isLinearColorSpace

    Returns true if the current color space setting is set to Linear, false otherwise.

    Declaration
    public static bool isLinearColorSpace { get; }
    Property Value
    Type Description
    Boolean

    isSinglePassStereoEnabled

    Returns true if single-pass stereo rendering is active, false otherwise.

    Declaration
    public static bool isSinglePassStereoEnabled { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    This property only works in the editor.

    isVREnabled

    Returns true if VR is enabled, false otherwise.

    Declaration
    public static bool isVREnabled { get; }
    Property Value
    Type Description
    Boolean

    scriptableRenderPipelineActive

    Returns true if a scriptable render pipeline is currently in use, false otherwise.

    Declaration
    public static bool scriptableRenderPipelineActive { get; }
    Property Value
    Type Description
    Boolean

    supportsDeferredShading

    Returns true if deferred shading is supported on the target platform, false otherwise.

    Declaration
    public static bool supportsDeferredShading { get; }
    Property Value
    Type Description
    Boolean

    supportsDepthNormals

    Returns true if is supported on the target platform, false otherwise.

    Declaration
    public static bool supportsDepthNormals { get; }
    Property Value
    Type Description
    Boolean

    transparentTexture

    A 1x1 transparent texture.

    Declaration
    public static Texture2D transparentTexture { get; }
    Property Value
    Type Description
    Texture2D
    Remarks

    This texture is only created once and recycled afterward. You shouldn't modify it.

    transparentTexture3D

    A 1x1x1 transparent texture.

    Declaration
    public static Texture3D transparentTexture3D { get; }
    Property Value
    Type Description
    Texture3D
    Remarks

    This texture is only created once and recycled afterward. You shouldn't modify it.

    whiteTexture

    A 1x1 white texture.

    Declaration
    public static Texture2D whiteTexture { get; }
    Property Value
    Type Description
    Texture2D
    Remarks

    This texture is only created once and recycled afterward. You shouldn't modify it.

    whiteTexture3D

    A 1x1x1 white texture.

    Declaration
    public static Texture3D whiteTexture3D { get; }
    Property Value
    Type Description
    Texture3D
    Remarks

    This texture is only created once and recycled afterward. You shouldn't modify it.

    Methods

    BlitFullscreenTriangle(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, RenderTargetIdentifier, PropertySheet, Int32, Boolean, Nullable<Rect>)

    Blits a fullscreen triangle using a given material.

    Declaration
    public static void BlitFullscreenTriangle(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, RenderTargetIdentifier depth, PropertySheet propertySheet, int pass, bool clear = false, Rect? viewport = default(Rect? ))
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    RenderTargetIdentifier depth

    The depth render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    Boolean clear

    Should the destination target be cleared?

    Nullable<Rect> viewport

    An optional viewport to consider for the blit

    BlitFullscreenTriangle(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, Boolean, Nullable<Rect>)

    Does a copy of source to destination using a fullscreen triangle.

    Declaration
    public static void BlitFullscreenTriangle(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, bool clear = false, Rect? viewport = default(Rect? ))
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    Boolean clear

    Should the destination target be cleared?

    Nullable<Rect> viewport

    An optional viewport to consider for the blit

    BlitFullscreenTriangle(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, PropertySheet, Int32, RenderBufferLoadAction, Nullable<Rect>)

    Blits a fullscreen triangle using a given material.

    Declaration
    public static void BlitFullscreenTriangle(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, PropertySheet propertySheet, int pass, RenderBufferLoadAction loadAction, Rect? viewport = default(Rect? ))
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    RenderBufferLoadAction loadAction

    The load action for this blit

    Nullable<Rect> viewport

    An optional viewport to consider for the blit

    BlitFullscreenTriangle(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, PropertySheet, Int32, Boolean, Nullable<Rect>)

    Blits a fullscreen triangle using a given material.

    Declaration
    public static void BlitFullscreenTriangle(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, PropertySheet propertySheet, int pass, bool clear = false, Rect? viewport = default(Rect? ))
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    Boolean clear

    Should the destination target be cleared?

    Nullable<Rect> viewport

    An optional viewport to consider for the blit

    BlitFullscreenTriangle(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier[], RenderTargetIdentifier, PropertySheet, Int32, Boolean, Nullable<Rect>)

    Blits a fullscreen triangle using a given material.

    Declaration
    public static void BlitFullscreenTriangle(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier[] destinations, RenderTargetIdentifier depth, PropertySheet propertySheet, int pass, bool clear = false, Rect? viewport = default(Rect? ))
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier[] destinations

    An array of destinations render targets

    RenderTargetIdentifier depth

    The depth render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    Boolean clear

    Should the destination target be cleared?

    Nullable<Rect> viewport

    An optional viewport to consider for the blit

    BlitFullscreenTriangleFromDoubleWide(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, Material, Int32, Int32)

    Blits a fullscreen triangle from a double-wide source.

    Declaration
    public static void BlitFullscreenTriangleFromDoubleWide(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material material, int pass, int eye)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    Material material

    The material to use for the blit

    Int32 pass

    The pass from the material to use

    Int32 eye

    The target eye

    BlitFullscreenTriangleFromTexArray(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, PropertySheet, Int32, Boolean, Int32)

    Blits a fullscreen triangle using a given material.

    Declaration
    public static void BlitFullscreenTriangleFromTexArray(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, PropertySheet propertySheet, int pass, bool clear = false, int depthSlice = -1)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source texture array

    RenderTargetIdentifier destination

    The destination render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    Boolean clear

    Should the destination target be cleared?

    Int32 depthSlice

    The slice to use for the texture array

    BlitFullscreenTriangleToDoubleWide(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, PropertySheet, Int32, Int32)

    Blits a fullscreen triangle to a double-wide destination.

    Declaration
    public static void BlitFullscreenTriangleToDoubleWide(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, PropertySheet propertySheet, int pass, int eye)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    Int32 eye

    The target eye

    BlitFullscreenTriangleToTexArray(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, PropertySheet, Int32, Boolean, Int32)

    Blits a fullscreen triangle using a given material.

    Declaration
    public static void BlitFullscreenTriangleToTexArray(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, PropertySheet propertySheet, int pass, bool clear = false, int depthSlice = -1)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    PropertySheet propertySheet

    The property sheet to use

    Int32 pass

    The pass from the material to use

    Boolean clear

    Should the destination target be cleared?

    Int32 depthSlice

    The array slice to consider as a source

    BuiltinBlit(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier)

    Does a copy of source to destination using the builtin blit command.

    Declaration
    public static void BuiltinBlit(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    UnityEngine.Rendering.RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    BuiltinBlit(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier, Material, Int32)

    Blits a fullscreen quad using the builtin blit command and a given material.

    Declaration
    public static void BuiltinBlit(this CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material mat, int pass = 0)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    UnityEngine.Rendering.RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    Material mat

    The material to use for the blit

    Int32 pass

    The pass from the material to use

    CopyTexture(CommandBuffer, RenderTargetIdentifier, RenderTargetIdentifier)

    Copies the content of a texture into the other. Both textures must have the same size and format or this method will fail.

    Declaration
    public static void CopyTexture(CommandBuffer cmd, RenderTargetIdentifier source, RenderTargetIdentifier destination)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to use

    RenderTargetIdentifier source

    The source render target

    RenderTargetIdentifier destination

    The destination render target

    Remarks

    If the CopyTexture command isn't supported on the target platform it will revert to a fullscreen blit command instead.

    CreateIfNull<T>(ref T)

    Creates an instance of a class if it's null.

    Declaration
    public static void CreateIfNull<T>(ref T obj)
        where T : class, new()
    Parameters
    Type Name Description
    T obj

    A reference to an instance to check and create if needed

    Type Parameters
    Name Description
    T

    The type to create

    Destroy(Object)

    Properly destroys a given Unity object.

    Declaration
    public static void Destroy(Object obj)
    Parameters
    Type Name Description
    UnityEngine.Object obj

    The object to destroy

    DestroyProfile(PostProcessProfile, Boolean)

    Properly destroys a given profile.

    Declaration
    public static void DestroyProfile(PostProcessProfile profile, bool destroyEffects)
    Parameters
    Type Name Description
    PostProcessProfile profile

    The profile to destroy

    Boolean destroyEffects

    Should we destroy all the embedded settings?

    DestroyVolume(PostProcessVolume, Boolean, Boolean)

    Properly destroys a volume.

    Declaration
    public static void DestroyVolume(PostProcessVolume volume, bool destroyProfile, bool destroyGameObject = false)
    Parameters
    Type Name Description
    PostProcessVolume volume

    The volume to destroy

    Boolean destroyProfile

    Should we destroy the attached profile?

    Boolean destroyGameObject

    Should we destroy the volume Game Object?

    Exp2(Single)

    Returns the base-2 exponential function of x, which is 2 raised to the power x.

    Declaration
    public static float Exp2(float x)
    Parameters
    Type Name Description
    Single x

    Value of the exponent

    Returns
    Type Description
    Single

    The base-2 exponential function of x

    GenerateJitteredProjectionMatrixFromOriginal(PostProcessRenderContext, Matrix4x4, Vector2)

    Gets a jittered perspective projection matrix from an original projection matrix.

    Declaration
    public static Matrix4x4 GenerateJitteredProjectionMatrixFromOriginal(PostProcessRenderContext context, Matrix4x4 origProj, Vector2 jitter)
    Parameters
    Type Name Description
    PostProcessRenderContext context

    The current render context

    Matrix4x4 origProj

    The original projection matrix

    Vector2 jitter

    The jitter offset

    Returns
    Type Description
    Matrix4x4

    A jittered projection matrix

    GetAllAssemblyTypes()

    Gets all currently available assembly types.

    Declaration
    public static IEnumerable<Type> GetAllAssemblyTypes()
    Returns
    Type Description
    IEnumerable<Type>

    A list of all currently available assembly types

    Remarks

    This method is slow and should be use with extreme caution. We recommend you use GetAllTypesDerivedFrom<T>() instead if possible.

    See Also
    GetAllTypesDerivedFrom<T>()

    GetAllSceneObjects<T>()

    Gets all scene objects in the hierarchy, including inactive objects. This method is slow on large scenes and should be used with extreme caution.

    Declaration
    public static IEnumerable<T> GetAllSceneObjects<T>()
        where T : Component
    Returns
    Type Description
    IEnumerable<T>

    A list of all components of type T in the scene

    Type Parameters
    Name Description
    T

    The component to look for

    GetAllTypesDerivedFrom<T>()

    Gets all currently available assembly types derived from type T.

    Declaration
    public static IEnumerable<Type> GetAllTypesDerivedFrom<T>()
    Returns
    Type Description
    IEnumerable<Type>

    A list of all currently available assembly types derived from type T

    Type Parameters
    Name Description
    T

    The type to look for

    GetAttribute<T>(Type)

    Helper method to get the first attribute of type T on a given type.

    Declaration
    public static T GetAttribute<T>(this Type type)
        where T : Attribute
    Parameters
    Type Name Description
    Type type

    The type to explore

    Returns
    Type Description
    T

    The attribute found

    Type Parameters
    Name Description
    T

    The attribute type to look for

    GetFieldPath<TType, TValue>(Expression<Func<TType, TValue>>)

    Returns a string path from an expression. This is mostly used to retrieve serialized properties without hardcoding the field path as a string and thus allowing proper refactoring features.

    Declaration
    public static string GetFieldPath<TType, TValue>(Expression<Func<TType, TValue>> expr)
    Parameters
    Type Name Description
    Expression<Func<TType, TValue>> expr

    An expression path fo the member

    Returns
    Type Description
    String

    A string representation of the expression path

    Type Parameters
    Name Description
    TType

    The class type where the member is defined

    TValue

    The member type

    GetJitteredOrthographicProjectionMatrix(Camera, Vector2)

    Gets a jittered orthographic projection matrix for a given camera.

    Declaration
    public static Matrix4x4 GetJitteredOrthographicProjectionMatrix(Camera camera, Vector2 offset)
    Parameters
    Type Name Description
    Camera camera

    The camera to build the orthographic matrix for

    Vector2 offset

    The jitter offset

    Returns
    Type Description
    Matrix4x4

    A jittered projection matrix

    GetJitteredPerspectiveProjectionMatrix(Camera, Vector2)

    Gets a jittered perspective projection matrix for a given camera.

    Declaration
    public static Matrix4x4 GetJitteredPerspectiveProjectionMatrix(Camera camera, Vector2 offset)
    Parameters
    Type Name Description
    Camera camera

    The camera to build the projection matrix for

    Vector2 offset

    The jitter offset

    Returns
    Type Description
    Matrix4x4

    A jittered projection matrix

    GetLutStrip(Int32)

    Gets a 2D lookup table for color grading use. Its size will be width = height * height.

    Declaration
    public static Texture2D GetLutStrip(int size)
    Parameters
    Type Name Description
    Int32 size

    The height of the lookup table

    Returns
    Type Description
    Texture2D

    A 2D lookup table

    Remarks

    Lookup tables are recycled and only created once per size. You shouldn't modify them.

    GetMemberAttributes<TType, TValue>(Expression<Func<TType, TValue>>)

    Returns all attributes set on a specific member.

    Declaration
    public static Attribute[] GetMemberAttributes<TType, TValue>(Expression<Func<TType, TValue>> expr)
    Parameters
    Type Name Description
    Expression<Func<TType, TValue>> expr

    An expression path to the member

    Returns
    Type Description
    Attribute[]

    An array of attributes

    Type Parameters
    Name Description
    TType

    The class type where the member is defined

    TValue

    The member type

    Remarks

    This method doesn't return inherited attributes, only explicit ones.

    isFloatingPointFormat(RenderTextureFormat)

    Checks if a given render texture format is a floating-point format.

    Declaration
    public static bool isFloatingPointFormat(RenderTextureFormat format)
    Parameters
    Type Name Description
    RenderTextureFormat format

    The format to test

    Returns
    Type Description
    Boolean

    true if the format is floating-point, false otherwise

    IsPostProcessingActive(PostProcessLayer)

    Checks if a post-processing layer is active.

    Declaration
    public static bool IsPostProcessingActive(PostProcessLayer layer)
    Parameters
    Type Name Description
    PostProcessLayer layer

    The layer to check; can be null

    Returns
    Type Description
    Boolean

    true if the layer is enabled, false otherwise

    IsResolvedDepthAvailable(Camera)

    Checks if resolved depth is available on the current target platform.

    Declaration
    public static bool IsResolvedDepthAvailable(Camera camera)
    Parameters
    Type Name Description
    Camera camera

    A rendering camera

    Returns
    Type Description
    Boolean

    true if resolved depth is available, false otherwise

    IsTemporalAntialiasingActive(PostProcessLayer)

    Checks if temporal anti-aliasing is active on a given post-process layer.

    Declaration
    public static bool IsTemporalAntialiasingActive(PostProcessLayer layer)
    Parameters
    Type Name Description
    PostProcessLayer layer

    The layer to check

    Returns
    Type Description
    Boolean

    true if temporal anti-aliasing is active, false otherwise

    SetRenderTargetWithLoadStoreAction(CommandBuffer, RenderTargetIdentifier, RenderBufferLoadAction, RenderBufferStoreAction)

    Sets the current render target using specified .

    Declaration
    public static void SetRenderTargetWithLoadStoreAction(this CommandBuffer cmd, RenderTargetIdentifier rt, RenderBufferLoadAction loadAction, RenderBufferStoreAction storeAction)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to set the render target on

    RenderTargetIdentifier rt

    The render target to set

    RenderBufferLoadAction loadAction

    The load action

    RenderBufferStoreAction storeAction

    The store action

    Remarks

    are only used on Unity 2018.2 or newer.

    SetRenderTargetWithLoadStoreAction(CommandBuffer, RenderTargetIdentifier, RenderBufferLoadAction, RenderBufferStoreAction, RenderTargetIdentifier, RenderBufferLoadAction, RenderBufferStoreAction)

    Sets the current render target and its depth using specified .

    Declaration
    public static void SetRenderTargetWithLoadStoreAction(this CommandBuffer cmd, RenderTargetIdentifier color, RenderBufferLoadAction colorLoadAction, RenderBufferStoreAction colorStoreAction, RenderTargetIdentifier depth, RenderBufferLoadAction depthLoadAction, RenderBufferStoreAction depthStoreAction)
    Parameters
    Type Name Description
    CommandBuffer cmd

    The command buffer to set the render target on

    RenderTargetIdentifier color

    The render target to set as color

    RenderBufferLoadAction colorLoadAction

    The load action for the color render target

    RenderBufferStoreAction colorStoreAction

    The store action for the color render target

    RenderTargetIdentifier depth

    The render target to set as depth

    RenderBufferLoadAction depthLoadAction

    The load action for the depth render target

    RenderBufferStoreAction depthStoreAction

    The store action for the depth render target

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023