#version 430
#if 1
#define extern uniform
#define Image sampler2D
#endif

layout (binding=0) uniform sampler2D input;
in vec2 texcoord;
layout (location=0) out vec4 out0;

layout (location=2) uniform float num_sectors;

void main() {

	float angle = 2*3.14159/num_sectors;
	vec2 p=2.*(texcoord - vec2(.5,.5));
	float a = atan(p.y,p.x)+2*3.1415926;
	float part = a/angle;
	float sector,fangce;
	float fangle = modf(part,sector);
	int s = int(sector);
	int invert = s&1;
	float i = -float(2*invert-1);
	
	float tangle = i*fangle + invert*angle;
	p = vec2(0.5) + 0.5*length(p) * vec2(cos(tangle),sin(tangle));
	
	vec4 intex = texture(input,p);
	out0 = intex;
}
