opengl - Shader execution after writing to gl_FragDepth -
given fragment shader modifies original depth of fragment , writes gl_fragdepth
. code after writing gl_fragdepth
still executed if depth test fails @ point?
example:
in float depth; layout(depth_less) out float gl_fragdepth; void main() { float newdepth = depth - somemodification; gl_fragdepth = newdepth; a(); }
will a
executed if newdepth
greater current value in gl_fragdepth
?
if so, alternative stop shader doing unneccessary computations in a
- without using custom depth buffer?
in example, a() executed long contributes output value, e.g. color (otherwise, compiler remove optimization). depth test per-sample operation performed after fragment shader. under special circumstances, possible test before fragment shader, requires fragment shader not write gl_fragdepth.
is modification uniform 1 or different each fragment? if uniform, in geometry shader - apply depth modification whole primitive. use early-z. if it's on per-fragment basis, try binding current depth render target readonly image, fetch stored depth value, perform manual comparison in shader , discard fragment if fails. however, neither know whether can bind bound framebuffer's render targets images, readonly, nor whether more or less performant executing a().
Comments
Post a Comment