Log in
TechniqueBy HypernaturalVersion 1, updated

Render printed products in 3D

hn/python-render-printed-products-in-3d

Render printed products in 3D from their real print files, so every frame shows the print exactly: a 5x7 card that flips front to back, an 11 oz mug that turns until its design faces the camera, and a shower of cards and mugs that fall like paper and pottery and land into a flat-lay on the music's beats. Glazed-ceramic mugs, shadows, motion blur, on a generated table with a room behind. Local and free with moderngl on the GPU. Use for print-on-demand and photo products (cards, mugs) where a video model would smear the printed text.

SKILL.md

Give it the products' print files; get 1080p shots in which the print is the real file, exact on every frame: a hero card flip, a hero mug turn, and cards and mugs raining onto a table to the music. Real geometry, glazed ceramic, shadows and 48-sub-frame motion blur; local and free (the 4 s finale rendered in about 10 s on an Apple M1 Max).

A video model redraws printed text and photos as it moves them; this draws the file. For the product in a person's hands or a filmed scene, animate a still instead (guide-animate-a-shot, guide-keep-small-details). For an app screen, use python-float-a-screen-in-3d.

Inputs

  • Card fronts at 5:7 (resized to 1024×1414), and for the hero card its real back. Every other card shows a plain back: white paper with a small mark of the brand's. Left blank, tumbling backs read as flat grey slabs.
  • Mug wraps: the 11 oz print file, about 2.4:1 (8.5 × 3.5 in), wrapped round the body except a 60° gap at the handle.
  • The handle: references/handle-11oz.md, written to refs/handle_11oz.json.
  • The set: a table image and a room plate (nano-banana-plates-for-a-3d-scene, chosen with guide-stage-a-3d-render).
  • For the rain: the music's beat length and the beat the burst starts on (python-map-song-bars).

Run it

Write references/scene3d.md, references/hero.md and references/rain.md into the job's scripts/ as scene3d.py, hero.py and rain.py, unchanged. Run each from the job folder:

exec("python", ["scripts/hero.py", "mug", "renders/hero_mug.mp4", "--print", "refs/mug_wrap.png",
     "--handle", "refs/handle_11oz.json", "--table", "refs/table.png", "--tint", "1,0.8,0.77",
     "--backdrop", "refs/room.png", "--table-rect", "-14,-9.5,14,14"], cwd="<job>", skill="python-render-printed-products-in-3d")
exec("python", ["scripts/hero.py", "card", "renders/hero_card.mp4", "--front", "refs/card_front.png",
     "--back", "refs/card_back.png", "--table", "refs/table.png", "--tint", "1,0.8,0.77",
     "--backdrop", "refs/room.png", "--table-rect", "-14,-9.5,14,14"], cwd="<job>", skill="python-render-printed-products-in-3d")
exec("python", ["scripts/rain.py", "open", "renders/rain_open.mp4", "--cards", "refs/cards", "--mugs", "refs/mugs",
     "--hero-card", "refs/card_front.png", "--hero-mug", "refs/mug_wrap.png", "--back", "refs/card_back.png",
     "--plain-back", "refs/card_back_plain.png", "--handle", "refs/handle_11oz.json", "--beat", "0.4412",
     "--drop", "3.608", "--table", "refs/table.png", "--tint", "1,0.8,0.77", "--check"],
     cwd="<job>", skill="python-render-printed-products-in-3d")

Run the rain with --check first, then --still, then with neither for the video. finale is the same call with finale. Each hero call with --still writes three PNGs. Without --table and --backdrop the products stand on a plain white studio floor.

What you get

H.264 MP4s at 1920×1080, 30 fps, CRF 14, picture only: hero_mug and hero_card 3.53 s, rain_open 7.14 s, rain_finale 4.0 s (--secs changes them). Cut them together and add the music afterwards.

Tips and traps

  • Motion blur needs many sub-frames: at 8, a fast card printed its greeting three times over; at 48, it is one smooth streak.
  • Colour: the first renders mixed colour spaces and came out washed out. The engine works in linear light with ACES at exposure 0.62, and keeps the glare on card faces low, so the prints keep real blacks.
  • Falls that look alive: one eased formula for everything gave near-straight paths ("pretty lame", "almost linear"). Cards fall like stiff paper: they swing 0.6–1.4 units side to side, 1.1–1.8 swings a fall, bank 0.35–0.6 rad into each swing, pause at its ends, sometimes flip once or twice, then cushion and skid 0.2–0.45 along their own momentum. Mugs come in on a gravity arc bowed sideways, tilted and spinning, bounce twice (0.30 then 0.07 high) and rock on the rim.
  • Nothing passes through anything: a landing wobble pushed half a card under the one below, flickering several times a second. Each card rises by exactly as much as its tilt pushes a corner down. Mugs land after the cards they stand on. Everything starts above the frame (--check). Shadows fade in with height instead of switching on.
  • The mug read as plastic with matte shading. The glaze reflects four studio soft boxes, with Fresnel, a tight highlight, a faint orange-peel ripple, darkening inside the cup and behind the handle, and a contact shadow.
  • Match a shape by measuring, not by eye: two handle rebuilds judged by eye were rejected. Tracing the product photo's silhouette and fitting the handle to it got the hole within 0.028 mug radii. The photo shows the handle only side-on, so its front-to-back thickness (1.4× the band) is an estimate.
  • The tint is what the glaze reflects from the table: 1, 0.8, 0.77 on warm oak, 1, 1, 1 on white linen.
  • Every sampler needs a texture bound: one left empty made the driver sample black from another. The engine binds a blank to each.
  • 4× MSAA is the most Apple's GPUs allow; the sub-frames do the rest.
  • moderngl isn't in the app's own Python; skill set to this skill adds it.

Check it

  • rain.py --check prints pop-ins: 0.
  • Stills of each shot on a contact sheet (python-contact-sheet): prints the right way up and readable, no grey slabs, the hero design facing the camera at the end.
  • Go frame by frame at full size through the busiest landing stretch. Flicker on the edges of dark cards only shows there, not on a sheet.
  • ffprobe-inspect-media on each file: 1920×1080, the expected length.

FAQs

Render printed products in 3D from their real print files, so every frame shows the print exactly: a 5x7 card that flips front to back, an 11 oz mug that turns until its design faces the camera, and a shower of cards and mugs that fall like paper and pottery and land into a flat-lay on the music's beats. Glazed-ceramic mugs, shadows, motion blur, on a generated table with a room behind. Local and free with moderngl on the GPU. Use for print-on-demand and photo products (cards, mugs) where a video model would smear the printed text.

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-render-printed-products-in-3d) and it installs hn/python-render-printed-products-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