Sign in to follow this  

Alpha Blended objects could hurt my FPS

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
#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 ?

Share this post


Link to post
Share on other sites
#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.

Share this post


Link to post
Share on other sites
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 =)

Share this post


Link to post
Share on other sites

This topic is 4664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this