Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the difference between a 2D texture array and a 3D texture?

If I understand correctly, if I was to set TEXTURE_MIN_FILTER to NEAREST then there's not much difference between sampler2DArray/TEXTURE_2D_ARRAY and sampler3D/TEXTURE_3D

The differences seem to be

  • GenerateMipmap will blend cross layers with 3D textures but not 2D arrays
  • the Z coordinate passed to texture in GLSL is 0 to 1 with 3D textures but an 0 to N (depth) in 2D arrays.
  • If filtering is not NEAREST 3D will blend across layers, 2D array will not.

Correct?

like image 765
gman Avatar asked Mar 05 '16 18:03

gman


1 Answers

Apart from the answer already given, there is another difference worth noting: The size limits are also quite different. A single layer of an array texture may be as big as an standard 2D texture, and there is an extra limit on the number of layers, while for 3D textures, there is a limit constraining the maximum size in all dimensions.

For example, OpenGL 4.5 guarantees the following minimal values:

GL_MAX_TEXTURE_SIZE           16384
GL_MAX_ARRAY_TEXTURE_LAYERS   2048
GL_MAX_3D_TEXTURE_SIZE        2048

So a 16384 x 16384 x 16 array texture is fine (and should also fit into memory for every GL 4.5 capable GPU found in the real world), while a 3D texture of the same dimensions would be unsupported on most of todays implementations (even though the complete mipmap pyramid would consume less memory in the 3D texture case).

like image 145
derhass Avatar answered Oct 15 '22 16:10

derhass