Capillary ink-bleed scene dissolve

I wanted to know if one ElementGL WebGL 2 canvas could pour dark ink across a cream paper notebook from wherever you tap, letting pigment race along paper fibres and DOM luminance edges before revealing a live midnight obsidian studio underneath. Tap open paper or slate to pour from that point, edit either field, or drag Scrub % to inspect the wet rim.

FOLIO 04 · COTTON RAG 0 stamps

Field notebook: capillary wash

Sumi pigment wicks along woven rag fibres and bright margins before soaking into dark serif text. Tap empty paper anywhere to pour into the studio view.

Note: Cold press 300 gsm · oak gall

STUDIO 09 · OBSIDIAN SLATE Cyan #38E8FF · 0 drops

Midnight ink studio

The wet pigment rim clears into crisp studio controls whose hit boxes switch on once the pour settles at 100%.

Plate: Obsidian plate · cyan #38e8ff

Starting canvas…

Show the code two drawable scenes, capillary FBM shader, tMs envelope, geometry sync and 2D fallback
  1. Two contrasting live scenes in one canvas. Both #ib-scene-a and #ib-scene-b sit inside one <canvas content="drawable" layoutsubtree>, with inert disabling the inactive layer.
  2. Capillary ink-bleed fragment shader. Combines radial distance from uOrigin with domain-warped FBM paper permeability, DOM luminance edges, a damp moisture fringe and a dark wet pigment rim.
  3. Explicit tMs transition envelope. Advances launchBleed() and stepBleed() from explicit timestamps and snaps immediately when reduced motion is active.
  4. Gated ElementGL upload path. Waits for hasPainted inside paint and calls stage.begin() before stage.upload() with UNPACK_PREMULTIPLY_ALPHA_WEBGL enabled.
  5. Hit-box sync with geometryUnit(). Flips inert and pointer-events cleanly, calibrates transforms via updateElementGeometry() and toggles data-hit-tick.
  6. Five-argument 2D radial mask and plain-HTML fallbacks. Clips an organic ink pool in 2D using five-argument drawElementImage() or moves both scenes into #plain-host on context loss.

How it works

Both #ib-scene-a and #ib-scene-b sit inside a single <canvas content="drawable" layoutsubtree> backed by one ElementGL WebGL 2 context. At creation and inside onRestored, the context sets gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) so crisp serif ink, input carets and cyan borders upload cleanly via gl.texElementSubImage2D(). Uploads are gated on hasPainted inside the paint handler, calling stage.begin() before stage.upload().

When you tap open paper or slate (or press Pour ink), launchBleed() records the normalised tap origin (ox, oy) and advances the bleed front over 1,350 ms using stepBleed(bleed, tMs). In the fragment shader, Euclidean radial distance from uOrigin is warped by four-octave domain-warped FBM paper fibres plus perpendicular weave channels. A five-tap sample of the outgoing DOM texture adds luminance and edge magnitude so ink spreads slightly faster across bright open margins and wicks along printed borders.

Along the advancing boundary, an outer moisture band dampens the outgoing paper, followed by a dark sumi-indigo wet pigment crest (rgb(2, 3, 5)) that reads darker than both cream rag paper and the midnight obsidian slate before revealing crisp Scene B controls inside. While mid-transition, both scenes are marked inert so partial controls don't steal taps. Once settled at 0% or 100%, syncSceneGeometry() calibrates transforms with geometryUnit(), calls canvas.updateElementGeometry() and toggles data-hit-tick to clear Chromium's hit-test cache.

Scrolling vertically over the stage works by touch via touch-action: pan-y, while selectstart is cancelled outside <input> elements so taps don't select page labels. Animation pauses off screen via IntersectionObserver and when document.hidden is true. Under prefers-reduced-motion: reduce (or the Reduced motion checkbox), pours snap straight to the destination view. Without WebGL 2, a 2D context clips an organic radial mask using five-argument drawElementImage(), and context loss moves both scenes into #plain-host.

Live checks

Checks wait for a tap so the demo opens with one WebGL context. Each check builds an isolated fixture on testStage() and retires its canvas afterwards.

Findings