Video as a material for editable text

The large text below is two editable HTML elements in one canvas. A shader takes their picture as one texture and a video frame as a second. Type in the text, select it, and pick an effect. Under the code listing, the same fill is built three times with CSS and no shader.

VIDEO IN TYPE

Edit these words. The browser wraps them, places the caret and draws the selection. The canvas receives the result as a picture and a shader fills it with the video.

Show the code text texture, video texture, one shader, and the 2D and CSS versions
  1. The markup. Two contenteditable elements in a drawable child of the canvas. The video is outside the canvas.
  2. The CSS. White text on a clear background. The font size follows the canvas width, so the text wraps again when the canvas changes size.
  3. WebGL 2: two textures. texElementSubImage2D() for the text and texImage2D(video) for the frame, in the paint handler.
  4. The fragment shader. Six effects. Coverage is the smallest of the three colour channels.
  5. 2D canvas: no shader. drawElementImage(), then the video with source-in or source-out.
  6. WebGPU. drawElementImageToTexture() for the text and copyExternalImageToTexture() for the frame.
  7. When to paint. The video isn't a canvas child, so the page asks for a paint for each video frame.
  8. The CSS for the three versions with no shader.
  9. The markup for the three versions with no shader.

The fill without a shader

Each box below plays the same video. The first two can be edited.

BLEND
Plain DOM, no canvas. White text on a black box with mix-blend-mode: multiply, over a <video>.
DRAWN
The same markup as a drawable canvas child, drawn by one drawElementImage() call. The blend is in the element's picture.
A <video> with clip-path: url(#…) to an SVG <clipPath> that holds <text>. SVG text doesn't wrap and can't be edited.

How it works

Live checks

Each check builds its own small canvas in a corner of the window. The text above isn't touched. One check selects text in its own fixture, which clears a selection made elsewhere on the page for a moment and then restores it.

ResultExperimentDetail

Findings

From Chromium 157 headless with software rendering and software video decoding, 2026-11-21. The rows above say what your browser does.