Each material occupies one slice of the array.
The brdf textures are already working, but I'm having trouble rendering to the individual array slices, and sampling them.
1) Rendering to texture arrays.
As I understand, if you use a Texture2D as a rendertarget, and it has an ArraySize higher than 1, you need to specify which slice to render to using the SV_RenderTargetArrayIndex semantic, right?
Unfortunately you can't seem to use that semantic in the vertex shader, so this requires using a 'dummy' geometry shader, that passes the vertex shader values to the pixel shader, and adds the array index.
Is this the correct way of doing this?
Does this allow rendering the individual slices in different passes, or do I need to render all slices in a single pass?
2) Sampling from texture arrays.
This one, I'm even more confused about.
In HLSL you can define textures in many different ways, none of them throwing any errors:
Texture2D brdf;Texture2D brdf[2];Texture2DArray brdf;Texture2DArray brdf[2];
Which one is the correct way?
The docs also indicate that when using texture arrays, you sample them using float3 instead of float2, with the last parameter being the array slice.
I assume getting the second slice (brdf[1]) would work as follows:
brdf.Sample(sampler, float3(texCoord, 1.0f));
Is this correct?
Whatever I do, I always seem to be working on the first array slice, I can also use completely out of bound values (even negative) wherever I want, and I'm always rendering to the first slice and sampling from that one as well.
3) Texture3D
I was thinking about using 3d volume textures instead of 2d texture arrays, but I couldn't find any examples on them, so I don't know how to render to them or sample from them either :(
How does this work?
Cheers,
Hyu