Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: TinyPlanet shader problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    12

    TinyPlanet shader problem

    Hello, I'm using the next shader to create tiny planet images.
    The problem I'm facing is that though it renders perfectly in Desktop machines, when it comes to Android mobile devices it renders also a small square-artifact right at the center of the final image. Can anyone spot the problem? Thank you

    Code :
    varying vec2 v_texcoord;
    uniform sampler2D u_texture;
     
    void main()
    {
    	float PI = 3.14159265358979323846264;
    	float HALF_PI = PI * 0.5;
    	float TWO_PI = PI * 2.0;
    	float SCALE = 0.45;
    	float PLANET_FACTOR = 4.7;
     
    	float cosphi0 = cos(PLANET_FACTOR);
    	float sinphi0 = sin(PLANET_FACTOR);
     
    	float x = (v_texcoord.x - 0.5) / SCALE;
    	float y = (0.5 - v_texcoord.y) / SCALE;
    	float rho = sqrt(x * x + y * y);
    	float c = 2.0 * atan(rho);
     
    	float sinc = sin(c);
    	float cosc = cos(c);
     
    	float lambda = atan(x * sinc, rho * cosc);
    	float phi = asin(y * sinc / rho);
    	float cosphi = cos(phi);
     
    	float x1 = cos(lambda) * cosphi;
    	float y1 = sin(lambda) * cosphi;
    	float z1 = sin(phi);
    	lambda = atan(y1, x1 * cosphi0 + z1 * sinphi0);
    	phi = asin(z1 * cosphi0 - x1 * sinphi0);
     
    	vec2 coord = vec2((lambda + PI) / TWO_PI, (phi + HALF_PI) / PI);
     
    	gl_FragColor = texture2D(u_texture, coord);
    }
    Last edited by sanchiski; 02-20-2015 at 08:17 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •