Alpha Blended objects could hurt my FPS

Started by
3 comments, last by EDI 19 years, 1 month ago
Greetings all, Initial: My engine only draws sprites using quads It is my understanding, that Alpha blended objects must be drawn: 1. after all non alpha blended objects 2. back to front now implementing this is pretty easy, however i am concerned about some performance issues. as things are now, I use a single "grow-only" vertex buffer, and i group all of my quads by texture, so that i can do: 1. set texture 2. draw lots of primitives from index a to index b 3. repeat... this has worked well for me, but it seems the introduction of alpha blending is going to cause some issues. lets assume that half of my quads are to be blended 50% and the other half are opaque. I can draw the opaque ones with the above method, but for the translucent ones i will need to do (asuming i have them sorted back to front): 1.set texture 2.draw a single quad 3.repeat before I was able to ignore rendering order because of the ZBuffer, but now I lose that ability. So given that I do have alot *about half* of all my quads using intermediate alpha, isn't this going to severely hinder my rendering? please let me know of any misconceptions I may have. and what to do about this issue (if it is indeed an issue). thanks =) -Raymond

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

Advertisement
You still have a lot of options:

1) Sort by texture and distance:
foreach texture: draw back to front

2)Anything that doesn't blend but only uses Alpha Test can be drawn as if opaque.

3) Do 2 passes: First draw only the opaque parts of your blended sprites, then just the blended parts. Artifacts are likely not significant.

4) Don't worry about back to front, just draw 'em. Works fine for things that are additively blended.

And many more. It really depends on what you're doing.
Stay Casual,KenDrunken Hyena
#4 seems the only viable one for us,

however it doesnt make sense for instance,

when i draw a sprite with alpha it modifies the z buffer
and if i draw another alpha blended sprite over it, it 'punches a hole in it'

because the Z's at that area indicate it is behind and shouldnt draw because it thinks the previous sprite covered it up, here is a screen shot example:




note the fireball and the guy at the top left (both of these sprites have alpha bleded edges), the fairball was drawn first and thus wrote to the z buffer, causing the guy to be drawn with a hole in him (Z tests at that area were rejected the pixels).

am I missing somthing still ?

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

#4 is only viable for additively blended stuff. Many particle systems use this, but for what you're doing it's not viable.

Have you tried drawing your characters sprites with just Alpha Test? If the visual quality is okay then it will make things easier.

It might be useful to split your objects into 3 classes:
1)Opaque
2)Anti-Aliased (Your characters would be in this category)
3)Blended

And draw them in that order.
Stay Casual,KenDrunken Hyena
yes we tried them with alpha testing and the edges were very aliased.

the rendering engine (it's in a adaption dll) unfortunetly cant diferatiate between what is a character and what isnt. So I get the feeling we simple have to suck it up and deal with the performance that we get, with luck it wont be too severe.

Thanks for your help =)

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

This topic is closed to new replies.

Advertisement