Film-develop file upload shader
I wanted to know if an ElementGL fragment shader can apply a darkroom negative-to-print chemical wave strictly inside an uploaded <img> frame while leaving the surrounding <input type="file">, <select> and buttons sharp and clickable. Drop an image, choose a file, switch sample prints, or scrub the bath slider.
Starting darkroom ElementGL shader...
Show the code rect-restricted chemical shader, file upload and hit sync
- Darkroom upload form inside a drawable canvas. Keeps the preview
<img>, hidden<input type="file">, film stock<select>and button in one semantic form. - Rect-scoped negative-to-print shader. Tests normalized UV against
uFrameUvso surrounding form controls pass through untouched while the photo goes from safelight negative through developer ripples to its chosen film stock. - Measuring the photo box without transform drift. Walks untransformed layout offsets to compute
uFrameUvand calibratesupdateElementGeometry()withgeometryUnit().
How it works
This experiment rebuilds Yanis Lebzar's Film Develop Upload (Memorables) using one ElementGL WebGL 2 context.
Everything lives inside a real <form drawable>, with local SVG data URLs for the built-in samples and URL.createObjectURL() when you drop or pick a local file so pixels stay same-origin and readable by texElementSubImage2D().
Rather than running the darkroom shader across the whole card and blurring text labels, measureFrameUv() computes the normalised rectangle of #print-frame from its layout offsets and passes it as uFrameUv.
Outside that rectangle, the fragment shader outputs crisp DOM pixels untouched.
Inside uFrameUv, an animated value-noise chemical front sweeps upward, shifting inverted safelight-amber negative tones into warm Portra, monochrome Tri-X, Prussian-blue Cyanotype or punchy Velvia colour while syncCardGeometry() keeps the file picker, stock menu and button clickable.
Live checks
These checks wait for a tap so the page keeps one WebGL context until requested. Each check runs inside its own isolated fixture on the test stage and retires its canvas afterwards.
Findings
- Measured in Chrome Canary
161.0.8200.0on 2026-12-04 at412x915(DPR2.625, SwiftShader WebGL): all 7 live checks passed with zero JS errors, zero lost contexts, zero open snapshots and zero horizontal overflow on a924x1192canvas (8.4 MB). - Bounding the shader via
uFrameUvkept the chemical inversion strictly inside the630x473print frame: atuProgress=0the photo readrgb(255,63,0), atuProgress=1it developed torgb(34,147,212), and atuProgress=0.5the undeveloped top readrgb(255,76,11)while the developed bottom readrgb(34,147,212)and the outer bar stayedrgb(255,255,255). - Changing the preset switched the corner sample from Neon
rgb(21,16,32)to Botanicalrgb(255,240,211), while file upload label,<select>and button hit tests all passed. - Blink does not stretch an
inset: 0child of<canvas layoutsubtree>to the canvas height, so at1280x900the form laid out at422x363inside a518x454canvas and its controls were hit-tested above where they were drawn. Sizing the form fromcanvas.clientWidthandcanvas.clientHeightthrough--card-wand--card-hfixed it: the form now measures518x454on desktop and352x454at412x915, and the file label, stock select and Re-develop button hit at their drawn centres with0pxvertical drift.