The thing is that I need to "abort" the execution of 2x2 blocks of fragments in a checkerboard pattern considering how GPUs work in blocks of pixels.
I've thought of several approaches which are the following :
- Discard fragments in the fragment shader using a condition like this one :
float mod2 = gl_FragCoord.x + gl_FragCoord.y; float res = mod(mod2, 2.0f); if (res == 0.0f) discard;
Use the stencil buffer and write a checkerboard pattern on it using an image or such.
Use some kind of clipping method where I have several quads in front of the camera forming a checkerboard pattern.
The first approach seems to be the worse because I have to branch and after, discard fragments. And considering the fact that GPUs work in blocks of 2x2 pixels, I need to find a way to abort block by block so that I don't get the fragment shader processed anyway (even with a discard). And I'm not even sure this would force a block to abort and skip the fragment shader.
The second method seems OK, but I'm not sure if there's a better way to do it. Would the fragment shader be processed anyway ?
The third seems to need to process more polygons which is not really a good idea I guess even though it does not require a lot of processing considering they would be simple quads.
What would be the most efficient method (listed here or not) for skipping these blocks ?