How to use the hardware's 3D texture sampling with a flipbook style volume texture?
<p><a href="https://stackoverflow.com/questions/23006414/3d-texture-in-webgl-three-js-using-2d-texture-workaround">A question sort of addressing the problem</a> and <a href="https://stackoverflow.com/questions/10617810/how-to-use-3d-texture-in-opengl-and-cg-shaders">another question asking a related question</a>.</p>

<p>I have a 2D texture that has 12x12 slices of a volume layered in a grid like this:
<a href="https://i.stack.imgur.com/G5FWb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G5FWb.jpg" alt="enter image description here"></a> </p>

<p>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 <a href="https://en.wikipedia.org/wiki/Volume_rendering#Direct_volume_rendering" rel="nofollow noreferrer">here</a> and <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb509695%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">here</a>, 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.</p>

<p>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.</p>

<p>If I am misunderstanding this completely I would also appreciate being told so.</p>

<p>Thank you for your help.</p>