Coverage, barycentrics and the depth buffer

Drag the six handles. Every grid cell runs the same inside test, gets its colour from barycentric weights, and then has to survive the depth test.

triangle A — 10 m at the left, 14 m at the right triangle B — a decal lying on A's plane red corner dot — a fragment shaded and then thrown away by the depth test

What to notice. Wind B offset down towards −0.2 m and the overlap shatters into speckle: that is z-fighting, two depths too close to tell apart at this precision. Fewer depth bits makes it worse and happen sooner; the band strip under the grid shows why, because with ordinary depth nearly every storable value is spent on the first few metres. Turn on reversed-Z and the bands even out. Turn the depth test off and only draw order decides — swap it and watch the wrong triangle win.

← all demos