docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IRenderAttachmentRenderGraphBuilder

    An intermediary interface for builders that can set render attachments and random access attachments (UAV).

    Inherited Members
    IBaseRenderGraphBuilder.UseTexture(in TextureHandle, AccessFlags)
    IBaseRenderGraphBuilder.UseGlobalTexture(int, AccessFlags)
    IBaseRenderGraphBuilder.UseAllGlobalTextures(bool)
    IBaseRenderGraphBuilder.SetGlobalTextureAfterPass(in TextureHandle, int)
    IBaseRenderGraphBuilder.UseBuffer(in BufferHandle, AccessFlags)
    IBaseRenderGraphBuilder.CreateTransientTexture(in TextureDesc)
    IBaseRenderGraphBuilder.CreateTransientTexture(in TextureHandle)
    IBaseRenderGraphBuilder.CreateTransientBuffer(in BufferDesc)
    IBaseRenderGraphBuilder.CreateTransientBuffer(in BufferHandle)
    IBaseRenderGraphBuilder.UseRendererList(in RendererListHandle)
    IBaseRenderGraphBuilder.EnableAsyncCompute(bool)
    IBaseRenderGraphBuilder.AllowPassCulling(bool)
    IBaseRenderGraphBuilder.AllowGlobalStateModification(bool)
    IBaseRenderGraphBuilder.EnableFoveatedRasterization(bool)
    IBaseRenderGraphBuilder.GenerateDebugData(bool)
    IDisposable.Dispose()
    Namespace: UnityEngine.Rendering.RenderGraphModule
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    public interface IRenderAttachmentRenderGraphBuilder : IBaseRenderGraphBuilder, IDisposable

    Methods

    SetRandomAccessAttachment(TextureHandle, int, AccessFlags)

    Binds the texture as a random-access attachment for this pass (DX12: Unordered Access View, Vulkan: Storage Image).

    Declaration
    TextureHandle SetRandomAccessAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.ReadWrite)
    Parameters
    Type Name Description
    TextureHandle tex

    The texture to expose as a UAV in this pass.

    int index

    The binding slot the shader uses to access this UAV (HLSL: register(u[index])).

    AccessFlags flags

    Access mode for this texture in the pass. Defaults to AccessFlags.ReadWrite.

    Returns
    Type Description
    TextureHandle

    This declares that shaders in the pass will access the texture via RWTexture2D, RWTexture3D, etc., enabling read/write operations, atomics, and other UAV-style operations using standard HLSL.

    The value passed to the tex parameter. The return value is deprecated.

    Remarks

    Random-access (UAV) textures share index-based binding slots with render targets and input attachments. Refer to CommandBuffer.SetRandomWriteTarget for platform-specific details and constraints.

    SetRenderAttachment(TextureHandle, int, AccessFlags)

    Binds the texture as a color render target (MRT attachment) for this pass.

    Declaration
    void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags = AccessFlags.Write)
    Parameters
    Type Name Description
    TextureHandle tex

    The texture to bind as a render target for this pass.

    int index

    The MRT slot the shader writes to. This maps to SV_Target in the shader, for example, a value of 1 maps to SV_Target1.

    AccessFlags flags

    The access mode for the texture. The default value is AccessFlags.Write.

    Remarks

    Potential access flags:

    • Write: This pass outputs to the texture using render target rasterization. The render graph binds the texture to the specified MRT slot (index). In HLSL, write to the slot using float4 outColor : SV_Target{index} = value;. To use random-access writes, use SetRandomAccessAttachment (UAV). Don't write to this target with UAV-style indexed access (operator[]).
    • Read: This pass might read the current contents of the render target implicitly, depending on rasterization state (for example, blending operations that read before writing).

    The render graph can't determine how much of the target you overwrite. By default, it assumes partial updates and preserves existing content. If you fully overwrite the target (for example, in a fullscreen pass), use AccessFlags.WriteAll for better performance.

    SetRenderAttachment(TextureHandle, int, AccessFlags, int, int)

    Binds the texture as a color render target (MRT attachment) for this pass.

    Declaration
    void SetRenderAttachment(TextureHandle tex, int index, AccessFlags flags, int mipLevel, int depthSlice)
    Parameters
    Type Name Description
    TextureHandle tex

    The texture to bind as a render target for this pass.

    int index

    The MRT slot the shader writes to (corresponds to SV_Target{index}).

    AccessFlags flags

    How this pass accesses the texture. Defaults to AccessFlags.Write.

    int mipLevel

    The mip level to bind.

    int depthSlice

    The array slice to bind. Use -1 to bind all slices.

    Remarks

    Potential access flags:

    • Write: This pass outputs to the texture using render target rasterization. The render graph binds the texture to the specified MRT slot (index). In HLSL, write to the slot using float4 outColor : SV_Target{index} = value;. To use random-access writes, use SetRandomAccessAttachment (UAV). Don't write to this target with UAV-style indexed access (operator[]).
    • Read: This pass might read the current contents of the render target implicitly, depending on rasterization state (for example, blending operations that read before writing).

    The render graph can't determine how much of the target you overwrite. By default, it assumes partial updates and preserves existing content. If you fully overwrite the target (for example, in a fullscreen pass), use AccessFlags.WriteAll for better performance.

    Using the same texture handle with different depth slices at different render target indices is not supported.

    SetRenderAttachmentDepth(TextureHandle, AccessFlags)

    Binds the texture as the depth buffer for this pass.

    Declaration
    void SetRenderAttachmentDepth(TextureHandle tex, AccessFlags flags = AccessFlags.ReadWrite)
    Parameters
    Type Name Description
    TextureHandle tex

    The texture to use as the depth buffer for this pass.

    AccessFlags flags

    Access mode for the texture in this pass. Defaults to AccessFlag.ReadWrite.

    Remarks

    Potential access flags:

    • Write: The pass writes fragment depth to the bound depth buffer (required if ZWrite is enabled in shader code).
    • Read: The pass reads from the bound depth buffer for depth testing (required if ZTest is set to an operation other than Disabled, Never, or Always in shader code).

    Only one depth buffer can be tested against or written to in a single pass. To output depth to multiple textures, register the additional texture as a color attachment using SetRenderAttachment(), then compute and write the depth value in the shader. If you call SetRenderAttachmentDepth() more than once on the same builder, it results in an error.

    SetRenderAttachmentDepth(TextureHandle, AccessFlags, int, int)

    Binds the texture as the depth buffer for this pass.

    Declaration
    void SetRenderAttachmentDepth(TextureHandle tex, AccessFlags flags, int mipLevel, int depthSlice)
    Parameters
    Type Name Description
    TextureHandle tex

    The texture to use as the depth buffer for this pass.

    AccessFlags flags

    How this pass will access the depth texture (for example, AccessFlags.Read, AccessFlags.Write, AccessFlags.ReadWrite).

    int mipLevel

    The mip level to bind.

    int depthSlice

    The array slice to bind. Use -1 to bind all slices.

    Remarks

    Potential access flags:

    • Write: The pass writes fragment depth to the bound depth buffer (required if ZWrite is enabled in shader code).
    • Read: The pass reads from the bound depth buffer for depth testing (required if ZTest is set to an operation other than Disabled, Never, or Always in shader code).

    Only one depth texture can be read from or written to in a single pass. To output depth to multiple textures, register the additional texture as a color attachment using SetRenderAttachment(), then compute and write the depth value in the shader. If you call SetRenderAttachmentDepth() more than once on the same builder, it results in an error.

    Using the same texture handle with different depth slices at different render target indices is not supported.

    UseBufferRandomAccess(BufferHandle, int, bool, AccessFlags)

    Binds the buffer as a random-access attachment for this pass (DX12: Unordered Access View, Vulkan: Storage Buffer).

    Declaration
    BufferHandle UseBufferRandomAccess(BufferHandle tex, int index, bool preserveCounterValue, AccessFlags flags = AccessFlags.Read)
    Parameters
    Type Name Description
    BufferHandle tex

    The buffer to expose as a UAV in this pass.

    int index

    The binding slot the shader uses to access this UAV (HLSL: register(u[index])).

    bool preserveCounterValue

    Whether to keep the current append/consume counter unchanged for this UAV buffer. Defaults to preserving the existing counter value.

    AccessFlags flags

    Access mode for this buffer in the pass. Defaults to AccessFlags.Read.

    Returns
    Type Description
    BufferHandle

    The value passed to the buffer parameter. The return value is deprecated.

    Remarks

    This declares that shaders in the pass will access the buffer via RWStructuredBuffer, RWByteAddressBuffer, etc., enabling read/write, atomics, and other UAV-style operations using standard HLSL.

    Random-access (UAV) buffers share index-based binding slots with render targets and input attachments. Refer to CommandBuffer.SetRandomWriteTarget for platform-specific details and constraints.

    UseBufferRandomAccess(BufferHandle, int, AccessFlags)

    Binds the buffer as a random-access attachment for this pass (DX12: Unordered Access View, Vulkan: Storage Buffer).

    Declaration
    BufferHandle UseBufferRandomAccess(BufferHandle tex, int index, AccessFlags flags = AccessFlags.Read)
    Parameters
    Type Name Description
    BufferHandle tex

    The buffer to expose as a UAV in this pass.

    int index

    The binding slot the shader uses to access this UAV (HLSL: register(u[index])).

    AccessFlags flags

    Access mode for this buffer in the pass. Defaults to AccessFlags.Read.

    Returns
    Type Description
    BufferHandle

    The value passed to the buffer parameter. The return value is deprecated.

    Remarks

    This declares that shaders in the pass will access the buffer via RWStructuredBuffer, RWByteAddressBuffer, etc., enabling read/write, atomics, and other UAV-style operations using standard HLSL.

    Random-access (UAV) buffers share index-based binding slots with render targets and input attachments. Refer to CommandBuffer.SetRandomWriteTarget for platform-specific details and constraints.

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)