Archived

This topic is now archived and is closed to further replies.

Simagery

Rendering alpha polygons

Recommended Posts

Simagery    732
How do you guys handle alpha polygons? With modern hardware (i.e. z-buffers) there is no easy way to do them automatically, because soft-alpha has to be sorted depth-wise. Do you guys usually mix alpha polygons with regular geometry, or do you separate it out to render separately (to save on state changes). I''m constantly running into the problem of bad alpha when I try to do it automatically (treating alpha like any other polygon).

Share this post


Link to post
Share on other sites
Simagery    732
Well, I would be curious to learn how OpenGL does it, and I very much doubt that DirectX does it for you... but, this doesn''t seem to come up anywhere, so maybe not!

But think about it this way: when the hardware puts down an alpha''d polygon, say with alpha 128, it has to decide whether or not that counts as a hit on the z-buffer. Well, if it was a solid pixel, then yes it would. If it was a non-solid pixel, then no it wouldn''t. But 50/50?

If the z-buffer isn''t flagged, then a polygon drawn later that is behind the alpha''d polygon will cover it up. If the z-buffer is flagged, then the polygon won''t be drawn at all (but the correct answer is to blend them)!

So, what does OpenGL do? In my experience of OpenGL, I never dealt with this topic, and didn''t notice artifacts, so I assume OpenGL takes care of it. But, in using it now I am running into it!

Share this post


Link to post
Share on other sites
Dredge-Master    175
if you set the alpha pixel as 128 with an alpha test, it depends at what you set the threshhold at.

In alpha blending I have no idea how it works, I just let it handle it but in the test, it is jsut a less than, greater than, and or equals or not equals test.
so if a==128 and the test was for anything greater than 64 if would draw the pixel, otherwise if it was lower than or equal to 64 it would not update the buffers.

for alpha blending, as far as I can guess if a=128 (50%) it just adds 50% to the colour buffer and updates the depth buffer the the last rendered pixel. Since this will only work in one direction, I disable the depth buffer for it when rendering the translucent surfaces, and enable them for others
so far so good, but I have never done any complex objects with it as yet.

I would really like to hear from other people about the alpha blending though, or any sure fire ways to do it so I don''t have to figure it out if I ever find problems with it.



Beer - the love catalyst
good ol'' homepage

Share this post


Link to post
Share on other sites