Sign in to follow this  

Equirectangular environment map

This topic is 1829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

 

[code]#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);
}[/code]

Edited by Chris_F

Share this post


Link to post
Share on other sites

This topic is 1829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this