Skip to content

Add camera motion blur to WebP renders#249

Merged
slimbuck merged 1 commit into
playcanvas:mainfrom
slimbuck:motion-dev
May 27, 2026
Merged

Add camera motion blur to WebP renders#249
slimbuck merged 1 commit into
playcanvas:mainfrom
slimbuck:motion-dev

Conversation

@slimbuck
Copy link
Copy Markdown
Member

Summary

Adds opt-in camera motion blur for .webp output. Enabled by passing --camera-end; the renderer averages N sub-frames with the camera linearly interpolated between the start pose (--camera, --look-at, --up) and the end pose (--camera-end, --look-at-end, --up-end).

New CLI flags (all under "IMAGE OUTPUT (.webp)"):

  • --camera-end <x,y,z> — end camera position; presence enables motion blur.
  • --look-at-end <x,y,z> — end target. Default: same as --look-at.
  • --up-end <x,y,z> — end up vector. Default: same as --up.
  • --shutter <0..1> — fraction of the start→end segment integrated, centered on the midpoint (standard shutter-angle convention: 1.0 = full motion, 0.5 = 180° shutter). Default: 1.
  • --motion-samples <n> — sub-frames to accumulate. Default: 16.

Disabled by default — without --camera-end the existing single-sample path runs unchanged.

Approach

Motion blur is a thin orchestration layer in writeImage: no shader, rasterizer, or render-pass changes. For each sub-frame i ∈ [0, N) we lerp position + target, nlerp up, recompute DoF uniforms against the interpolated pose (so focus distance follows the look-at point), call the existing renderSplats(), and accumulate the returned RGBA buffer in a Float32Array. Final pixels are round(accum / N).

DoF (--f-stop etc.) composes naturally — each sub-frame applies its own per-splat covariance dilation, and the average is a physically-reasonable approximation of simultaneous defocus + motion blur. Equirect projection is also supported.

Files touched: src/lib/types.ts, src/lib/writers/write-image.ts, src/cli/index.ts, src/lib/write.ts, README.md.

Test plan

  • npm run build clean
  • npm run lint clean
  • npm test — all 491 tests pass, including the 3 render-golden cases (tiny, mid, tiny-dof)
  • Regression check: without --camera-end, output is byte-identical to current main (covered by goldens)
  • Idempotence: --camera-end equal to --camera with --motion-samples 16 produces a bit-identical WebP to the single-sample render
  • --shutter 1 vs --shutter 0.5 on a dolly produces visibly shorter streaks at 0.5
  • --camera-end + --f-stop 2.8 composes both effects in one frame
  • --projection equirect --camera-end ... produces a panoramic frame with motion blur

Example invocation:

splat-transform input.ply view.webp \
    --camera 0,1,-3 --look-at 0,0,0 \
    --camera-end 1,1,-3 \
    --motion-samples 16 --shutter 1

@slimbuck slimbuck requested a review from Copilot May 27, 2026 12:01
@slimbuck slimbuck self-assigned this May 27, 2026
@slimbuck slimbuck added the enhancement New feature or request label May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in camera motion blur for .webp rendering by interpolating camera poses across multiple sub-frame renders and averaging the result.

Changes:

  • Extends render options and CLI flags for end camera pose, shutter fraction, and motion sample count.
  • Updates writeImage to build per-sample cameras, recompute DoF per pose, accumulate RGBA output, and encode the averaged result.
  • Documents the new flags and adds a README example.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib/writers/write-image.ts Implements motion-blur camera interpolation and frame accumulation for WebP output.
src/lib/write.ts Passes new render motion-blur options into the image writer.
src/lib/types.ts Adds public option fields for motion-blur rendering controls.
src/cli/index.ts Adds CLI parsing, validation, and help text for motion-blur flags.
README.md Documents new WebP motion-blur options and example usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/writers/write-image.ts
Comment thread src/lib/writers/write-image.ts
@slimbuck slimbuck marked this pull request as ready for review May 27, 2026 12:06
@slimbuck slimbuck requested a review from a team May 27, 2026 12:06
@slimbuck slimbuck merged commit f32eab2 into playcanvas:main May 27, 2026
3 checks passed
@slimbuck slimbuck deleted the motion-dev branch May 27, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants