I found this code online to convert my reflection vector into texture coordinates for a equirectangular environment map. It works, but the orientation is wrong and there is an annoying black dot in the center of the reflection. What's the best way to solve this?
#define PI 3.141592653589793
vec4 RadialLookup(sampler2D a_radialTex, vec3 a_coords, float a_mipLevel)
{
float r = length(a_coords);
float lon = atan(a_coords.z, a_coords.x);
float lat = acos(a_coords.y / r); // Remove divide if a_coords is normalized
const vec2 rads = vec2(1.0 / (PI * 2.0), 1.0 / PI);
vec2 sphereCoords = vec2(lon, lat) * rads;
return textureLod(a_radialTex, sphereCoords, a_mipLevel);
}
Edited by Chris_F, 12 January 2013 - 07:34 PM.






