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

对着背影说爱祢 提交于 2020-12-30 06:14:32

问题


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?


回答1:


Incorrect. There's one more difference: mipmap sizes.

In a 3D texture, the width, height, and depth all decrease at lower mipmap sizes. In a 2D array texture, every mipmap level has the same number of array layers; only width and height decrease.

It's not just a matter of blending and some texture coordinate oddities; the very size of the texture data is different. It is very much a different kind of texture, as different from 3D textures as 2D textures are from 1D textures.

This is also why you cannot create a view texture of a 3D texture that is a 2D array, or vice-versa.




回答2:


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).



来源:https://stackoverflow.com/questions/35818027/understanding-the-difference-between-a-2d-texture-array-and-a-3d-texture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!