Is there a way/method/function that takes a World Space Direction vector, and gets the correct pixel on a "latlong" format HDR texture?
It's easy with a cubemap (textureCube) but I need to do this in one pass, using the texture2D latlong HDR, in World Space.
I found this online, but for me it produces a messed up projection:
const vec2 invAtan = vec2(0.1591, 0.3183);
vec2 SampleSphericalMap(vec3 v)
{
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
uv *= invAtan;
uv += 0.5;
return uv;
}
It's supposed to take in a world space vector, but when I pass it the face-normal vector of the mesh in the fragment shader, the mapping is insanely distorted...
Has anyone ever done this before?
Aucun commentaire:
Enregistrer un commentaire