spherical mapping artefacts

I have some problems with sphere map texturing in webgl.

My texture:

enter image description here

Now I texturize a sphere. Everything is OK, if the sphere is in front of the camera: enter image description here

The sphere is a unit-sphere (r = 1), defined with longitudes and latitudes.

But i get some artefacts, if i translate the sphere in x-direction -2.5 (without rotating the camera): enter image description here

This image is without mipmapping. And the following image is with mipmapping:

enter image description here

Vertices and normals seems to be ok.


precision highp float;

uniform mat4 mvMatrix;  // Matrix zum Transformieren des Verex vom model-space in den view-space
uniform mat4 mvpMatrix; // Matrix zum Transformieren des Vertex vom model-space in den clip-space
uniform mat3 mvNMatrix; // Matrix zum Transformieren der Vertex-Normale vom model-space in den view-space

attribute vec4 mV;  // Vertex im model-space
attribute vec3 mVN; // Vertex-Normale im model-space

varying vec2 vN;

void main(void)
   vec3 e = normalize( vec3( mvMatrix * mV ) );
   vec3 n = normalize( mvNMatrix * mVN );

   vec3 r = reflect( e, n );            
   //float d = dot(n, e);
   //vec3 r = e - 2.0 * d * n;

   float m = 2.0 * sqrt( 
      pow( r.x, 2.0 ) + 
      pow( r.y, 2.0 ) + 
      pow( r.z + 1.0, 2.0 ) 
   vN.s = r.x / m + 0.5;
   vN.t = r.y / m + 0.5;

   gl_Position = mvpMatrix * mV;

And fragment shader:

precision highp float;

uniform sampler2D uSampler;
varying vec2 vN;

void main(void)
   vec3 base = texture2D( uSampler, vN ).rgb;
   gl_FragColor = vec4( base, 1.0 );

Does anybody know, why i get these artefacts? I am working with windows and firefox.


Your surface normals are backward, or you're culling the wrong side in general. You've done something like azimuthal projection, but you're rendering the inside of the sphere instead of the outside, so you're seeing greater than 180 degrees, including the 'bridge' separating forward and back. See also: map projections, which shows that azimuthal mapping is conformal everywhere but excludes at least the true equator with line of sight.