Hi there,

I'm creating all my textures from BufferedImages which I load into
memory "manually". This gives me maximum control over texture alpha ...
for example, I can load a standard RGB image, calculate the alpha as a
mask (a=(r==0 && g==0 && b==0)?255:0) or as a blending (a=(r+g+b)/3) and
then use it as a texture. Provided that you have aquired the image for
the texture (getImage() or similiar), the following code will return a
texture with blended alpha (masked alpha works accordingly):

    
private Texture2D createTextureBlendAlpha(Image a_image)
{

    // Create and fill buffered image
    BufferedImage l_img = new
BufferedImage(a_image.getWidth(null),a_image.getHeight(null),BufferedIma
ge.TYPE_4BYTE_ABGR);
    l_img.createGraphics().drawImage(a_image,0,0,null);

    // Process image (alphamask)
    WritableRaster l_rst = l_img.getRaster();
    int l_val[] = new int[4];
    for (int x=0; x<l_img.getWidth(); x++)
    {
        for (int y=0; y<l_img.getHeight(); y++)
        {
            l_rst.getPixel(x,y,l_val);
            l_val[3]=(l_val[0]+l_val[1]+l_val[2])/3;
            l_rst.setPixel(x,y,l_val);
        }
    }

    // Create texture and fill it
    Texture2D l_tex = new
Texture2D(Texture2D.BASE_LEVEL,Texture2D.RGBA,l_img.getWidth(),l_img.get
Height());
    l_tex.setImage(0, new
ImageComponent2D(ImageComponent2D.FORMAT_RGBA,l_img,false,false));

    // Return result
    return(l_tex);

}

HTH 

Wolfgang Kienreich

====================================================================
Wolfgang Kienreich
Technical Research
Knowledge Retrieval / Knowledge Visualization
Know-Center  http://www.know-center.at
Inffeldgasse 16c, 8010 Graz, Austria
email : [EMAIL PROTECTED]
phone : +43 316 820918 647
fax   : +43 316 873 5688
==================================================================== 





-----Ursprüngliche Nachricht-----
Von: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]] Im Auftrag von Risto Rangel-Kuoppa
Gesendet: Dienstag, 04. Februar 2003 16:33
An: [EMAIL PROTECTED]
Betreff: [JAVA3D] Invisible pixels in textures


Hello!, I have created a set of objects in a stack and each with a
different texture, but I would like to define a color in each texture so
it is considered an “invisible color” and therefore it is not rendered
and I can “see” the texture of the object “below”, I have read about the
transparency property but I understand this gives the transparency to
the whole texture.  Could any please give me some advice on how to
achieve the effect I am looking for?.  I don’t know if this is a rookie
issue but the fact is that I have not found how to do it and I would
really appreciate the any help any could give me.  Thanks in advance.
 
Cheers.
 
Risto Rangel-Kuoppa.

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to