Zen Garden WebGL — Raymarched Sand Raking Simulation

← Back to Visuals

About This Simulation

The Zen Garden renders a top-down sand bed entirely on your GPU using heightfield raymarching — a camera ray steps forward until it drops below the sand's height at that point, refined by a short binary search for a crisp intersection. Drag your mouse or finger across the sand and every stroke is stamped into a small ping-pong texture that the shader reads back each frame, so the grooves you rake genuinely persist rather than fading away as a decorative trail. Three raised stone islands sit permanently in the garden, each softly shadowed by a second raymarch cast toward the sun. Switch between dawn, noon and dusk lighting, adjust how wide your rake strokes are, and press Smooth Sand whenever you want a blank canvas again — the impermanence is the point.

Technique

Heightfield Raymarching

Drawing

Ping-Pong GPU Texture

Shadows

Soft Raymarched Sun Shadow

Reset

Eased Smooth-Sand Fade

Frequently Asked Questions

How does dragging my mouse actually rake the sand?

Every pointer movement is written into a small offscreen texture the GPU updates every frame. Each new brush stroke stamps a ringed groove pattern along the segment between your previous and current position, and that texture persists — unlike a purely visual trail, the groove stays in the sand because the same texture feeds back into itself as the next frame's starting point.

What is a ping-pong texture?

Ping-ponging means alternating between two textures: one is read as the previous state while the other is written as the new state, then their roles swap next frame. This is how the Zen Garden accumulates rake grooves over time entirely on the GPU — no history array, no CPU-side canvas, just two textures trading places every frame.

What is heightfield raymarching?

Instead of a generic signed-distance function, the sand is treated as a height map: at every point in the garden there is exactly one height value. The camera ray steps forward and checks whether it has dropped below the terrain height at that point; when it has, a short binary search between the last two steps finds the exact intersection. It renders raked sand and stone bumps without any 3D mesh data.

How does the smooth sand button work?

Pressing it fades the entire groove texture toward flat (zero height) over about two and a half seconds using an eased blend, rather than snapping instantly. The stones and the permanent circular rake pattern around them are unaffected — only the grooves you personally drew are erased, ready for a fresh drawing.

How are the stones lit and shadowed?

Each stone is a smooth raised bump blended into the sand height field. A second, shorter raymarch is cast from every visible surface point toward the sun direction; if that ray is blocked by rising terrain before it escapes, the point sits in shadow. The ratio of the ray's clearance to its distance produces a soft, naturally graded penumbra rather than a hard-edged shadow.

What do the three sun buttons change?

Dawn casts a low warm-orange light with long soft shadows and a muted rose sky. Noon lights the garden from almost directly overhead in bright neutral white with short shadows, showing the raked texture most clearly. Dusk casts a low rose-violet light from the opposite side, echoing the warm-cool contrast of Crystal Cave's light modes.

What is the Rake Width slider for?

It changes the radius of the groove ring stamped by your brush stroke, from a fine single-line rake to a broad wave pattern more like a garden rake with many tines. Try a narrow width for delicate spiral patterns and a wide one for sweeping ocean-like waves across the whole garden.

What sound pairs best with the Zen Garden?

Wind Chimes or Tibetan Bowl from the Sound Mixer suit the slow, contemplative pace of raking sand. Gentle Rain also works well if you prefer an ambient backdrop without discrete musical notes while you draw.

Does the Zen Garden work offline?

Yes. ASMR Sanctuary is a Progressive Web App. After your first visit the Service Worker caches the page and all assets, so raking the sand garden works fully offline with no internet connection required.

My device is struggling — any performance tips?

Shrink the browser window or zoom in to lower the canvas resolution — the heightfield raymarch cost scales with pixel count. The groove texture itself is a fixed small resolution regardless of screen size, so drawing performance stays constant. Pausing stops the render loop entirely, which also stops the rake simulation from decaying while you are away.