Archived

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

cnagle150

Sorting Alpha Blended stuff.

Recommended Posts

Got some questions concerning alpha blending... 1. Currently I''m not sorting my alpha blended quads rendered during explosions. The look I''m getting isn''t quite right. I can see through parts of the quad by I definitly see the general outline of the quad. My guess it''s happening whenever a quad is blended behind another quad. Is this correct? And will sorting the quads resolve this? 2. Suppose I have an explosion occuring right beside a window. Suppose I can orient the camera such that the transparent window is in the middle of the explosion. Now, normally you batch polygons to be rendered by textures. Doing so here would mean all of the sorted explosive quads would get rendered before or after all the sorted window quads. Would this look correct? In school they talked about doing it for speed. I can just imagine the headache of switching Textures constantly as two alpha blended entities intermingle. How should this be handled. Batch if you can, but if two or more alpha blended entities interpenetrate, sort everything?

Share this post


Link to post
Share on other sites
quote:
Original post by cnagle150
Got some questions concerning alpha blending...

1. Currently I''m not sorting my alpha blended quads rendered during explosions. The look I''m getting isn''t quite right. I can see through parts of the quad by I definitly see the general outline of the quad. My guess it''s happening whenever a quad is blended behind another quad. Is this correct? And will sorting the quads resolve this?

Yes, it will. Note that if you''re using on/off transparency (no translucency/semi-transparency) you can use alpha testing instead of alpha blending which will (a) increase performance, and (b) remove the need for sorting.
quote:

2. Suppose I have an explosion occuring right beside a window. Suppose I can orient the camera such that the transparent window is in the middle of the explosion. Now, normally you batch polygons to be rendered by textures. Doing so here would mean all of the sorted explosive quads would get rendered before or after all the sorted window quads. Would this look correct? In school they talked about doing it for speed. I can just imagine the headache of switching Textures constantly as two alpha blended entities intermingle. How should this be handled. Batch if you can, but if two or more alpha blended entities interpenetrate, sort everything?


The way I''d do it is to sort and render everything of the explosion behind the window (splitting triangles/quads where they intersect the window plane), render the window, and then render the rest of the explosion - that way you only need to set textures 3 times.
On the other hand, I find it hard to believe that there exists such a thing as an explosion that can pass unhindered through glass without damaging it.

- JQ
Yes I do have holidays at the moment. And yes, that does explain the increased posting.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
NOOO everyone is suggesting alpha testing as a solution to this problem. It''s WRONG. While rendering your blended particles, simply turn off ZWRITE, but keep zbuffering on so it still uses the buffer to check if it''s going to be occluded. This will solve your quad outlines problem nicely.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
NOOO everyone is suggesting alpha testing as a solution to this problem. It''s WRONG.

What''s wrong about it, if there is no translucency? I think I stated that limitation quite clearly. In addition, testing is considerably faster than blending.
quote:
While rendering your blended particles, simply turn off ZWRITE, but keep zbuffering on so it still uses the buffer to check if it''s going to be occluded. This will solve your quad outlines problem nicely.

This will work in some cases, but it''s certainly not a general solution, as it can bring up artifacts if there are other translucent objects among the particles (such as cnagle150''s window problem) as the order of blending is completely jumbled and looks quite bad. It will also make intersecting particle clouds look very odd.
If you don''t have many (different) particle sources and no translucent objects, go ahead and use it, but otherwise use the tried and true method of sorting.



- JQ
Yes I do have holidays at the moment. And yes, that does explain the increased posting.

Share this post


Link to post
Share on other sites