Now, what about volumetric textures?



Well, the same issue is present: the (S,T,R) coordinates will not match with exactly one volumetric pixel inside the volume. The look-up position will be in between some texels (volumetric pixels - small cubes if you want - inside the volume). And this time its more complex, you don’t just have a flat map, you have another dimension. Essentially, this means that its kind of like having 2 texture maps on top of each other. The S and T coordinates indicate a position inside these 2 maps, just like with a 2D texture, but this time you have another coordinate, R. This R says where you are between these 2 texture maps, so between 2 slices. Now what we can do is use bilinear filtering inside the 2 slices and then we blend the resulting color of those slices together using the R value, so you mix the two colors and you get the final value. Now, those of you paying attention will have noticed something, bilinear requires 4 texels from the 2D texture map, yet inside a 3D texture you need 2 times bilinear in different slices, so you need not 4, but 8 texels. More texels means more bandwidth, and more bandwidth can result in a slow down. People who know trilinear filtering will realize that looking up a color inside a 3D texture is identically to doing trilinear filtering between 2 mipmap levels. Below you can see an image that illustrates this lookup process for a 3D texture.






I think its clear that 3D volumetric textures do not suffer from the discontinuity issues like 2D maps, there is no wrapping around, there is more something like cutting out of. The generation of the coordinates is also trivial. All you need to do is link the 3D coordinates of the model to 3D coordinates inside the volume, which is much easier then trying to wrap paper around a ball, all you do is cut the ball out of the volumetric cube!

I hope that by now you more or less understand what a 3D texture is and how it works. You should also realize one major advantage: easy texture coordinates, but you should also realize one disadvantage: you need many samples just to get the color of one pixel (8 to be precise - even worse for those who know mipmapping, you can also mipmap a 3D texture…but imagine the bandwidth cost of doing that: 16 texels!).