Jump to content
  • Advertisement

Archived

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

Syrus

Alpha blending in games

This topic is 5488 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

Hi i want to use alpha blending in my game but it seems very slow. I am asking for every good optimization you know that can help me. I can''t use colorkey for passive objects like scout tower, wall, house etc. because it does not look like part of the nature itself if you know what i want to say. In another way i can use this for charachters. Please if you can help me to do best optimization with alpha blending(half transparent edges).It is 2D game. thx!

Share this post


Link to post
Share on other sites
Advertisement
The alpha blening itself ain''t slow when performed on the hardware.I''ve saw over 20,000 alpha blended particles running 0n 200 FPS for second so i suppose your problem is other.Are you calling glEnable/glDisable and other state functions for each object?They are EXTREMELY expensive you know!

"You losers better learn...NOONE CONTROLS OUR GOD DAMN LIFE!!!" - MANOWAR

Share this post


Link to post
Share on other sites
Let''s see now... Off the top of my head, I''d recommend the following:

First off, try rearranging your renderings so that all opaque elements (No alpha involved) are rendered.
THEN render all elements that involve alpha (this way your render states are setup once).

Other tips: Add an ''alpha test'', meaning if the alpha is below 5% or whatever, the hardware won''t even bother drawing the pixel. Which saves on Z-buffer work and texel work.

You''re working on DirectX or OpenGL?

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Share this post


Link to post
Share on other sites
Right, well as Mihail and I said
1-Make sure you setup your ''opaque'' render states once.
2-Render all opaque geometry, minimize the number of drawprimitive by batching. You shouldn''t have to make -any- render state changes other than texture shifts.
3-Setup your ''alpha-ready'' render states once.
4-Render all alpha-blended geometry. Again, batch primitives together to minimize the number of DrawPrimitive calls.


If that doesn''t work, maybe you''re working in software mode or in Reference mode (which is always atrociously slow) rather than in Hardware T&L.


Hope this helps.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!