I’ve run into problems when trying to set the depth of a fragment using gl_FragDepth.
My aim is to offset the object to the front a bit while using a depthtest, as to achieve a ‘band’ similar as one would use polygon_offset.
However, gl_FragDepth behaves very strangely.
It renders ok when we would write:
gl_FragDepth = gl_FragCoord.z;
and it EVEN COMPILES AND RUNS when I say:
gl_FragDepth = gl_FragCoord.z + 1; // SHOULD GENERATE TYPE CAST ERROR
When I use:
gl_FragDepth = a;
with a between (0.0, 1.0) gives always the same erroneous depthmap.
I got this strange behaviour under linux (driver 61.11) using a GeForce FX 5200.