PDA

View Full Version : volume rendering and combiners



werh37
04-16-2004, 07:11 AM
This may belong in the advanced coding forum, but I'll give it a shot here, first.

So I've made a volume renderer that reads in raw 64x64x64 @ 1byte per voxel. I store this data in a 3D texture with a GL_ALPHA8 format. I also create a 256x256 2D texture as a lookup table (the type is GL_FLOAT with a GL_RGBA format).

Since the 3D texture is nothing but Alpha values, I use GL_DEPENDENT_AR_TEXTURE_2D_NV as the shader operation for the lookup table. My understanding is that all I have to do after the lookup is combine the RGB and Alpha values in the final combiner. So I have something like this:


glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_G_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);Unfortunately, my image looks really washed out:
bad image (http://www.mcs.anl.gov/~jones/Images/VOL/bad.png)

After playing around with the combiners, I found something that looks half-way decent


glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_G_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);The results look pretty good:
good image (http://www.mcs.anl.gov/~jones/Images/VOL/good.png)

So my question is, why did my first attempt produce a lousy result? My next attempt looks nice, but I'm not entirely sure why it works. I'm guessing that it squares the alpha values. I'm also using the over operator for blending, btw. If I can understand what's going on, it'll help me when I try to add more advanced features like shading/lighting.

Thanks much - Dave