Queue Texture 2D Array

Hi, this is I believe the equivalent of a Queue node for spread but this one will output a Texture2DArray.

It is using a compute shader with RWTexture2DArray<float4> (read and write texture 2d array).

shader QueueTexture_ComputeFX : ComputeShaderBase, Texturing
{
    RWTexture2DArray<float4> RWArray;
    int2 Reso;
    int counter;

    override void Compute()
    {
        uint2 uv = streams.DispatchThreadId.xy;
        float2 texUV = (float2(uv.x % Reso.x, uv.y % Reso.y) + 0.5) / Reso;
        float4 col = Texture0.SampleLevel(LinearSampler, texUV, 0);

        RWArray[uint3(uv, counter)] = col;
    }
};

TextureQueueArray.zip (5.6 KB)

hey, as you don’t have to sample (interpolate) you can use the Load methods instead of SampleLevel it is much faster because it loads the pixel data directly, like accessing a buffer. Load (DirectX HLSL Texture Object) - Win32 apps | Microsoft Docs

and the logic in your shader is a RingBuffer, not a Queue… a Queue would always shift all entries one up and insert at 0.

so, something like that could work:

shader RingBufferTexture_ComputeFX : ComputeShaderBase, Texturing
{
    RWTexture2DArray<float4> RWArray;
    int2 Reso;
    int counter;

    override void Compute()
    {
        uint2 uv = streams.DispatchThreadId.xy;

        if (any(uv >= Reso))
            return;

        float4 col = Texture0.Load(int3(uv, 0));

        RWArray[uint3(uv, counter)] = col;
    }
};

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.