Jump to content

View more

Image of the Day

Full Syncs #screenshotsaturday favourites https://t.co/i1Flnwcg3l #xbox #ps4 https://t.co/m0v2F1SxGs
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

Equirectangular environment map

2: Adsense

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.


  • You cannot reply to this topic
1 reply to this topic

#1 Chris_F   Members   

3030
Like
0Likes
Like

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
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.


#2 Chris_F   Members   

3030
Like
0Likes
Like

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.