Skip to main content
Shaders for Games (GLSL) Lesson 11 of 20

Truchet tiles — patterns that connect

Give each cell a random orientation and watch a maze of flowing curves appear.

A plain grid repeats the SAME cell everywhere. The next step is a tile that comes in a few variations, dropped at random per cell — and if the variations are designed so their edges always line up, the whole surface joins into one connected pattern. That is a Truchet tiling, and it is how shaders make mazes, circuit boards, pipes and woven knots.

The classic Truchet tile has two quarter-circle arcs joining opposite corners. Each cell randomly either keeps the tile or flips it (here, mirror the x inside the cell when the cell’s random value is over 0.5). Because every arc still meets the cell edge at the same two points, flipped or not, the arcs connect across cell borders into long flowing curves. One random bit per cell, and an ordered grid becomes an endless woven maze.

That maze of curves came from one tile and one coin-flip per cell. It builds on everything in the patterns and randomness lessons: floor() for the cell, fract() for the position inside it, and random() for the per-cell choice. Swap the arcs for diagonal lines and you get a maze; thicken them and you get pipes.

Tip Because the tiling is driven by per-cell randomness with no single correct image, this is a playground, not a graded exercise. Try more cells, thicker lines, or feed the cell’s random value into a color so each tile is tinted.
Quick check

Why do Truchet tiles connect into continuous curves across the grid?

▶ Weave your own tiles Change the cell count, thicken the arcs, or tint each tile by its random value.
Wayline
Tools, assets and tutorials for game makers
Get started