3
\$\begingroup\$

I've just learnt that DirectX 10 and above have a feature called "texture arrays". Which, basically, is just a normal array of textures (shader resources) which in a shader is declared like:

Texture2D myTextures[2];

What I've been using so far is 2 multiple separate textures:

Texture2D myFirstTexture;
Texture2D mySecondTexture;

Is there any practical (performance, memory etc...) difference between the two?

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

Not exactly: texture arrays are declared in HLSL as Texture2DArray for Texture2D and not as an array of texture, so it is quite different. They are almost acting as a 3D texture, where the z is a slice of the 2D Texture (in terms of uv, it is the w dimension). The difference with 3D texture is that they are not supporting trilinear interpolation between the 2D slices but you can still select dynamically a Texture2D slice with a z/w component (unlike an array of texture), the z/w component is rounded to the nearest integer to select the z/w slice. Concerning the memory, I believe this is equivalent, for performance, not sure they give a huge boost even accessing a set of Texture2D compare to an array of texture (but they support dynamic indexing). Using Texture2DArray is also easier as you only need to bind it to a single slot.

\$\endgroup\$
7
  • \$\begingroup\$ Oh, I was following this tutorial: rastertek.com/dx11tut17.html and it uses an array of textures. Is it incorrect then (in calling it a texture array)? \$\endgroup\$
    – NPS
    Mar 2, 2014 at 13:18
  • \$\begingroup\$ "but this should be better" But what should be better? \$\endgroup\$
    – NPS
    Mar 2, 2014 at 13:18
  • \$\begingroup\$ Sorry for stacking comments but these are separate issues. I've just found this thread: gamedev.net/topic/… Is it wrong? Do TextureXDArrays support interpolating between slices? \$\endgroup\$
    – NPS
    Mar 2, 2014 at 13:40
  • \$\begingroup\$ For the last one - I haven't tried but I believe I should be able to. \$\endgroup\$
    – NPS
    Mar 2, 2014 at 13:57
  • 2
    \$\begingroup\$ No, trilinear interpolation isn't done with Texture2DArray, only with volume textures (Texture3D). The z component of the texture coordinate simply selects a slice using its integer index; no blending between slices is done. That gamedev.net topic you linked to is correct. \$\endgroup\$ Mar 3, 2014 at 0:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .