FW: 12-bit intensity textures with alpha

New Message Reply Date view Thread view Subject view Author view

From: Don Tidrow (dtidrow++at++nvl.army.mil)
Date: 12/05/2000 13:57:16


Since the original bounced for being too fat, let me try again without the
original texture image - if anybody wants to see it, I'll send it to them
directly.

-----FW: 12-bit intensity textures with alpha-----

Date: Tue, 05 Dec 2000 16:33:59 -0500 (EST)
From: Don Tidrow <dtidrow++at++nvl.army.mil>
To: info-performer++at++sgi.com
Subject: 12-bit intensity textures with alpha

I'm currently trying to load in a 16-bit image as an intensity texture with
alpha (12 bits intensity, 4 bits alpha) and am having problems. Here's what
I'm doing:

    IMAGE *imgFile = iopen(argv[1], "r");
    unsigned short* image;
    if (imgFile)
    {
        unsigned int nc = imgFile->zsize,
                     sx = imgFile->xsize,
                     sy = imgFile->ysize,
                     bpp = BPP(imgFile->type);
        
        image = (unsigned short*)
            pfMalloc(imgFile->xsize*imgFile->ysize*
                     imgFile->zsize*BPP(imgFile->type),
                     pfGetSharedArena());
        for(int i = 0; i < sy; ++i)
            getrow(imgFile, image+i*sx, i, 0);
        
        tex->setImage((unsigned int*)image, 1, sx, sy, 1); // hack for now
        tex->setFormat(PFTEX_INTERNAL_FORMAT, PFTEX_I_12A_4);
        tex->setFormat(PFTEX_EXTERNAL_FORMAT, PFTEX_PACK_16);
        tex->setFormat(PFTEX_IMAGE_FORMAT, PFTEX_LUMINANCE_ALPHA);
        
        // set up pfMaterial properties
        mtl->setColor(PFMTL_AMBIENT, 0.0, 0.0, 0.0);
        mtl->setColor(PFMTL_DIFFUSE, 0.0, 0.0, 0.0);
        mtl->setColor(PFMTL_EMISSION, 0.5, 0.5, 0.5);
        mtl->setColor(PFMTL_SPECULAR, 0.0, 0.0, 0.0);
        ...
    }

The image being loaded is a ramp from 0 intensity in the upper left corner, to
4095 in the lower right corner, and alpha being set to 8 (ie. in the lower 4
bits of each image pixel) on all pixels (ramp.int, attached). When I apply this
texture to a quad, I get what's in image1.

Changing

   tex->setFormat(PFTEX_IMAGE_FORMAT, PFTEX_LUMINANCE_ALPHA);

to

   tex->setFormat(PFTEX_IMAGE_FORMAT, PFTEX_LUMINANCE);

results in image2. What I really want is a half-transparent version of image2 -
any suggestions on what changes I need to make, either in the code or in the
source image?

Don

-- 
In October 1997, three computer lab staffers 
disappeared from the server room while debugging
a mysterious router problem.

One year later, their packet logs were found...

The Blair Switch Project

-------------------------------------------------- | Don Tidrow | | Visual Simulation Developer | | US Army TACOM (currently working with NVESD) | | ph: (703)704-1361 fax: (703)704-1753 | --------------------------------------------------

--------------End of forwarded message-------------------------

-- In October 1997, three computer lab staffers disappeared from the server room while debugging a mysterious router problem.

One year later, their packet logs were found...

The Blair Switch Project

-------------------------------------------------- | Don Tidrow | | Visual Simulation Developer | | US Army TACOM (currently working with NVESD) | | ph: (703)704-1361 fax: (703)704-1753 | --------------------------------------------------



End of MIME message


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Dec 05 2000 - 13:57:27 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.