I draw transparent figures by depth peeling, the result is ugly when I render to multisample (a grid appears)
vec4 fragColor = texelFetch(frontTexture, ivec2(gl_FragCoord.xy), 0);
if (gl_FragCoord.z < nearestDepth) {
// Skip this depth in the peeling algorithm
return;
}
fragColor += someColor;
Without "if return" everything is alright (but I need this "if"). The grid is exactly the same as when I use mipmapping with non-uniform flow control.
Available only in the fragment language, gl_FragCoord is an input variable that contains the window relative coordinate (x, y, z, 1/w) values for the fragment. If multi-sampling, this value can be for any location within the pixel [!!!]
P.S. Depth peeling use strict depth comparison, it is impossible if we get depth "for any location within the pixel". Instead of
if (gl_FragCoord.z < nearestDepth)
use
if (gl_FragCoord.z < nearestDepth - 0.0001)
(it is the first rough solution)