简体   繁体   English

如何将硬件的3D纹理采样与活动簿样式的体积纹理一起使用?

[英]How to use the hardware's 3D texture sampling with a flipbook style volume texture?

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: 我有一个2D纹理,它具有12x12的体积切片,分层排列在这样的网格中: 在此处输入图片说明

What I am doing now is to calculate the offset and sampling based of the 3D coordinate inside the volume using HLSL code myself. 我现在正在做的是自己使用HLSL代码基于体积内的3D坐标来计算偏移量和采样。 I have followed the descriptions found here and here , where the first link also talks about 3D sampling from a 2D sliced texture. 我按照此处此处的描述进行操作,其中第一个链接还讨论了从2D切片纹理进行3D采样。 I have also heard that modern hardware have the ability to sample 3D textures. 我也听说现代硬件具有对3D纹理进行采样的能力。

That being said, I have not found any description or example code that samples the 3D texture. 话虽如此,我还没有找到任何采样或示例代码来采样3D纹理。 What HLSL, or OpenGL, function can I use to sample this flipbook type of texture? 我可以使用什么HLSL或OpenGL函数对这种活页簿类型的纹理进行采样? 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. 我没有找到可以提供U和V方向上的层数的采样器功能,因此在不知道每个轴有多少切片的情况下,我看不到它如何进行采样。

If I am misunderstanding this completely I would also appreciate being told so. 如果我完全误解了,我也将被告知。

Thank you for your help. 谢谢您的帮助。

OpenGL has support for true 3D textures for ages (actually 3D texture support already appeared in OpenGL-1.2). OpenGL一直支持真正的3D纹理(实际上3D纹理支持已在OpenGL-1.2中出现)。 With that you upload your 3D texture not as a "flipbook" but simply as a stack of 2D images, using the function glTexImage3D . 这样,您可以使用glTexImage3D函数将3D纹理(而不是作为“活页簿”)上传,而只是作为2D图像堆栈上传。 In GLSL you then just use the regular texture access function, but with a sampler3D and a 3 component texture coordinate vector (except in older versions of GLSL, ie before GLSL-1.5/OpenGL-3 where you use texture3D ). 然后,在GLSL中,您只需使用常规的texture访问功能,但要使用sampler3D和3分量的纹理坐标矢量(旧版本的GLSL中除外,即,在使用texture3D GLSL-1.5 / OpenGL-3之前)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM