Defining a 3D rendertarget target layer in a vertex shader? [HLSL]

When working in HLSL / Directx11, I see that there are two methods of 3D-rendertarget binding: either you bind the whole target, or bind it when specifying a layer.

If you are linking the entire target, how do you specify the layer in the HLSL code to which the output color applies?

I have a suspicion that this requires a geometric shader ... is this correct?

Is there any other approach that would allow this in the vertex shader or elsewhere?

+3
source share
1 answer

If you bind the entire texture of a volume (or TextureArray), you really need to use a Geometry Shader to write to a specific fragment.

GS :

struct GSOutput
{
    float4 pos : SV_Position;
    uint slice : SV_RenderTargetArrayIndex;
    //Add anything else you need for your triangle
};

, , , , , .

, Geometry Shader.

rendertargetview , , ( Texture2DArray, , Texture3D):

D3D11_RENDER_TARGET_VIEW_DESC rtvd;

rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
rtvd.Texture2DArray.ArraySize = 1;
rtvd.Texture2DArray.FirstArraySlice = yourslice;

, .

, , ( ), . .

+3

All Articles