Jump to content
  • Advertisement
Sign in to follow this  
dpadam450

Particles

This topic is 4348 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 am currently drawing particles as quads with a mask texture, and then the actual texture over it. The only problem is that this way I have to disable the depth test. What way should I do it? glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_DST_COLOR, GL_ZERO); glBindTexture(GL_TEXTURE_2D, texture[8]); //Draw the mask here glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[9]); //Draw the actual particle here

Share this post


Link to post
Share on other sites
Advertisement
forget about masks theyre so 1980/90s
normally the method u use is stick the 'how much of the pixel u want to show through' info in the alpha channel of the texture and enable alphatest or blending.
much faster/flexible/easier

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or render each particle as a cube volume for soft particles

Share this post


Link to post
Share on other sites
usually we want to disable depth tests when rendering particles. If we have to depth test every particle the performance of the system will take a fairly significant hit, especially for larger particle systems, this is why in many games you can see certain effects through the terrain/buildings/etc.

zedzeek is absolutely right though, in general the texture you are using for the particle should contain the mask itself, then we simply have to set the blending mode appropriately and we get the desired effect.

enable blending first by calling glEnable(GL_BLEND); then set the blending operation with a call to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); This is the most common usage of the blend func and will work very well for particle textures with a black background used as the baked in mask.

Share this post


Link to post
Share on other sites
Actually I modified my code and it works fine. I was draw 20 squares and the problem with drawing was that there would be a slight z-fight. But no particle in general will have the same rotation and position (meaning more than a row of pixels shouldnt be fighting for a z value. So I'm actually fine with my code now. Should have just changed the values in the first place so that they dont overlap so much.

What it looks like.


[Edited by - dpadam450 on September 20, 2006 10:55:55 PM]

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.

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!