directx 11 - Specifying the target layer of a 3D rendertarget in vertex shader? [HLSL] -
when working in hlsl/directx11 see there 2 methods binding 3d rendertarget: either bind entire target or bind while specifying layer.
if bind entire target how 1 specify layer in hlsl code output color applied?
i have suspicion requires geometry shader ... correct?
is there other approach allow done in vertex shader or elsewhere?
if bind whole volume texture (or texturearray), indeed need use geometry shader write specific slice.
your gs output structure this:
struct gsoutput { float4 pos : sv_position; uint slice : sv_rendertargetarrayindex; //add else need triangle };
please not slice not interpolated, if need emit several slices need push 1 primitive per slice.
second case not want use geometry shader.
create rendertargetview description same parameters previous one, each slice, change parameters (this texture2darray, it's same if use texture3d) :
d3d11_render_target_view_desc rtvd; rtvd.viewdimension = d3d11_rtv_dimension_texture2darray; rtvd.texture2darray.arraysize = 1; rtvd.texture2darray.firstarrayslice = yourslice;
now have render target slice only, can directly bind single slice in pipeline.
please note works if know in advance (in cpu) slice draw call render. can render single slice draw call.
Comments
Post a Comment