简体   繁体   中英

GLSL - Sample an volume of 3d texture

I'm recently working with 3d textures in OpenGL. I realized that when you are working with 3d textures, you have to use texture3d() A LOT. Which is pretty much a gpu killer. Is there any function in glsl that allows me to sample an VOLUME of 3d texture? So, instead of calling texture3D() 32768 times, I can do something like this:

texture3DVolume(3dtexture, vec3(0.5, 0.5, 0.5), vec3(0.2, 0.2, 0.2));

Which samples at 0.5 0.5 0.5, an volume of 0.2 0.2 0.2.

No : this would involve, as you noticed it yourself, sampling all the volume.

In 2D you can use Summed Area Tables. It enables you to compute the sum of all the values of a matrix inside a "box" with only 4 samples; I guess the concept extends to 3D easily.

Note that you will have a pretty expensive preprocessing step; and you can only have the mean and the sum, no other fancy stuff like geometric mean or median.

Here are some explanations from AMD on a different use-case : http://developer.amd.com/media/gpu_assets/GDC2005_SATEnvironmentReflections.pdf

I guess you could also use mipmaps : to sample a 2x2x2 volume, sample the 1rst mipmap... but this won't work out of the box for arbitrary sample locations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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