Log in
TechniqueBy HypernaturalVersion 1, updated

Float a screen in 3D

hn/python-float-a-screen-in-3d

Render an app walkthrough as one real screen floating in 3D over a generated table and room: the pages change on that screen (a flip that shows the next page on its back, a slide inside the window, or a crossfade), photos fly onto their slots and cast shadows, and a 3D cursor lifts off the screen between targets and presses onto it. Local and free with moderngl on the GPU, about 30 ms a frame; the whole shot is a JSON spec. Use for a product or app walkthrough that should feel like a physical object rather than a flat screen recording.

SKILL.md

Give it the real screenshots of one flow, a table image and a room plate, and a shot spec; get a 1920×1080 MP4 of one screen floating as a thin rounded card above the table, gently bobbing, with the pages changing on it, photos flying in, and a cursor that moves in 3D and casts a soft shadow on the screen. Depth of field, motion blur and real shadows make it read as an object on a set. Rendered locally: a 12.8 s shot took 11 s on an Apple M1 Max.

For a held screen revealed part by part in 2D, use hn4a-compositor-make-product-ui-exciting; for UI whose data must change, rebuild it (hn4a-compositor-rebuild-product-screen). Which one fits the viewer's need is guide-show-a-product-on-screen.

Inputs

  • The pages: one PNG per state you show, all the same size, captured at 2× (2986×1714 from a 1493×857 window; guide-pull-product-highlights for capturing). Capture both sides of every change: the empty and the filled editor, so the photos that fly in are cut from the filled page and land exactly on it.
  • The set: a top-down table image and a room plate (nano-banana-plates-for-a-3d-scene; which set fits is guide-stage-a-3d-render). Either can be null.
  • Every pixel the shot touches: click targets and photo slots, read off a gridded full-size page (python-contact-sheet with --grid 50) or from the page's own layout times 2.
  • If cuts land on music, its beat grid (python-map-song-bars).

Run it

Write references/screen3d.md's script into the job's scripts/ as screen3d.py, unchanged. Write the spec to work/screen3d/spec.json from the example in references/spec.md. Lint it, render stills, then the shot:

exec("python", ["scripts/screen3d.py", "work/screen3d/spec.json", "work/screen3d/shot.mp4", "--lint"],
     cwd="<job>", skill="python-float-a-screen-in-3d")
exec("python", ["scripts/screen3d.py", "work/screen3d/spec.json", "work/screen3d/shot.mp4",
     "--still", "2.0,2.7,4.5,7.5,8.1,10.6", "--sub", "16"], cwd="<job>", skill="python-float-a-screen-in-3d")
exec("python", ["scripts/screen3d.py", "work/screen3d/spec.json", "work/screen3d/shot.mp4"],
     cwd="<job>", skill="python-float-a-screen-in-3d")

The first line it prints names the GPU (renderer: Apple M1 Max). A software renderer there means minutes a frame, not milliseconds: stop and say so.

Writing the spec

What worked on the test shot (references/spec.md has it whole):

  • Camera: open wide (9.5 units, azimuth −17°, elevation 13°) and glide in over 1.4 s. On each beat, push to 3.7–3.9 units, aimed 55–60% of the way from the screen's centre toward the thing being clicked. At 5.0–5.7 units and 35% the person found it "zoomed out a bit from the action"; at 3.6 units with the screen filling the frame, it stopped reading as 3D.
  • Swap the azimuth's side between pages (−10°, then +10°), so the screen is always seen at an angle.
  • Flip (0.85 s) between steps of the flow, alternating direction, with a pull-back of 1.3 on the camera key after it. The screen drops back 0.75 and rises 0.12 as it turns, then settles with a small overshoot.
  • Slide (0.62 s) for the next page within a step. Cut for a change on the same page (a panel opening).
  • Cursor: fly in from "cam" [1.0, -0.55, 1.5] (big and out of focus past the lens), approach at hz 0.25–0.3, touch (hz 0) 0.1 s before the click and stay 0.1 s after. Between targets it arcs 0.22 off the screen by itself. Through a flip, park it near the centre at hz 0.95: its keys are in the screen's rest frame, so it stays put while the screen turns under it. Leave toward "cam" [1.4, 0.75, 1.6].
  • Photos flying in: start them about 0.6 s before their cut, falling 0.4 s and 0.2 s apart for a grid. The cut to the filled page must come after the last one settles (start + fall + 0.16 s); --lint checks it.

What you get

shot.mp4: H.264, CRF 15, yuv420p, BT.709 tags, at the spec's size and fps, picture only. With --still, PNGs named shot_<t>.png instead.

Tips and traps

  • One screen, its pages changing on it. A first take with four screens in a row and the camera flying between them was "cool", but the person asked for one screen with transitions between its pages.
  • No tone curve: the screen is drawn in linear light and converted straight back, so the UI's whites stay white. A filmic curve greys them.
  • Averaging 32 jittered sub-frames gives motion blur, depth of field and smooth edges in one pass, with no MSAA. 16 is enough for stills.
  • Shadows are worked out from flat shapes (the screen, each photo, the cursor sprite) and soften with distance. Two faults fixed in the script: the cursor's blurred shadow streaked lines across the frame until samples outside the sprite were zeroed, and photos high above the screen cast muddy grey squares until their shadows faded with distance.
  • GL's texture rows run bottom-up: the script flips each image once on load. An early test flipped twice and the screens came out upside down.
  • Reading the page: at 3.8 units a 2× capture is drawn about 2.6× smaller, so headings, prices and buttons read and small print does not. Push in only on what must be read.
  • Captions and music are added afterwards. Over the busy set a caption needs a solid pill behind it.
  • moderngl isn't in the app's own Python; skill set to this skill adds it.

Check it

  • --lint prints spec ok: times in order, every page known and the same size, a cursor key down on every click, the photos settled before their cut, and the cursor clear of the screen through every flip.
  • Stills at every click, mid-flip, mid-slide and each photo landing, on a contact sheet (python-contact-sheet). A page must read the right way round after a flip; the cursor never goes inside the screen; nothing pops in.
  • ffprobe-inspect-media on the delivered file: the size, the spec's duration, and duration × fps frames.
  • Show the person stills first, then the moving shot, before adding captions and music.

FAQs

Render an app walkthrough as one real screen floating in 3D over a generated table and room: the pages change on that screen (a flip that shows the next page on its back, a slide inside the window, or a crossfade), photos fly onto their slots and cast shadows, and a 3D cursor lifts off the screen between targets and presses onto it. Local and free with moderngl on the GPU, about 30 ms a frame; the whole shot is a JSON spec. Use for a product or app walkthrough that should feel like a physical object rather than a flat screen recording.

Install Hypernatural Desktop, a free Mac app, and connect it to Claude Code, Codex or Claude Desktop. Then describe the video you want and your agent finds the skill itself, or paste this page's link (https://hypernatural.ai/skill/hn/python-float-a-screen-in-3d) and it installs hn/python-float-a-screen-in-3d and follows it.

Nothing. The skill is free and runs with tools on your own Mac, like python and ffmpeg.

Yes. Ask your agent to adjust it for your job, or to save its own version. You can publish your version under your own handle so anyone can install it.

Go make something cool.

Install the app, open your agent, describe the video. That's the whole onboarding.

Sticker HypernaturalSticker BannerSticker TVBoy