2D texture and 3D texture volume rendering

2D texture and 3D texture volume rendering

Post by zhengrongy » Sun, 20 Jun 2004 03:44:06


Hi, I am relatively new to opengl. I am trying to use 2D texture and
3D texture for volume rendering. that is, I have a volumetric image,
for example, 500 slices, each slice has 400 by 320 pixels. I want to
do the direct 3D volume rendering using opengl 2D texture or/and 3D
texture. can some one show me some sample codes how to do it?

are there any other ways for rendering the volume?


thanks,
Zhengrong Ying
 
 
 

2D texture and 3D texture volume rendering

Post by Wolfgang D » Sun, 20 Jun 2004 08:13:36


This is the right attempt, however your image/volume dimensions
must be a power of 2. Instead of GL_TEXTURE_2D and you've to use
GL_TEXTURE_3D_ARB as the texture target.

But one problem will be the size of the final texture: Given your
dimensions with RGBA voxels will result in 244.2MiB needed
texture space. Using texture compression you can probably shrink
this about 1/3.

Wolfgang

 
 
 

2D texture and 3D texture volume rendering

Post by zhengrongy » Mon, 21 Jun 2004 02:14:36


thanks for the reply. can I load the whole images (244.2MB) into the
video card? for the 2D rendering, it requires three stacks of images.
this means it needs over 700 MB. But the Nvidia card (e.g. 5950) only
has 256MB memory. how do I do it?

thanks,
ZY
 
 
 

2D texture and 3D texture volume rendering

Post by Wolfgang D » Mon, 21 Jun 2004 05:04:38


Well, you could reduce the bits per pixel resolution. I'm not
sure, if texture compression is avaliable for 3D textures.

But one question: Why not write a small raycaster for this? If it
has not to be realtime this probably the more robust solution.

There are also some techniques to convert a volumetric dataset
into a a set of isosurfaces. I've a PDF about this here, I could
send it per Mail.

Wolfgang
 
 
 

2D texture and 3D texture volume rendering

Post by zhengrongy » Mon, 21 Jun 2004 11:31:44


thanks for the reply again. The major problem is that the application
has to be in real time. Another issue which is worse is that the
original raw data can have different color schemes resulting in more
than one RGBA data sets for volume rendering. The isosurface is not
good for the application.
 
 
 

2D texture and 3D texture volume rendering

Post by Andy » Mon, 21 Jun 2004 12:38:48


You may need to do a lot of memory management for this -- load a portion
of the volume, render it, load another portion, render it, etc. Multiple
threads should help overlap the operations.

You will probably need to have multiple resolutions of your volume, and
choose which resolution level to use based on distance from the eye and
how much long you can take to render the frame. You might want to keep
high frame rates at the expense of resolution while the user is
manipulating the volume, and have one more pass at high resolution
afterwards.

Good luck!
 
 
 

2D texture and 3D texture volume rendering

Post by Stephane M » Mon, 21 Jun 2004 20:16:29


Well, isn't the original data 8 bit unsigned ? That's usually the case.
If so, you can load it as an 8 bit indexed 3D texture
(GL_COLOR_INDEX8_EXT) which fits into the video card memory (320*200*500
is ~64Mb), and then apply the RGBA transfer function using glColorTableEXT.

Also, there are different techniques for volume rendering. Mostly, you
have two techniques if you want hardware acceleration :
- draw the data using three sets of parallel slices
- draw the data using screen-parallel slices that intersect a 3d texture

As for source code, see for example this project :
http://www.yqcomputer.com/

Stephane
 
 
 

2D texture and 3D texture volume rendering

Post by Wolfgang D » Mon, 21 Jun 2004 20:24:42


Also most cards having 3D texture support (expect GeForce3) have
cpability for executing pixelshaders, which can be used to
implement a flexible color table lookup:

Intensity of a voxel is the range coordinate for a 1D RGBA
texture, that gives the final color.

Wolfgang
 
 
 

2D texture and 3D texture volume rendering

Post by zhengrongy » Tue, 22 Jun 2004 02:11:23


can someone show me or point me to some sample codes using opengl 2d
texture and 3d texture for volume rendering?

thanks,
zy
 
 
 

2D texture and 3D texture volume rendering

Post by JB Wes » Tue, 22 Jun 2004 04:26:44

 
 
 

2D texture and 3D texture volume rendering

Post by zhengrongy » Tue, 22 Jun 2004 23:10:21


thanks all for the replies. In the 2D texture rendering, which opengl
commands shall I use to load 500 textures into the video card? after I
load the texture into the video memory, how do I do the blending? or I
should load one texture into video card memory at a time and do the
blending?

thanks,
ZY
 
 
 

2D texture and 3D texture volume rendering

Post by zhengrongy » Wed, 23 Jun 2004 02:08:19


Also, what are the typical values assigned to alpha channel for each slice?
 
 
 

2D texture and 3D texture volume rendering

Post by Wolfgang D » Wed, 23 Jun 2004 04:17:13


At a best you should use a 3D texture. Loading only one slice at
a time will result in a fairly bad performance.

Blending is easy: Just render the slices back to front and use
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
as the blend mode. The "brighter" the texture at the given
location is, the more it opaque the slice will be there.

Wolfgang
 
 
 

2D texture and 3D texture volume rendering

Post by JB Wes » Wed, 23 Jun 2004 12:47:23

start with (1/# of slices, or 1/255., whichever is larger).

I sugest that you run and look at the code for, one of the many volume
rendering open source
tools out there. It's a very complicated topic, especially managing more
texture memory
than will fit on the card, and you will be very hard pressed to do better
than what volren
does. ( http://www.yqcomputer.com/ )







slice?
 
 
 

2D texture and 3D texture volume rendering

Post by zhengrongy » Fri, 25 Jun 2004 06:31:46


Another question, in my 500 slices of images, most of them are
backgrounds, so I assign RGB zero values to the background, and after
I blend, I got very dark images. or even without blending, each image
is very dark too. Is there a way for doing an inverse video operation
in glut?

thanks,
ZY