Skip to content

🎥 Make videos programmatically with React

Move fisheye shader fix to a separate PR

Jonny Burger5f945dfe1d59
diff --git a/packages/effects/src/fisheye/fisheye-shaders.ts b/packages/effects/src/fisheye/fisheye-shaders.ts
index 64658c5903..2b2fb3fdc9 100644
--- a/packages/effects/src/fisheye/fisheye-shaders.ts
+++ b/packages/effects/src/fisheye/fisheye-shaders.ts
@@ -28,7 +28,7 @@ void main() {
float r = dist / max(uRadius, 0.0001);
if (r > 1.0 || uFieldOfView <= 0.0001) {
- fragColor = texture(uSource, vUv);
+ fragColor = vec4(0.0);
return;
}
diff --git a/packages/effects/src/visual-test/effects-visual.test.ts b/packages/effects/src/visual-test/effects-visual.test.ts
index 62efdab099..8ddf5bb008 100644
--- a/packages/effects/src/visual-test/effects-visual.test.ts
+++ b/packages/effects/src/visual-test/effects-visual.test.ts
@@ -4,7 +4,6 @@ import {colorCorrection} from '../color-correction.js';
import {contrast} from '../contrast.js';
import {evolve} from '../evolve.js';
import {exposure} from '../exposure.js';
-import {fisheye} from '../fisheye.js';
import {levels} from '../levels.js';
import {noise} from '../noise.js';
import {outline} from '../outline.js';
@@ -38,56 +37,6 @@ test('stacks repeated WebGL effects without blanking or flipping the image', asy
});
});
-test('fisheye() preserves pixels outside the lens radius and at zero field of view', async () => {
- const width = 64;
- const height = 64;
- const source = document.createElement('canvas');
- source.width = width;
- source.height = height;
- const sourceContext = source.getContext('2d');
- if (!sourceContext) {
- throw new Error('Could not get source context');
- }
-
- sourceContext.fillStyle = 'rgb(12, 34, 56)';
- sourceContext.fillRect(0, 0, width, height);
-
- const canvas = await renderEffectChainToCanvas({
- source,
- width,
- height,
- effects: descriptorsToMemoizedEffects([
- fisheye({fieldOfView: 1, radius: 0.25}),
- ]),
- });
- const context = canvas.getContext('2d');
- if (!context) {
- throw new Error('Could not get output context');
- }
-
- const pixelOutsideLens = context.getImageData(2, 2, 1, 1).data;
- expect([...pixelOutsideLens]).toEqual([12, 34, 56, 255]);
-
- const zeroFieldOfViewCanvas = await renderEffectChainToCanvas({
- source,
- width,
- height,
- effects: descriptorsToMemoizedEffects([fisheye({fieldOfView: 0})]),
- });
- const zeroFieldOfViewContext = zeroFieldOfViewCanvas.getContext('2d');
- if (!zeroFieldOfViewContext) {
- throw new Error('Could not get zero field of view output context');
- }
-
- const zeroFieldOfViewPixel = zeroFieldOfViewContext.getImageData(
- 32,
- 32,
- 1,
- 1,
- ).data;
- expect([...zeroFieldOfViewPixel]).toEqual([12, 34, 56, 255]);
-});
-
test('outline() draws around alpha while preserving the source', async () => {
const width = 64;
const height = 64;