Advertisement

Particle System (about tricky details, not the basics)

Started by January 01, 2001 09:53 PM
7 comments, last by MrSandman666 23 years, 10 months ago
I want to do a particle system (of course) and so I looked at NeHe''s tutorial. The problem is, he disables depth testing completely. That''s nice if you have only the particle system on the screen or if the particles are always on top of the scene but my particles are supposed to be some kind of trail and they will fly through a 3d scenery so that they will be covered by other objects pretty often and if I enable depth testing, there are these nasty artifacts(borders, whatever) and it looks just crappy. How do you get around this problem (without doing the depthsortig yourself)? And another question: Since I only use quadratic bitmaps as textures, would it make much sense to use GL_TRIANGLE_STRIPS insted of GL_QUADS? Does it speed up the program at all? In both cases define 4 vertices and restart the rendering process after that. Thanx in advance. "Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
this is my first post to gamedev.net. Hello to everyone, I hope I can add something to the community.

Nate Robbins has an excellent particle demonstration in openGL with depth enabled. Visual C++ compiles it fine. It shows a waterfall, a fountain and, particle collision. keys: w,s,f,l +, - p, P effect the speed or direction of the particles. check it out.

you can search Nate Robbins site:
http://www.xmission.com/~nate/opengl.html

I also posted on my site for easy access:
http://webhost.bridgew.edu/jfallon/


it''''s all about a good time!
-Jamie
it's all about a good time!AOLIM name: -LOKAPUJA-
Advertisement
Are the particles the only transparent objects in your scene? If so, then do all of the particles have the same alpha value? If so then, first draw your whole scene with depth testing. Then draw your particles WITH DEPTH READING, BUT MAKE SURE THEY DON''T WRITE TO THE DEPTH BUFFER. This may sort of work if you particles have different alpha values, but it would look much better if you''d sort them.
How do you prevent writing to a buffer ?
(you can find me on IRC : #opengl on undernet)
Uhhhm, Jamie, the link on your homepage doesn''t work. I was able to acccess the file via the direct url though. If you don''t mind, here''s a working URL. I don''t know whether your host allows you to link to the homepage from the outside and I don''t won''t to get you into trouble so I only write down the URL here and not an actual link:

http://webhost.bridgew.edu/jfallon/particle.c

And wolfman: I have no idea what you''re talking about.


"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
Ok, I had a quick lok at Nate''s particle code. It works for him because he uses GL_POINTS for the particles and not blended GL_QUADS like I do. GL_POINTS don''t leave artifacts when you stack them onto each other with depth testing enabled.

"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
Advertisement
Ok, I got it working.

When you render the particles at the very last in the rendering loop with depth testing enabled it works perfectly.

"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"
--How do you prevent writing to a buffer

glDepthMask(GL_FALSE);

http://members.xoom.com/myBollux
Allright, zedzeek!
Your hint solved the last few of my problems! Thanx guys! The rest should be a piece of cake!

"Mr Sandman bring me a dream"
-----------------------------"Mr Sandman bring me a dream"

This topic is closed to new replies.

Advertisement