I am trying to draw a rope by generating a mesh from a set of control points - however I get some weird issues that seem to be related to lighting when the mesh self intersects:
It looks like additive alpha blending to me but I am just using the standard shader (it happens with other shaders too though). If I turn off the light the issue goes away. I am guess it has something to do with the fact that the overlapping parts of the rope have the same z value? But any guidance on what is going wrong here would be greatly appreciated.
That’s exactly the reason. The standard shader, and really any lit shader in Unity, renders any lighting beyond the first directional light as additive passes, one for each light. The first pass of an lit opaque shader writes to the depth buffer, and the subsequent passes use that to prevent overdraw, but if everything is on the same z plane it causes overlapping areas to add together like you’re seeing. This will also happen if the shader is transparent as generally those don’t render to the depth buffer either.
The easiest solution is probably to very slightly offset the vertices of the mesh over the length, like add or subtract 0.0001 to the z position accumatively.