Recommended Posts

Hi all...
I made a particle system, the principe is to render only one object with all particle in, and each particle can have its own lifeTime and fade.
the problem is the depth sorting.... its very slow. I compute Particle distance with each other with a DotProduct.
Are there a way to depth sort with hardware z-buffer or someting like this ??
maybe anyone can help ??
tank you..
Fantasio

Share this post

Link to post

Share on other sites

Prosper/LOADED, yes you do. If you are using additive blending and NO ZBUFFER, then you don''t.

Even translucent polygons make a write to the Zbuffer. If you draw a particle near the camera, and it obscures half the scene, no other particle will appear "behind" it because they are "obscured" by the foremost particle.

For particles... well, if your particles are never going to be very big on-screen, don''t bother sorting them. If there is a chance that they''ll be huge, I''d suggest a filthy axis sort...

For a given GROUP of particles, not each particle, determine which of the six cardinal axes (Z+, Z-, X+, X-, Y+, Y-) is closest to the direction the camera is facing. Then, use your preferred fast sort algorithm on the particles, measuring only the relevant axis.

For example, if the camera is looking 5 degrees to the left of straight up the -X axis (relative position irrevelant), sort your particles with the lowest X values at the "front", and highest as "back".