Skip to content

🎥 Make videos programmatically with React

`@remotion/starburst`: Add starburst ray effect package

Jonny Burgerde7d8fc3c004
diff --git a/bun.lock b/bun.lock
index 5fee488532..45596cf6a0 100644
--- a/bun.lock
+++ b/bun.lock
@@ -422,6 +422,7 @@
"@remotion/sfx": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/skia": "workspace:*",
+ "@remotion/starburst": "workspace:*",
"@remotion/studio": "workspace:*",
"@remotion/svg-3d-engine": "workspace:*",
"@remotion/tailwind": "workspace:*",
@@ -632,6 +633,7 @@
"@remotion/sfx": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/skia": "workspace:*",
+ "@remotion/starburst": "workspace:*",
"@remotion/studio": "workspace:*",
"@remotion/svg-3d-engine": "workspace:*",
"@remotion/tailwind-v4": "workspace:*",
@@ -1378,6 +1380,25 @@
"remotion": "workspace:*",
},
},
+ "packages/starburst": {
+ "name": "@remotion/starburst",
+ "version": "4.0.434",
+ "dependencies": {
+ "remotion": "workspace:*",
+ "zod": "catalog:",
+ },
+ "devDependencies": {
+ "@remotion/eslint-config-internal": "workspace:*",
+ "@typescript/native-preview": "catalog:",
+ "eslint": "catalog:",
+ "react": "catalog:",
+ "react-dom": "catalog:",
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0",
+ "react-dom": ">=16.8.0",
+ },
+ },
"packages/streaming": {
"name": "@remotion/streaming",
"version": "4.0.434",
@@ -3683,6 +3704,8 @@
"@remotion/skills": ["@remotion/skills@workspace:packages/skills"],
+ "@remotion/starburst": ["@remotion/starburst@workspace:packages/starburst"],
+
"@remotion/streaming": ["@remotion/streaming@workspace:packages/streaming"],
"@remotion/studio": ["@remotion/studio@workspace:packages/studio"],
diff --git a/packages/cli/src/list-of-remotion-packages.ts b/packages/cli/src/list-of-remotion-packages.ts
index 1f100c0607..a52ce6dae7 100644
--- a/packages/cli/src/list-of-remotion-packages.ts
+++ b/packages/cli/src/list-of-remotion-packages.ts
@@ -84,6 +84,7 @@ export const listOfRemotionPackages = [
'@remotion/web-renderer',
'@remotion/design',
'@remotion/light-leaks',
+ '@remotion/starburst',
'@remotion/vercel',
'@remotion/sfx',
];
diff --git a/packages/create-video/src/list-of-remotion-packages.ts b/packages/create-video/src/list-of-remotion-packages.ts
index 1f100c0607..a52ce6dae7 100644
--- a/packages/create-video/src/list-of-remotion-packages.ts
+++ b/packages/create-video/src/list-of-remotion-packages.ts
@@ -84,6 +84,7 @@ export const listOfRemotionPackages = [
'@remotion/web-renderer',
'@remotion/design',
'@remotion/light-leaks',
+ '@remotion/starburst',
'@remotion/vercel',
'@remotion/sfx',
];
diff --git a/packages/docs/components/TableOfContents/api.tsx b/packages/docs/components/TableOfContents/api.tsx
index 43aa965a58..bfcaa6df8e 100644
--- a/packages/docs/components/TableOfContents/api.tsx
+++ b/packages/docs/components/TableOfContents/api.tsx
@@ -13,7 +13,6 @@ import {TableOfContents as LambdaTableOfContents} from '../../docs/lambda/table-
import {TableOfContents as LayoutUtilsTableOfContents} from '../../docs/layout-utils/table-of-contents';
import {TableOfContents as LicensingTableOfContents} from '../../docs/licensing/TableOfContents';
import {TableOfContents as LightLeaksTableOfContents} from '../../docs/light-leaks/table-of-contents';
-import {TableOfContents as SfxTableOfContents} from '../../docs/sfx/table-of-contents';
import {TableOfContents as LottieTableOfContents} from '../../docs/lottie/table-of-contents';
import {TableOfContents as MediaParserTableOfContents} from '../../docs/media-parser/TableOfContents';
import {TableOfContents as MediaUtilsTableOfContents} from '../../docs/media-utils/table-of-contents';
@@ -27,8 +26,10 @@ import {TableOfContents as PreloadTableOfContents} from '../../docs/preload/tabl
import {TableOfContents as RemotionTableOfContents} from '../../docs/remotion/table-of-contents';
import {TableOfContents as RendererTableOfContents} from '../../docs/renderer/TableOfContents';
import {TableOfContents as RiveTableOfContents} from '../../docs/rive/table-of-contents';
+import {TableOfContents as SfxTableOfContents} from '../../docs/sfx/table-of-contents';
import {TableOfContents as ShapesTableOfContents} from '../../docs/shapes/table-of-contents';
import {TableOfContents as SkiaTableOfContents} from '../../docs/skia/TableOfContents';
+import {TableOfContents as StarburstTableOfContents} from '../../docs/starburst/table-of-contents';
import {TableOfContents as StudioTableOfContents} from '../../docs/studio/TableOfContents';
import {TableOfContents as TailwindV4TableOfContents} from '../../docs/tailwind-v4/TableOfContents';
import {TableOfContents as TailwindTableOfContents} from '../../docs/tailwind/TableOfContents';
@@ -159,6 +160,9 @@ export const TableOfContents: React.FC = () => {
<h2>@remotion/light-leaks</h2>
<p>Light leak effects</p>
<LightLeaksTableOfContents />
+ <h2>@remotion/starburst</h2>
+ <p>Starburst ray effects</p>
+ <StarburstTableOfContents />
<h2>@remotion/vercel</h2>
<p>Render videos on Vercel Sandbox</p>
<VercelTableOfContents />
diff --git a/packages/docs/docs/starburst-guide.mdx b/packages/docs/docs/starburst-guide.mdx
new file mode 100644
index 0000000000..354499cdbd
--- /dev/null
+++ b/packages/docs/docs/starburst-guide.mdx
@@ -0,0 +1,115 @@
+---
+image: /generated/articles-docs-starburst-guide.png
+id: starburst
+title: Starburst
+crumb: 'Techniques'
+---
+
+# Starburst<AvailableFrom v="4.0.435"/>
+
+The [`<Starburst>`](/docs/starburst/starburst) component from [`@remotion/starburst`](/docs/starburst/api) renders a WebGL-based retro starburst ray effect. The effect reveals during the first half of its duration and retracts during the second half.
+
+```tsx twoslash title="MyComp.tsx"
+import {Starburst} from '@remotion/starburst';
+import {AbsoluteFill} from 'remotion';
+
+const MyComp = () => {
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Starburst durationInFrames={60} rays={16} color1="#ffdd00" color2="#ff8800" />
+ </AbsoluteFill>
+ );
+};
+```
+
+## Changing the number of rays
+
+The [`rays`](/docs/starburst/starburst#rays) prop controls how many rays appear in the pattern. Values from `2` to `100` are supported.
+
+```tsx twoslash title="ManyRays.tsx"
+import {Starburst} from '@remotion/starburst';
+import {AbsoluteFill} from 'remotion';
+
+// ---cut---
+const MyComp = () => {
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Starburst rays={24} durationInFrames={30} />
+ </AbsoluteFill>
+ );
+};
+```
+
+## Changing the colors
+
+Use [`color1`](/docs/starburst/starburst#color1) and [`color2`](/docs/starburst/starburst#color2) to set the alternating ray colors:
+
+```tsx twoslash title="CustomColors.tsx"
+import {Starburst} from '@remotion/starburst';
+import {AbsoluteFill} from 'remotion';
+
+// ---cut---
+const MyComp = () => {
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Starburst color1="#ff0066" color2="#6600ff" durationInFrames={30} />
+ </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 rotation={45} durationInFrames={30} />
+ </AbsoluteFill>
+ );
+};
+```
+
+## Using as a transition
+
+Combined with [`<TransitionSeries.Overlay>`](/docs/transitions/transitionseries#transitionseriesoverlay), you can place a starburst at the cut point between two sequences without shortening the timeline.
+
+```tsx twoslash title="StarburstTransition.tsx"
+import {AbsoluteFill} from 'remotion';
+const Fill = ({color}: {color: string}) => <AbsoluteFill style={{backgroundColor: color}} />;
+
+// ---cut---
+import {Starburst} from '@remotion/starburst';
+import {TransitionSeries} from '@remotion/transitions';
+
+const StarburstTransition = () => {
+ return (
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <Fill color="#0b84f3" />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Overlay durationInFrames={20}>
+ <Starburst rays={12} color1="#ffdd00" color2="#ff8800" />
+ </TransitionSeries.Overlay>
+ <TransitionSeries.Sequence durationInFrames={60}>
+ <Fill color="pink" />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ );
+};
+```
+
+At the midpoint, the starburst covers most of the canvas, hiding the cut between scenes.
+
+## See also
+
+- [`<Starburst>` API reference](/docs/starburst/starburst)
+- [`@remotion/starburst`](/docs/starburst/api)
+- [`<TransitionSeries.Overlay>`](/docs/transitions/transitionseries#transitionseriesoverlay)
+- [Transitions](/docs/transitioning)
diff --git a/packages/docs/docs/starburst/index.mdx b/packages/docs/docs/starburst/index.mdx
new file mode 100644
index 0000000000..a1e168a0d2
--- /dev/null
+++ b/packages/docs/docs/starburst/index.mdx
@@ -0,0 +1,22 @@
+---
+image: /generated/articles-docs-starburst-index.png
+id: starburst-api
+slug: /starburst/api
+title: '@remotion/starburst'
+---
+
+# @remotion/starburst<AvailableFrom v="4.0.435" />
+
+Starburst ray effects for Remotion videos.
+
+import {TableOfContents} from './table-of-contents';
+
+<Installation pkg="@remotion/starburst" />
+
+## Components
+
+<TableOfContents />
+
+## License
+
+[Remotion License](/docs/license)
diff --git a/packages/docs/docs/starburst/starburst.mdx b/packages/docs/docs/starburst/starburst.mdx
new file mode 100644
index 0000000000..0fd59571f6
--- /dev/null
+++ b/packages/docs/docs/starburst/starburst.mdx
@@ -0,0 +1,71 @@
+---
+image: /generated/articles-docs-starburst-starburst.png
+title: '<Starburst>'
+crumb: '@remotion/starburst'
+---
+
+# &lt;Starburst><AvailableFrom v="4.0.435" />
+
+Renders a WebGL-based retro starburst ray effect.
+The effect reveals during the first half of the duration and retracts during the second half.
+Is a [`<Sequence>`](/docs/sequence) component under the hood and accepts its props.
+
+## Example
+
+```tsx twoslash title="MyComp.tsx"
+import {Starburst} from '@remotion/starburst';
+import {AbsoluteFill} from 'remotion';
+
+const MyVideo = () => {
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Starburst
+ durationInFrames={60}
+ rays={16}
+ color1="#ffdd00"
+ color2="#ff8800"
+ rotation={15}
+ />
+ </AbsoluteFill>
+ );
+};
+```
+
+## API
+
+Apart from the props listed below, all props from [`<Sequence>`](/docs/sequence) except `children` and `layout` are accepted.
+
+### `durationInFrames?`
+
+The duration of the starburst effect in frames. The effect reveals during the first half and retracts during the second half.
+
+If not specified, defaults to the duration of the composition or sequence, reading from [`useVideoConfig()`](/docs/use-video-config).
+
+### `rays?`
+
+The number of rays in the starburst pattern. Must be between `2` and `100`. Default: `12`.
+
+### `color1?`
+
+The primary color of the starburst rays as a hex string. Default: `"#ffdd00"` (yellow).
+
+### `color2?`
+
+The secondary (alternating) color of the starburst rays as a hex string. Default: `"#ff8800"` (orange).
+
+### `rotation?`
+
+Rotates the starburst pattern in degrees (`0`-`360`). Default: `0`.
+
+### `smoothness?`
+
+Controls the softness of the ray edges. `0` gives hard edges, `1` gives very soft edges. Default: `0.1`.
+
+## Compatibility
+
+<CompatibilityTable chrome firefox safari nodejs="" bun="" serverlessFunctions="" clientSideRendering serverSideRendering player studio hideServers />
+
+## See also
+
+- [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/docs/starburst/table-of-contents.tsx b/packages/docs/docs/starburst/table-of-contents.tsx
new file mode 100644
index 0000000000..3501c441e1
--- /dev/null
+++ b/packages/docs/docs/starburst/table-of-contents.tsx
@@ -0,0 +1,16 @@
+import React from 'react';
+import {Grid} from '../../components/TableOfContents/Grid';
+import {TOCItem} from '../../components/TableOfContents/TOCItem';
+
+export const TableOfContents: React.FC = () => {
+ return (
+ <div>
+ <Grid>
+ <TOCItem link="/docs/starburst/starburst">
+ <strong>{'<Starburst>'}</strong>
+ <div>Render a starburst ray effect</div>
+ </TOCItem>
+ </Grid>
+ </div>
+ );
+};
diff --git a/packages/docs/package.json b/packages/docs/package.json
index a15045b203..63985cbc15 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -54,6 +54,7 @@
"@remotion/layout-utils": "workspace:*",
"@remotion/licensing": "workspace:*",
"@remotion/light-leaks": "workspace:*",
+ "@remotion/starburst": "workspace:*",
"@remotion/lottie": "workspace:*",
"@remotion/media": "workspace:*",
"@remotion/media-parser": "workspace:*",
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 18be262d8c..165afa8310 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -460,6 +460,15 @@ const sidebars: SidebarsConfig = {
},
items: ['light-leaks/light-leak'],
},
+ {
+ type: 'category',
+ label: '@remotion/starburst',
+ link: {
+ type: 'doc',
+ id: 'starburst/starburst-api',
+ },
+ items: ['starburst/starburst'],
+ },
{
type: 'category',
label: '@remotion/sfx',
@@ -908,6 +917,7 @@ const sidebars: SidebarsConfig = {
'animation-math',
'shaders',
'light-leaks',
+ 'starburst',
],
},
{
diff --git a/packages/example/package.json b/packages/example/package.json
index 1cdd0f9712..ad8f725efe 100644
--- a/packages/example/package.json
+++ b/packages/example/package.json
@@ -50,6 +50,7 @@
"@remotion/lambda-client": "workspace:*",
"@remotion/layout-utils": "workspace:*",
"@remotion/light-leaks": "workspace:*",
+ "@remotion/starburst": "workspace:*",
"@remotion/lottie": "workspace:*",
"@remotion/media": "workspace:*",
"@remotion/media-parser": "workspace:*",
diff --git a/packages/example/src/Root.tsx b/packages/example/src/Root.tsx
index 1f76d00c01..977046c6c4 100644
--- a/packages/example/src/Root.tsx
+++ b/packages/example/src/Root.tsx
@@ -145,6 +145,7 @@ import {PrintProps} from './PrintProps';
import {SfxExample} from './Sfx';
import {SmoothTextTransition} from './SmoothTextTransition';
import {SpringSeason} from './SpringSeason';
+import {StarburstExample} from './Starburst';
import {Seek} from './StudioApis/Seek';
import {TikTokTextBoxPlayground} from './TikTokTextbox/TikTokTextBox';
import {FitTextOnNLines, fitTextOnNLinesSchema} from './Title/FitTextOnNLines';
@@ -1854,6 +1855,16 @@ export const Index: React.FC = () => {
durationInFrames={120}
/>
</Folder>
+ <Folder name="starburst">
+ <Composition
+ id="starburst"
+ component={StarburstExample}
+ width={1080}
+ height={1080}
+ fps={30}
+ durationInFrames={90}
+ />
+ </Folder>
<Composition
id="sfx"
component={SfxExample}
diff --git a/packages/example/src/Starburst/index.tsx b/packages/example/src/Starburst/index.tsx
new file mode 100644
index 0000000000..a9ea187f6e
--- /dev/null
+++ b/packages/example/src/Starburst/index.tsx
@@ -0,0 +1,23 @@
+import {Starburst} from '@remotion/starburst';
+import React from 'react';
+import {AbsoluteFill} from 'remotion';
+
+export const StarburstExample: React.FC = () => {
+ return (
+ <AbsoluteFill style={{backgroundColor: 'black'}}>
+ <Starburst
+ durationInFrames={60}
+ rays={16}
+ color1="#ffdd00"
+ color2="#ff8800"
+ />
+ <Starburst
+ durationInFrames={60}
+ rays={8}
+ color1="#ff0066"
+ color2="#6600ff"
+ rotation={22.5}
+ />
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/example/tsconfig.json b/packages/example/tsconfig.json
index 3077506bb3..2858e379bb 100644
--- a/packages/example/tsconfig.json
+++ b/packages/example/tsconfig.json
@@ -41,6 +41,7 @@
{"path": "../webcodecs"},
{"path": "../whisper-web"},
{"path": "../light-leaks"},
+ {"path": "../starburst"},
{"path": "../sfx"},
{"path": "../layout-utils"},
{"path": "../media"},
diff --git a/packages/starburst/.npmignore b/packages/starburst/.npmignore
new file mode 100644
index 0000000000..71352c3fd9
--- /dev/null
+++ b/packages/starburst/.npmignore
@@ -0,0 +1,10 @@
+dist/test/**
+src
+eslint.config.mjs
+tsconfig.tsbuildinfo
+*.tgz
+.turbo
+tsconfig.json
+.prettierrc.js
+bundle.ts
+dist/cjs/test
\ No newline at end of file
diff --git a/packages/starburst/README.md b/packages/starburst/README.md
new file mode 100644
index 0000000000..d14350aca2
--- /dev/null
+++ b/packages/starburst/README.md
@@ -0,0 +1,18 @@
+# @remotion/starburst
+
+Starburst ray effects for Remotion
+
+[![NPM Downloads](https://img.shields.io/npm/dm/@remotion/starburst.svg?style=flat&color=black&label=Downloads)](https://npmcharts.com/compare/@remotion/starburst?minimal=true)
+
+## Installation
+
+```bash
+npm install @remotion/starburst --save-exact
+```
+
+When installing a Remotion package, make sure to align the version of all `remotion` and `@remotion/*` packages to the same version.
+Remove the `^` character from the version number to use the exact version.
+
+## Usage
+
+See the [documentation](https://www.remotion.dev/docs/starburst) for more information.
diff --git a/packages/starburst/bundle.ts b/packages/starburst/bundle.ts
new file mode 100644
index 0000000000..f7b114c5c3
--- /dev/null
+++ b/packages/starburst/bundle.ts
@@ -0,0 +1,34 @@
+import path from 'path';
+import {build} from 'bun';
+
+if (process.env.NODE_ENV !== 'production') {
+ throw new Error('This script must be run using NODE_ENV=production');
+}
+
+console.time('Generated.');
+const output = await build({
+ entrypoints: ['src/index.ts'],
+ naming: '[name].mjs',
+ external: [
+ 'remotion',
+ 'remotion/no-react',
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ ],
+});
+
+if (!output.success) {
+ console.log(output.logs.join('\n'));
+ process.exit(1);
+}
+
+for (const file of output.outputs) {
+ const str = await file.text();
+ const out = path.join('dist', 'esm', file.path);
+
+ await Bun.write(out, str);
+}
+
+console.timeEnd('Generated.');
diff --git a/packages/starburst/eslint.config.mjs b/packages/starburst/eslint.config.mjs
new file mode 100644
index 0000000000..ab29acaba0
--- /dev/null
+++ b/packages/starburst/eslint.config.mjs
@@ -0,0 +1,7 @@
+import {remotionFlatConfig} from '@remotion/eslint-config-internal';
+
+const config = remotionFlatConfig({react: true});
+
+export default {
+ ...config,
+};
diff --git a/packages/starburst/package.json b/packages/starburst/package.json
new file mode 100644
index 0000000000..02ad386c9f
--- /dev/null
+++ b/packages/starburst/package.json
@@ -0,0 +1,57 @@
+{
+ "name": "@remotion/starburst",
+ "version": "4.0.434",
+ "description": "Starburst ray effects for Remotion",
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "module": "dist/esm/index.mjs",
+ "repository": {
+ "url": "https://github.com/remotion-dev/remotion/tree/main/packages/starburst"
+ },
+ "sideEffects": false,
+ "type": "module",
+ "scripts": {
+ "formatting": "oxfmt src --check",
+ "format": "oxfmt src",
+ "lint": "eslint src",
+ "watch": "tsgo -w",
+ "make": "tsgo && bun --env-file=../.env.bundle bundle.ts"
+ },
+ "author": "Jonny Burger <[email protected]>",
+ "contributors": [],
+ "license": "Remotion License",
+ "bugs": {
+ "url": "https://github.com/remotion-dev/remotion/issues"
+ },
+ "dependencies": {
+ "remotion": "workspace:*",
+ "zod": "catalog:"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0",
+ "react-dom": ">=16.8.0"
+ },
+ "exports": {
+ ".": {
+ "types": "./dist/index.d.ts",
+ "module": "./dist/esm/index.mjs",
+ "import": "./dist/esm/index.mjs"
+ },
+ "./package.json": "./package.json"
+ },
+ "devDependencies": {
+ "react": "catalog:",
+ "react-dom": "catalog:",
+ "@remotion/eslint-config-internal": "workspace:*",
+ "eslint": "catalog:",
+ "@typescript/native-preview": "catalog:"
+ },
+ "keywords": [
+ "remotion",
+ "starburst"
+ ],
+ "publishConfig": {
+ "access": "public"
+ },
+ "homepage": "https://www.remotion.dev/docs/starburst"
+}
diff --git a/packages/starburst/src/Starburst.tsx b/packages/starburst/src/Starburst.tsx
new file mode 100644
index 0000000000..ac5abb4489
--- /dev/null
+++ b/packages/starburst/src/Starburst.tsx
@@ -0,0 +1,363 @@
+import React, {useCallback, useEffect, useRef, useState} from 'react';
+import {type SequenceControls, type SequenceSchema} from 'remotion';
+import {
+ AbsoluteFill,
+ Internals,
+ Sequence,
+ useCurrentFrame,
+ useDelayRender,
+ useVideoConfig,
+ type AbsoluteFillLayout,
+ type LayoutAndStyle,
+ type SequenceProps,
+} from 'remotion';
+
+export type StarburstProps = Omit<
+ SequenceProps,
+ 'children' | 'durationInFrames' | keyof LayoutAndStyle
+> &
+ Omit<AbsoluteFillLayout, 'layout'> & {
+ readonly durationInFrames?: number;
+ readonly rays?: number;
+ readonly color1?: string;
+ readonly color2?: string;
+ readonly rotation?: number;
+ readonly smoothness?: number;
+ };
+
+const hexToRgb = (hex: string): [number, number, number] => {
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
+ if (!result) {
+ throw new Error(`Invalid hex color: ${hex}`);
+ }
+
+ return [
+ parseInt(result[1], 16) / 255,
+ parseInt(result[2], 16) / 255,
+ parseInt(result[3], 16) / 255,
+ ];
+};
+
+const VERTEX_SHADER = `
+attribute vec2 position;
+void main() {
+ gl_Position = vec4(position, 0.0, 1.0);
+}
+`;
+
+const FRAGMENT_SHADER = `
+#ifdef GL_ES
+precision mediump float;
+#endif
+
+uniform float progress;
+uniform float numRays;
+uniform vec3 color1;
+uniform vec3 color2;
+uniform float rotationOffset;
+uniform float smoothEdge;
+uniform vec2 resolution;
+
+const float Pi = 3.14159265359;
+
+void main() {
+ vec2 uv = gl_FragCoord.xy / resolution;
+ vec2 center = uv - 0.5;
+ center.x *= resolution.x / resolution.y;
+
+ float angle = atan(center.y, center.x) + rotationOffset;
+ float rayPattern = cos(angle * numRays) * 0.5 + 0.5;
+
+ float edgeSmooth = smoothEdge * 0.5;
+ float ray = smoothstep(0.5 - edgeSmooth, 0.5 + edgeSmooth, rayPattern);
+
+ vec3 col = mix(color2, color1, ray);
+
+ float dist = length(center);
+
+ float revealRadius = progress * 2.0;
+ float alpha = smoothstep(revealRadius, revealRadius - 0.3, dist);
+
+ float retractProgress = max(0.0, progress * 2.0 - 1.0);
+ float innerRadius = retractProgress * 1.5;
+ float retractAlpha = smoothstep(innerRadius - 0.3, innerRadius, dist);
+
+ alpha *= retractAlpha;
+
+ gl_FragColor = vec4(col, alpha);
+}
+`;
+
+type GlContext = {
+ gl: WebGLRenderingContext;
+ resLoc: WebGLUniformLocation;
+ progressLoc: WebGLUniformLocation;
+ numRaysLoc: WebGLUniformLocation;
+ color1Loc: WebGLUniformLocation;
+ color2Loc: WebGLUniformLocation;
+ rotationOffsetLoc: WebGLUniformLocation;
+ smoothEdgeLoc: WebGLUniformLocation;
+};
+
+const StarburstCanvas: React.FC<{
+ readonly rays: number;
+ readonly color1: string;
+ readonly color2: string;
+ readonly rotation: number;
+ readonly smoothness: number;
+}> = ({rays, color1, color2, rotation, smoothness}) => {
+ const frame = useCurrentFrame();
+ const {width, height, durationInFrames} = useVideoConfig();
+ const canvasRef = useRef<HTMLCanvasElement>(null);
+ const glRef = useRef<GlContext | null>(null);
+
+ const {delayRender, continueRender, cancelRender} = useDelayRender();
+ const [handle] = useState(() => delayRender());
+
+ const initGl = useCallback(
+ (canvas: HTMLCanvasElement): GlContext | null => {
+ const gl = canvas.getContext('webgl', {
+ premultipliedAlpha: false,
+ alpha: true,
+ });
+ if (!gl) {
+ cancelRender(
+ new Error(
+ 'Failed to get WebGL context. Try rendering with --gl=angle to enable WebGL.',
+ ),
+ );
+ return null;
+ }
+
+ gl.enable(gl.BLEND);
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
+
+ const compile = (type: number, src: string) => {
+ const s = gl.createShader(type)!;
+ gl.shaderSource(s, src);
+ gl.compileShader(s);
+ return s;
+ };
+
+ const program = gl.createProgram()!;
+ gl.attachShader(program, compile(gl.VERTEX_SHADER, VERTEX_SHADER));
+ gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT_SHADER));
+ gl.linkProgram(program);
+ gl.useProgram(program);
+
+ const buf = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
+ gl.bufferData(
+ gl.ARRAY_BUFFER,
+ new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
+ gl.STATIC_DRAW,
+ );
+ const pos = gl.getAttribLocation(program, 'position');
+ gl.enableVertexAttribArray(pos);
+ gl.vertexAttribPointer(pos, 2, gl.FLOAT, false, 0, 0);
+
+ continueRender(handle);
+
+ return {
+ gl,
+ resLoc: gl.getUniformLocation(program, 'resolution')!,
+ progressLoc: gl.getUniformLocation(program, 'progress')!,
+ numRaysLoc: gl.getUniformLocation(program, 'numRays')!,
+ color1Loc: gl.getUniformLocation(program, 'color1')!,
+ color2Loc: gl.getUniformLocation(program, 'color2')!,
+ rotationOffsetLoc: gl.getUniformLocation(program, 'rotationOffset')!,
+ smoothEdgeLoc: gl.getUniformLocation(program, 'smoothEdge')!,
+ };
+ },
+ [continueRender, handle, cancelRender],
+ );
+
+ useEffect(() => {
+ const canvas = canvasRef.current;
+ if (!canvas || glRef.current) return;
+ glRef.current = initGl(canvas);
+ }, [initGl]);
+
+ useEffect(() => {
+ const ctx = glRef.current;
+ if (!ctx) return;
+ const {
+ gl,
+ resLoc,
+ progressLoc,
+ numRaysLoc,
+ color1Loc,
+ color2Loc,
+ rotationOffsetLoc,
+ smoothEdgeLoc,
+ } = ctx;
+
+ const normalized =
+ durationInFrames <= 1 ? 0 : frame / (durationInFrames - 1);
+
+ const rgb1 = hexToRgb(color1);
+ const rgb2 = hexToRgb(color2);
+ const rotationRad = (rotation * Math.PI) / 180;
+
+ gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.uniform1f(progressLoc, normalized);
+ gl.uniform1f(numRaysLoc, rays);
+ gl.uniform3f(color1Loc, rgb1[0], rgb1[1], rgb1[2]);
+ gl.uniform3f(color2Loc, rgb2[0], rgb2[1], rgb2[2]);
+ gl.uniform1f(rotationOffsetLoc, rotationRad);
+ gl.uniform1f(smoothEdgeLoc, smoothness);
+ gl.uniform2f(resLoc, gl.canvas.width, gl.canvas.height);
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+ }, [
+ frame,
+ durationInFrames,
+ rays,
+ color1,
+ color2,
+ rotation,
+ smoothness,
+ width,
+ height,
+ ]);
+
+ return (
+ <AbsoluteFill>
+ <canvas ref={canvasRef} width={width} height={height} />
+ </AbsoluteFill>
+ );
+};
+
+/*
+ * @description Renders a WebGL-based starburst ray effect as a Sequence.
+ * @see [Documentation](https://www.remotion.dev/docs/starburst/starburst)
+ */
+const starburstSchema = {
+ rays: {
+ type: 'number',
+ min: 2,
+ max: 100,
+ step: 1,
+ default: 12,
+ description: 'Number of Rays',
+ },
+ rotation: {
+ type: 'number',
+ min: 0,
+ max: 360,
+ step: 1,
+ default: 0,
+ description: 'Rotation',
+ },
+ smoothness: {
+ type: 'number',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: 0.1,
+ description: 'Edge Smoothness',
+ },
+ 'style.translate': {
+ type: 'translate',
+ step: 1,
+ default: '0px 0px',
+ description: 'Position',
+ },
+ 'style.scale': {
+ type: 'number',
+ min: 0.05,
+ max: 100,
+ step: 0.01,
+ default: 1,
+ description: 'Scale',
+ },
+ 'style.rotate': {
+ type: 'rotation',
+ step: 1,
+ default: '0deg',
+ description: 'Rotation',
+ },
+ 'style.opacity': {
+ type: 'number',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: 1,
+ description: 'Opacity',
+ },
+} as const satisfies SequenceSchema;
+
+const StarburstInner: React.FC<
+ StarburstProps & {
+ readonly controls: SequenceControls | undefined;
+ }
+> = ({
+ rays = 12,
+ color1 = '#ffdd00',
+ color2 = '#ff8800',
+ rotation = 0,
+ smoothness = 0.1,
+ durationInFrames,
+ style,
+ controls,
+ ...sequenceProps
+}) => {
+ const {durationInFrames: videoDuration} = useVideoConfig();
+ const resolvedDuration = durationInFrames ?? videoDuration;
+
+ 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 (typeof rotation !== 'number' || !Number.isFinite(rotation)) {
+ throw new TypeError(
+ `"rotation" must be a finite number, but got ${JSON.stringify(rotation)}`,
+ );
+ }
+
+ if (typeof smoothness !== 'number' || !Number.isFinite(smoothness)) {
+ throw new TypeError(
+ `"smoothness" must be a finite number, but got ${JSON.stringify(smoothness)}`,
+ );
+ }
+
+ if (smoothness < 0 || smoothness > 1) {
+ throw new RangeError(
+ `"smoothness" must be between 0 and 1, but got ${smoothness}`,
+ );
+ }
+
+ return (
+ <Sequence
+ durationInFrames={resolvedDuration}
+ name="<Starburst>"
+ controls={controls}
+ {...sequenceProps}
+ style={style}
+ >
+ <StarburstCanvas
+ rays={rays}
+ color1={color1}
+ color2={color2}
+ rotation={rotation}
+ smoothness={smoothness}
+ />
+ </Sequence>
+ );
+};
+
+export const Starburst = Internals.wrapInSchema(
+ StarburstInner,
+ starburstSchema,
+);
+
+Starburst.displayName = 'Starburst';
+
+Internals.addSequenceStackTraces(Starburst);
diff --git a/packages/starburst/src/index.ts b/packages/starburst/src/index.ts
new file mode 100644
index 0000000000..d7da444332
--- /dev/null
+++ b/packages/starburst/src/index.ts
@@ -0,0 +1,2 @@
+export {Starburst} from './Starburst';
+export type {StarburstProps} from './Starburst';
diff --git a/packages/starburst/tsconfig.json b/packages/starburst/tsconfig.json
new file mode 100644
index 0000000000..22b60bbe95
--- /dev/null
+++ b/packages/starburst/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../tsconfig.settings.json",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "dist",
+ "jsx": "react-jsx",
+ "skipLibCheck": true,
+ "target": "ES2022",
+ "module": "es2020",
+ "moduleResolution": "bundler",
+ "declaration": true,
+ "emitDeclarationOnly": true
+ },
+ "include": ["src"],
+ "references": [{"path": "../core"}]
+}
diff --git a/packages/studio-shared/src/package-info.ts b/packages/studio-shared/src/package-info.ts
index 90dfebfb52..770c8c86f2 100644
--- a/packages/studio-shared/src/package-info.ts
+++ b/packages/studio-shared/src/package-info.ts
@@ -83,6 +83,7 @@ export const packages = [
'web-renderer',
'design',
'light-leaks',
+ 'starburst',
'vercel',
'sfx',
] as const;
@@ -207,6 +208,7 @@ export const descriptions: {[key in Pkgs]: string | null} = {
'web-renderer': 'Render videos in the browser (not yet released)',
design: 'Design system',
'light-leaks': 'Light leak effects for Remotion',
+ starburst: 'Starburst ray effects for Remotion',
vercel: 'Render Remotion videos on Vercel Sandbox',
sfx: 'Sound effect library',
};
@@ -295,6 +297,7 @@ export const installableMap: {[key in Pkgs]: boolean} = {
'web-renderer': false,
design: false,
'light-leaks': true,
+ starburst: true,
vercel: true,
sfx: true,
};
@@ -387,6 +390,7 @@ export const apiDocs: {[key in Pkgs]: string | null} = {
'web-renderer': 'https://www.remotion.dev/docs/web-renderer/',
design: 'https://www.remotion.dev/design',
'light-leaks': 'https://www.remotion.dev/docs/light-leaks',
+ starburst: 'https://www.remotion.dev/docs/starburst',
vercel: 'https://www.remotion.dev/docs/vercel/api',
sfx: 'https://www.remotion.dev/docs/sfx',
};
diff --git a/tsconfig.json b/tsconfig.json
index f2ff8fd4b3..dc24f1e882 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -252,6 +252,9 @@
{
"path": "./packages/light-leaks"
},
+ {
+ "path": "./packages/starburst"
+ },
{
"path": "./packages/vercel"
},