🎥 Make videos programmatically with React
feat(transitions): support effectsOutputSize in shader presentations
JonnyBurgerc2a54a5c6be3
diff --git a/packages/docs/docs/effects/index.mdx b/packages/docs/docs/effects/index.mdxindex d15f222e2a..2cf81f08b5 100644--- a/packages/docs/docs/effects/index.mdx+++ b/packages/docs/docs/effects/index.mdx@@ -35,7 +35,7 @@ Pass effects through the `effects` prop of these components:- [`<Heart>`](/docs/shapes/heart)- [`<Arrow>`](/docs/shapes/arrow)-## Effect resolution<AvailableFrom v="4.0.535" />+## Effect resolution<AvailableFrom v="4.0.536" />Use `effectsOutputSize` on any supported component to choose the pixel dimensions used by its effect chain:@@ -58,6 +58,20 @@ Omitting `effectsOutputSize` preserves the existing effect resolution. Empty orA larger effect resolution increases processing and canvas memory. Resizing a low-resolution source cannot restore missing detail. This prop controls effect processing; [`maxCanvasSinkFrameSize`](/docs/media/video#maxcanvassinkframesize) separately controls decoded preview frame size.+Shader-based [transition presentations](/docs/transitions/presentations), including custom presentations created with [`makeHtmlInCanvasPresentation()`](/docs/transitions/make-html-in-canvas-presentation), accept `effectsOutputSize` alongside `effects`:++```tsx twoslash title="MyComposition.tsx"+import {dissolve} from '@remotion/transitions/dissolve';+import {pixelate} from '@remotion/effects/pixelate';+// ---cut---+dissolve({+ effects: [pixelate({blockSize: 12})],+ effectsOutputSize: {width: 1920, height: 1080},+});+```++This sets the resolution of the effects applied after the transition shader. The shader and transition output keep their existing dimensions.+## Effects<TableOfContents />diff --git a/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdx b/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdxindex b2cc23446f..3096071ef6 100644--- a/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdx+++ b/packages/docs/docs/transitions/make-html-in-canvas-presentation.mdx@@ -288,6 +288,16 @@ Whatever you typed your `Props` as.A `presentation` that you can pass to a [`<TransitionSeries.Transition>`](/docs/transitions/transitionseries#transitionseriestransition).+The returned function accepts your shader props and the following options:++### `effects`?++[Effects](/docs/effects/api) to apply after the transition shader. Defaults to an empty array.++### `effectsOutputSize`?<AvailableFrom v="4.0.536" />++An object with positive integer `width` and `height` values that sets the [effect resolution](/docs/effects/api#effect-resolution). By default, effects use the transition canvas dimensions. This does not change the shader or output dimensions.+## Types### `HtmlInCanvasShader`diff --git a/packages/transitions/src/html-in-canvas-presentation.tsx b/packages/transitions/src/html-in-canvas-presentation.tsxindex cfe3be6cc5..f25c915638 100644--- a/packages/transitions/src/html-in-canvas-presentation.tsx+++ b/packages/transitions/src/html-in-canvas-presentation.tsx@@ -6,6 +6,7 @@ import {Internals,useDelayRender,type EffectsProp,+ type EffectsOutputSize,} from 'remotion';import type {DrawFunction} from './TransitionSeries';import type {@@ -23,11 +24,13 @@ export const HtmlInCanvasPresentation = <presentationDirection,shader,effects,+ effectsOutputSize,passedProps,bothEnteringAndExiting,}: TransitionPresentationComponentProps<TPassedProps> & {readonly shader: HtmlInCanvasShader<TPassedProps>;readonly effects?: EffectsProp;+ readonly effectsOutputSize: EffectsOutputSize | null;}) => {if (!HtmlInCanvas.isSupported()) {throw new Error(getHtmlInCanvasUnsupportedMessage());@@ -103,7 +106,7 @@ export const HtmlInCanvasPresentation = <};}, [instance]);- const chainState = Internals.useEffectChainState();+ const chainState = Internals.useEffectChainState(effectsOutputSize);const {delayRender, continueRender, cancelRender} = useDelayRender();const draw: DrawFunction = useCallback(@@ -251,7 +254,7 @@ export const HtmlInCanvasPresentation = <}canvas.requestPaint?.();- }, [presentationProgress, passThrough, memoizedEffects]);+ }, [presentationProgress, passThrough, memoizedEffects, chainState]);useLayoutEffect(() => {if (passThrough) {@@ -334,17 +337,21 @@ export const makeHtmlInCanvasPresentation = <>(shader: HtmlInCanvasShader<TPassedProps>,) => {- type AugmentedProps = TPassedProps & {effects?: EffectsProp};+ type AugmentedProps = TPassedProps & {+ effects?: EffectsProp;+ effectsOutputSize?: EffectsOutputSize;+ };const CompWithShader: React.FC<TransitionPresentationComponentProps<AugmentedProps>> = (props) => {const {passedProps, ...otherProps} = props;- const {effects, ...restPassedProps} = props.passedProps;+ const {effects, effectsOutputSize, ...restPassedProps} = props.passedProps;return (<HtmlInCanvasPresentationshader={shader}passedProps={restPassedProps as TPassedProps}effects={effects}+ effectsOutputSize={effectsOutputSize ?? null}{...otherProps}/>);diff --git a/packages/transitions/src/presentations/blur-slide.tsx b/packages/transitions/src/presentations/blur-slide.tsxindex a8c25f651f..3a5d4f6ac2 100644--- a/packages/transitions/src/presentations/blur-slide.tsx+++ b/packages/transitions/src/presentations/blur-slide.tsx@@ -1,4 +1,4 @@-import type {EffectsProp} from 'remotion';+import type {EffectsProp, EffectsOutputSize} from 'remotion';import type {HtmlInCanvasShader} from '../html-in-canvas-presentation';import {makeHtmlInCanvasPresentation} from '../html-in-canvas-presentation';import type {TransitionPresentation} from '../types';@@ -384,8 +384,16 @@ export const blurSlideShader = (const makeBlurSlide = makeHtmlInCanvasPresentation(blurSlideShader);export const blurSlide = (- props: BlurSlideProps & {effects?: EffectsProp} = {},-): TransitionPresentation<BlurSlideProps & {effects?: EffectsProp}> => {+ props: BlurSlideProps & {+ effects?: EffectsProp;+ effectsOutputSize?: EffectsOutputSize;+ } = {},+): TransitionPresentation<+ BlurSlideProps & {+ effects?: EffectsProp;+ effectsOutputSize?: EffectsOutputSize;+ }+> => {validateProps(props);return makeBlurSlide(props);};