PDA

View Full Version : Fast Volume Rendering



LLM
05-29-2006, 11:42 PM
Use glTexImage3D to Create a Volume image.I need
change the Alpha value of the image in real-time
mode.But Create 3D Texture need too much time.
How can I do these?

Klaus
05-30-2006, 06:09 AM
You can use a 1D texture as a lookup table for a dependent texture lookup that maps each scalar value from your volume to a RGBA value. Such a RGBA lookup table (transfer function) usually consists of ramps or multiple trapezoids. You only need to update the small 1D texture to change the alpha values instead of the volume.Bind the lookup table to a different texture stage than the volume.


uniform sampler3D volume;
uniform sampler1D transferfunction;

void main()
{
float data = texture3D(volume, gl_MultiTexCoord0.xyz);
gl_FragColor = texture1D(transferfunction, data);
}More info here ... (http://www.vrvis.at/via/resources/course-volgraphics-2004/)

- Klaus

LLM
05-30-2006, 06:51 PM
Thank you a lot. You give me more information than I expect.

LLM
05-30-2006, 11:31 PM
And I have a problem. Could I Create the lookup
table without OpenGL Extentions sunch as
glColorTableEXT and GL_COLOR_INDEX8_EXT.
As I compehend, Use glTexImage1D
could create the table instead of glColorTableEXT. Right? If it was possible, How could I use the 1D Texture, which need more Vertices than 3D Texture.

Klaus
05-31-2006, 03:04 AM
Could I Create the lookup
table without OpenGL Extentions sunch as
glColorTableEXT and GL_COLOR_INDEX8_EXT. No, glColorTableEXT is not supported on newer graphics hardware.


Use glTexImage1D
could create the table instead of glColorTableEXT. Right? Yes, you can use glTexImage1D to create the table instead.


How could I use the 1D Texture, which need more Vertices than 3D Texture. You just slice or raycast your 3D texture as usual. No need to create vertices for the 1D texture.

- Klaus

LLM
05-31-2006, 08:33 PM
It is very kind of you. But it is still confuse
me that how I could use the glTexImage3D and glTexImage1D together.How Could I use the 1D texture created by glTexImage1D to affect the 3D texture created by glTexImage3D? Use the MultiTexture?
And What's the means that "Such a RGBA lookup table (transfer function) usually consists of ramps or multiple trapezoids." And How to bind the table(1D texture)? like this ?

glEnable(GL_TEXTURE_1D);
glEnable(GL_TEXTURE_3D);
render();
glDisable(GL_TEXTURE_3D);
glDisable(GL_TEXTURE_1D);

Klaus
06-01-2006, 02:22 AM
And How to bind the table(1D texture)? like this ? No, multitextures are required: Bind the 3D texture to texture stage 0 and the 1D texture to texture stage 1. You don't need to enable textures when using glsl.


And What's the means that "Such a RGBA lookup table (transfer function) usually consists of ramps or multiple trapezoids. Here's a small introduction to volume rendering and transfer functions: http://astronomy.swin.edu.au/~pbourke/raytracing/volume/

- Klaus

LLM
06-02-2006, 12:24 AM
I think I have a progress. I can change the volume alpha with 1D texture,but it does not seem correct. my code is:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D,m_VolumeTexture);
glEnable(GL_TEXTURE_3D);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);

glActiveTexture( GL_TEXTURE1);
glBindTexture(GL_TEXTURE_1D, 12);
glEnable(GL_TEXTURE_1D);
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE);

DrawVolume();

glActiveTextureARB( GL_TEXTURE0_ARB );
glDisable(GL_TEXTURE_3D);
glActiveTextureARB( GL_TEXTURE1_ARB );
glDisable(GL_TEXTURE_1D);
It can change the volume's Alpha Value but change the Volume's Color too. How deal with this?
It seems that only the first value of 1DTexture is enable, another 255 values seems disable.when
I just want to change the Alpha value of red color, what should I do?

Klaus
06-02-2006, 03:52 AM
I just want to change the Alpha value of red color, what should I do?
So if i understand you right, you want to use RGB from the 3D texture and A from the lookup table. Then this code should do it:



glBindTexture(GL_TEXTURE_1D, 12);
This does not look right.



glEnable(GL_TEXTURE_3D);
...
glEnable(GL_TEXTURE_1D);
...
glDisable(GL_TEXTURE_3D);
...
glDisable(GL_TEXTURE_1D);You don't need to enable textures when using GLSL. So this is not needed ...



glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);You don't need this either ...

- Klaus

LLM
06-02-2006, 01:34 PM
So if i understand you right, you want to use RGB from the 3D texture and A from the lookup table.
Yes, that is just what I want. Use GLSL is a good idea.

But Could we fast rendering the volume without shading language.And as I used to do, we use texture combiner and so on should we?