Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
Last active January 19, 2017 08:15
Show Gist options
  • Save suzumura-ss/5885266 to your computer and use it in GitHub Desktop.
Save suzumura-ss/5885266 to your computer and use it in GitHub Desktop.
uniform sampler2D tex;
float M_2PI = 6.283185307179586;
float SQRT2 = 1.4142135623730951;
void main()
{
float x = (gl_TexCoord[0].x - 0.5);
float y = (gl_TexCoord[0].y - 0.5);
float r = sqrt(x*x+y*y);
float s = atan(y, x)/M_2PI;
if (y<0.0) {
s = s + 1.0;
}
s = (1.75-s);
if (s>1.0) { s = s - 1.0; }
gl_FragColor = texture2D(tex, vec2(s, r*SQRT2));
// gl_FragColor = texture2D(tex, vec2(s, 1.0 - r*SQRT2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment