Render 3D texture as volume based on multiple 2D image textures

Hello OF community!

I’m currently working on a project where I have a dataset of multiple images that represent 2D slices of a 3D object. I’d like to render these 2D slices stacked as a 3D object. The goal is to render them using the Volume Rendering techniques.

To get started, I’d like to load all the images of my dataset into a single 3D texture. I’m familiar with the general process to do this in raw OpenGL, but how would I go about doing this in OF? I’m aware of the ofTexture, of3dPrimitive, ofMesh classes, I’m guessing that I would leverage one or more of them?

Hi there!

OF doesn’t have a wrapper for 3D textures, yet.

You’ll have to create a 3D texture using raw openGL an then pass it to a shader like so:

ofShader::setUniformTexture("yourTexture3D", GL_TEXTURE_3D, yourGLuint, yourTextureLocation);

Check this two addons.
One does the Volume Rendering in a shader:

the other one can be used to process volume data on cpu as in ofImage:

Thanks @Jordi and @hubris. I think for now I’ll write the texture loading code myself and then create the shaders.