Depth peeling and coplanar issue (z-fighting)
I have troubles with the depth peeling technique and coplanar surfaces. The original algorithm is able to peel only one layer at the i-th depth, so if you have more than one, only one will be peeled.
I found this paper online http://dl.acm.org/authorize?6581249, he says
Extending F2B: We present the Z-fighting free F2B (F2BZF) depth peeling by adapting the F2B algorithm to peel all fragments placed at the same depth.
When we have peeled all fragments at one depth, the next depth layer underneath is returned. To obtain all fragments at the same depth we discard the fragments that are not placed at this depth.
To distinguish among z-fighting fragments, we extract (peel) the color of the fragment which has the maximum primitive identifier (build-in variable glPrimitiveID of GLSL [Kessenich 2009]). One extra geometry pass is used to calculate the sum of the (remaining, not peeled) z-fighting fragments and find which of them should be extracted next. We discard peeled fragments of the same depth by eliminating all fragments that have a primitive identifier smaller than the maximum primitive id determined during the previous step. Both computations are performed in one pass using additive and maximum blending operations respectively.
I dont get how he can calculate the sum of the remaining z-fighting fragments and the next hightest id with the add and max blending..
Shader code here
He should use an extra color texture (with internal pixel format RGBA_32F) to store the identifiers