Slices in images volume and ofxVTK

Hi there,

Currently I’m working on project using OpenFrameworks and I want to use volumetric images.
My plan is to show slices within volumes similar to the images in the following article: http://www.vtk.org/Wiki/VTK/Image-Rendering-Classes

Is there any image volume slicing addon for OpenFrameworks or does anyone here have experience linking a VTK image slicer to ofImage? I’m curious to hear your ideas on how to approach this.

Hi, I wrote a volumetric rendering addon that you might find useful: https://github.com/timscaffidi/ofxVolumetrics

This is for displaying an entire volume in 3d, but if all you want to do is render a slice through a volume, its much easier. The concept is to create a 3d texture and then render the slice by drawing a quad at the right angle and with the right texture coordinates. the GPU will do all the work for you. You can use the ofxTexture3d class in my addon to get you started.

Thanks Tim! This is exactly what I needed.
Here’s the code on how I did it, in case anyone else needs it.

  
  
    //volumeTexture is an ofxTexture3d from the ofxVolumetrics addon  
    volumeTexture.bind();  
  
    glBegin(GL_QUADS);  
    glNormal3f(0.0f,0.0f,1.0f);  
        //The glTexCoord3f coordinates can be set within the 3d texture volume  
        glTexCoord3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f,0.0f,0.0f);  
        glTexCoord3f(1.0f, 0.0f, 0.0f); glVertex3f(volWidth,0.0f,0.0f);  
        glTexCoord3f(1.0f, 1.0f, 0.0f); glVertex3f(volWidth,volHeight,0.0f);  
        glTexCoord3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f, volHeight,0.0f);  
    glEnd();  
  
    volumeTexture.unbind();  
  

Yeah, this is exactly what I was talking about! I might split ofxTexture3d into a separate addon, because it is useful in its own right

It definitely is useful!

It seems the texture does some kind of wrap-around when parts of the glTexCoord3f quad fall outside of the volume dimensions. Is there any was of preventing the wrapping?

Hey Tim,

Sorry for dredging up this old forum-thread, but your library looks exactly like what I’m looking for. Could you give a second opinion on whether what I have in mind is feasible?

I’m trying to dust off a very old installation. As you can see, we both make time-distortion themed artworks. There’s nothing new under the sun, is there?

I programmed that installation with a now-outdated custom Cinder library (a friend and more capable programmer than me implemented volumetric textures for it). However, we’ve since lost the source code :-/. Also, I like to update it with something newer, more cross-platform, and hopefully less hackish and less likely to break in the long run.

What the program did was use a volume texture with the z-axis represeting time. Every frame updated a slice. So far nothing new.

However, instead of a planar slice through the volume, it used a shader and another texture as a “depth mask”. Think of it like an alpha mask, where 0 equals “most recent frame” and 1 means “oldest frame in the volume”. Do you think something like that is possible with your library?

Hi Job,

Yes you can absolutely use the 3d Texture class that comes with ofxVolumetrics, then write a custom shader to render the desired offset into the volume per pixel based on a depth map.

Thanks, I’ll have a go! If I come across any oddities I’ll ask for more advice.

Fingers crossed the Intel HD 4000 of my current laptop even supports 3D textures…

Good luck! The GMA900 era intel graphics even had support for 3D textures, though they could barely utilize them, and didn’t support shaders. The HD4000 should have no problems though