Creating 3D Texture - Sample Help

Hi,
One of the possible solutions I have been told in the forum is to load my medical images slices into a 3d Textures. How do to this, is another question in itself. I found a tutorial for 3d texturing Game Programming Wiki - GPWiki

I was able to compile the code by making some changes. I’m going to study the code to see what I learn.

My hope was either to

  1. Read the image and put in a slice of the cube. But how are the coordinates supposed to be set? (texture coords)

  2. Set each pixel color to the correct part of the array and then bind the slice.

Any additional info that you guys can provide.

I also purchased Real-time volume graphics that I hope it helps. I should it have by next week.
thanks,
Francisco

While waiting for your book to come, start reading the following courses/tutorials:

http://www.real-time-volume-graphics.org/?page_id=28

The book is actually based upon these materials.

But how are the coordinates supposed to be set? (texture coords)

This depends on what method you use for rendering of the volume.
If you use object aligned 3D texture slicing, you will need to update the texture coordinates depending on the axis overlapping the viewing direction. If you use the view aligned 3D texture slicing, the texture coordinates are generated using a simple ray/box intersection.
The book gives everything you would need. In addition, I have given some details on my blog here http://mmmovania.blogspot.com/2008/06/object-aligned-slice-based-volume.html
Any more help, just ask here.

Mobeen,
do you think I could get the code your wrote? I would be very interested not only the visualization but how to read the medical images. I was thinking to use imebra to read them.

thanks,
Francisco

Well i can help u in the process. Itsjust backtofront blending with 3d texturemapping. The code can be obtained from the realtime volume gfx book site given above. For medical image formats i used a basic loader to read in raw ct data.for our application wehad a proprietory format.
You shud giv it a try i will help u in the process.

Sure, I will. I already received the book (saturday delivery) and I’m finishing chapter 3. I’m going to take this week to read the book as much as I can. I like the book, but is all little pieces that I have to put together. It seems very difficult but I think I can do it.

I’m having trouble compiling the code from the book. I posted another thread for that:
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=297798#Post297798

nevermind … it compiles now…
However, I encounter another error.

what is the error?

Now it compiles fine.
The errors I get is at runtime due to CG. I have an ATI card which maybe the problem.

Well, the CG compiler does a pretty good job at highlighting the details of what’s wrong so i suspect u might be doing something wrong. Could u post the CG shader that u r using so that we may help u with the error.

It comes from the sample of the book located at the site SimpleSlicer3DTex .the command line says featured not supported, but the demo runs. I don’t know know if it runs as it should.
I think I’m going to try to get me a machine that has nvidia to test it as well.

However, I think I have to move on. I think I have to create 3d Textures sample. Here I need help.

I want to test with dummy data. So I want to create a texture that it will be 256x256x2 , with different coles, 256 times, to build a big cube. I guess is either that or I work on not rendering some of the objects that are not visible. I think I should start with the 3d Texture.

This is to simulate each 2d image that I will have which is 256x256 with a small seperation. Instead of having a small seperation, I will put all of them together,hence my original idea of having small cubes each representing a pixel.

so, I’m not sure if texturing thing will work or will I have to use something like octrees or different techniques.

as of now of course, if Y try to render
256x256x256 cubes , it will not render… it will render so far up to 64x64x64 but moving around gets slow.

Now, someone may ask? why do you want to have all the images stack. It is part of some experiment that my PhD adviser wants me to do.

with all of this said, maybe I can start with baby steps to get where I want. I was happy when I was able to render 32x32x32 but when I notice that past N=64 would get slow, I have reach a mental block.
The book is helping a bit.

thanks for help, I will await for feedback/instructions/comments

thanks,
Francisco

What do u want to do? Are u looking to create a 3D texture? or are u trying to see cubic voxelization?

if I want to have small cubes each representing the color of a given pixel, would it be better with 3d textures to just put all the image in one bigger cube, or do the latter you mention. I think the latter is what I want. I’m including a picture here of what I have. but it is too slow if I increment the N. this big cube, is build with many cubes (i’m building the cubes using triangles, instead of quads) and to each cube I assigned a color. I have NxNxN cubes.


thanks
PS: How do I add code. I try before <code> int i =0;</code> but it didn’t work

I see only here a big cube where the color is interpolated between the 8 cube’s corners
(or composed of NxNxN very very smalls cubes)

=> we can have visualy the same result with only 6 quad faces (or 12 triangles) …

What is the url for the SimpleSlicer3DTex site ?

PS : it’s [something][/something] (UBBCode)
not <something></something> (HTML)

I see now the “Mach bands”
=> your NxNxN cubes are not as little as this :slight_smile:

You can draw horizontals and verticals lines on the texture for to represent the separation between each “voxels” and only use a big cube.

Ok, So textures is the answer.

One 3d texture that has all the 256 2d slices?

The web site is http://www.real-time-volume-graphics.org/
however, that cube is not based on their code.

Yes, “One 3d texture that has all the 256 2d slices” :slight_smile:

great. (Which had been suggested to me.)
I found some code in the red book (checkerboard - checker.c) that gives me an idea how to do it with 2d textures. Something similar would be for 3d textures. However, what confuses me big deal is the coordinates for the textures.
Any 3D Texture sample, similar to this, anywhere? specially if it uses GLSL since my code is for opengl 3.2 (the one that I have been using , with the help of the opengl bible libraries from the opengl bible fifth edition)
thanks,
Francisco