Question on properly Blending Particle Effects

Started by
5 comments, last by Wudan 18 years, 10 months ago
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.
President: Video Game Development Club of UCIhttp://spirit.dos.uci.edu/vgdc
Advertisement
can't you just disable the zbuffer writing?
keep depthtest on always
for the particles turn off depth writes with glDepthMask( GL_FALSE );
and (perhaps) draw them from back to front
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.
President: Video Game Development Club of UCIhttp://spirit.dos.uci.edu/vgdc
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)
Thanks guys!
President: Video Game Development Club of UCIhttp://spirit.dos.uci.edu/vgdc
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.

This topic is closed to new replies.

Advertisement