Feature idea: feed a shader with an SVG subtree rendered in the same frame (multi-pass in one video)

Open
#210 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

The proposal sketches a svgr! subtree passed to a shader via ShaderUniforms::layer, so the API surface and the offscreen rendering path are the places to look. Nothing in the payload names an existing file, so first confirm with the maintainer whether the feature is wanted and where the layer binding should live. Done means an agreed API and a design for the Skia GPU path with a CPU fallback, not a finished patch.

Written by the indexing model from the issue text.

Description

Motivation

I recreated @mnowakdesign's tracking-HUD look (the same one you posted) with a camera that films the screen: perspective tilt, depth of field focused on the tracked glyph, LED grid, bloom, chromatic aberration, per-scene palette, all in one SkSL pass.

The shader needs the flat screen as its input, so today it takes two fframes projects:

  1. flat renders the terminal + tracker at 3840×2160 to an mp4 (crf 8).
  2. lens reads it with get_synced_video_frame(..).into_image() and binds it as iChannel0.

That works (thanks for the video-frames-in-shaders support), but it costs a 4K h264 round trip per frame (disk, decode, compression artefacts under 3× magnification), two binaries, and a shared crate just so both passes agree on the timeline.

Idea

Let a shader take an SVG subtree of the same frame as a child image, rendered offscreen first:

let screen = fframes::svgr!(<g>{terminal}{tracker}</g>);
let layer = self.lens.draw(&frame, ShaderUniforms::new()
    .layer("iChannel0", screen, 3840, 2160)   // rendered offscreen, bound as `uniform shader`
    .float("uZoom", zoom));
fframes::svgr!(<image href={layer.href()} width="1920" height="1080" />)

On Skia this could stay on the GPU: draw the subtree into an offscreen surface and bind its image snapshot as the child shader, with no CPU readback. On the CPU backend it could fall back to rasterizing the subtree. Is this something you'd want in fframes? I can help with the API, an example or tests.

Example (C)

The project is at https://github.com/mrsarac/ff-tracking (MIT): 6 s, 12 scenes, a two-pass render plus a synthesized sound track (~40 s end to end on an M3 Pro). If it's useful, I can contribute a trimmed version as examples/screen-camera, now as a two-pass example or later as the single-pass demo of the feature above. Video: https://x.com/0xsarac/status/2108515856544317489

Dominant language
Rust
Stars
3.3k
Forks
118
Avg merge
1d 8h
Merged PRs (30d)
16

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dmtrKovalenko/fframes

All issues in dmtrKovalenko/fframes

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.