I don't want all my particles being additively blended. And when I have those being additively blended with those not being it looks like complete ass because of lack of depth sorting.
I'm assuming there's probably a huge performance impact when it comes to sorting by depth; is there?
Depth-sorting particles..
DirectQ does rough depth-sorting of particles by initially grouping them into batches based on the function that spawned them, then depth-sorting those batches. The particle depth-sort goes through the same sorting routine as anything else with alpha, so you get a more-or-less accurate blend not only between particles and other particles, but also between particles and everything else. You'll obviously need to re-engineer your particle system a little for this, of course.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
What about smoke trails?mh wrote:DirectQ does rough depth-sorting of particles by initially grouping them into batches based on the function that spawned them, then depth-sorting those batches. The particle depth-sort goes through the same sorting routine as anything else with alpha, so you get a more-or-less accurate blend not only between particles and other particles, but also between particles and everything else. You'll obviously need to re-engineer your particle system a little for this, of course.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Yeah, it does those too. They all come from R_RocketTrail but it groups by type within that. A trail in R_RocketTrail is actually a quite short thing, so reasonably decent sorting is obtainable.Sajt wrote:What about smoke trails?mh wrote:DirectQ does rough depth-sorting of particles by initially grouping them into batches based on the function that spawned them, then depth-sorting those batches. The particle depth-sort goes through the same sorting routine as anything else with alpha, so you get a more-or-less accurate blend not only between particles and other particles, but also between particles and everything else. You'll obviously need to re-engineer your particle system a little for this, of course.
Typically there might be just over 100 groups to be sorted in a typical trail/explosion combination, but that's not too bad. There's no need to sqrt the distances for doing the comparison op, and if you justuse qsort rather than trying anything fancy it all works out fine.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
From what I'm getting here, I'll have to do the following:
When creating particles, put them in groups.
Sort groups by distance.
In those groups, sort each particle in the group by distance as well.
Go down the sorted list of groups..
Render each particle in the group based upon the previously sorted particles.
Works? =D
When creating particles, put them in groups.
Sort groups by distance.
In those groups, sort each particle in the group by distance as well.
Go down the sorted list of groups..
Render each particle in the group based upon the previously sorted particles.
Works? =D
Nah, I don't bother with the sorting each particle in the group by distance part. It's rough but it works. The setup goes something like this:
Then depth-sort on pt->origin.
Have a look at my code, it should be clearer there.
Code: Select all
void Particle_SpawnFunc (vec3_t org, int count, etc)
{
particle_type_t *pt = R_NewParticleType ();
VectoryCopy (org, pt->origin);
for (i = 0; i < count; i++)
{
particle_t *p = R_NewParticle (pt);
}
}
Have a look at my code, it should be clearer there.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
if the particles are close enough and have compatible blend modes, they don't really need to be sorted if depth writing is off.
its only really when the blend mode is destructive that they need sorting.
If the only particles on screen are additive rocket-explosion particles, then sorting isn't needed.
Tbh though, whatever lets you batch particles best will give better speedup than would be lost from sorting them.
its only really when the blend mode is destructive that they need sorting.
If the only particles on screen are additive rocket-explosion particles, then sorting isn't needed.
Tbh though, whatever lets you batch particles best will give better speedup than would be lost from sorting them.
The problem resides in my own particle effects, where it's several smokepuffs being emitted in a radial pattern around an additively blended yellowish explosion particles in the center.
The smokepuffs that end up behind it show as if they were in front of it.
I think I'd have to sort by depth for every particle in that situation, wouldn't you agree?
The smokepuffs that end up behind it show as if they were in front of it.
I think I'd have to sort by depth for every particle in that situation, wouldn't you agree?