🎥 Make videos programmatically with React
`@remotion/effects`: Migrate starburst effect (#9677)
Jonny Burger0b6b173b8e49
diff --git a/bun.lock b/bun.lockindex 7d44fe7fcc..93afbfde8b 100644--- a/bun.lock+++ b/bun.lock@@ -109,7 +109,6 @@"@remotion/rough-notation": "workspace:*","@remotion/sfx": "workspace:*","@remotion/shapes": "workspace:*",- "@remotion/starburst": "workspace:*","@remotion/svg-3d-engine": "workspace:*","@remotion/tailwind-v4": "workspace:*","@remotion/transitions": "workspace:*",@@ -1627,6 +1626,7 @@"name": "@remotion/starburst","version": "4.0.499","dependencies": {+ "@remotion/effects": "workspace:*","remotion": "workspace:*","zod": "catalog:",},diff --git a/packages/brand/package.json b/packages/brand/package.jsonindex eb14b039a0..8c2f1ba443 100644--- a/packages/brand/package.json+++ b/packages/brand/package.json@@ -28,7 +28,6 @@"@remotion/rough-notation": "workspace:*","@remotion/shapes": "workspace:*","@remotion/sfx": "workspace:*",- "@remotion/starburst": "workspace:*","@remotion/svg-3d-engine": "workspace:*","@remotion/captions": "workspace:*","@remotion/tailwind-v4": "workspace:*",diff --git a/packages/brand/src/effects/StarburstEffectShowcase.tsx b/packages/brand/src/effects/StarburstEffectShowcase.tsxindex 9a3824deea..1fadfa7ef8 100644--- a/packages/brand/src/effects/StarburstEffectShowcase.tsx+++ b/packages/brand/src/effects/StarburstEffectShowcase.tsx@@ -1,5 +1,5 @@import {halftone} from '@remotion/effects/halftone';-import {starburst} from '@remotion/starburst';+import {starburst} from '@remotion/effects/starburst';import React from 'react';import {AbsoluteFill,diff --git a/packages/docs/components/demos/StarburstDemo.tsx b/packages/docs/components/demos/StarburstDemo.tsxindex 07ffad7b62..cfae0038ef 100644--- a/packages/docs/components/demos/StarburstDemo.tsx+++ b/packages/docs/components/demos/StarburstDemo.tsx@@ -1,36 +1,31 @@-import {Starburst} from '@remotion/starburst';+import {starburst} from '@remotion/effects/starburst';import React from 'react';-import {AbsoluteFill, useVideoConfig} from 'remotion';+import {+ AbsoluteFill,+ interpolate,+ Solid,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';-interface Props {- readonly rays: number;- readonly rotation: number;- readonly smoothness: number;- readonly vignette: number;- readonly originOffsetX: number;- readonly originOffsetY: number;-}+export const StarburstDemoComp: React.FC = () => {+ const frame = useCurrentFrame();+ const {width, height} = useVideoConfig();-export const StarburstDemoComp: React.FC<Props> = ({- rays,- rotation,- smoothness,- vignette,- originOffsetX,- originOffsetY,-}) => {- const {durationInFrames} = useVideoConfig();return (<AbsoluteFill style={{backgroundColor: 'black'}}>- <Starburst- rays={rays}- colors={['#ffdd00', '#ff8800']}- rotation={rotation}- smoothness={smoothness}- vignette={vignette}- originOffsetX={originOffsetX}- originOffsetY={originOffsetY}- durationInFrames={durationInFrames}+ <Solid+ width={width}+ height={height}+ effects={[+ starburst({+ rays: 16,+ colors: ['#ffdd00', '#ff8800'],+ rotation: interpolate(frame, [0, 45, 89], [0, 180, 360]),+ smoothness: interpolate(frame, [0, 45, 89], [0, 0.3, 0]),+ origin: [0.5, 0.5],+ }),+ ]}/></AbsoluteFill>);diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.tsindex c899f58d82..60f23166e3 100644--- a/packages/docs/components/demos/types.ts+++ b/packages/docs/components/demos/types.ts@@ -1545,65 +1545,10 @@ export const starburstDemo: DemoType = {durationInFrames: 90,fps: 30,id: 'starburst',- autoPlay: false,+ autoPlay: true,controls: false,logLevel: 'info',- options: [- {- name: 'rays',- type: 'numeric',- default: 12,- min: 2,- max: 100,- step: 1,- optional: 'no',- },- {- name: 'rotation',- type: 'numeric',- default: 0,- min: 0,- max: 360,- step: 1,- optional: 'no',- },- {- name: 'smoothness',- type: 'numeric',- default: 0,- min: 0,- max: 1,- step: 0.01,- optional: 'no',- },- {- name: 'vignette',- type: 'numeric',- default: 1,- min: 0,- max: 1,- step: 0.01,- optional: 'no',- },- {- name: 'originOffsetX',- type: 'numeric',- default: 0,- min: -1,- max: 1,- step: 0.01,- optional: 'no',- },- {- name: 'originOffsetY',- type: 'numeric',- default: 0,- min: -1,- max: 1,- step: 0.01,- optional: 'no',- },- ],+ options: [],};export const transitionSeriesTransitionDemo: DemoType = {diff --git a/packages/docs/components/effects-demos/registry.ts b/packages/docs/components/effects-demos/registry.tsindex fea15e325e..d4c87ca40b 100644--- a/packages/docs/components/effects-demos/registry.ts+++ b/packages/docs/components/effects-demos/registry.ts@@ -47,6 +47,7 @@ import {shine} from '@remotion/effects/shine';import {shrinkwrap} from '@remotion/effects/shrinkwrap';import {skew} from '@remotion/effects/skew';import {speckle} from '@remotion/effects/speckle';+import {starburst} from '@remotion/effects/starburst';import {thermalVision} from '@remotion/effects/thermal-vision';import {tint} from '@remotion/effects/tint';import {uvTranslate, xyTranslate} from '@remotion/effects/translate';@@ -59,7 +60,6 @@ import {whiteNoise} from '@remotion/effects/white-noise';import {zigzag} from '@remotion/effects/zigzag';import {zoomBlur} from '@remotion/effects/zoom-blur';import {lightLeakEffectSchema} from '@remotion/light-leaks';-import {starburstEffectSchema} from '@remotion/starburst';import {EffectsBarrelDistortionPreview} from '../effects/effects-barrel-distortion-preview';import {EffectsBlurPreview} from '../effects/effects-blur-preview';import {EffectsBrightnessPreview} from '../effects/effects-brightness-preview';@@ -686,9 +686,12 @@ export const effectsDemos: EffectsDemoType[] = [...defaults,id: 'effects-starburst',effectName: 'starburst',- effectImportPath: '@remotion/starburst',+ effectImportPath: '@remotion/effects/starburst',comp: EffectsStarburstPreview,- schema: starburstEffectSchema,+ schema: starburst({+ rays: 16,+ colors: ['#dff4ff', '#7cc6ff'],+ }).definition.schema,initialValues: STARBURST_PREVIEW_PARAMS,},{diff --git a/packages/docs/components/effects/effects-starburst-preview.tsx b/packages/docs/components/effects/effects-starburst-preview.tsxindex 89c96ce840..1011665e11 100644--- a/packages/docs/components/effects/effects-starburst-preview.tsx+++ b/packages/docs/components/effects/effects-starburst-preview.tsx@@ -1,4 +1,4 @@-import {starburst} from '@remotion/starburst';+import {starburst} from '@remotion/effects/starburst';import React from 'react';import {CanvasImage} from 'remotion';import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';@@ -10,7 +10,7 @@ const fullSize: React.CSSProperties = {export const STARBURST_PREVIEW_PARAMS = {rays: 16,- colors: ['#ff6600', '#ffff00'],+ colors: ['#dff4ff', '#7cc6ff'],rotation: 0,smoothness: 0,origin: [0.5, 0.5] as const,diff --git a/packages/docs/docs/effects/starburst.mdx b/packages/docs/docs/effects/starburst.mdxnew file mode 100644index 0000000000..8a52406751--- /dev/null+++ b/packages/docs/docs/effects/starburst.mdx@@ -0,0 +1,84 @@+---+image: /generated/articles-docs-effects-starburst.png+slug: /effects/starburst+title: starburst()+sidebar_label: starburst()+crumb: '@remotion/effects'+---++# starburst()<AvailableFrom v="4.0.500" />++_Part of the [`@remotion/effects`](/docs/effects/api) package._++Renders a WebGL2-based retro starburst ray pattern on canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas) and [`<Solid>`](/docs/solid).++`starburst()` replaces the underlying pixels instead of blending over them. It is usually the first effect in a chain, or applied to a [`<Solid>`](/docs/solid) before other effects.++## Preview++<EffectsDemo type="effects-starburst" />++## Example++```tsx twoslash title="MyComp.tsx"+import {starburst} from '@remotion/effects/starburst';+import {AbsoluteFill, Solid} from 'remotion';++export const MyComp: React.FC = () => {+ return (+ <AbsoluteFill>+ <Solid+ width={1280}+ height={720}+ effects={[+ starburst({+ rays: 16,+ colors: ['#ff6600', '#ffff00'],+ rotation: 0,+ smoothness: 0,+ origin: [0.5, 0.5],+ }),+ ]}+ />+ </AbsoluteFill>+ );+};+```++## API++Pass an object with the following properties.++### `rays`++The number of rays in the starburst pattern. Must be between `2` and `100`.++### `colors`++An array with at least two CSS color strings. Colors are assigned to rays cyclically.++### `rotation?`++Rotates the starburst pattern in degrees. Defaults to `0`.++### `smoothness?`++Controls the blend width at each ray boundary. Must be between `0` and `1`. Defaults to `0` for hard edges.++### `origin?`++UV coordinate of the starburst origin. `[0, 0]` is the top-left corner and `[1, 1]` is the bottom-right corner. Defaults to `[0.5, 0.5]`.++### `disabled?`++When `true`, the effect is skipped. Defaults to `false`.++## Requirements++`starburst()` uses a WebGL2 backend. During renders, enable WebGL via [`Config.setChromiumOpenGlRenderer('angle')`](/docs/config#setchromiumopenglrenderer). See [Using WebGL during renders](/docs/remotion/html-in-canvas#using-webgl-during-renders).++## See also++- [Designing a starburst](/docs/starburst)+- [`@remotion/effects`](/docs/effects/api)+- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/starburst.ts)diff --git a/packages/docs/docs/starburst-guide.mdx b/packages/docs/docs/starburst-guide.mdxindex 35e85ca8be..be02bc25df 100644--- a/packages/docs/docs/starburst-guide.mdx+++ b/packages/docs/docs/starburst-guide.mdx@@ -2,47 +2,54 @@image: /generated/articles-docs-starburst-guide.pngid: starbursttitle: Starburst-crumb: 'Techniques'+crumb: 'Designing visuals'----# Starburst<AvailableFrom v="4.0.435"/>+# Starburst<AvailableFrom v="4.0.500"/>-The [`<Starburst>`](/docs/starburst/starburst) component from [`@remotion/starburst`](/docs/starburst/api) renders a static WebGL-based retro starburst ray pattern.+The [`starburst()`](/docs/effects/starburst) effect from [`@remotion/effects`](/docs/effects/api) renders a WebGL2-based retro ray pattern.<Demo type="starburst" />+Apply the effect to a [`<Solid>`](/docs/solid) and animate its parameters with [`interpolate()`](/docs/interpolate):+```tsx twoslash title="MyComp.tsx"-import {Starburst} from '@remotion/starburst';-import {AbsoluteFill} from 'remotion';+import {starburst} from '@remotion/effects/starburst';+import {+ AbsoluteFill,+ interpolate,+ Solid,+ useCurrentFrame,+ useVideoConfig,+} from 'remotion';++export const MyComp: React.FC = () => {+ const frame = useCurrentFrame();+ const {width, height} = useVideoConfig();-const MyComp = () => {return (- <AbsoluteFill style={{backgroundColor: 'black'}}>- <Starburst durationInFrames={60} rays={16} colors={['#ffdd00', '#ff8800']} />+ <AbsoluteFill>+ <Solid+ width={width}+ height={height}+ effects={[+ starburst({+ rays: 16,+ colors: ['#ffdd00', '#ff8800'],+ rotation: interpolate(frame, [0, 45, 89], [0, 180, 360]),+ smoothness: interpolate(frame, [0, 45, 89], [0, 0.3, 0]),+ origin: [0.5, 0.5],+ }),+ ]}+ /></AbsoluteFill>);};```-## Rotating the pattern--Use [`rotation`](/docs/starburst/starburst#rotation) to offset the angle of the rays in degrees:--```tsx twoslash title="Rotated.tsx"-import {Starburst} from '@remotion/starburst';-import {AbsoluteFill} from 'remotion';--// ---cut----const MyComp = () => {- return (- <AbsoluteFill style={{backgroundColor: 'black'}}>- <Starburst rays={12} colors={['#ffdd00', '#ff8800']} rotation={45} durationInFrames={30} />- </AbsoluteFill>- );-};-```+Keeping the `interpolate()` calls inline makes the keyframes editable in [Remotion Studio](/docs/studio/interactivity-best-practices#keep-effects-editable).## See also-- [`<Starburst>` API reference](/docs/starburst/starburst)-- [`@remotion/starburst`](/docs/starburst/api)+- [`starburst()` API reference](/docs/effects/starburst)+- [`@remotion/effects`](/docs/effects/api)diff --git a/packages/docs/docs/starburst/index.mdx b/packages/docs/docs/starburst/index.mdxindex 2beac40047..3fcb9ae83c 100644--- a/packages/docs/docs/starburst/index.mdx+++ b/packages/docs/docs/starburst/index.mdx@@ -8,6 +8,10 @@ crumb: API# @remotion/starburst<AvailableFrom v="4.0.435" />+:::warning Deprecated+`@remotion/starburst` is deprecated and will no longer be published starting with Remotion 5.0. Migrate to [`starburst()`](/docs/effects/starburst) from `@remotion/effects/starburst`. The `<Starburst>` component will not be moved to `@remotion/effects`.+:::+Starburst ray effect for Remotion videos.import {TableOfContents} from './table-of-contents';diff --git a/packages/docs/docs/starburst/starburst-effect.mdx b/packages/docs/docs/starburst/starburst-effect.mdxindex c96f8841ba..eef9f18382 100644--- a/packages/docs/docs/starburst/starburst-effect.mdx+++ b/packages/docs/docs/starburst/starburst-effect.mdx@@ -8,6 +8,10 @@ crumb: '@remotion/starburst'# starburst()<AvailableFrom v="4.0.468" />+:::warning Deprecated+`@remotion/starburst` is deprecated and will no longer be published starting with Remotion 5.0. Migrate to [`starburst()`](/docs/effects/starburst) from `@remotion/effects/starburst`.+:::+_Part of the [`@remotion/starburst`](/docs/starburst/api) package._Renders a WebGL2-based retro starburst ray pattern as an effect for canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas) and [`<Solid>`](/docs/solid).@@ -83,6 +87,7 @@ When `true`, the effect is skipped. Defaults to `false`.## See also- [`@remotion/starburst`](/docs/starburst/api)+- [`starburst()` from `@remotion/effects`](/docs/effects/starburst)- [`<Starburst>`](/docs/starburst/starburst)- [`@remotion/effects`](/docs/effects/api)- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/starburst/src/starburst-effect.ts)diff --git a/packages/docs/docs/starburst/starburst.mdx b/packages/docs/docs/starburst/starburst.mdxindex 996fe1e889..43fa25c916 100644--- a/packages/docs/docs/starburst/starburst.mdx+++ b/packages/docs/docs/starburst/starburst.mdx@@ -8,6 +8,10 @@ crumb: '@remotion/starburst'# <Starburst><AvailableFrom v="4.0.435" />+:::warning Deprecated+`@remotion/starburst` is deprecated and will no longer be published starting with Remotion 5.0. Migrate to [`starburst()`](/docs/effects/starburst) from `@remotion/effects/starburst`. The `<Starburst>` component will not be moved to `@remotion/effects`.+:::+Renders a static WebGL-based retro starburst ray pattern.Is a [`<Sequence>`](/docs/sequence) component under the hood and accepts its props.@@ -77,6 +81,6 @@ Shifts the origin of the starburst pattern vertically. `-1` moves the origin to## See also-- [`starburst()` effect](/docs/starburst/starburst-effect)+- [`starburst()` effect from `@remotion/effects`](/docs/effects/starburst)- [Source code for this component](https://github.com/remotion-dev/remotion/blob/main/packages/starburst/src/Starburst.tsx)- [`<Sequence>`](/docs/sequence)diff --git a/packages/docs/elements/backgrounds/rotating-starburst/rotating-starburst.tsx b/packages/docs/elements/backgrounds/rotating-starburst/rotating-starburst.tsxindex c097c8fba8..46303c1f77 100644--- a/packages/docs/elements/backgrounds/rotating-starburst/rotating-starburst.tsx+++ b/packages/docs/elements/backgrounds/rotating-starburst/rotating-starburst.tsx@@ -1,4 +1,4 @@-import {starburst} from '@remotion/starburst';+import {starburst} from '@remotion/effects/starburst';import React from 'react';import {interpolate, Solid, useCurrentFrame, useVideoConfig} from 'remotion';diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex 894a970e16..c1d035008c 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -322,6 +322,7 @@ const sidebars: SidebarsConfig = {'effects/shrinkwrap','effects/skew','effects/speckle',+ 'effects/starburst','effects/thermal-vision','effects/tint','effects/tv-signal-off',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 0f793a5cf4..a917ba099a 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -2222,6 +2222,15 @@ export const articles = [noAi: false,slug: 'effects/speckle',},+ {+ id: 'effects/starburst',+ title: 'starburst()',+ relativePath: 'docs/effects/starburst.mdx',+ compId: 'articles-docs-effects-starburst',+ crumb: '@remotion/effects',+ noAi: false,+ slug: 'effects/starburst',+ },{id: 'effects/thermal-vision',title: 'thermalVision()',@@ -6729,7 +6738,7 @@ export const articles = [title: 'Starburst',relativePath: 'docs/starburst-guide.mdx',compId: 'articles-docs-starburst-guide',- crumb: 'Techniques',+ crumb: 'Designing visuals',noAi: false,slug: 'starburst',},diff --git a/packages/docs/static/generated/articles-docs-effects-starburst.png b/packages/docs/static/generated/articles-docs-effects-starburst.pngnew file mode 100644index 0000000000..d5b449c6d1Binary files /dev/null and b/packages/docs/static/generated/articles-docs-effects-starburst.png differdiff --git a/packages/effects/bundle.ts b/packages/effects/bundle.tsindex 766cac901b..abbb379a70 100644--- a/packages/effects/bundle.ts+++ b/packages/effects/bundle.ts@@ -56,6 +56,7 @@ const effectEntrypoints = ['src/shrinkwrap.ts','src/skew.ts','src/speckle.ts',+ 'src/starburst.ts','src/thermal-vision.ts','src/tint.ts','src/translate.ts',diff --git a/packages/effects/package.json b/packages/effects/package.jsonindex 0f542cabdf..28d5693e13 100644--- a/packages/effects/package.json+++ b/packages/effects/package.json@@ -279,6 +279,11 @@"module": "./dist/esm/speckle.mjs","import": "./dist/esm/speckle.mjs"},+ "./starburst": {+ "types": "./dist/starburst.d.ts",+ "module": "./dist/esm/starburst.mjs",+ "import": "./dist/esm/starburst.mjs"+ },"./thermal-vision": {"types": "./dist/thermal-vision.d.ts","module": "./dist/esm/thermal-vision.mjs",@@ -485,6 +490,9 @@"speckle": ["dist/speckle.d.ts"],+ "starburst": [+ "dist/starburst.d.ts"+ ],"thermal-vision": ["dist/thermal-vision.d.ts"],diff --git a/packages/effects/src/index.ts b/packages/effects/src/index.tsindex c41fb6179b..e6d96d8a6b 100644--- a/packages/effects/src/index.ts+++ b/packages/effects/src/index.ts@@ -1,6 +1,12 @@export {checkerboard, type CheckerboardParams} from './checkerboard.js';export {pattern, type PatternOrigin, type PatternParams} from './pattern.js';export {rings, type RingsCenter, type RingsParams} from './rings.js';+export {+ starburst,+ starburstEffectSchema,+ type StarburstEffectParams,+ type StarburstOrigin,+} from './starburst.js';export {gridlines, type GridlinesParams} from './gridlines.js';export {zigzag, type ZigzagDirection, type ZigzagParams} from './zigzag.js';export {diff --git a/packages/effects/src/starburst.ts b/packages/effects/src/starburst.tsnew file mode 100644index 0000000000..75dac1fcd2--- /dev/null+++ b/packages/effects/src/starburst.ts@@ -0,0 +1,440 @@+import type {InteractivitySchema} from 'remotion';+import {Internals} from 'remotion';+import {NoReactInternals} from 'remotion/no-react';++const {createEffect, createWebGL2ContextError} = Internals;++const colorToRgb = (color: string): [number, number, number] => {+ const packed = NoReactInternals.processColor(color);++ return [(packed >>> 16) & 255, (packed >>> 8) & 255, packed & 255];+};++const DEFAULT_ORIGIN = [0.5, 0.5] as const;++export const starburstEffectSchema = {+ rays: {+ type: 'number',+ min: 2,+ max: 100,+ step: 1,+ default: undefined,+ description: 'Number of Rays',+ hiddenFromList: false,+ },+ colors: {+ type: 'array',+ item: {+ type: 'color',+ },+ default: undefined,+ minLength: 2,+ newItemDefault: '#ff0000',+ description: 'Colors',+ keyframable: false,+ },+ rotation: {+ type: 'number',+ min: 0,+ max: 360,+ step: 1,+ default: 0,+ description: 'Rotation',+ hiddenFromList: false,+ },+ smoothness: {+ type: 'number',+ min: 0,+ max: 1,+ step: 0.01,+ default: 0,+ description: 'Edge Smoothness',+ hiddenFromList: false,+ },+ origin: {+ type: 'uv-coordinate',+ min: 0,+ max: 1,+ step: 0.01,+ default: DEFAULT_ORIGIN,+ description: 'Origin',+ },+} as const satisfies InteractivitySchema;++export type StarburstOrigin = readonly [number, number];++export type StarburstEffectParams = {+ readonly rays: number;+ readonly colors: readonly string[];+ readonly rotation?: number;+ readonly smoothness?: number;+ readonly origin?: StarburstOrigin;+};++type StarburstResolved = {+ rays: number;+ colors: readonly string[];+ rotation: number;+ smoothness: number;+ origin: StarburstOrigin;+};++const resolve = (p: StarburstEffectParams): StarburstResolved => ({+ rays: p.rays,+ colors: p.colors,+ rotation: p.rotation ?? 0,+ smoothness: p.smoothness ?? 0,+ origin: (p.origin ?? DEFAULT_ORIGIN) as StarburstOrigin,+});++const validateStarburstEffectParams = (params: StarburstEffectParams): void => {+ if (params === null || typeof params !== 'object') {+ throw new TypeError(+ `Starburst effect requires a parameters object, but got ${JSON.stringify(params)}`,+ );+ }++ const {rays, colors} = params;++ if (typeof rays !== 'number' || !Number.isFinite(rays)) {+ throw new TypeError(+ `"rays" must be a finite number, but got ${JSON.stringify(rays)}`,+ );+ }++ if (rays < 2 || rays > 100) {+ throw new RangeError(`"rays" must be between 2 and 100, but got ${rays}`);+ }++ if (!Array.isArray(colors) || colors.length < 2) {+ throw new TypeError(+ `"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`,+ );+ }++ const r = resolve(params);++ if (typeof r.rotation !== 'number' || !Number.isFinite(r.rotation)) {+ throw new TypeError(+ `"rotation" must be a finite number, but got ${JSON.stringify(params.rotation)}`,+ );+ }++ if (typeof r.smoothness !== 'number' || !Number.isFinite(r.smoothness)) {+ throw new TypeError(+ `"smoothness" must be a finite number, but got ${JSON.stringify(params.smoothness)}`,+ );+ }++ if (r.smoothness < 0 || r.smoothness > 1) {+ throw new RangeError(+ `"smoothness" must be between 0 and 1, but got ${r.smoothness}`,+ );+ }++ if (+ !Array.isArray(r.origin) ||+ r.origin.length !== 2 ||+ r.origin.some((coordinate) => {+ return typeof coordinate !== 'number' || !Number.isFinite(coordinate);+ })+ ) {+ throw new TypeError('"origin" must be a [number, number] tuple');+ }++ if (r.origin.some((coordinate) => coordinate < 0 || coordinate > 1)) {+ throw new RangeError(+ `"origin" must contain coordinates between 0 and 1, but got ${JSON.stringify(r.origin)}`,+ );+ }++ for (const c of r.colors) {+ colorToRgb(c);+ }+};++const STARBURST_VS = /* glsl */ `#version 300 es+in vec2 aPos;+in vec2 aUv;+out vec2 vUv;+void main() {+ vUv = aUv;+ gl_Position = vec4(aPos, 0.0, 1.0);+}+`;++const STARBURST_FS = /* glsl */ `#version 300 es+precision highp float;++uniform sampler2D colorPalette;+uniform float numRays;+uniform float rotationOffset;+uniform float smoothEdge;+uniform vec2 resolution;+uniform float numColors;+uniform vec2 origin;++in vec2 vUv;+out vec4 fragColor;++const float Pi = 3.14159265359;++void main() {+ vec2 uv = vUv;+ vec2 center = uv - origin;+ center.x *= resolution.x / resolution.y;++ float angle = atan(center.y, center.x) + rotationOffset;+ float normalizedAngle = (angle + Pi) / (2.0 * Pi);+ float sector = normalizedAngle * numRays;+ float rayIndex = mod(floor(sector), numRays);++ float colorIndex = mod(rayIndex, numColors);+ float texCoord = (colorIndex + 0.5) / numColors;+ vec3 col = texture(colorPalette, vec2(texCoord, 0.5)).rgb;++ float fractSector = fract(sector);+ float edgeSmooth = smoothEdge * 0.5;+ float nextColorIndex = mod(rayIndex + 1.0, numColors);+ float nextTexCoord = (nextColorIndex + 0.5) / numColors;+ vec3 nextCol = texture(colorPalette, vec2(nextTexCoord, 0.5)).rgb;++ float blend = smoothstep(1.0 - edgeSmooth, 1.0, fractSector);+ col = mix(col, nextCol, blend);+ float blendStart = smoothstep(edgeSmooth, 0.0, fractSector);+ float prevColorIndex = mod(rayIndex - 1.0 + numColors, numColors);+ float prevTexCoord = (prevColorIndex + 0.5) / numColors;+ vec3 prevCol = texture(colorPalette, vec2(prevTexCoord, 0.5)).rgb;+ col = mix(col, prevCol, blendStart);++ fragColor = vec4(col, 1.0);+}+`;++type StarburstGlState = {+ gl: WebGL2RenderingContext;+ program: WebGLProgram;+ vao: WebGLVertexArrayObject;+ vbo: WebGLBuffer;+ paletteTexture: WebGLTexture;+ uColorPalette: WebGLUniformLocation | null;+ uNumRays: WebGLUniformLocation | null;+ uRotationOffset: WebGLUniformLocation | null;+ uSmoothEdge: WebGLUniformLocation | null;+ uResolution: WebGLUniformLocation | null;+ uNumColors: WebGLUniformLocation | null;+ uOrigin: WebGLUniformLocation | null;+ cachedPaletteKey: string;+ palettePixelData: Uint8Array;+};++const compileShader = (+ gl: WebGL2RenderingContext,+ type: number,+ source: string,+): WebGLShader => {+ const shader = gl.createShader(type);+ if (!shader) {+ throw new Error('Failed to create WebGL shader');+ }++ gl.shaderSource(shader, source);+ gl.compileShader(shader);+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {+ const log = gl.getShaderInfoLog(shader);+ gl.deleteShader(shader);+ throw new Error(`Starburst shader compile failed: ${log ?? '(no log)'}`);+ }++ return shader;+};++const linkProgram = (+ gl: WebGL2RenderingContext,+ vs: WebGLShader,+ fs: WebGLShader,+): WebGLProgram => {+ const program = gl.createProgram();+ if (!program) {+ throw new Error('Failed to create WebGL program');+ }++ gl.attachShader(program, vs);+ gl.attachShader(program, fs);+ gl.linkProgram(program);+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {+ const log = gl.getProgramInfoLog(program);+ gl.deleteProgram(program);+ throw new Error(`Starburst program link failed: ${log ?? '(no log)'}`);+ }++ return program;+};++export const starburst = createEffect<StarburstEffectParams, StarburstGlState>({+ type: 'remotion/starburst',+ label: 'starburst()',+ documentationLink: 'https://www.remotion.dev/docs/effects/starburst',+ backend: 'webgl2',+ calculateKey: (params) => {+ const r = resolve(params);+ return `starburst-${r.rays}-${r.colors.join('|')}-${r.rotation}-${r.smoothness}-${r.origin.join(':')}`;+ },+ setup: (target) => {+ const gl = target.getContext('webgl2', {+ premultipliedAlpha: true,+ alpha: true,+ preserveDrawingBuffer: true,+ });+ if (!gl) {+ throw createWebGL2ContextError('starburst effect');+ }++ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);++ const vs = compileShader(gl, gl.VERTEX_SHADER, STARBURST_VS);+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, STARBURST_FS);+ const program = linkProgram(gl, vs, fs);+ gl.deleteShader(vs);+ gl.deleteShader(fs);++ const vao = gl.createVertexArray();+ if (!vao) {+ throw new Error('Failed to create WebGL vertex array');+ }++ gl.bindVertexArray(vao);++ const data = new Float32Array([+ -1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,+ ]);++ const vbo = gl.createBuffer();+ if (!vbo) {+ throw new Error('Failed to create WebGL buffer');+ }++ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);++ const aPos = gl.getAttribLocation(program, 'aPos');+ const aUv = gl.getAttribLocation(program, 'aUv');+ gl.enableVertexAttribArray(aPos);+ gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);+ gl.enableVertexAttribArray(aUv);+ gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);++ gl.bindVertexArray(null);++ const paletteTexture = gl.createTexture();+ if (!paletteTexture) {+ throw new Error('Failed to create WebGL palette texture');+ }++ gl.bindTexture(gl.TEXTURE_2D, paletteTexture);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);+ gl.bindTexture(gl.TEXTURE_2D, null);++ return {+ gl,+ program,+ vao,+ vbo,+ paletteTexture,+ uColorPalette: gl.getUniformLocation(program, 'colorPalette'),+ uNumRays: gl.getUniformLocation(program, 'numRays'),+ uRotationOffset: gl.getUniformLocation(program, 'rotationOffset'),+ uSmoothEdge: gl.getUniformLocation(program, 'smoothEdge'),+ uResolution: gl.getUniformLocation(program, 'resolution'),+ uNumColors: gl.getUniformLocation(program, 'numColors'),+ uOrigin: gl.getUniformLocation(program, 'origin'),+ cachedPaletteKey: '',+ palettePixelData: new Uint8Array(0),+ };+ },+ apply: ({width, height, params, state}) => {+ const r = resolve(params);+ const {+ gl,+ program,+ vao,+ paletteTexture,+ uColorPalette,+ uNumRays,+ uRotationOffset,+ uSmoothEdge,+ uResolution,+ uNumColors,+ uOrigin,+ } = state;++ const rotationRad = (r.rotation * Math.PI) / 180;++ const paletteKey = r.colors.join('|');+ const paletteDirty = state.cachedPaletteKey !== paletteKey;+ if (paletteDirty) {+ state.cachedPaletteKey = paletteKey;+ const len = r.colors.length * 4;+ if (state.palettePixelData.length !== len) {+ state.palettePixelData = new Uint8Array(len);+ }++ const {palettePixelData} = state;+ for (let i = 0; i < r.colors.length; i++) {+ const rgb = colorToRgb(r.colors[i]);+ palettePixelData[i * 4] = rgb[0];+ palettePixelData[i * 4 + 1] = rgb[1];+ palettePixelData[i * 4 + 2] = rgb[2];+ palettePixelData[i * 4 + 3] = 255;+ }+ }++ gl.viewport(0, 0, width, height);+ gl.clearColor(0, 0, 0, 0);+ gl.clear(gl.COLOR_BUFFER_BIT);++ gl.useProgram(program);+ gl.bindVertexArray(vao);++ gl.activeTexture(gl.TEXTURE0);+ gl.bindTexture(gl.TEXTURE_2D, paletteTexture);+ if (paletteDirty) {+ gl.texImage2D(+ gl.TEXTURE_2D,+ 0,+ gl.RGBA,+ r.colors.length,+ 1,+ 0,+ gl.RGBA,+ gl.UNSIGNED_BYTE,+ state.palettePixelData,+ );+ }++ if (uColorPalette) gl.uniform1i(uColorPalette, 0);+ if (uNumRays) gl.uniform1f(uNumRays, r.rays);+ if (uNumColors) gl.uniform1f(uNumColors, r.colors.length);+ if (uRotationOffset) gl.uniform1f(uRotationOffset, rotationRad);+ if (uSmoothEdge) gl.uniform1f(uSmoothEdge, r.smoothness);+ if (uOrigin) gl.uniform2f(uOrigin, r.origin[0], 1 - r.origin[1]);+ if (uResolution) gl.uniform2f(uResolution, width, height);++ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);++ gl.bindVertexArray(null);+ gl.bindTexture(gl.TEXTURE_2D, null);+ gl.useProgram(null);+ },+ cleanup: ({gl, program, vao, vbo, paletteTexture}) => {+ gl.deleteBuffer(vbo);+ gl.deleteProgram(program);+ gl.deleteVertexArray(vao);+ gl.deleteTexture(paletteTexture);+ },+ schema: starburstEffectSchema,+ validateParams: validateStarburstEffectParams,+});diff --git a/packages/effects/src/test/effect-params.test.ts b/packages/effects/src/test/effect-params.test.tsindex 96fb29e321..62b56931d8 100644--- a/packages/effects/src/test/effect-params.test.ts+++ b/packages/effects/src/test/effect-params.test.ts@@ -51,6 +51,7 @@ import {shine} from '../shine.js';import {shrinkwrap} from '../shrinkwrap.js';import {skew} from '../skew.js';import {speckle} from '../speckle.js';+import {starburst} from '../starburst.js';import {thermalVision} from '../thermal-vision.js';import {tint} from '../tint.js';import {uvTranslate, xyTranslate} from '../translate.js';@@ -231,6 +232,10 @@ test('@remotion/effects expose documentation links', () => {expect(speckle().definition.documentationLink).toBe('https://www.remotion.dev/docs/effects/speckle',);+ expect(+ starburst({rays: 12, colors: ['#ff0000', '#00ff00']}).definition+ .documentationLink,+ ).toBe('https://www.remotion.dev/docs/effects/starburst');expect(thermalVision().definition.documentationLink).toBe('https://www.remotion.dev/docs/effects/thermal-vision',);diff --git a/packages/starburst/src/test/starburst-effect-params.test.ts b/packages/effects/src/test/starburst.test.tssimilarity index 72%rename from packages/starburst/src/test/starburst-effect-params.test.tsrename to packages/effects/src/test/starburst.test.tsindex 9f6f29539b..a15d949e48 100644--- a/packages/starburst/src/test/starburst-effect-params.test.ts+++ b/packages/effects/src/test/starburst.test.ts@@ -1,7 +1,5 @@import {expect, test} from 'bun:test';-import {colorToRgb} from '../color-to-rgb.js';-import {starburst} from '../starburst-effect.js';-import {starburstSchema} from '../Starburst.js';+import {starburst} from '../starburst.js';test('starburst() throws when rays is not passed', () => {expect(() =>@@ -21,16 +19,11 @@ test('starburst() accepts CSS named colors', () => {expect(() => starburst({rays: 12, colors: ['red', 'blue']})).not.toThrow();});-test('colorToRgb() parses CSS colors using Remotion color parsing', () => {- expect(colorToRgb('red')).toEqual([255, 0, 0]);- expect(colorToRgb('hsl(120, 100%, 50%)')).toEqual([0, 255, 0]);-});-test('starburst() exposes its documentation link', () => {expect(starburst({rays: 12, colors: ['#ff0000', '#00ff00']}).definition.documentationLink,- ).toBe('https://www.remotion.dev/docs/starburst/starburst-effect');+ ).toBe('https://www.remotion.dev/docs/effects/starburst');});test('starburst() exposes its API name as the Studio label', () => {@@ -39,7 +32,7 @@ test('starburst() exposes its API name as the Studio label', () => {).toBe('starburst()');});-test('starburst() does not expose the removed vignette control', () => {+test('starburst() does not expose a vignette control', () => {expect('vignette' instarburst({rays: 12, colors: ['#ff0000', '#00ff00']}).definition.schema,@@ -52,8 +45,6 @@ test('starburst() exposes origin as a UV coordinate control', () => {colors: ['#ff0000', '#00ff00'],}).definition;- expect('originOffsetX' in schema).toBe(false);- expect('originOffsetY' in schema).toBe(false);expect(schema.origin).toEqual({type: 'uv-coordinate',min: 0,@@ -83,27 +74,6 @@ test('starburst() exposes colors as an array control', () => {});});-test('<Starburst> exposes colors as an array control', () => {- expect(starburstSchema.colors).toEqual({- type: 'array',- item: {- type: 'color',- },- default: undefined,- minLength: 2,- newItemDefault: '#ff0000',- description: 'Colors',- keyframable: false,- });-});--test('<Starburst> exposes background and border controls', () => {- expect('style.backgroundColor' in starburstSchema).toBe(true);- expect('style.borderWidth' in starburstSchema).toBe(true);- expect('style.borderStyle' in starburstSchema).toBe(true);- expect('style.borderColor' in starburstSchema).toBe(true);-});-test('starburst() parameters produce distinct effect keys', () => {const defaultStarburst = starburst({rays: 12,diff --git a/packages/example/src/CenteredSolid.tsx b/packages/example/src/CenteredSolid.tsxindex 6bbad6cc2e..a1385749a5 100644--- a/packages/example/src/CenteredSolid.tsx+++ b/packages/example/src/CenteredSolid.tsx@@ -2,8 +2,8 @@ import {fisheye} from '@remotion/effects/fisheye';import {glow} from '@remotion/effects/glow';import {halftone} from '@remotion/effects/halftone';import {halftoneLinearGradient} from '@remotion/effects/halftone-linear-gradient';+import {starburst} from '@remotion/effects/starburst';import {vignette} from '@remotion/effects/vignette';-import {starburst} from '@remotion/starburst';import React from 'react';import {AbsoluteFill, Solid, interpolate, useCurrentFrame} from 'remotion';diff --git a/packages/example/src/EffectsTestbed/EffectsTestbed.tsx b/packages/example/src/EffectsTestbed/EffectsTestbed.tsxindex ec56b57b3f..c8d5506fc3 100644--- a/packages/example/src/EffectsTestbed/EffectsTestbed.tsx+++ b/packages/example/src/EffectsTestbed/EffectsTestbed.tsx@@ -1,10 +1,10 @@import {blur} from '@remotion/effects/blur';import {halftone} from '@remotion/effects/halftone';+import {starburst} from '@remotion/effects/starburst';import {tint} from '@remotion/effects/tint';import {wave} from '@remotion/effects/wave';import {lightLeak} from '@remotion/light-leaks';import {Video} from '@remotion/media';-import {starburst} from '@remotion/starburst';import React from 'react';import {AbsoluteFill, Solid, useCurrentFrame, useVideoConfig} from 'remotion';diff --git a/packages/skills/skills/remotion-markup/effects.md b/packages/skills/skills/remotion-markup/effects.mdindex 244f01b513..7c6136bd92 100644--- a/packages/skills/skills/remotion-markup/effects.md+++ b/packages/skills/skills/remotion-markup/effects.md@@ -18,7 +18,7 @@ Install the package that provides the chosen effect:npx remotion add @remotion/effects```-Use `npx remotion add @remotion/light-leaks` for `lightLeak()` and `npx remotion add @remotion/starburst` for `starburst()`.+Use `npx remotion add @remotion/light-leaks` for `lightLeak()`.Effects are functions passed to the `effects` prop of canvas-based components such as `<Video>` from `@remotion/media`, `<Solid>`, `<CanvasImage>`, and `<HtmlInCanvas>`.@@ -29,7 +29,7 @@ import {blur} from '@remotion/effects/blur';<Video src="https://remotion.media/video.mp4" effects={[blur({radius: 8})]} />;```-Use the effect docs for exact props and imports. Most `@remotion/effects` imports use `@remotion/effects/<effect-slug>`; `uvTranslate()` and `xyTranslate()` use `@remotion/effects/translate`; `lightLeak()` uses `@remotion/light-leaks`; `starburst()` uses `@remotion/starburst`.+Use the effect docs for exact props and imports. Most `@remotion/effects` imports use `@remotion/effects/<effect-slug>`; `uvTranslate()` and `xyTranslate()` use `@remotion/effects/translate`; `lightLeak()` uses `@remotion/light-leaks`.These effects use WebGL2. During renders, enable WebGL with:diff --git a/packages/starburst/bundle.ts b/packages/starburst/bundle.tsindex f7b114c5c3..ed3aa2e6f9 100644--- a/packages/starburst/bundle.ts+++ b/packages/starburst/bundle.ts@@ -10,6 +10,7 @@ const output = await build({entrypoints: ['src/index.ts'],naming: '[name].mjs',external: [+ '@remotion/effects/starburst','remotion','remotion/no-react','react',diff --git a/packages/starburst/package.json b/packages/starburst/package.jsonindex 14552c78aa..37c68d3fd8 100644--- a/packages/starburst/package.json+++ b/packages/starburst/package.json@@ -24,6 +24,7 @@"url": "https://github.com/remotion-dev/remotion/issues"},"dependencies": {+ "@remotion/effects": "workspace:*","remotion": "workspace:*","zod": "catalog:"},diff --git a/packages/starburst/src/starburst-effect.ts b/packages/starburst/src/starburst-effect.tsindex a78eedbcf0..978e6f07a8 100644--- a/packages/starburst/src/starburst-effect.ts+++ b/packages/starburst/src/starburst-effect.ts@@ -1,434 +1,6 @@-import type {InteractivitySchema} from 'remotion';-import {Internals} from 'remotion';-import {colorToRgb} from './color-to-rgb';--const {createEffect, createWebGL2ContextError} = Internals;--const DEFAULT_ORIGIN = [0.5, 0.5] as const;--export const starburstEffectSchema = {- rays: {- type: 'number',- min: 2,- max: 100,- step: 1,- default: undefined,- description: 'Number of Rays',- hiddenFromList: false,- },- colors: {- type: 'array',- item: {- type: 'color',- },- default: undefined,- minLength: 2,- newItemDefault: '#ff0000',- description: 'Colors',- keyframable: false,- },- rotation: {- type: 'number',- min: 0,- max: 360,- step: 1,- default: 0,- description: 'Rotation',- hiddenFromList: false,- },- smoothness: {- type: 'number',- min: 0,- max: 1,- step: 0.01,- default: 0,- description: 'Edge Smoothness',- hiddenFromList: false,- },- origin: {- type: 'uv-coordinate',- min: 0,- max: 1,- step: 0.01,- default: DEFAULT_ORIGIN,- description: 'Origin',- },-} as const satisfies InteractivitySchema;--export type StarburstOrigin = readonly [number, number];--export type StarburstEffectParams = {- readonly rays: number;- readonly colors: readonly string[];- readonly rotation?: number;- readonly smoothness?: number;- readonly origin?: StarburstOrigin;-};--type StarburstResolved = {- rays: number;- colors: readonly string[];- rotation: number;- smoothness: number;- origin: StarburstOrigin;-};--const resolve = (p: StarburstEffectParams): StarburstResolved => ({- rays: p.rays,- colors: p.colors,- rotation: p.rotation ?? 0,- smoothness: p.smoothness ?? 0,- origin: (p.origin ?? DEFAULT_ORIGIN) as StarburstOrigin,-});--const validateStarburstEffectParams = (params: StarburstEffectParams): void => {- if (params === null || typeof params !== 'object') {- throw new TypeError(- `Starburst effect requires a parameters object, but got ${JSON.stringify(params)}`,- );- }-- const {rays, colors} = params;-- if (typeof rays !== 'number' || !Number.isFinite(rays)) {- throw new TypeError(- `"rays" must be a finite number, but got ${JSON.stringify(rays)}`,- );- }-- if (rays < 2 || rays > 100) {- throw new RangeError(`"rays" must be between 2 and 100, but got ${rays}`);- }-- if (!Array.isArray(colors) || colors.length < 2) {- throw new TypeError(- `"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`,- );- }-- const r = resolve(params);-- if (typeof r.rotation !== 'number' || !Number.isFinite(r.rotation)) {- throw new TypeError(- `"rotation" must be a finite number, but got ${JSON.stringify(params.rotation)}`,- );- }-- if (typeof r.smoothness !== 'number' || !Number.isFinite(r.smoothness)) {- throw new TypeError(- `"smoothness" must be a finite number, but got ${JSON.stringify(params.smoothness)}`,- );- }-- if (r.smoothness < 0 || r.smoothness > 1) {- throw new RangeError(- `"smoothness" must be between 0 and 1, but got ${r.smoothness}`,- );- }-- if (- !Array.isArray(r.origin) ||- r.origin.length !== 2 ||- r.origin.some((coordinate) => {- return typeof coordinate !== 'number' || !Number.isFinite(coordinate);- })- ) {- throw new TypeError('"origin" must be a [number, number] tuple');- }-- if (r.origin.some((coordinate) => coordinate < 0 || coordinate > 1)) {- throw new RangeError(- `"origin" must contain coordinates between 0 and 1, but got ${JSON.stringify(r.origin)}`,- );- }-- for (const c of r.colors) {- colorToRgb(c);- }-};--const STARBURST_VS = /* glsl */ `#version 300 es-in vec2 aPos;-in vec2 aUv;-out vec2 vUv;-void main() {- vUv = aUv;- gl_Position = vec4(aPos, 0.0, 1.0);-}-`;--const STARBURST_FS = /* glsl */ `#version 300 es-precision highp float;--uniform sampler2D colorPalette;-uniform float numRays;-uniform float rotationOffset;-uniform float smoothEdge;-uniform vec2 resolution;-uniform float numColors;-uniform vec2 origin;--in vec2 vUv;-out vec4 fragColor;--const float Pi = 3.14159265359;--void main() {- vec2 uv = vUv;- vec2 center = uv - origin;- center.x *= resolution.x / resolution.y;-- float angle = atan(center.y, center.x) + rotationOffset;- float normalizedAngle = (angle + Pi) / (2.0 * Pi);- float sector = normalizedAngle * numRays;- float rayIndex = mod(floor(sector), numRays);-- float colorIndex = mod(rayIndex, numColors);- float texCoord = (colorIndex + 0.5) / numColors;- vec3 col = texture(colorPalette, vec2(texCoord, 0.5)).rgb;-- float fractSector = fract(sector);- float edgeSmooth = smoothEdge * 0.5;- float nextColorIndex = mod(rayIndex + 1.0, numColors);- float nextTexCoord = (nextColorIndex + 0.5) / numColors;- vec3 nextCol = texture(colorPalette, vec2(nextTexCoord, 0.5)).rgb;-- float blend = smoothstep(1.0 - edgeSmooth, 1.0, fractSector);- col = mix(col, nextCol, blend);- float blendStart = smoothstep(edgeSmooth, 0.0, fractSector);- float prevColorIndex = mod(rayIndex - 1.0 + numColors, numColors);- float prevTexCoord = (prevColorIndex + 0.5) / numColors;- vec3 prevCol = texture(colorPalette, vec2(prevTexCoord, 0.5)).rgb;- col = mix(col, prevCol, blendStart);-- fragColor = vec4(col, 1.0);-}-`;--type StarburstGlState = {- gl: WebGL2RenderingContext;- program: WebGLProgram;- vao: WebGLVertexArrayObject;- vbo: WebGLBuffer;- paletteTexture: WebGLTexture;- uColorPalette: WebGLUniformLocation | null;- uNumRays: WebGLUniformLocation | null;- uRotationOffset: WebGLUniformLocation | null;- uSmoothEdge: WebGLUniformLocation | null;- uResolution: WebGLUniformLocation | null;- uNumColors: WebGLUniformLocation | null;- uOrigin: WebGLUniformLocation | null;- cachedPaletteKey: string;- palettePixelData: Uint8Array;-};--const compileShader = (- gl: WebGL2RenderingContext,- type: number,- source: string,-): WebGLShader => {- const shader = gl.createShader(type);- if (!shader) {- throw new Error('Failed to create WebGL shader');- }-- gl.shaderSource(shader, source);- gl.compileShader(shader);- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {- const log = gl.getShaderInfoLog(shader);- gl.deleteShader(shader);- throw new Error(`Starburst shader compile failed: ${log ?? '(no log)'}`);- }-- return shader;-};--const linkProgram = (- gl: WebGL2RenderingContext,- vs: WebGLShader,- fs: WebGLShader,-): WebGLProgram => {- const program = gl.createProgram();- if (!program) {- throw new Error('Failed to create WebGL program');- }-- gl.attachShader(program, vs);- gl.attachShader(program, fs);- gl.linkProgram(program);- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {- const log = gl.getProgramInfoLog(program);- gl.deleteProgram(program);- throw new Error(`Starburst program link failed: ${log ?? '(no log)'}`);- }-- return program;-};--export const starburst = createEffect<StarburstEffectParams, StarburstGlState>({- type: 'dev.remotion.starburst.starburst',- label: 'starburst()',- documentationLink: 'https://www.remotion.dev/docs/starburst/starburst-effect',- backend: 'webgl2',- calculateKey: (params) => {- const r = resolve(params);- return `starburst-${r.rays}-${r.colors.join('|')}-${r.rotation}-${r.smoothness}-${r.origin.join(':')}`;- },- setup: (target) => {- const gl = target.getContext('webgl2', {- premultipliedAlpha: true,- alpha: true,- preserveDrawingBuffer: true,- });- if (!gl) {- throw createWebGL2ContextError('starburst effect');- }-- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);-- const vs = compileShader(gl, gl.VERTEX_SHADER, STARBURST_VS);- const fs = compileShader(gl, gl.FRAGMENT_SHADER, STARBURST_FS);- const program = linkProgram(gl, vs, fs);- gl.deleteShader(vs);- gl.deleteShader(fs);-- const vao = gl.createVertexArray();- if (!vao) {- throw new Error('Failed to create WebGL vertex array');- }-- gl.bindVertexArray(vao);-- const data = new Float32Array([- -1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, 1, 1, 1,- ]);-- const vbo = gl.createBuffer();- if (!vbo) {- throw new Error('Failed to create WebGL buffer');- }-- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);-- const aPos = gl.getAttribLocation(program, 'aPos');- const aUv = gl.getAttribLocation(program, 'aUv');- gl.enableVertexAttribArray(aPos);- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);- gl.enableVertexAttribArray(aUv);- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);-- gl.bindVertexArray(null);-- const paletteTexture = gl.createTexture();- if (!paletteTexture) {- throw new Error('Failed to create WebGL palette texture');- }-- gl.bindTexture(gl.TEXTURE_2D, paletteTexture);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);- gl.bindTexture(gl.TEXTURE_2D, null);-- return {- gl,- program,- vao,- vbo,- paletteTexture,- uColorPalette: gl.getUniformLocation(program, 'colorPalette'),- uNumRays: gl.getUniformLocation(program, 'numRays'),- uRotationOffset: gl.getUniformLocation(program, 'rotationOffset'),- uSmoothEdge: gl.getUniformLocation(program, 'smoothEdge'),- uResolution: gl.getUniformLocation(program, 'resolution'),- uNumColors: gl.getUniformLocation(program, 'numColors'),- uOrigin: gl.getUniformLocation(program, 'origin'),- cachedPaletteKey: '',- palettePixelData: new Uint8Array(0),- };- },- apply: ({width, height, params, state}) => {- const r = resolve(params);- const {- gl,- program,- vao,- paletteTexture,- uColorPalette,- uNumRays,- uRotationOffset,- uSmoothEdge,- uResolution,- uNumColors,- uOrigin,- } = state;-- const rotationRad = (r.rotation * Math.PI) / 180;-- const paletteKey = r.colors.join('|');- const paletteDirty = state.cachedPaletteKey !== paletteKey;- if (paletteDirty) {- state.cachedPaletteKey = paletteKey;- const len = r.colors.length * 4;- if (state.palettePixelData.length !== len) {- state.palettePixelData = new Uint8Array(len);- }-- const {palettePixelData} = state;- for (let i = 0; i < r.colors.length; i++) {- const rgb = colorToRgb(r.colors[i]);- palettePixelData[i * 4] = rgb[0];- palettePixelData[i * 4 + 1] = rgb[1];- palettePixelData[i * 4 + 2] = rgb[2];- palettePixelData[i * 4 + 3] = 255;- }- }-- gl.viewport(0, 0, width, height);- gl.clearColor(0, 0, 0, 0);- gl.clear(gl.COLOR_BUFFER_BIT);-- gl.useProgram(program);- gl.bindVertexArray(vao);-- gl.activeTexture(gl.TEXTURE0);- gl.bindTexture(gl.TEXTURE_2D, paletteTexture);- if (paletteDirty) {- gl.texImage2D(- gl.TEXTURE_2D,- 0,- gl.RGBA,- r.colors.length,- 1,- 0,- gl.RGBA,- gl.UNSIGNED_BYTE,- state.palettePixelData,- );- }-- if (uColorPalette) gl.uniform1i(uColorPalette, 0);- if (uNumRays) gl.uniform1f(uNumRays, r.rays);- if (uNumColors) gl.uniform1f(uNumColors, r.colors.length);- if (uRotationOffset) gl.uniform1f(uRotationOffset, rotationRad);- if (uSmoothEdge) gl.uniform1f(uSmoothEdge, r.smoothness);- if (uOrigin) gl.uniform2f(uOrigin, r.origin[0], 1 - r.origin[1]);- if (uResolution) gl.uniform2f(uResolution, width, height);-- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);-- gl.bindVertexArray(null);- gl.bindTexture(gl.TEXTURE_2D, null);- gl.useProgram(null);- },- cleanup: ({gl, program, vao, vbo, paletteTexture}) => {- gl.deleteBuffer(vbo);- gl.deleteProgram(program);- gl.deleteVertexArray(vao);- gl.deleteTexture(paletteTexture);- },- schema: starburstEffectSchema,- validateParams: validateStarburstEffectParams,-});+export {+ starburst,+ starburstEffectSchema,+ type StarburstEffectParams,+ type StarburstOrigin,+} from '@remotion/effects/starburst';diff --git a/packages/starburst/src/test/starburst-component-params.test.ts b/packages/starburst/src/test/starburst-component-params.test.tsnew file mode 100644index 0000000000..10000de255--- /dev/null+++ b/packages/starburst/src/test/starburst-component-params.test.ts@@ -0,0 +1,38 @@+import {expect, test} from 'bun:test';+import {colorToRgb} from '../color-to-rgb.js';+import {starburst, StarburstInternals} from '../index.js';+import {starburstSchema} from '../Starburst.js';++test('colorToRgb() parses CSS colors using Remotion color parsing', () => {+ expect(colorToRgb('red')).toEqual([255, 0, 0]);+ expect(colorToRgb('hsl(120, 100%, 50%)')).toEqual([0, 255, 0]);+});++test('<Starburst> exposes colors as an array control', () => {+ expect(starburstSchema.colors).toEqual({+ type: 'array',+ item: {+ type: 'color',+ },+ default: undefined,+ minLength: 2,+ newItemDefault: '#ff0000',+ description: 'Colors',+ keyframable: false,+ });+});++test('<Starburst> exposes background and border controls', () => {+ expect('style.backgroundColor' in starburstSchema).toBe(true);+ expect('style.borderWidth' in starburstSchema).toBe(true);+ expect('style.borderStyle' in starburstSchema).toBe(true);+ expect('style.borderColor' in starburstSchema).toBe(true);+});++test('@remotion/starburst re-exports the migrated effect', () => {+ expect(StarburstInternals.starburst).toBe(starburst);+ expect(+ starburst({rays: 12, colors: ['#ff0000', '#00ff00']}).definition+ .documentationLink,+ ).toBe('https://www.remotion.dev/docs/effects/starburst');+});diff --git a/packages/studio-server/src/test/update-keyframes.test.ts b/packages/studio-server/src/test/update-keyframes.test.tsindex ccb4f710f6..50f33ac3d9 100644--- a/packages/studio-server/src/test/update-keyframes.test.ts+++ b/packages/studio-server/src/test/update-keyframes.test.ts@@ -1212,7 +1212,7 @@ test('updateSequenceKeyframes migrates rotate away from interpolateColors', asyn});test('updateSequenceKeyframes returns a node path that still resolves after inserting a frame hook', async () => {- const input = `import {starburst} from '@remotion/starburst';+ const input = `import {starburst} from '@remotion/effects/starburst';import React from 'react';import {AbsoluteFill, Solid} from 'remotion';diff --git a/packages/studio-shared/src/effect-catalog.ts b/packages/studio-shared/src/effect-catalog.tsindex 18618d4089..5252ad0dd7 100644--- a/packages/studio-shared/src/effect-catalog.ts+++ b/packages/studio-shared/src/effect-catalog.ts@@ -18,10 +18,6 @@ export const getEffectDocumentationPath = (item: EffectCatalogItem) => {return '/docs/light-leaks/light-leak-effect';}- if (item.id === 'effects-starburst') {- return '/docs/starburst/starburst-effect';- }-return `/docs/effects/${item.id.slice('effects-'.length)}`;};@@ -792,7 +788,7 @@ export const EFFECT_CATALOG: readonly EffectCatalogItem[] = [description: 'Starburst ray effect',effect: {name: 'starburst',- importPath: '@remotion/starburst',+ importPath: '@remotion/effects/starburst',config: {rays: 16,colors: ['#ff6600', '#ffff00'],diff --git a/packages/studio/src/test/effect-catalog.test.ts b/packages/studio/src/test/effect-catalog.test.tsindex c4a9a775db..e34d570f12 100644--- a/packages/studio/src/test/effect-catalog.test.ts+++ b/packages/studio/src/test/effect-catalog.test.ts@@ -37,6 +37,6 @@ test('effect catalog exposes documentation links for picker context menu', () =>'https://www.remotion.dev/docs/light-leaks/light-leak-effect',);expect(links.get('starburst()')).toBe(- 'https://www.remotion.dev/docs/starburst/starburst-effect',+ 'https://www.remotion.dev/docs/effects/starburst',);});