My particle systems currently supports a few blend modes. For example: Additive, multiplicative or alpha blending.
Everything works fine so far, yet I am struggling with the actual understanding.
Lets take additive blending as an example and assume we are drawing two particles. Either Particle 1 (P1) or Particle 2 (P2) is drawn first. Which leads to one of the images shown below:
On the right side is how it should look. The left side is how it shouldn't. The problem here is even though I use additive blending, which is for itself order independent, the output merger does some depth testing magic which results in the image shown on the left. The area T overlaps P2 and all fragments of P2 being removed (or never drawn).
My question is why or how the output merger exactly performs that depth test. And how that error on the left side of the image can occur. I mean it is clear that it is the drawing order that causes the problem but how the rasterizer does the depth test per fragment is a mystery.
I also know that if I disable depth write for my particles everything works fine since no fragments getting rejected.
So far I have disabled depth writing for all blend modes but alpha blending. Since they are order independent blend modes. But now I am wondering if I even need depth writing for alpha blending. In fact I wonder if I ever need depth writing for any blend mode? Maybe it has some performance advantages?