Add camera motion blur to WebP renders#249
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
writeImageto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in camera motion blur for
.webpoutput. 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-endthe 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-framei ∈ [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 existingrenderSplats(), and accumulate the returned RGBA buffer in aFloat32Array. Final pixels areround(accum / N).DoF (
--f-stopetc.) 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 buildcleannpm run lintcleannpm test— all 491 tests pass, including the 3 render-golden cases (tiny,mid,tiny-dof)--camera-end, output is byte-identical to current main (covered by goldens)--camera-endequal to--camerawith--motion-samples 16produces a bit-identical WebP to the single-sample render--shutter 1vs--shutter 0.5on a dolly produces visibly shorter streaks at 0.5--camera-end+--f-stop 2.8composes both effects in one frame--projection equirect --camera-end ...produces a panoramic frame with motion blurExample 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