title: Cube to Sphere mapping (inverse function wanted)
body: <p>I've came across a cube to sphere mapping function that provides a more uniform result than just normalizing the coordinates or other mapping methods. Unfortunately there is no unwrapping function.</p>
  <p>Source: <a href="http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html" rel="nofollow noreferrer">http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html</a></p>
  <pre><code>vec3 spherify ( vec3 v ) {
      float x2 = v.x * v.x;
      float y2 = v.y * v.y;
      float z2 = v.z * v.z;
      vec3 s;
      s.x = v.x * sqrt(1.0 - y2 / 2.0 - z2 / 2.0 + y2 * z2 / 3.0);
      s.y = v.y * sqrt(1.0 - x2 / 2.0 - z2 / 2.0 + x2 * z2 / 3.0);
      s.z = v.z * sqrt(1.0 - x2 / 2.0 - y2 / 2.0 + x2 * y2 / 3.0);
      return s;
  }
  </code></pre>
  <p>How could this be unwrapped back to a cube face? To wrap back to a square i use the following, though it doesn't unwrap the special squeezing of the coordinates.</p>
  <pre><code>vec3 cubify ( vec3 s ) {
      
      s.x = ( s.x / s.z );
      s.y = ( s.y / s.z );
      
      return s;
  }
  </code></pre>
  <p>Which looks as the following
  <a href="https://i.stack.imgur.com/zz9SS.png" rel="nofollow noreferrer">Mapping</a></p>