uniform shader image; uniform float2 imageSize; uniform float radius; uniform float segments; half4 main(float2 coord) { float2 uv = coord / imageSize; float2 normCoord = 2.0 * uv - 1.0; // to polar coords float r = length(normCoord); float phi = atan(normCoord.y, normCoord.x); r = r - mod(r, radius) + 0.03; phi = phi - mod(phi, segments); normCoord.x = r * cos(phi); normCoord.y = r * sin(phi); float2 textureCoordinateToUse = normCoord / 2.0 + 0.5; textureCoordinateToUse *= imageSize; return image.eval(textureCoordinateToUse); }