0

I tried to split equirectangular map to cubit map,it refer to https://stackoverflow.com/a/36976448/10988559, and it works(I think so) at here(jsfiddle).

      /** MAIN CODE **/
      void main() {
        vec3 xyz = uvToXYZ(vUv, ${face});
        float x = xyz.x;
        float y = xyz.y;
        float z = xyz.z;
        float theta = PI + atan(y, x);
        float r = pow(x * x + y * y, 0.5);
        float phi = PI_DIV_2 - atan(z, r);

        float uf = theta / PI2;
        float vf = phi / PI;

        if(uf > 1.0) {
          uf -= 1.0;
        } else if (uf < 0.0) {
          uf += 1.0;
        }

        gl_FragColor = texture2D(texture, vec2(uf, vf));
      }

BUT, Why singularity still exists in glsl and not exists in python? What's my fault? Thanks for any help.

here is a screenshot

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • to fix this you have to use real cube maps, converted will always have this artifact. btw, jsfiddle you reference as working also suffer from this problem – Alex Khoroshylov Jan 30 '19 at 09:37
  • @AlexKhoroshylov `float r = pow(x * x + y * y, 0.5);` is equal to `r = length(xyz.xy);` - see [`length`](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/length.xhtml) – Rabbid76 Jan 30 '19 at 16:44
  • @AlexKhoroshylov I mean it works(not too good...) – tang xiaoming Jan 31 '19 at 02:40

0 Answers0