Ink Field
- group .........
- 3D and WebGL scenes
- source ........
- https://ui.aryank.space/components/ink-field
- markdown ......
- /lab/ink-field.md
- human .........
- /lab/ink-field
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
A sumi-e ink field you can paint into, rebuilt from the InkField engine's mark-making pipeline. A spring-damped brush stamps grayscale geometry, an animated wind map decides which way ink creeps, and a diffusion shader spreads it under a rule that lets ink darken a pixel but never brighten one, so strokes accumulate instead of washing out. Colour only exists at commit time, which is why the same geometry can be replayed in any of 36 pigments with optional Kubelka-Munk mixing. Seven brush modes, six diffusion behaviours, five post effects, eight flow displacement styles and a six-material metallic etching pass. All ten GLSL shaders are the originals, transcribed byte-exact.
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* Ink can darken a pixel but never brighten one
Every diffusion step takes min(here, upwind). That single rule is the whole physics: density only ever increases, so strokes accumulate and overlap instead of washing each other out, and spreading ink can never invent pigment that was not painted.
* The stroke is grayscale until you let go
Diffusion runs on one channel so spreading ink cannot drift in hue, and colour is a separate mapping applied at commit. A live preview pass tints the draft meanwhile, which is why you see colour before the stroke has actually been encoded.
* The wind map is re-rendered every frame
Ink does not creep in a fixed direction; it follows an animated force field regenerated against a moving clock. A mark made now diffuses along a different field than the same mark made ten seconds later.
* Diffusion runs last, so it shows up next frame
The feedback pass is the final step of the frame, after the passes that display it. The simulation is always one step ahead of the picture, which is inherent to a ping-pong feedback system.
* Speed is subtracted from size, not multiplied
brushSizeNow = brushSize - brushSpeed. Move fast enough on a small brush and the width goes negative, breaking the mark into the dry gaps calligraphers call flying white.
* Brush identity is stored per pixel
On white paper a white stroke and bare paper are the same value, so a second buffer records which brush laid down each pixel. It is also why displacement runs twice: colour and identity must move together or the two drift apart.