Skip to content

🎥 Make videos programmatically with React

Add shine effect to @remotion/effects

Cursor Agentcd4659676a16
diff --git a/packages/docs/components/demos/index.tsx b/packages/docs/components/demos/index.tsx
index 53d0246768..1a21f4b2e3 100644
--- a/packages/docs/components/demos/index.tsx
+++ b/packages/docs/components/demos/index.tsx
@@ -32,6 +32,7 @@ import {
effectsMirrorDemo,
effectsSaturationDemo,
effectsScaleDemo,
+ effectsShineDemo,
effectsStarburstDemo,
effectsTintDemo,
effectsUvTranslateDemo,
@@ -101,6 +102,7 @@ const demos: DemoType[] = [
effectsInvertDemo,
effectsSaturationDemo,
effectsTintDemo,
+ effectsShineDemo,
effectsMirrorDemo,
effectsScaleDemo,
effectsXyTranslateDemo,
diff --git a/packages/docs/components/demos/types.ts b/packages/docs/components/demos/types.ts
index 24e2c4e207..f987824394 100644
--- a/packages/docs/components/demos/types.ts
+++ b/packages/docs/components/demos/types.ts
@@ -14,6 +14,7 @@ import {EffectsLightLeakPreview} from '../effects/effects-light-leak-preview';
import {EffectsMirrorPreview} from '../effects/effects-mirror-preview';
import {EffectsSaturationPreview} from '../effects/effects-saturation-preview';
import {EffectsScalePreview} from '../effects/effects-scale-preview';
+import {EffectsShinePreview} from '../effects/effects-shine-preview';
import {EffectsStarburstPreview} from '../effects/effects-starburst-preview';
import {EffectsTintPreview} from '../effects/effects-tint-preview';
import {
@@ -1684,6 +1685,74 @@ export const effectsTintDemo: DemoType = {
],
};
+export const effectsShineDemo: DemoType = {
+ comp: EffectsShinePreview,
+ compHeight: 720,
+ compWidth: 1280,
+ durationInFrames: 1,
+ fps: 30,
+ id: 'effects-shine',
+ autoPlay: false,
+ controls: false,
+ logLevel: 'info',
+ options: [
+ {
+ name: 'progress',
+ type: 'numeric',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: 0.5,
+ optional: 'no',
+ },
+ {
+ name: 'angle',
+ type: 'numeric',
+ min: -180,
+ max: 180,
+ step: 1,
+ default: 30,
+ optional: 'no',
+ },
+ {
+ name: 'haloSigma',
+ type: 'numeric',
+ min: 1,
+ max: 500,
+ step: 1,
+ default: 200,
+ optional: 'no',
+ },
+ {
+ name: 'coreSigma',
+ type: 'numeric',
+ min: 1,
+ max: 500,
+ step: 1,
+ default: 65,
+ optional: 'no',
+ },
+ {
+ name: 'haloIntensity',
+ type: 'numeric',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: 0.3,
+ optional: 'no',
+ },
+ {
+ name: 'coreIntensity',
+ type: 'numeric',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: 0.4,
+ optional: 'no',
+ },
+ ],
+};
+
export const effectsMirrorDemo: DemoType = {
comp: EffectsMirrorPreview,
compHeight: 720,
diff --git a/packages/docs/components/effects/effects-shine-preview.tsx b/packages/docs/components/effects/effects-shine-preview.tsx
new file mode 100644
index 0000000000..8420e990bc
--- /dev/null
+++ b/packages/docs/components/effects/effects-shine-preview.tsx
@@ -0,0 +1,39 @@
+import {shine} from '@remotion/effects/shine';
+import React from 'react';
+import {CanvasImage} from 'remotion';
+import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';
+
+export const EffectsShinePreview: React.FC<{
+ readonly progress: number;
+ readonly angle: number;
+ readonly haloSigma: number;
+ readonly coreSigma: number;
+ readonly haloIntensity: number;
+ readonly coreIntensity: number;
+}> = ({
+ progress,
+ angle,
+ haloSigma,
+ coreSigma,
+ haloIntensity,
+ coreIntensity,
+}) => {
+ return (
+ <CanvasImage
+ src={EFFECTS_PREVIEW_IMAGE_SRC}
+ width={1280}
+ height={720}
+ fit="cover"
+ effects={[
+ shine({
+ progress,
+ angle,
+ haloSigma,
+ coreSigma,
+ haloIntensity,
+ coreIntensity,
+ }),
+ ]}
+ />
+ );
+};
diff --git a/packages/docs/docs/effects/shine.mdx b/packages/docs/docs/effects/shine.mdx
new file mode 100644
index 0000000000..1be06e1351
--- /dev/null
+++ b/packages/docs/docs/effects/shine.mdx
@@ -0,0 +1,100 @@
+---
+image: /generated/articles-docs-effects-shine.png
+slug: /effects/shine
+title: shine()
+sidebar_label: shine()
+crumb: '@remotion/effects'
+---
+
+# shine()<AvailableFrom v="4.0.468" />
+
+_Part of the [`@remotion/effects`](/docs/effects/api) package._
+
+Adds a glossy light sweep to canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas) and [`<Solid>`](/docs/solid).
+
+Use it for stickers, badges, titles, and surfaces that should look reflective.
+
+## Preview
+
+<Demo type="effects-shine" />
+
+## Example
+
+```tsx twoslash title="MyComp.tsx"
+import {AbsoluteFill, interpolate, useCurrentFrame} from 'remotion';
+import {Video} from '@remotion/media';
+import {shine} from '@remotion/effects/shine';
+
+export const MyComp: React.FC = () => {
+ const frame = useCurrentFrame();
+ const progress = interpolate(frame, [15, 45], [0, 1], {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ });
+
+ return (
+ <AbsoluteFill>
+ <Video
+ src="https://remotion.media/video.mp4"
+ effects={[
+ shine({
+ progress,
+ angle: 30,
+ haloSigma: 200,
+ coreSigma: 65,
+ haloIntensity: 0.3,
+ coreIntensity: 0.4,
+ }),
+ ]}
+ />
+ </AbsoluteFill>
+ );
+};
+```
+
+## API
+
+Pass an object with the following properties. You can also call `shine()` without arguments.
+
+### `progress?`
+
+Position of the shine sweep from `0` to `1`. Defaults to `0.5`.
+
+Use `0` when the band is before the element, `0.5` when it is centered, and `1` when it has left the element.
+
+### `angle?`
+
+Direction the shine sweeps in degrees. Defaults to `30`.
+
+`0` moves rightward. `90` moves upward.
+
+### `haloSigma?`
+
+Soft outer halo width in pixels. Defaults to `200`. Must be greater than `0`.
+
+### `coreSigma?`
+
+Bright core width in pixels. Defaults to `65`. Must be greater than `0`.
+
+### `haloIntensity?`
+
+Peak halo brightness from `0` to `1`. Defaults to `0.3`.
+
+### `coreIntensity?`
+
+Peak core brightness from `0` to `1`. Defaults to `0.4`.
+
+### `disabled?`
+
+When `true`, the effect is skipped. Defaults to `false`.
+
+## Requirements
+
+`shine()` uses a WebGL2 backend. During renders, enable WebGL via [`Config.setChromiumOpenGlRenderer()`](/docs/config#setchromiumopenglrenderer) (for example `'angle'`). See [Using WebGL during renders](/docs/remotion/html-in-canvas#using-webgl-during-renders).
+
+## See also
+
+- [`@remotion/effects`](/docs/effects/api)
+- [`glow()`](/docs/effects/glow)
+- [HTML-in-canvas guide](/docs/html-in-canvas)
+- [Source code for this effect](https://github.com/remotion-dev/remotion/blob/main/packages/effects/src/shine.ts)
diff --git a/packages/docs/docs/effects/table-of-contents.tsx b/packages/docs/docs/effects/table-of-contents.tsx
index e6db562ae6..74e3b23a40 100644
--- a/packages/docs/docs/effects/table-of-contents.tsx
+++ b/packages/docs/docs/effects/table-of-contents.tsx
@@ -45,6 +45,13 @@ const categories: {
name: 'glow()',
description: 'Soft halo effect',
},
+ {
+ link: '/docs/effects/shine',
+ preview: '/img/effects-shine-preview.jpg',
+ alt: 'shine effect preview',
+ name: 'shine()',
+ description: 'Glossy light sweep effect',
+ },
{
link: '/docs/effects/grayscale',
preview: '/img/effects-grayscale-preview.jpg',
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index 39012d1908..0cb2fde325 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -282,6 +282,7 @@ const sidebars: SidebarsConfig = {
'effects/mirror',
'effects/saturation',
'effects/scale',
+ 'effects/shine',
'effects/tint',
'effects/uv-translate',
'effects/vignette',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index fdf56386a8..c4cf1cda44 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -1853,6 +1853,15 @@ export const articles = [
noAi: false,
slug: 'effects/scale',
},
+ {
+ id: 'effects/shine',
+ title: 'shine()',
+ relativePath: 'docs/effects/shine.mdx',
+ compId: 'articles-docs-effects-shine',
+ crumb: '@remotion/effects',
+ noAi: false,
+ slug: 'effects/shine',
+ },
{
id: 'effects/tint',
title: 'tint()',
diff --git a/packages/docs/static/generated/articles-docs-effects-shine.png b/packages/docs/static/generated/articles-docs-effects-shine.png
new file mode 100644
index 0000000000..b10ca0b1eb
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-effects-shine.png differ
diff --git a/packages/docs/static/img/effects-shine-preview.jpg b/packages/docs/static/img/effects-shine-preview.jpg
new file mode 100644
index 0000000000..859425dfab
Binary files /dev/null and b/packages/docs/static/img/effects-shine-preview.jpg differ
diff --git a/packages/effects/bundle.ts b/packages/effects/bundle.ts
index dd4a33540f..ac6a6e62ed 100644
--- a/packages/effects/bundle.ts
+++ b/packages/effects/bundle.ts
@@ -21,6 +21,7 @@ const effectEntrypoints = [
'src/mirror.ts',
'src/saturation.ts',
'src/scale.ts',
+ 'src/shine.ts',
'src/tint.ts',
'src/translate.ts',
'src/vignette.ts',
diff --git a/packages/effects/package.json b/packages/effects/package.json
index e3acdbe4dc..b65932008c 100644
--- a/packages/effects/package.json
+++ b/packages/effects/package.json
@@ -102,6 +102,11 @@
"module": "./dist/esm/scale.mjs",
"import": "./dist/esm/scale.mjs"
},
+ "./shine": {
+ "types": "./dist/shine.d.ts",
+ "module": "./dist/esm/shine.mjs",
+ "import": "./dist/esm/shine.mjs"
+ },
"./tint": {
"types": "./dist/tint.d.ts",
"module": "./dist/esm/tint.mjs",
@@ -168,6 +173,9 @@
"scale": [
"dist/scale.d.ts"
],
+ "shine": [
+ "dist/shine.d.ts"
+ ],
"tint": [
"dist/tint.d.ts"
],
diff --git a/packages/effects/src/shine.ts b/packages/effects/src/shine.ts
new file mode 100644
index 0000000000..4d71a2288a
--- /dev/null
+++ b/packages/effects/src/shine.ts
@@ -0,0 +1,366 @@
+import type {SequenceSchema} from 'remotion';
+import {Internals} from 'remotion';
+import {
+ assertOptionalFiniteNumber,
+ validateUnitInterval,
+} from './color-utils.js';
+import {assertEffectParamsObject} from './validate-effect-param.js';
+
+const {createEffect, createWebGL2ContextError} = Internals;
+
+const DEFAULT_PROGRESS = 0.5 as const;
+const DEFAULT_ANGLE = 30 as const;
+const DEFAULT_HALO_SIGMA = 200 as const;
+const DEFAULT_CORE_SIGMA = 65 as const;
+const DEFAULT_HALO_INTENSITY = 0.3 as const;
+const DEFAULT_CORE_INTENSITY = 0.4 as const;
+
+const shineSchema = {
+ progress: {
+ type: 'number',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: DEFAULT_PROGRESS,
+ description: 'Progress',
+ },
+ angle: {
+ type: 'number',
+ min: -180,
+ max: 180,
+ step: 1,
+ default: DEFAULT_ANGLE,
+ description: 'Angle',
+ },
+ haloSigma: {
+ type: 'number',
+ min: 1,
+ max: 500,
+ step: 1,
+ default: DEFAULT_HALO_SIGMA,
+ description: 'Halo sigma',
+ },
+ coreSigma: {
+ type: 'number',
+ min: 1,
+ max: 500,
+ step: 1,
+ default: DEFAULT_CORE_SIGMA,
+ description: 'Core sigma',
+ },
+ haloIntensity: {
+ type: 'number',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: DEFAULT_HALO_INTENSITY,
+ description: 'Halo intensity',
+ },
+ coreIntensity: {
+ type: 'number',
+ min: 0,
+ max: 1,
+ step: 0.01,
+ default: DEFAULT_CORE_INTENSITY,
+ description: 'Core intensity',
+ },
+} as const satisfies SequenceSchema;
+
+export type ShineParams = {
+ /** Position of the shine sweep from `0` to `1`. Defaults to `0.5`. */
+ readonly progress?: number;
+ /** Sweep direction in degrees. Defaults to `30`. */
+ readonly angle?: number;
+ /** Soft outer halo width in pixels. Defaults to `200`. */
+ readonly haloSigma?: number;
+ /** Bright core width in pixels. Defaults to `65`. */
+ readonly coreSigma?: number;
+ /** Peak halo brightness from `0` to `1`. Defaults to `0.3`. */
+ readonly haloIntensity?: number;
+ /** Peak core brightness from `0` to `1`. Defaults to `0.4`. */
+ readonly coreIntensity?: number;
+};
+
+type ShineResolved = {
+ readonly progress: number;
+ readonly angle: number;
+ readonly haloSigma: number;
+ readonly coreSigma: number;
+ readonly haloIntensity: number;
+ readonly coreIntensity: number;
+};
+
+const resolve = (p: ShineParams): ShineResolved => ({
+ progress: p.progress ?? DEFAULT_PROGRESS,
+ angle: p.angle ?? DEFAULT_ANGLE,
+ haloSigma: p.haloSigma ?? DEFAULT_HALO_SIGMA,
+ coreSigma: p.coreSigma ?? DEFAULT_CORE_SIGMA,
+ haloIntensity: p.haloIntensity ?? DEFAULT_HALO_INTENSITY,
+ coreIntensity: p.coreIntensity ?? DEFAULT_CORE_INTENSITY,
+});
+
+const validatePositive = (value: number, name: string): void => {
+ if (value <= 0) {
+ throw new TypeError(
+ `"${name}" must be greater than 0, but got ${JSON.stringify(value)}`,
+ );
+ }
+};
+
+const validateShineParams = (params: ShineParams): void => {
+ assertEffectParamsObject(params, 'Shine');
+ assertOptionalFiniteNumber(params.progress, 'progress');
+ assertOptionalFiniteNumber(params.angle, 'angle');
+ assertOptionalFiniteNumber(params.haloSigma, 'haloSigma');
+ assertOptionalFiniteNumber(params.coreSigma, 'coreSigma');
+ assertOptionalFiniteNumber(params.haloIntensity, 'haloIntensity');
+ assertOptionalFiniteNumber(params.coreIntensity, 'coreIntensity');
+
+ const r = resolve(params);
+ validateUnitInterval(r.progress, 'progress');
+ validatePositive(r.haloSigma, 'haloSigma');
+ validatePositive(r.coreSigma, 'coreSigma');
+ validateUnitInterval(r.haloIntensity, 'haloIntensity');
+ validateUnitInterval(r.coreIntensity, 'coreIntensity');
+};
+
+type ShineState = {
+ readonly gl: WebGL2RenderingContext;
+ readonly program: WebGLProgram;
+ readonly vao: WebGLVertexArrayObject;
+ readonly vbo: WebGLBuffer;
+ readonly texture: WebGLTexture;
+ readonly uSource: WebGLUniformLocation | null;
+ readonly uResolution: WebGLUniformLocation | null;
+ readonly uBandNormal: WebGLUniformLocation | null;
+ readonly uBandT: WebGLUniformLocation | null;
+ readonly uHaloSigma: WebGLUniformLocation | null;
+ readonly uCoreSigma: WebGLUniformLocation | null;
+ readonly uHaloIntensity: WebGLUniformLocation | null;
+ readonly uCoreIntensity: WebGLUniformLocation | null;
+};
+
+const SHINE_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 SHINE_FS = /* glsl */ `#version 300 es
+precision highp float;
+
+in vec2 vUv;
+out vec4 fragColor;
+
+uniform sampler2D uSource;
+uniform vec2 uResolution;
+uniform vec2 uBandNormal;
+uniform float uBandT;
+uniform float uHaloSigma;
+uniform float uCoreSigma;
+uniform float uHaloIntensity;
+uniform float uCoreIntensity;
+
+void main() {
+ vec4 source = texture(uSource, vUv);
+ vec2 px = vec2(vUv.x * uResolution.x, (1.0 - vUv.y) * uResolution.y);
+ vec2 center = uResolution * 0.5;
+
+ float dist = dot(px - center, uBandNormal) - uBandT;
+ float halo = exp(-(dist * dist) / (uHaloSigma * uHaloSigma)) * uHaloIntensity;
+ float core = exp(-(dist * dist) / (uCoreSigma * uCoreSigma)) * uCoreIntensity;
+ float intensity = clamp(halo + core, 0.0, 1.0);
+
+ vec3 finalPremult = source.rgb * (1.0 - intensity) + intensity * source.a;
+ fragColor = vec4(finalPremult, source.a);
+}
+`;
+
+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(`Shine 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(`Shine program link failed: ${log ?? '(no log)'}`);
+ }
+
+ return program;
+};
+
+export const shine = createEffect<ShineParams, ShineState>({
+ type: 'remotion/shine',
+ label: 'shine()',
+ documentationLink: 'https://www.remotion.dev/docs/effects/shine',
+ backend: 'webgl2',
+ calculateKey: (params) => {
+ const r = resolve(params);
+ return `shine-${r.progress}-${r.angle}-${r.haloSigma}-${r.coreSigma}-${r.haloIntensity}-${r.coreIntensity}`;
+ },
+ setup: (target) => {
+ const gl = target.getContext('webgl2', {
+ premultipliedAlpha: true,
+ alpha: true,
+ preserveDrawingBuffer: true,
+ });
+ if (!gl) {
+ throw createWebGL2ContextError('shine effect');
+ }
+
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
+
+ const vs = compileShader(gl, gl.VERTEX_SHADER, SHINE_VS);
+ const fs = compileShader(gl, gl.FRAGMENT_SHADER, SHINE_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 texture = gl.createTexture();
+ if (!texture) {
+ throw new Error('Failed to create WebGL texture');
+ }
+
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ 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,
+ texture,
+ uSource: gl.getUniformLocation(program, 'uSource'),
+ uResolution: gl.getUniformLocation(program, 'uResolution'),
+ uBandNormal: gl.getUniformLocation(program, 'uBandNormal'),
+ uBandT: gl.getUniformLocation(program, 'uBandT'),
+ uHaloSigma: gl.getUniformLocation(program, 'uHaloSigma'),
+ uCoreSigma: gl.getUniformLocation(program, 'uCoreSigma'),
+ uHaloIntensity: gl.getUniformLocation(program, 'uHaloIntensity'),
+ uCoreIntensity: gl.getUniformLocation(program, 'uCoreIntensity'),
+ };
+ },
+ apply: ({source, width, height, params, state, flipSourceY}) => {
+ const r = resolve(params);
+ const angleRad = (r.angle * Math.PI) / 180;
+ const bandNormalX = Math.cos(angleRad);
+ const bandNormalY = -Math.sin(angleRad);
+ const bboxProjection =
+ Math.abs(bandNormalX) * width + Math.abs(bandNormalY) * height;
+ const sweepHalfRange = bboxProjection / 2 + 3 * r.haloSigma;
+ const bandT = -sweepHalfRange + r.progress * sweepHalfRange * 2;
+ const {gl, program, vao, texture} = state;
+
+ gl.viewport(0, 0, width, height);
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+
+ gl.activeTexture(gl.TEXTURE0);
+ gl.bindTexture(gl.TEXTURE_2D, texture);
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
+ gl.texImage2D(
+ gl.TEXTURE_2D,
+ 0,
+ gl.RGBA,
+ gl.RGBA,
+ gl.UNSIGNED_BYTE,
+ source as TexImageSource,
+ );
+
+ gl.useProgram(program);
+ if (state.uSource) gl.uniform1i(state.uSource, 0);
+ if (state.uResolution) gl.uniform2f(state.uResolution, width, height);
+ if (state.uBandNormal)
+ gl.uniform2f(state.uBandNormal, bandNormalX, bandNormalY);
+ if (state.uBandT) gl.uniform1f(state.uBandT, bandT);
+ if (state.uHaloSigma) gl.uniform1f(state.uHaloSigma, r.haloSigma);
+ if (state.uCoreSigma) gl.uniform1f(state.uCoreSigma, r.coreSigma);
+ if (state.uHaloIntensity)
+ gl.uniform1f(state.uHaloIntensity, r.haloIntensity);
+ if (state.uCoreIntensity)
+ gl.uniform1f(state.uCoreIntensity, r.coreIntensity);
+
+ gl.bindVertexArray(vao);
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+
+ gl.bindVertexArray(null);
+ gl.bindTexture(gl.TEXTURE_2D, null);
+ gl.useProgram(null);
+ },
+ cleanup: ({gl, program, vao, vbo, texture}) => {
+ gl.deleteTexture(texture);
+ gl.deleteBuffer(vbo);
+ gl.deleteProgram(program);
+ gl.deleteVertexArray(vao);
+ },
+ schema: shineSchema,
+ validateParams: validateShineParams,
+});
diff --git a/packages/effects/src/test/effect-params.test.ts b/packages/effects/src/test/effect-params.test.ts
index f42591973a..29611f334d 100644
--- a/packages/effects/src/test/effect-params.test.ts
+++ b/packages/effects/src/test/effect-params.test.ts
@@ -13,6 +13,7 @@ import {invert} from '../invert.js';
import {mirror} from '../mirror.js';
import {saturation} from '../saturation.js';
import {scale} from '../scale.js';
+import {shine} from '../shine.js';
import {tint} from '../tint.js';
import {uvTranslate, xyTranslate} from '../translate.js';
import {vignette} from '../vignette.js';
@@ -61,6 +62,9 @@ test('@remotion/effects expose documentation links', () => {
expect(scale({scale: 1}).definition.documentationLink).toBe(
'https://www.remotion.dev/docs/effects/scale',
);
+ expect(shine().definition.documentationLink).toBe(
+ 'https://www.remotion.dev/docs/effects/shine',
+ );
expect(tint({color: '#fff'}).definition.documentationLink).toBe(
'https://www.remotion.dev/docs/effects/tint',
);
@@ -92,6 +96,7 @@ test('@remotion/effects expose API names as Studio labels', () => {
expect(mirror().definition.label).toBe('mirror()');
expect(saturation().definition.label).toBe('saturation()');
expect(scale({scale: 1}).definition.label).toBe('scale()');
+ expect(shine().definition.label).toBe('shine()');
expect(tint({color: '#fff'}).definition.label).toBe('tint()');
expect(uvTranslate().definition.label).toBe('uvTranslate()');
expect(vignette().definition.label).toBe('vignette()');
@@ -772,6 +777,75 @@ test('scale() axis flags produce distinct effect keys', () => {
expect(new Set(keys).size).toBe(keys.length);
});
+test('shine() accepts default params', () => {
+ expect(() => shine()).not.toThrow();
+});
+
+test('shine() accepts valid params', () => {
+ expect(() =>
+ shine({
+ progress: 0.25,
+ angle: 45,
+ haloSigma: 160,
+ coreSigma: 48,
+ haloIntensity: 0.4,
+ coreIntensity: 0.6,
+ }),
+ ).not.toThrow();
+});
+
+test('shine() rejects progress below range', () => {
+ expect(() => shine({progress: -0.1})).toThrow('"progress" must be >= 0');
+});
+
+test('shine() rejects progress above range', () => {
+ expect(() => shine({progress: 1.1})).toThrow('"progress" must be <= 1');
+});
+
+test('shine() rejects non-positive haloSigma', () => {
+ expect(() => shine({haloSigma: 0})).toThrow(
+ '"haloSigma" must be greater than 0',
+ );
+});
+
+test('shine() rejects non-positive coreSigma', () => {
+ expect(() => shine({coreSigma: 0})).toThrow(
+ '"coreSigma" must be greater than 0',
+ );
+});
+
+test('shine() rejects haloIntensity above range', () => {
+ expect(() => shine({haloIntensity: 1.1})).toThrow(
+ '"haloIntensity" must be <= 1',
+ );
+});
+
+test('shine() rejects coreIntensity below range', () => {
+ expect(() => shine({coreIntensity: -0.1})).toThrow(
+ '"coreIntensity" must be >= 0',
+ );
+});
+
+test('shine() parameters produce distinct effect keys', () => {
+ const defaultShine = shine();
+ const advanced = shine({progress: 0.75});
+ const angled = shine({angle: 75});
+ const wider = shine({haloSigma: 250});
+ const sharper = shine({coreSigma: 40});
+ const brighter = shine({coreIntensity: 0.8});
+
+ expect(
+ new Set([
+ defaultShine.effectKey,
+ advanced.effectKey,
+ angled.effectKey,
+ wider.effectKey,
+ sharper.effectKey,
+ brighter.effectKey,
+ ]).size,
+ ).toBe(6);
+});
+
test('xyTranslate() accepts default params', () => {
expect(() => xyTranslate()).not.toThrow();
});