• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Equirectangular environment map

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1Chris_F  Members

Posted 12 January 2013 - 07:15 PM

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
{
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;
}

Edited by Chris_F, 12 January 2013 - 07:34 PM.

### #2Chris_F  Members

Posted 13 January 2013 - 02:59 PM

The black dot seems to be caused by linear interpolation.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.