GLSL shader example

Kaleidoscope UV Folding

Fold angle into one wedge and mirror it. Preserve radius so texture lookup reflects continuously across wedge axes.

Live example

Edit the code and the preview updates as you type.

What to observe

Kaleidoscope UV Folding.

Mechanism

Fold angle into one wedge and mirror it. Preserve radius so texture lookup reflects continuously across wedge axes.

The controlling code

float sectors=3.+floor(u_parameter*9.);float a=atan(p.y,p.x)+u_time*.1;float wedge=6.28318/sectors;a=abs(mod(a,wedge)-wedge*.5);vec2 q=length(p)*vec2(cos(a),sin(a));c=texture2D(u_texture,q+.5).rgb;

Experiment

Set u_parameter to 0 and then 1, taking sectors=3.+floor(u_parameter*9.) from 3 to 12. More mirrored wedges repeat around the same center while radius remains unchanged.

Debugging and cost

The folded coordinates still require only one texture sample per pixel. Replace q+.5 with q*.4+.5 to keep more lookups inside the fixture instead of clamping to its outer colors.

Understand the technique

Built-in functions used

Learn it step by step