[info-performer] Re: [info-volumizer] pfVolume: Problems with setShader

Date view Thread view Subject view Author view

From: Praveen Bhaniramka (praveenb++at++mrcoffee.engr.sgi.com)
Date: 06/13/2003 12:02:21


Hi Bjorn,

Looks like you need to attach your LookupTable to your shape's appearance.

shape->getAppearance()->setParameter("lookup_table", table);

If the "lookup_table" parameter is not found, the LUT shader would cause a
vzError::error() which in turn invokes pfVolume::exceptionHandler() (see
pfVolume.cxx).

The width of the table is the number of entries in the lookup table. The
interpolated texel value from your 3D texture is used to lookup into the
lookup_table parameter to determine the final color and alpha value for
this texel. Hence the number of entries in the LUT is going to determine
the accuracy of the transfer function that you get for the volume data.
Usually 256 works OK since most data sets are unsigned byte data sets. On
IR, you can get upto 1024 entries of RGBA LUT entries. So your current
setting of 16 might be a bit too low!

hth,
Praveen

On Fri, 13 Jun 2003, Bjorn Hanch Sollie wrote:

> Hi all,
>
> I'm using pfVolume in a Performer application, and I'm trying to
> adjust the transparency of a volume. To do this, I'm trying to use a
> lookup table with the vzTMLUTshader. However, when I use setShader()
> to apply the new shader, my application exits with the following error
> message (some code is listed below):
>
> PF Fatal(12): pfVolume error type 9, severity 0,
>
> What is the best way to set the volume transparency? Why doesn't my
> code work? Also, can someone explain to me exactly what the
> "width"-parameter to vzParameterLookupTable does?
>
> Thanks,
>
> -Beorn
>
> void Surge::initScene(void)
> {
> pfLightSource *light;
> pfVolume *vol;
>
> scene = new pfScene();
> light = new pfLightSource();
> scene->addChild(light);
>
> vol = new pfVolume();
> vol->init();
> vol->loadFile("/oslo/people/bjorns/Surge/data/3d/AAA43_CT.vz");
>
> scene->addChild(vol);
>
> // Initialize a LUMINANCE_ALPHA lookup table
> int width = 16;
> float* data = (float*)pfMalloc(4*width*sizeof(float));
>
> for (int i = 0; i < width; i++)
> {
> data[i*4 + 0] = i;
> data[i*4 + 1] = i;
> data[i*4 + 2] = i;
> data[i*4 + 3] = 0.4;
> }
>
> vzParameterLookupTable* table =
> new vzParameterLookupTable(width, data, VZ_FLOAT, VZ_RGBA);
>
> vzTMLUTShader *newShader = new vzTMLUTShader();
> vol->getShape()->getAppearance()->setShader(newShader);
>
> return;
> }
>
>
> void Surge::initChannels(void)
> {
> pfSphere bsphere;
> pfCoord viewCoord;
> pfChannel *masterChan; // Main channel.
> pfPipeWindow *window;
>
> // Determine extent of entire scene.
> bsphere = bsphere;
> scene->getBound(&bsphere);
>
> // Create and return a window
> window = new pfPipeWindow(pfGetPipe(0));
> window->setWinType(PFWIN_TYPE_X);
> pfuInitInput(window, PFUINPUT_X);
> // Window size (and position).
> window->setSize(960, 540);
> window->open();
>
> masterChan = new pfChannel(pfGetPipe(0));
> window->addChan(masterChan);
>
> masterChan->setScene(scene);
> masterChan->setFOV(60.0, 0.0);
> viewCoord.xyz.set(0.0f, -3.0f*bsphere.radius, 1.0f);
> viewCoord.hpr.set(0.0f, 0.0f, 0.0f);
> masterChan->setView(viewCoord.xyz, viewCoord.hpr);
>
> return;
> }
>
>
> void Surge::execute(int argc, char *argv[])
> {
> /* Configure Performer. */
> pfNotifyLevel(PFNFY_INFO);
> // Initialize OpenGL Performer.
> pfInit();
> // Initialize the utility library.
> pfuInit();
> // If multiprocessing, configure the rendering pipe and forks
> processes
> pfConfig();
> // Create the visual database.
> Surge::initScene();
> // Initialize channels.
> Surge::initChannels();
> // Find the highest resolution clock available and initialize it.
> pfInitClock(0.0);
> // Set the desired frame rate.
> pfFrameRate(30.0);
>
> /* Application main loop */
> while (!exitFlag)
> {
> // Sleep until next frame.
> pfSync();
> // Trigger cull and draw processing for this frame.
> pfFrame();
> }
>
> /* Clean up. */
> pfuFreeAllCPUs();
> pfuExitInput();
> pfuExitUtil();
> pfExit();
>
> return;
> }
>
>
>

-- 
-----------------------------------------------------------------
Praveen Bhaniramka               Member of Technical Staff (MTS)
praveenb++at++sgi.com                 Advanced Graphics Division
(650)933-1785                    Silicon Graphics, Inc.
-----------------------------------------------------------------


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Jun 13 2003 - 12:04:17 PDT