Classic Tree Billboard ( How The Hell? )

Alright, I have my bmp file loaded. How do I eliminate the black background of the image, but not make the tree translucent? Is there a special combination of the Blend function that will allow me to do this. Please HELP!!!

I don’t understand exactly what you mean, but basically, you should set the alpha of the black pixels to zero (assuming your black is background, and no other pixels in the tree are black), leave the rest at 1, and do an alpha test when you render, so that you don’t render the ones with alpha=0.

Maybe I have the same question with jeff_a16. But I don’t know how to assign each pixel of the BMP an specific alpha value. As far as I know, BMP doesn’t contain alpha channel. And, how to use the BMP to build tree billboard after setting its alpha value? I’m a little confused. Would you please put some code here? Thanx so much.

You would need to enable Blending with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_ALPHA); and your bmp loading function should have code that gives each black coloured pixed an alpha value of 0, and all other pixels 1, this way the black coloured pixels will be transparent

You would need to enable Blending with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_ALPHA); and your bmp loading function should have code that gives each black coloured pixed an alpha value of 0, and all other pixels 1, this way the black coloured pixels will be transparent

Perhaps I didn’t make myself clear.
My point is: BMP file format doesn’t include any alpha information. You said: ‘…and your bmp loading function should have code that gives each black coloured pixel an alpha value of 0, and all other pixels 1’ But where should I assign the alpha value of each pixel of the BMP to?

[This message has been edited by Dong Ke (edited 11-25-2001).]

Use some format that supports alpha channel, like tga. (I have a loader source on my site). Then I would advice to use alpha test, for which you need not to sort the polys in any case. For blending the polys have to be sorted in some cases (If you use GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA with alpha values other than 1 and 0)

-Lev

Originally posted by Lev:
[b]Use some format that supports alpha channel, like tga. (I have a loader source on my site). Then I would advice to use alpha test, for which you need not to sort the polys in any case. For blending the polys have to be sorted in some cases (If you use GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA with alpha values other than 1 and 0)

-Lev[/b]

So would you please put your link to your site here?

Originally posted by Lev:
Use some format that supports alpha channel, like tga.

Right, but he has a BMP file.

void make_alpha (char rgb, int count, char **rgba)
{
static int trans_pix = 0x00000000;
rgba = new char[count4
sizeof char];
for (char p=&rgb[count3-3], *p2=rgba[count4-4]; p >= rgb; p-=3, p2-=4)
{
*p2=p[2],p2[1]=p[1],p2[2]=*p;
if ((((int&)*p) & 0x00ffffff) == 0)
p2[3] = 0;
else
p2[3] = 0xff;
}
}

should be working

[This message has been edited by Michalek366 (edited 11-26-2001).]

So would you please put your link to your site here?

Why not check out his user profile (one of the four buttons above the message)?

Yeah I’v got it, thanx