Jump to content
  • Advertisement

Archived

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

Halo Vortex

Depth-correct particles?

This topic is 5886 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''ve created a simple particle engine using additive colors. The problem is, if you disable GL_DEPTH_TEST, particles are shown in front of ,say, all the obstacles or aren''t seen at all because any polygon simply overwrites it. If I enable it, I get freaky results(using simple shading circle texture, Z-buffer uses the whole quad). Does anybody know a solution to this problem, so that I could have an emmiter in the level and it was hiden/shown properly? Another question: Is there a fast way to make a real-color particles, not additive ones, which don''t allow you to render red particles against white polygons. I have read about masking on NeHe, but it requires 2 texture switches per particle.

Share this post


Link to post
Share on other sites
Advertisement
Leave Depth test on and use-

When done drawing particals
glDepthMask(GL_TRUE);

Before Drawing particals
glDepthMask(GL_FALSE);

[edited by - Xero-X2 on June 5, 2002 2:38:03 AM]

Share this post


Link to post
Share on other sites
Don't disable depth testing, do this:
glDepthMask(GL_FALSE);
...
//draw particle
...
glDepthMask(GL_TRUE);
EDIT: Ah, you were too fast for me Xero-X2

------------
aud.vze.com - The Audacious Engine <-- Newbie alert, look at your own risk. Can induce severe laughing fits and other variations of hysterical outburst.

[edited by - LockePick on June 5, 2002 2:39:08 AM]

Share this post


Link to post
Share on other sites
To answer the second part of your question, if you want to do non-blended particles, use Alpha Testing. To use this, your particle texture will need to have an alpha channel (which you effectively use as a mask).

If you have a texture where transparent parts have 0 alpha, you would use the alpha function:
glAlphaFunc(GL_GREATER, 0.0);
(or sumfin like that... too early in the morning here to be sure )

Then, before you draw your particles, call:
glDepthMask(GL_FALSE);
glEnable(GL_ALPHA_TEST);

and once you have finished:
glDepthMask(GL_TRUE);
glDisable(GL_ALPHA_TEST);

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!