GLSL shader example
Truchet Tile Maze
Each tile selects one of two arc orientations with endpoints at edge midpoints, preserving connections after random flips.
Live example
Edit the code and the preview updates as you type.
What to observe
Truchet Tile Maze.
Mechanism
Each tile selects one of two arc orientations with endpoints at edge midpoints, preserving connections after random flips.
The controlling code
vec2 q=p*6.,id=floor(q),f=fract(q);if(hash(id)>.5)f.x=1.-f.x;float d=min(abs(length(f)-.5),abs(length(f-1.)-.5));c=mix(c,vec3(.9,.7,.25),1.-smoothstep(.025,.045,d));
Experiment
Change the tile scale q=p*6. to q=p*3.. The quarter-circle paths become larger while their endpoints still meet at tile-edge midpoints.
Debugging and cost
Each tile evaluates two circle distances and optionally mirrors f.x using hash(id)>.5. Raise .5 to 1. to disable those random flips and reveal the regular repeating arc arrangement without a neighbor search.