Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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)? –  NPS Mar 2 '14 at 13:18
    
"but this should be better" But what should be better? –  NPS Mar 2 '14 at 13:18
    
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? –  NPS Mar 2 '14 at 13:40
    
For the last one - I haven't tried but I believe I should be able to. –  NPS Mar 2 '14 at 13:57
1  
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. –  Nathan Reed Mar 3 '14 at 0:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.