title: LineRenderer on Mesh surface
body: <p><strong>Goal:</strong> Render distance lines between two points on the surface of a mesh-based primitive (i.e. sphere, cube, etc).</p>
  
  <p><a href="https://i.stack.imgur.com/NKx3I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKx3I.png" alt="Lines drawn on surface of sphere"></a>
  <strong>Current Solution:</strong> Iteratively traverse distance line between two end points and "reverse" raycast through this point somehow. <em>Since the distance line directly connects both vertices through the mesh, the according points on the mesh surface are required.</em> </p>
  
  <pre><code>Ray ray = new Ray();
  RaycastHit raycastHit;
  ray.origin = posOnDistanceLine;
  ray.direction = raycastNormal.normalized;
  // Reverse ray since we can't raycast from inside the mesh
  ray.origin = ray.GetPoint(1);
  ray.direction = -ray.direction;
  </code></pre>
  
  <p>Lines are then drawn using Unity's <code>LineRenderer</code> which is being populated with positions of vertices whenever a change in normals (to previous raycast) is identified. </p>
  
  <p><strong>Issues:</strong> </p>
  
  <ul>
  <li><p>Horrible performance (as 100 rays are cast whenever the end points move).</p></li>
  <li><p>Solution doesn't always work and produces unexpected, jagged lines / points.</p></li>
  </ul>
  
  <p><strong>Question:</strong> 
  Is there a better approach to implement this?</p>