• Advertisement
Sign in to follow this  

Question on properly Blending Particle Effects

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

I'm having a bit of trouble blending my particle effects with the rest of my scene. My problem comes when one particle is in front of an object but behind another particle. Because it fails the depth test (being behind another particle), it doesn't contribute to the specified pixels even when the existing pixel does not have full alpha. I tried glDisable(GL_DEPTH_TEST) and that got my particles blending with each other just right but then would be drawn on top of objects that they are supposed to be behind. How do I get this to work? How do I get a particle's pixel to contribute to the scene in the case where the previous pixel had an alpha value of < 1 AND in front of the current pixel? If it helps, I'm using GLSL for fragment shading. Thanks in advance for your help.

Share this post


Link to post
Share on other sites
Advertisement
keep depthtest on always
for the particles turn off depth writes with glDepthMask( GL_FALSE );
and (perhaps) draw them from back to front

Share this post


Link to post
Share on other sites
neuch: Isn't that the same as the depth buffer? If so, that doesn't work because then my effect can appear on top of some object that they are supposed to be behind.

Share this post


Link to post
Share on other sites
as zedzeek said keep the depth buffer test on just disable the depth write (when rendering your particles). and yes depth buffer is zbuffer (i'm on ps2)

Share this post


Link to post
Share on other sites
I had this same problem with my particles, and it makes sense when you think about it.

When you draw an object to the screen, with GL_DEPTH_TEST enabled, openGL figures out where to draw it, compares what it has decided to draw against the depth buffer, and rasters the appropriate and logical pixels to the screen AS well as to the depth buffer. when you disable GL_DEPTH_TEST you still draw, but openGL does not check against the depth buffer and does not write to the depth buffer.

Conversely, when you turn off the depth mask, openGL still checks against the depth buffer BUT doesn't write to the depth buffer - which works great for blended objects.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement