Case study
Transparent video on the web
Path-traced glass
One 1.58 MB MP4
Forged in light,
shaped in glass.
A path-traced glass object, playing on the page with a real transparent background, in every browser, from a single ordinary MP4. Here's why it had to be video, and how it works.
01 Why not render it live?
The material is
path-traced.
The orb is a Blender Cycles material. Its sparkle comes from a trick that only works when light is simulated, not rasterized.
- Random IOR per sample. White noise drives the refraction index between 1.4 and 1.5. Every light sample bends a little differently, and hundreds of samples average into that crystalline glitter.
- Faked dispersion. The same noise feeds a rainbow ramp into the refraction color, so light appears to split.
- Real light paths. Rays enter the sphere, bounce inside it, exit through the spines and refract the object itself.
WebGL rasterizes. Its glass is one screen-space refraction of a blurred backdrop: no internal bounces, no glass seeing glass. At one sample per pixel per frame, the random IOR becomes flickering static. Browser path tracers exist, but they converge over seconds, standing still, on a desktop GPU. Not at 60 fps while bouncing on a phone.

02 Why not an image sequence?
Same 90 frames.
92× lighter.
PNG keeps transparency everywhere, which is why scroll-driven image sequences are the usual fallback. But every frame is a full lossless image, downloaded and decoded on its own. Compressing the frames to WebP cuts that to 22.6 MB, still 14× heavier than the video.
- One PNG frame
- 1.62 MB bigger than the entire video
- Files to request
- 90 → 1 one HTTP request, streamed
- At 20 Mbit/s
- 58 s / 9.0 s → 0.6 s time to download, no overhead
Linear scale. Measured from this project's files: EXPORT/0001–0090.png vs glass-stack.mp4.
03 Why not a video with alpha?
No single format
works everywhere.
Transparent video exists, but each browser family wants a different file, and one of them can only be made on a Mac. The standard method serves both from one <video> tag, HEVC listed first: Safari takes it, everyone else falls through to the WebM.
| Browser | Format with alpha | The catch |
|---|---|---|
| Chrome, Firefox, Edge | WebM, VP9 with alpha | Fine: Premiere's WebM export has an Include Alpha box |
| Safari (macOS, iOS) | HEVC with alpha (.mov) | Safari plays VP9, but not VP9 with transparency |
- HEVC with alpha is an Apple extension. It can only be encoded on macOS (Compressor or Apple's encoder).
- Premiere Pro 2026's HEVC export has no alpha option, and Media Encoder doesn't export it on Mac or Windows.
- No Mac was available. ProRes 4444 carries alpha, but it's a mastering format, not something to ship to a browser. An online ProRes-to-HEVC-alpha converter exists (Touchpix), but it wasn't tested.
The goal: a short looping render on its own layer between the background and the CTA, on every device, without falling back to a PNG sequence.
04 The workaround
Hide the alpha
in plain sight.
Stack color and transparency in one ordinary, double-height video, then rebuild it in the browser. The codec never has to know about alpha, so one file plays everywhere.
- Top half: colorThe render, composited over black.
- Bottom half: matteWhite is opaque, black is transparent.
- One MP4Plain H.264. Chrome, Firefox and Safari all decode it.
- One shaderWebGL reads RGB from the top, alpha from the bottom, and draws it on a canvas.
The file on this page
- Frame
- 1080 × 2160 two 1080² halves
- Codec
- H.264 no alpha support needed
- Timing
- 30 fps · 3 s 90 frames, looped
- Size
- 1.58 MB one request, streams as it plays
What the page needs
- A hidden <video> with autoplay, loop, muted, playsinline.
- A WebGL canvas: only a shader can apply the matte.
- Frame uploads: each new video frame becomes the texture.
- Layers: background, then the canvas, then the CTA.
- Click-through:
pointer-events: noneand a transparent canvas, so the CTA stays clickable.
The whole trick, in GLSL
// uv.y: 0 = top of the visible frame
vec3 rgb = texture2D(video, vec2(uv.x, uv.y * 0.5)).rgb; // top half
float a = texture2D(video, vec2(uv.x, 0.5 + uv.y * 0.5)).r; // bottom half
gl_FragColor = vec4(min(rgb, vec3(a)), a); // color was over black: already premultiplied05 Building it in Premiere Pro 2026
Nine steps,
no plugins.
- SequenceOne custom sequence at double height, 30 fps, square pixels: 1080×2160 for this orb.
- NestRendered frames on V2, select all, Nest. The nest behaves like one clip.
- DuplicateAlt-drag the nest to V3. V3 is the color copy, V2 the matte copy.
- PositionScale stays 100. V3 centered in the top half, V2 in the bottom half (540, 540 and 540, 1620 at 1080×2160).
- White solidA pure white Color Matte on V1, full frame, same length as the footage.
- Track Matte KeyOn the solid: Matte = Video 2, Composite Using = Matte Alpha. Don't move the solid; it moves the matte.
- Keep V2 visibleHiding V2 removes the matte and turns the whole frame white.
- CheckColor on top, a white silhouette below. Transparent areas export as black: white on black, exactly the matte the shader needs.
- ExportH.264 .mp4, no alpha options. Then re-encode it for phones.
06 It broke on phones. Silently.
Worked on one iPhone.
Not on the next.
An earlier build of this technique played on desktop and on an iPhone 17 Pro Max, but not on an iPhone 17 Pro or a 14 Pro Max. No error on screen. Not the file size, not the connection (5G), not the chip: same-chip phones disagreed. Why one phone accepted it is still unknown.
The headers gave it away: Premiere had tagged the H.264 stream level 6.0, Main profile. Desktop browsers don't care. Phone hardware decoders can refuse a stream flagged that high.
Playing on a computer and one phone is not "plays everywhere." Test a second phone, and read the profile and level of what the editor exported.
video readyState=0 error=4 size=0x0Error 4 = media source not supported. The decoder rejected the file; the page code was fine.
The fix: re-encode before upload
ffmpeg -i source.mp4 -an -c:v libx264 \
-profile:v high -level 5.1 -pix_fmt yuv420p \
-crf 20 -movflags +faststart out.mp4High profile, 8-bit 4:2:0, level 4.1, or 5.1 for frames larger than 720×2560. After the re-encode it played on every phone tested, and the file got smaller too.
07 The bug that looked like broken alpha
The video was fine.
The background was gone.
Dropped into a production theme, the transparent video sat on solid black, which looked exactly like a failed matte. The shader was fine. The theme's base stylesheet had one rule:
div:empty { display: none; } /* theme base.css */The background layer was an empty <div>, so the theme hid it. With nothing behind it, the transparent canvas showed the black page. The standalone test page didn't load the theme's stylesheet, so it never showed up there.
- Fix:
display: block !importanton the background layer. This page does the same, and never relies on an empty div. - Not the cause: crossorigin attributes, rAF vs. requestVideoFrameCallback, shader precision, console logging.
Result
One file. Every browser.
Real transparency.
Two lessons from getting it live: guard the background layer's display rule, and re-encode for phones. Everything you've scrolled past is that one MP4.