Jump to content
  • Advertisement
Sign in to follow this  
Spacekangaroo

GL_DEPTH_TEST/GL_BLEND issue

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

Hey guys, small problem I'm having.

Been following Nehe's tutorial for particle effects and I've built a fireball for my game, however the issue I'm having is that I have to disable GL_DEPTH_TEST for it to look good - otherwise the particles won't blend over one another, only the environment they appear over.

gldepthtest.png

So I'm trying to make sense of why this is happening? it's textured and blended.

The blend function I'm using is glBlendFunc(GL_SRC_ALPHA,GL_ONE);

Share this post


Link to post
Share on other sites
Advertisement
If you have the depth test enabled, then particles with occlude each other since the depth buffer is binary and has no concept of transparency. The blending function you use does not require back-to-front sorting, but you need to ensure that particles don't occlude each other. If you disable the depth test, then nothing will occlude the particles (not even things that should occlude them). Another option is to keep depth test enabled, but disable depth writes. That ensures that the environment occludes the particles, but the particles don't update the depth buffer so they never occlude themselves. Look up glDepthMask.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!