Jump to content
  • Advertisement

Archived

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

Marty666

Blending particles with depthtest

This topic is 5364 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 all I made a simple particle engine, but i stumbled uppon a small problem. I want to make particles like the stars in nehe''s lesson 9. I have 8 bit b&w bitmaps. I don''t want to turn depthtest off, because i want stuff to be able to be in front of the particles. When i do this the particles don''t blend anymore, but fill the whole quad (i can see the black parts of the textures now). Do i need some sort of aplha map now? Or is there a blendfunction that can keep depthtesting for the pixels and then adds* the pixels that are depthtested to the screen? thanx, Marty * By add i mean when bitmapcolor = 0 it doesn''t get colored at all and 255 it gets blenden onto the screen fully. (like the picture is the alphamap)

Share this post


Link to post
Share on other sites
Advertisement
This problem occurs when you draw a closer particle before a more distant particle. The transparent parts of the closer particle still add to the z-buffer, so when the more distant particle is drawn it''s fragments fail the depth test and don''t blend. The solution is to turn of depth writing when drawing the particles (glDepthMask(GL_FALSE)).

Enigma

Share this post


Link to post
Share on other sites
Thanx!

I still have one problem. What if I do this and want to render something behind the particle?
Should I render all particles last?

Marty

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!