0

A question sort of addressing the problem and another question asking a related question.

I have a 2D texture that has 12x12 slices of a volume layered in a grid like this: enter image description here

What I am doing now is to calculate the offset and sampling based of the 3D coordinate inside the volume using HLSL code myself. I have followed the descriptions found here and here, where the first link also talks about 3D sampling from a 2D sliced texture. I have also heard that modern hardware have the ability to sample 3D textures.

That being said, I have not found any description or example code that samples the 3D texture. What HLSL, or OpenGL, function can I use to sample this flipbook type of texture? If you can, please add a small example snippet with explanations. If you cant, pointing me to one or the documentation would be appreciated. I have found no sampler function where I can provide the number of layers in the U and V directions so I dont see how it can sample without knowing how many slices are per axis.

If I am misunderstanding this completely I would also appreciate being told so.

Thank you for your help.

4

1 回答 1

2

OpenGL 长期以来一直支持真正的 3D 纹理(实际上 3D 纹理支持已经出现在 OpenGL-1.2 中)。这样,您就可以使用glTexImage3D. 在 GLSL 中,您只需使用常规texture访问函数,但使用一个sampler3D和一个 3 分量纹理坐标向量(在旧版本的 GLSL 中除外,即在您使用的 GLSL-1.5/OpenGL-3 之前texture3D)。

于 2016-09-05T07:54:39.443 回答