Render glitches nearly coplanar faces

Hi there!

I’m working with a triangulation geometry and I’m getting some glitches where:

  • several primitives share one edge: sort primitives in depth camera axis ? and _.depthCompareFunction = .lessEqual

  • two primitives or are nearly to coplanar: improve rasterizer depth order test. How?

I need all the faces, inner too, because I’m working in a crystal shader with transparency

Screen Shot 2021-05-11 at 11.52.30

Any hint?

I haven’t had this problem. But I did find several things to research:

I believe this is the same as OpenGL’s glPolygonOffset:
https://developer.apple.com/documentation/metal/mtlrendercommandencoder/1516269-setdepthbias

With glPolygonOffset, this is really old so I don’t know how valid it is, but maybe worth following up:

Same old source - this looks interesting using Stencils:

Discussion of various methods:

1 Like

Thanks @caroline for all this stuff!!
Has led me to the solution