Backface Culling on LineRenderer

Hey folks!

I’m currently working on a project that requires LineRenderers that can be custom drawn by the user. The problem I’m facing is that when a LineRenderer makes a turn, it’ll often have artifacts, as can be seen in the image below

if I try front-face culling, it shows only the artifacted areas, as seen here:

However, if I try to back-face cull, the artifacts are still visible, as can be seen on the first image.

I’m wondering if anyone would have any idea how to stop these artifacts from being visible?

Well, the problem is not back or front face culling as by default most shaders use backface culling. The problem is that you have “negative” faces and overlapping faces because given your linewidth and the sharp bend the linerenderer wasn’t able to create a continuous triangle strip. Usually all faces will actually face the camera but your “line” is basically “folded” because the bend is too sharp. It all boils down to the algorithm Unity uses to create the mesh for the given points.

You can try adjusting the numCornerVertices and see if it gets better. However infinitly sharp corners will always give you trouble as it’s not possible to have a continuous gradient without overlapping. The only alternative would be to create a custom mesh and ensure to have no overlaps. Though i’ve done this in the past and it’s a pain to cover all edge cases. If you want to actually “draw” freely you may want to “draw” to a texture / blending mask. Though it’s difficult to recommend alternatives if the actual purpose is not clear.