title: How does this code sample from a spherical map?
body: <p>Going through this tutorial from:
  <a href="https://learnopengl.com/PBR/IBL/Diffuse-irradiance" rel="nofollow noreferrer">https://learnopengl.com/PBR/IBL/Diffuse-irradiance</a></p>
  
  <p>I encountered this piece of code:</p>
  
  <pre><code>const vec2 invAtan = vec2(0.1591, 0.3183);
  vec2 SampleSphericalMap(vec3 direction)
  {
      vec2 uv = vec2(atan(direction.z, direction.x), asin(direction.y));
      uv *= invAtan;
      uv += 0.5;
      return uv;
  }
  </code></pre>
  
  <p>To sample a image that looks like this:
  <a href="https://i.stack.imgur.com/m0o6j.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m0o6j.jpg" alt="Image"></a></p>
  
  <p>My question is where does this come from as well as the magic "invAtan" constant?</p>