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

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:
https://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node29.html

Same old source - this looks interesting using Stencils:
https://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node20.html

Discussion of various methods:

1 Like

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