Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / alpha depth problem Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
dimi86g

April 27, 2005, 05:41 AM

I wrote a small game engine some time ago and i still cant fix a bug im having with displaying trees, my tree leafs are random poligons with alpha textures for transparency and i'm some leafs cover other leafs and i cant see the leaf behind but the background (it sucks) and sorting every leaf dosent seem a good alternative. And no z buffer activated covers everyghting and so on and so on....

 
Rui Martins

April 27, 2005, 06:10 AM

Can you show us a picture of the problem ?
Your description is not sufficient to know what the problem is.

My only guess with what you mension is that you may be having Z precision problems, or using very small differences in depth values.

You may possibly also be failing the Alpha Test, but I don't know how you get the Background instead of what is actually behind.

What is your background ? Solid Color ?
Did you Enable Blending ?

Are you rendering all leafs to a texture ?
without texture Alpha channel ?

Also you don't mension what API or engine you are using.
Can't help you more with only this info.

 
PixelClear

April 27, 2005, 08:56 AM

Hi,

The problem you describe seems to come from the fact that you are not enabling Alpha test. As you use only alpha blending the depth of your transparent pixel are written in the depth buffer so if yo draw something behind it, the fragments are rejected and you end up seeing the backround.
Sorting can sometimes help when your polygons are small and somehow distant (like a particle system) but texture based trees are usully made of several large colygons contaning a batch of leaves. Sorting them according to their center will not work because they must be overlapping or intersecting.
To prevent that, define a low enough alpha threshold for you transparency and activate Alpha test. All the fragments that pass the test will be rejected and not written to the depth buffer.

Note that you can render your tree in an order independant way with alpha test but then avoid using semi-transparency or soft edges around your foliage, you would see your artefact again on the edges.

I hope this helps,
Phil

 
dimi86g

April 29, 2005, 04:28 AM

I dont kno how to post pictures but my problem is this, from my knoledge directx does transparency only for objects rendered after, so if you render some glass first and the object behind it second the object is invisible but if you render the glass last the object will be visible, same with alpha test and my tree leafs. What can i do ?

 
dimi86g

April 29, 2005, 04:28 AM

I dont kno how to post pictures but my problem is this, from my knoledge directx does transparency only for objects rendered after, so if you render some glass first and the object behind it second the object is invisible but if you render the glass last the object will be visible, same with alpha test and my tree leafs. What can i do ?

 
Goz

April 29, 2005, 06:36 AM

Sort all your alpha'd polys and render them in back to front order? And yes .. thats why very few commercial games do much transparency ...

 
JCash

April 29, 2005, 07:00 AM

just post the link to the picture (if you have a webpage that is)

 
JCash

April 29, 2005, 07:05 AM

If the leaves (in the texture) are opaque and the surrounding texture is completely transparent there shouldn't be necessary to sort all your leaves, right?
You just don't want to write the transparent pixels (of the leaves) into your z-buffer, and you'll accomplish that with the alpha testing.

But you should, however, sort the objects so you always render the opaque objects first (i.e background, the trunk of the tree etc) and after that, the transparent ones.

Slap me hard if i'm wrong...

 
Axel

April 29, 2005, 07:15 AM

Alpha testing will work but breaks MSAA...

 
dimi86g

May 03, 2005, 08:15 AM

ok if lets see if i got it right if i enbable the alpha test alone it will not write the pxels that dont pass the alpha test to the z buffer? ill try this and see what hapens, my problem is that i cant sort the leafs because their ~600->2000 in every tree and many are intersecting one another. From what i've seen there a loat of games who do transparency,from dungeon siege to setlers IV, half life II, gothic I II, Morrowind etc etc.

 
This thread contains 10 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.