Temporal display shaders: E-Ink, Playdate crank and Game Boy LCD
I wanted to know if a WebGL 2 ping-pong feedback shader could give live interactive HTML the temporal behaviour of hardware screens that stateless CSS filters can't express. Scroll, type, tick the boxes or press the buttons inside the screen below, then switch between E-Ink Carta partial-refresh ghosting with a full black flash, a 1-bit Playdate LCD driven by a draggable rotary crank, and a 4-shade olive Game Boy DMG-01 LCD with slow pixel persistence.
Show the code ping-pong WebGL 2 feedback, Bayer dithering, rotary crank and hit sync
- The drawable canvas and live scrollable reader. One
<canvas content="drawable" layoutsubtree>wraps#rd-screen, with an accessible crank pad overlaid on the right bezel in Playdate mode. - The ping-pong feedback fragment shader. Keeps E-Ink pigment ghosting across partial updates, runs the 220 ms black-to-white clearing waveform, and simulates slow passive-matrix LCD decay for Game Boy DMG.
- The display and hardware bezel shader. Applies 4x4 ordered Bayer dithering, Playdate 1-bit Sharp Memory LCD grid, Game Boy 4-shade olive dot matrix, and SDF rendering for the bezel and Playdate rotary crank.
- Two RGBA8 framebuffers on one
ElementGLcontext. Uploads the element once viagl.texElementSubImage2D(), runs the feedback pass off screen, and draws the full shell on screen. - Syncing hit boxes after drawing. Updates
updateElementGeometry()and togglesdataset.hitTickso taps, typing and text selection hit the rendered screen rectangle. - Playdate rotary crank input. Tracks circular pointer drags with
setPointerCapture(), wheel ticks and keyboard arrows to drive#rd-screen.scrollTop.
How it works
This experiment builds on /canvas-skin/ (styling live controls through shaders) and /time-scrubber/ (keeping temporal history across frames), and draws directly from three hardware screens: E-Ink Pearl and Carta partial-refresh panels, Panic's Playdate handheld (1-bit Sharp Memory LCD with a physical rotary crank), and Nintendo's Game Boy DMG-01 4-shade passive-matrix LCD.
CSS filters and SVG filter chains are stateless: they transform the current frame's pixels and forget every frame before it.
To model real E-Ink ghosting or passive-matrix LCD trails, the renderer has to remember what was on screen on the previous update.
I used one WebGL 2 context created with new ElementGL(canvas, ...) from /lib/element-gl.js and allocated two small RGBA8 ping-pong framebuffers on stage.gl.
Each time #rd-screen paints, scrolls or changes, ElementGL.upload() copies its picture into a WebGL texture via gl.texElementSubImage2D().
Pass 1 runs the feedback shader into the back framebuffer, reading both the live texture and the previous state texture.
In E-Ink mode it deposits lingering dark ghosting in the green channel whenever a dark pixel clears to white, holds that ghost while the panel is idle, and wipes it to zero during the 220 ms black-to-white full refresh waveform.
In Game Boy DMG mode it blends the live luminance toward the previous state with an asymmetric decay factor over a short settling loop, then stops requesting animation frames once the trail settles.
Pass 2 draws the entire handheld shell and screen in one quad using ElementGL.quad(): 4x4 ordered Bayer dithering, a 16-level warm paper ramp for E-Ink, razor-sharp 1-bit monochrome (#c7c3b8 and #2c2b28) with a pixel grid and SDF rotary crank for Playdate, and the 4-shade olive palette (#9bbc0f, #8bac0f, #306230, #0f380f) with subpixel gaps and cast pixel shadow for Game Boy DMG-01.
After sizing or switching modes, the page calls canvas.updateElementGeometry(screen, { canvasTransform }) and increments screen.dataset.hitTick so clicks, focus, typing and scrolling land inside the rendered screen box.
If WebGL 2 isn't available, the page falls back to a 2D canvas drawing #rd-screen with 5-argument drawElementImage() and copying into a plain non-drawable willReadFrequently: true scratch canvas for ordered Bayer dithering on each paint.
If the HTML-in-canvas API isn't enabled or the WebGL context is lost, #rd-screen moves out of the canvas so the reader stays usable as plain HTML until the context returns.
Live checks
These checks build their own small fixtures on the test stage and retire every canvas afterwards. Tap the button below to run them in this browser.
Findings
- Not verified yet in a live browser: none of the checks or visual modes have been run in Chromium 157 or on Chrome 159 for Android yet. Open the page in a browser with HTML-in-canvas enabled and run the live checks above to record measured results.
- Credits and inspirations: E-Ink Pearl and Carta partial-refresh waveforms, Panic's Playdate handheld (1-bit Sharp Memory LCD and physical rotary crank), Nintendo's Game Boy DMG-01 4-shade passive-matrix LCD, plus /canvas-skin/ and /time-scrubber/ on this site.
- One
ElementGLcontext is enough for both element uploads and off-screen ping-pong framebuffers. Reusingstage.glavoids opening a second WebGL context and keeps total GPU memory well under the mobile budget. - Mounting the Playdate crank hit target (
#crank-pad) as a sibling element over the right bezel withtouch-action: nonelets circular touch drags spin#rd-screen.scrollTopwithout blocking native touch scrolling or text selection inside the screen. - Because E-Ink ghosting only steps when the DOM updates and Game Boy DMG stops its settling loop after trails fade out, the canvas draws zero frames at rest.