As an experiment I decided to try rendering to a texture using the image API exclusively. At first the results were obviously wrong as the texture write occurred before the depth test. So I enabled the early_fragment_tests
, which I though was introduced for pretty much this type of use case, but now I get a weird sort of flickering which seems like Z-fighting, which seems strange since it should be performing the same depth test that works for regular rendering.
Anyway, I've included an image of the problem, and I'm curious if anyone has an explanation as what is going on, and why this doesn't work. Can it be made to work?
Here's a minimal reproducer
#version 420
in vec3 normal;
layout(binding = 0) writeonly uniform image2D outputTex;
void main()
{
vec4 fragColor = vec4(normal, 1);
imageStore(outputTex, ivec2(gl_FragCoord.xy), fragColor);
}