Skip to main content
gamedev.net
🔒 Locked

Multiple Alpha Objects

Started by smittix Nov 6, 2004 at 9:21 PM 4 replies 650+ views
Original Post
smittix
smittix
I have created a few objects that are textured using an alpha overlay so as to make part of the object see through. The trouble that I am having is that an object that is drawn first will still obcure the object drawn second if the object drawn first is in front of the object drawn second. Is there any way to fix this, short of rendering the second object twice?
lack o comments
lack o comments
Do you have the z-buffer active. If so, turn it off. When the z-test if performed it will not copy pixels if another pixel already exists in the buffer that was take from a polygon closer to the camera. Therefore if the closer polygon is draw first, the further will never be seen. Regardless of transparency.


Actually, I've never used the z-buffer. So I could be wrong about this, but then again, I've never heard of a z-buffer that takes into account transparency =)
Supernat02
Supernat02
It's pretty much a rule that you must render non-fully-opaque objects back to front, for this very reason. The z value gets rejected because there's already been a pixel drawn at a closer z value. You could disable the depth testing, but it may have a side-effect that you don't want. It will make the last object you draw the one on top, regardless of whether it's closer to the camera or not.

Chris
Chris ByersMicrosoft DirectX MVP - 2005
manzanilloleon
manzanilloleon
I have a doubt regarding this topic.

I know I must draw transparent objects from back to front. But what happens when the transparent parts of an object overlap each other? I'm thinking I should order the object triangles back to front... But, wouldn't that be awfully slow? What would be the most efficient way to do this?
Ximmer
Ximmer
Draw the Backfacing polygons first then render the front facing polygons last. it's cheap... done in hardware.. and works most of the time... it does have a few issues if a limb is behind the body from the facing camera.. but if it something like that you probably wouldn't be able to make out the limb behind the mass of polygons anyways.... that's the cheap solution anyways.
fractoid
fractoid
You could just do like Warcraft 3, turn off depth testing, and ignore the problem. If your objects are small enough on the screen, and/or are mostly convex, it's not extremely noticable, so you might be able to just put up with it.

Otherwise I'm afraid it's depth sorting for you... unless you happen to be able to use one of those funky new superenhanced everything-buffers that someone (nVidia?) was talking about, for sort-independant alpha...

[edit: or do as Ximmer says, which will be loads faster than sorting but still more correct than ignoring the problem. In fact, thinking about it, this is probably what wc3 does. ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.