Billboarded trees

Started by
19 comments, last by alfith 18 years ago
i am an opengl newbie but i remeber something from
directx where i got the same problem


directx:
g_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, DWORD(wert) ); // wert = 0<->255

thoose command changes the edge of colorkey effect
at edges..and it looks like same at your screens

but i dont know the openGL command for this


Advertisement
I had a similar problem, it is to do with the linear filtering on the textures, blending the white under the alpha channel of the TGA. Simply change the background colour to black or something for a quick fix.
grayrobertos is right. It definitely looks like the linear filtering is disturbing here. An easy way to solve this is to use alpha-testing like this I think:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.99);

drawyourtrees();

glDisable(GL_ALPHA_TEST);

You ensure, that only pixels with alpha of 1.0 (or very very close to 1.0) in you billboard texture are drawn and all others are skipped. So you also skip the fragments that result from a linear interpolation of an alpha=0.0 and alpha=1.0 (which creates some alpha between 0.0 and 1.0) ...

greetz
I did the glAlphaFunc(GL_GREATER, 0.99); and I coud barely see the trees!
I changed it to 0.5 and even then there was a small problem?
Also the picture of the tree is one layer, the tree on a transparent background, how do I change the background color to black? (gimp)
Thanks.

[Edited by - daniel_i_l on March 24, 2006 2:54:22 AM]
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
With The Gimp just add a black layer below your tree layer (if you can't move the new layer below, duplicate your tree layer and delete the original one)
Instead of black, you can use a color that is close to the one used for your tree because if you use mipmapping, you will probably get dark borders around far distance trees.
I added a layer under the tree layer and now I get a lot of black squares (all of the black showed up in the game) gimp said that tga can't handle layers and it merged everything together?
Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
I forgot a step sorry (I don't have gimp here).
add a mask to your tree layer using the "transfert alpha to mask" (or something like that).
then you can merge your two layers (it must be merged but not flattened ! if you flatten, you will get the alpha removed). And try using a green color instead of black.

what you should get is one layer (the tree on a black or better green background) and its mask.
hope it is ok now...
I created a mask for the first layer, then I merged the layers, and I got a tree on a green background, but again I saw green squares? It seens like it should do that cause all I have is one layer of a tree on a green BG?
Thanks? (I'm a total newb to gimp and 2D art in general)
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
I took gimp...
so:
you have a tree on a transparent background
right clic on the layer
"Add Layer Mask" option: Layer's alpha channel
right click on your layer
"Alpha to selection"
menu Select\invert
choose your foreground color (a green)
Ctrl+, (or "Edit\Fill with FG color")

save your tga...

Thanks, one question, when I save the gimp says that tga cant handle layers and masks and asks if I wan't to export, do I say yes?

Also, after doing that there still was some of the problem that I mentioned above, will fixing the pic as you said work without sorting and disableing z-write?
Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky

This topic is closed to new replies.

Advertisement