Pixel-Composer/shaders/sh_polar/sh_polar.fsh

18 lines
436 B
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
#define pi2 1.57079
#define pi 3.14159265
2022-01-13 05:24:03 +01:00
void main() {
vec2 center = v_vTexcoord - vec2(0.5, 0.5);
float radius = distance(v_vTexcoord, vec2(0.5, 0.5)) / (sqrt(2.) * .5);
float angle = (atan(center.y, center.x) / pi + 1.) / 2.;
2022-01-13 05:24:03 +01:00
vec2 polar = vec2(radius, angle);
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, polar );
}