Skip to content

Commit c35a332

Browse files
committed
fix: increase motion blur intensity range
1 parent dd84eda commit c35a332

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/components/video-editor/videoPlayback/zoomTransform.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { BlurFilter, Container } from "pixi.js";
22
import { MotionBlurFilter } from "pixi-filters/motion-blur";
33

4-
const PEAK_VELOCITY_PPS = 2000;
5-
const MAX_BLUR_PX = 8;
6-
const VELOCITY_THRESHOLD_PPS = 15;
4+
const PEAK_VELOCITY_PPS = 1400;
5+
const MAX_BLUR_PX = 14;
6+
const VELOCITY_THRESHOLD_PPS = 12;
7+
const MAX_AMOUNT_BOOST = 2.2;
8+
9+
function getMotionBlurAmountResponse(motionBlurAmount: number) {
10+
const clampedAmount = Math.min(1, Math.max(0, motionBlurAmount));
11+
// Keep the low end usable while giving the top of the slider substantially more headroom.
12+
return clampedAmount * (1 + (MAX_AMOUNT_BOOST - 1) * clampedAmount);
13+
}
714

815
export interface MotionBlurState {
916
lastFrameTimeMs: number;
@@ -185,6 +192,7 @@ export function applyZoomTransform({
185192
const dtMs = Math.min(80, Math.max(1, now - motionBlurState.lastFrameTimeMs));
186193
const dtSeconds = dtMs / 1000;
187194
motionBlurState.lastFrameTimeMs = now;
195+
const amountResponse = getMotionBlurAmountResponse(motionBlurAmount);
188196

189197
// Camera displacement this frame (stage-px)
190198
const dx = transform.x - motionBlurState.prevCamX;
@@ -204,17 +212,15 @@ export function applyZoomTransform({
204212

205213
const normalised = Math.min(1, speed / PEAK_VELOCITY_PPS);
206214
const targetBlur =
207-
speed < VELOCITY_THRESHOLD_PPS
208-
? 0
209-
: normalised * normalised * MAX_BLUR_PX * motionBlurAmount;
215+
speed < VELOCITY_THRESHOLD_PPS ? 0 : normalised * normalised * MAX_BLUR_PX * amountResponse;
210216

211217
const dirMag = Math.sqrt(velocityX * velocityX + velocityY * velocityY) || 1;
212-
const velocityScale = targetBlur * 1.2;
218+
const velocityScale = targetBlur * 2.4;
213219
motionBlurFilter.velocity =
214220
targetBlur > 0
215221
? { x: (velocityX / dirMag) * velocityScale, y: (velocityY / dirMag) * velocityScale }
216222
: { x: 0, y: 0 };
217-
motionBlurFilter.kernelSize = targetBlur > 4 ? 11 : targetBlur > 1.5 ? 9 : 5;
223+
motionBlurFilter.kernelSize = targetBlur > 8 ? 15 : targetBlur > 4 ? 11 : 7;
218224
motionBlurFilter.offset = targetBlur > 0.5 ? -0.2 : 0;
219225

220226
if (blurFilter) {

0 commit comments

Comments
 (0)