@flighthq/effects-wgpu 0.1.0 → 0.2.1-next.410.a23f189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/dist/wgpuBevelEffect.d.ts +4 -0
- package/dist/wgpuBevelEffect.d.ts.map +1 -0
- package/dist/wgpuBevelEffect.js +124 -0
- package/dist/wgpuBevelEffect.js.map +1 -0
- package/dist/wgpuBloomEffect.d.ts.map +1 -1
- package/dist/wgpuBloomEffect.js +9 -8
- package/dist/wgpuBloomEffect.js.map +1 -1
- package/dist/wgpuBlurEffect.d.ts +8 -0
- package/dist/wgpuBlurEffect.d.ts.map +1 -0
- package/dist/wgpuBlurEffect.js +70 -0
- package/dist/wgpuBlurEffect.js.map +1 -0
- package/dist/wgpuBokehDepthOfFieldEffect.d.ts.map +1 -1
- package/dist/wgpuBokehDepthOfFieldEffect.js +2 -2
- package/dist/wgpuBokehDepthOfFieldEffect.js.map +1 -1
- package/dist/wgpuCameraMotionBlurEffect.d.ts.map +1 -1
- package/dist/wgpuCameraMotionBlurEffect.js +2 -2
- package/dist/wgpuCameraMotionBlurEffect.js.map +1 -1
- package/dist/wgpuChromaticAberrationEffect.d.ts.map +1 -1
- package/dist/wgpuChromaticAberrationEffect.js +2 -2
- package/dist/wgpuChromaticAberrationEffect.js.map +1 -1
- package/dist/wgpuColorLutPass.d.ts +3 -0
- package/dist/wgpuColorLutPass.d.ts.map +1 -0
- package/dist/wgpuColorLutPass.js +144 -0
- package/dist/wgpuColorLutPass.js.map +1 -0
- package/dist/wgpuColorMatrixPass.d.ts +3 -0
- package/dist/wgpuColorMatrixPass.d.ts.map +1 -0
- package/dist/wgpuColorMatrixPass.js +51 -0
- package/dist/wgpuColorMatrixPass.js.map +1 -0
- package/dist/wgpuConvolutionEffect.d.ts +5 -0
- package/dist/wgpuConvolutionEffect.d.ts.map +1 -0
- package/dist/wgpuConvolutionEffect.js +108 -0
- package/dist/wgpuConvolutionEffect.js.map +1 -0
- package/dist/wgpuCrtEffect.d.ts.map +1 -1
- package/dist/wgpuCrtEffect.js +2 -2
- package/dist/wgpuCrtEffect.js.map +1 -1
- package/dist/wgpuDirectionalBlurEffect.d.ts.map +1 -1
- package/dist/wgpuDirectionalBlurEffect.js +2 -2
- package/dist/wgpuDirectionalBlurEffect.js.map +1 -1
- package/dist/wgpuDisplacementEffect.d.ts.map +1 -1
- package/dist/wgpuDisplacementEffect.js +2 -2
- package/dist/wgpuDisplacementEffect.js.map +1 -1
- package/dist/wgpuDitherEffect.d.ts.map +1 -1
- package/dist/wgpuDitherEffect.js +2 -2
- package/dist/wgpuDitherEffect.js.map +1 -1
- package/dist/wgpuDropShadowEffect.d.ts +4 -0
- package/dist/wgpuDropShadowEffect.d.ts.map +1 -0
- package/dist/wgpuDropShadowEffect.js +50 -0
- package/dist/wgpuDropShadowEffect.js.map +1 -0
- package/dist/wgpuEffectBlitShader.d.ts +17 -0
- package/dist/wgpuEffectBlitShader.d.ts.map +1 -0
- package/dist/wgpuEffectBlitShader.js +97 -0
- package/dist/wgpuEffectBlitShader.js.map +1 -0
- package/dist/wgpuEffectBoxBlur.d.ts +15 -0
- package/dist/wgpuEffectBoxBlur.d.ts.map +1 -0
- package/dist/wgpuEffectBoxBlur.js +106 -0
- package/dist/wgpuEffectBoxBlur.js.map +1 -0
- package/dist/wgpuEffectGradientRamp.d.ts +17 -0
- package/dist/wgpuEffectGradientRamp.d.ts.map +1 -0
- package/dist/wgpuEffectGradientRamp.js +89 -0
- package/dist/wgpuEffectGradientRamp.js.map +1 -0
- package/dist/wgpuEffectPass.d.ts +42 -0
- package/dist/wgpuEffectPass.d.ts.map +1 -0
- package/dist/wgpuEffectPass.js +271 -0
- package/dist/wgpuEffectPass.js.map +1 -0
- package/dist/wgpuEffectProgramCache.d.ts +2 -2
- package/dist/wgpuEffectProgramCache.d.ts.map +1 -1
- package/dist/wgpuEffectProgramCache.js +5 -5
- package/dist/wgpuEffectProgramCache.js.map +1 -1
- package/dist/wgpuEffectTintShader.d.ts +8 -0
- package/dist/wgpuEffectTintShader.d.ts.map +1 -0
- package/dist/wgpuEffectTintShader.js +109 -0
- package/dist/wgpuEffectTintShader.js.map +1 -0
- package/dist/wgpuFilmGrainEffect.d.ts.map +1 -1
- package/dist/wgpuFilmGrainEffect.js +2 -2
- package/dist/wgpuFilmGrainEffect.js.map +1 -1
- package/dist/wgpuFxaaEffect.d.ts.map +1 -1
- package/dist/wgpuFxaaEffect.js +2 -2
- package/dist/wgpuFxaaEffect.js.map +1 -1
- package/dist/wgpuGlitchEffect.d.ts.map +1 -1
- package/dist/wgpuGlitchEffect.js +2 -2
- package/dist/wgpuGlitchEffect.js.map +1 -1
- package/dist/wgpuGodRaysEffect.d.ts.map +1 -1
- package/dist/wgpuGodRaysEffect.js +2 -2
- package/dist/wgpuGodRaysEffect.js.map +1 -1
- package/dist/wgpuGradientBevelEffect.d.ts +4 -0
- package/dist/wgpuGradientBevelEffect.d.ts.map +1 -0
- package/dist/wgpuGradientBevelEffect.js +191 -0
- package/dist/wgpuGradientBevelEffect.js.map +1 -0
- package/dist/wgpuGradientGlowEffect.d.ts +4 -0
- package/dist/wgpuGradientGlowEffect.d.ts.map +1 -0
- package/dist/wgpuGradientGlowEffect.js +103 -0
- package/dist/wgpuGradientGlowEffect.js.map +1 -0
- package/dist/wgpuHalftoneEffect.d.ts.map +1 -1
- package/dist/wgpuHalftoneEffect.js +2 -2
- package/dist/wgpuHalftoneEffect.js.map +1 -1
- package/dist/wgpuInnerGlowEffect.d.ts +4 -0
- package/dist/wgpuInnerGlowEffect.d.ts.map +1 -0
- package/dist/wgpuInnerGlowEffect.js +50 -0
- package/dist/wgpuInnerGlowEffect.js.map +1 -0
- package/dist/wgpuInnerShadowEffect.d.ts +4 -0
- package/dist/wgpuInnerShadowEffect.d.ts.map +1 -0
- package/dist/wgpuInnerShadowEffect.js +55 -0
- package/dist/wgpuInnerShadowEffect.js.map +1 -0
- package/dist/wgpuKuwaharaEffect.d.ts.map +1 -1
- package/dist/wgpuKuwaharaEffect.js +2 -2
- package/dist/wgpuKuwaharaEffect.js.map +1 -1
- package/dist/wgpuLensDirtEffect.d.ts.map +1 -1
- package/dist/wgpuLensDirtEffect.js +2 -2
- package/dist/wgpuLensDirtEffect.js.map +1 -1
- package/dist/wgpuLensDistortionEffect.d.ts.map +1 -1
- package/dist/wgpuLensDistortionEffect.js +2 -2
- package/dist/wgpuLensDistortionEffect.js.map +1 -1
- package/dist/wgpuLensFlareEffect.d.ts.map +1 -1
- package/dist/wgpuLensFlareEffect.js +2 -2
- package/dist/wgpuLensFlareEffect.js.map +1 -1
- package/dist/wgpuMedianEffect.d.ts +5 -0
- package/dist/wgpuMedianEffect.d.ts.map +1 -0
- package/dist/wgpuMedianEffect.js +74 -0
- package/dist/wgpuMedianEffect.js.map +1 -0
- package/dist/wgpuMotionBlurEffect.d.ts.map +1 -1
- package/dist/wgpuMotionBlurEffect.js +6 -7
- package/dist/wgpuMotionBlurEffect.js.map +1 -1
- package/dist/wgpuOuterGlowEffect.d.ts +4 -0
- package/dist/wgpuOuterGlowEffect.d.ts.map +1 -0
- package/dist/wgpuOuterGlowEffect.js +46 -0
- package/dist/wgpuOuterGlowEffect.js.map +1 -0
- package/dist/wgpuOutlineEffect.d.ts.map +1 -1
- package/dist/wgpuOutlineEffect.js +2 -2
- package/dist/wgpuOutlineEffect.js.map +1 -1
- package/dist/wgpuPixelateEffect.d.ts.map +1 -1
- package/dist/wgpuPixelateEffect.js +2 -2
- package/dist/wgpuPixelateEffect.js.map +1 -1
- package/dist/wgpuPosterizeEffect.d.ts.map +1 -1
- package/dist/wgpuPosterizeEffect.js +2 -2
- package/dist/wgpuPosterizeEffect.js.map +1 -1
- package/dist/wgpuRadialBlurEffect.d.ts.map +1 -1
- package/dist/wgpuRadialBlurEffect.js +2 -2
- package/dist/wgpuRadialBlurEffect.js.map +1 -1
- package/dist/wgpuRenderEffectPipeline.d.ts +2 -2
- package/dist/wgpuRenderEffectPipeline.d.ts.map +1 -1
- package/dist/wgpuRenderEffectPipeline.js +74 -15
- package/dist/wgpuRenderEffectPipeline.js.map +1 -1
- package/dist/wgpuRenderEffectRegistrants.d.ts +1 -0
- package/dist/wgpuRenderEffectRegistrants.d.ts.map +1 -1
- package/dist/wgpuRenderEffectRegistrants.js +39 -28
- package/dist/wgpuRenderEffectRegistrants.js.map +1 -1
- package/dist/wgpuScanlinesEffect.d.ts.map +1 -1
- package/dist/wgpuScanlinesEffect.js +2 -2
- package/dist/wgpuScanlinesEffect.js.map +1 -1
- package/dist/wgpuScreenSpaceFogEffect.d.ts.map +1 -1
- package/dist/wgpuScreenSpaceFogEffect.js +2 -2
- package/dist/wgpuScreenSpaceFogEffect.js.map +1 -1
- package/dist/wgpuSharpenEffect.d.ts.map +1 -1
- package/dist/wgpuSharpenEffect.js +2 -2
- package/dist/wgpuSharpenEffect.js.map +1 -1
- package/dist/wgpuSketchEffect.d.ts.map +1 -1
- package/dist/wgpuSketchEffect.js +2 -2
- package/dist/wgpuSketchEffect.js.map +1 -1
- package/dist/wgpuSmaaEffect.d.ts.map +1 -1
- package/dist/wgpuSmaaEffect.js +2 -2
- package/dist/wgpuSmaaEffect.js.map +1 -1
- package/dist/wgpuSsaoEffect.d.ts.map +1 -1
- package/dist/wgpuSsaoEffect.js +2 -2
- package/dist/wgpuSsaoEffect.js.map +1 -1
- package/dist/wgpuSsrEffect.d.ts.map +1 -1
- package/dist/wgpuSsrEffect.js +2 -2
- package/dist/wgpuSsrEffect.js.map +1 -1
- package/dist/wgpuTaaEffect.d.ts.map +1 -1
- package/dist/wgpuTaaEffect.js +2 -2
- package/dist/wgpuTaaEffect.js.map +1 -1
- package/dist/wgpuTiltShiftEffect.d.ts.map +1 -1
- package/dist/wgpuTiltShiftEffect.js +2 -2
- package/dist/wgpuTiltShiftEffect.js.map +1 -1
- package/dist/wgpuToneMapEffect.d.ts.map +1 -1
- package/dist/wgpuToneMapEffect.js +2 -2
- package/dist/wgpuToneMapEffect.js.map +1 -1
- package/dist/wgpuVignetteEffect.d.ts.map +1 -1
- package/dist/wgpuVignetteEffect.js +2 -2
- package/dist/wgpuVignetteEffect.js.map +1 -1
- package/dist/wgpuWhiteBalanceEffect.d.ts.map +1 -1
- package/dist/wgpuWhiteBalanceEffect.js +2 -2
- package/dist/wgpuWhiteBalanceEffect.js.map +1 -1
- package/package.json +11 -7
- package/src/wgpuBevelEffect.test.ts +13 -0
- package/src/wgpuBlurEffect.test.ts +19 -0
- package/src/wgpuColorLutPass.test.ts +7 -0
- package/src/wgpuColorMatrixPass.test.ts +7 -0
- package/src/wgpuConvolutionEffect.test.ts +13 -0
- package/src/wgpuDropShadowEffect.test.ts +109 -0
- package/src/wgpuEffectBlitShader.test.ts +23 -0
- package/src/wgpuEffectBoxBlur.test.ts +75 -0
- package/src/wgpuEffectGradientRamp.test.ts +7 -0
- package/src/wgpuEffectPass.test.ts +51 -0
- package/src/wgpuEffectTintShader.test.ts +66 -0
- package/src/wgpuGradientBevelEffect.test.ts +13 -0
- package/src/wgpuGradientGlowEffect.test.ts +13 -0
- package/src/wgpuInnerGlowEffect.test.ts +137 -0
- package/src/wgpuInnerShadowEffect.test.ts +137 -0
- package/src/wgpuMedianEffect.test.ts +13 -0
- package/src/wgpuOuterGlowEffect.test.ts +108 -0
- package/src/wgpuRenderEffectPipeline.test.ts +2 -0
- package/src/wgpuRenderEffectRegistrants.test.ts +25 -14
- package/dist/wgpuBrightnessContrastEffect.d.ts +0 -4
- package/dist/wgpuBrightnessContrastEffect.d.ts.map +0 -1
- package/dist/wgpuBrightnessContrastEffect.js +0 -29
- package/dist/wgpuBrightnessContrastEffect.js.map +0 -1
- package/dist/wgpuChannelMixerEffect.d.ts +0 -4
- package/dist/wgpuChannelMixerEffect.d.ts.map +0 -1
- package/dist/wgpuChannelMixerEffect.js +0 -34
- package/dist/wgpuChannelMixerEffect.js.map +0 -1
- package/dist/wgpuColorGradeEffect.d.ts +0 -4
- package/dist/wgpuColorGradeEffect.d.ts.map +0 -1
- package/dist/wgpuColorGradeEffect.js +0 -52
- package/dist/wgpuColorGradeEffect.js.map +0 -1
- package/dist/wgpuExposureEffect.d.ts +0 -4
- package/dist/wgpuExposureEffect.d.ts.map +0 -1
- package/dist/wgpuExposureEffect.js +0 -28
- package/dist/wgpuExposureEffect.js.map +0 -1
- package/dist/wgpuGrayscaleEffect.d.ts +0 -4
- package/dist/wgpuGrayscaleEffect.d.ts.map +0 -1
- package/dist/wgpuGrayscaleEffect.js +0 -27
- package/dist/wgpuGrayscaleEffect.js.map +0 -1
- package/dist/wgpuHueSaturationEffect.d.ts +0 -4
- package/dist/wgpuHueSaturationEffect.d.ts.map +0 -1
- package/dist/wgpuHueSaturationEffect.js +0 -75
- package/dist/wgpuHueSaturationEffect.js.map +0 -1
- package/dist/wgpuInvertEffect.d.ts +0 -4
- package/dist/wgpuInvertEffect.d.ts.map +0 -1
- package/dist/wgpuInvertEffect.js +0 -26
- package/dist/wgpuInvertEffect.js.map +0 -1
- package/dist/wgpuLiftGammaGainEffect.d.ts +0 -4
- package/dist/wgpuLiftGammaGainEffect.d.ts.map +0 -1
- package/dist/wgpuLiftGammaGainEffect.js +0 -51
- package/dist/wgpuLiftGammaGainEffect.js.map +0 -1
- package/dist/wgpuLookupTableGradeEffect.d.ts +0 -4
- package/dist/wgpuLookupTableGradeEffect.d.ts.map +0 -1
- package/dist/wgpuLookupTableGradeEffect.js +0 -30
- package/dist/wgpuLookupTableGradeEffect.js.map +0 -1
- package/dist/wgpuSepiaEffect.d.ts +0 -4
- package/dist/wgpuSepiaEffect.d.ts.map +0 -1
- package/dist/wgpuSepiaEffect.js +0 -31
- package/dist/wgpuSepiaEffect.js.map +0 -1
- package/src/wgpuBrightnessContrastEffect.test.ts +0 -16
- package/src/wgpuChannelMixerEffect.test.ts +0 -13
- package/src/wgpuColorGradeEffect.test.ts +0 -13
- package/src/wgpuExposureEffect.test.ts +0 -13
- package/src/wgpuGrayscaleEffect.test.ts +0 -13
- package/src/wgpuHueSaturationEffect.test.ts +0 -13
- package/src/wgpuInvertEffect.test.ts +0 -13
- package/src/wgpuLiftGammaGainEffect.test.ts +0 -13
- package/src/wgpuLookupTableGradeEffect.test.ts +0 -16
- package/src/wgpuSepiaEffect.test.ts +0 -13
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { applyBlurEffectToWgpu, applyGaussianBlurToWgpu, defaultWgpuBlurEffectRunner } from './wgpuBlurEffect';
|
|
2
|
+
|
|
3
|
+
describe('applyBlurEffectToWgpu', () => {
|
|
4
|
+
it('is a function', () => {
|
|
5
|
+
expect(typeof applyBlurEffectToWgpu).toBe('function');
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('applyGaussianBlurToWgpu', () => {
|
|
10
|
+
it('is a function', () => {
|
|
11
|
+
expect(typeof applyGaussianBlurToWgpu).toBe('function');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('defaultWgpuBlurEffectRunner', () => {
|
|
16
|
+
it('is a function', () => {
|
|
17
|
+
expect(typeof defaultWgpuBlurEffectRunner).toBe('function');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { applyConvolutionEffectToWgpu, defaultWgpuConvolutionEffectRunner } from './wgpuConvolutionEffect';
|
|
2
|
+
|
|
3
|
+
describe('applyConvolutionEffectToWgpu', () => {
|
|
4
|
+
it('is a function', () => {
|
|
5
|
+
expect(typeof applyConvolutionEffectToWgpu).toBe('function');
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('defaultWgpuConvolutionEffectRunner', () => {
|
|
10
|
+
it('is a function', () => {
|
|
11
|
+
expect(typeof defaultWgpuConvolutionEffectRunner).toBe('function');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
vi.hoisted(() => {
|
|
2
|
+
vi.resetModules();
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
vi.mock('@flighthq/render-wgpu', () => {
|
|
6
|
+
let nextTargetId = 0;
|
|
7
|
+
return {
|
|
8
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
+
...descriptor,
|
|
10
|
+
id: `scratch-${nextTargetId++}`,
|
|
11
|
+
texture: {},
|
|
12
|
+
})),
|
|
13
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
+
applyWgpuEffectBlitOffsetPass: vi.fn(),
|
|
19
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
20
|
+
applyWgpuEffectErasePass: vi.fn(),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
24
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
vi.mock('./wgpuEffectPass', () => ({
|
|
28
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
vi.mock('./wgpuEffectTintShader', () => ({
|
|
32
|
+
applyWgpuEffectTintPass: vi.fn(),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
import { applyDropShadowEffectToWgpu, defaultWgpuDropShadowEffectRunner } from './wgpuDropShadowEffect';
|
|
36
|
+
import { applyWgpuEffectBlitPass, applyWgpuEffectErasePass } from './wgpuEffectBlitShader';
|
|
37
|
+
|
|
38
|
+
describe('applyDropShadowEffectToWgpu', () => {
|
|
39
|
+
it('is a function', () => {
|
|
40
|
+
expect(typeof applyDropShadowEffectToWgpu).toBe('function');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('draws the source by default', () => {
|
|
44
|
+
const source = createTarget('source');
|
|
45
|
+
const dest = createTarget('dest');
|
|
46
|
+
|
|
47
|
+
applyDropShadowEffectToWgpu(createState(), source, dest, createPool(), { kind: 'DropShadowEffect' });
|
|
48
|
+
|
|
49
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenCalledWith(expect.anything(), source, dest);
|
|
50
|
+
expect(applyWgpuEffectErasePass).not.toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('hides the source when sourceMode is hide', () => {
|
|
54
|
+
const source = createTarget('source');
|
|
55
|
+
const dest = createTarget('dest');
|
|
56
|
+
|
|
57
|
+
applyDropShadowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
58
|
+
kind: 'DropShadowEffect',
|
|
59
|
+
sourceMode: 'hide',
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(applyWgpuEffectBlitPass).not.toHaveBeenCalledWith(expect.anything(), source, dest);
|
|
63
|
+
expect(applyWgpuEffectErasePass).not.toHaveBeenCalled();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('erases the source silhouette when sourceMode is knockout', () => {
|
|
67
|
+
const source = createTarget('source');
|
|
68
|
+
const dest = createTarget('dest');
|
|
69
|
+
|
|
70
|
+
applyDropShadowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
71
|
+
kind: 'DropShadowEffect',
|
|
72
|
+
sourceMode: 'knockout',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(applyWgpuEffectBlitPass).not.toHaveBeenCalledWith(expect.anything(), source, dest);
|
|
76
|
+
expect(applyWgpuEffectErasePass).toHaveBeenCalledWith(expect.anything(), source, dest);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('defaultWgpuDropShadowEffectRunner', () => {
|
|
81
|
+
it('is a function', () => {
|
|
82
|
+
expect(typeof defaultWgpuDropShadowEffectRunner).toBe('function');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
vi.clearAllMocks();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
afterAll(() => {
|
|
91
|
+
vi.doUnmock('@flighthq/render-wgpu');
|
|
92
|
+
vi.doUnmock('./wgpuEffectBlitShader');
|
|
93
|
+
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
94
|
+
vi.doUnmock('./wgpuEffectPass');
|
|
95
|
+
vi.doUnmock('./wgpuEffectTintShader');
|
|
96
|
+
vi.resetModules();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
function createState(): never {
|
|
100
|
+
return {} as never;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function createPool(): never {
|
|
104
|
+
return { free: [] } as never;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function createTarget(id: string): never {
|
|
108
|
+
return { id, width: 32, height: 16, format: 'rgba8', texture: {} } as never;
|
|
109
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyWgpuEffectBlitOffsetPass,
|
|
3
|
+
applyWgpuEffectBlitPass,
|
|
4
|
+
applyWgpuEffectErasePass,
|
|
5
|
+
} from './wgpuEffectBlitShader';
|
|
6
|
+
|
|
7
|
+
describe('applyWgpuEffectBlitOffsetPass', () => {
|
|
8
|
+
it('is a function', () => {
|
|
9
|
+
expect(typeof applyWgpuEffectBlitOffsetPass).toBe('function');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('applyWgpuEffectBlitPass', () => {
|
|
14
|
+
it('is a function', () => {
|
|
15
|
+
expect(typeof applyWgpuEffectBlitPass).toBe('function');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('applyWgpuEffectErasePass', () => {
|
|
20
|
+
it('is a function', () => {
|
|
21
|
+
expect(typeof applyWgpuEffectErasePass).toBe('function');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const mockState = vi.hoisted(() => ({
|
|
2
|
+
uniformSnapshots: [] as number[][],
|
|
3
|
+
}));
|
|
4
|
+
|
|
5
|
+
vi.hoisted(() => {
|
|
6
|
+
vi.resetModules();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
vi.mock('./wgpuEffectPass', () => ({
|
|
10
|
+
createWgpuEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
11
|
+
drawWgpuEffectPass: vi.fn((_state, _source, _dest, _pipeline, setUniforms) => {
|
|
12
|
+
const f32 = new Float32Array(16);
|
|
13
|
+
const i32 = new Int32Array(f32.buffer);
|
|
14
|
+
setUniforms(f32, i32);
|
|
15
|
+
mockState.uniformSnapshots.push(Array.from(f32));
|
|
16
|
+
}),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
import { applyWgpuEffectBoxBlur } from './wgpuEffectBoxBlur';
|
|
20
|
+
import { createWgpuEffectPipeline, drawWgpuEffectPass } from './wgpuEffectPass';
|
|
21
|
+
|
|
22
|
+
describe('applyWgpuEffectBoxBlur', () => {
|
|
23
|
+
it('is a function', () => {
|
|
24
|
+
expect(typeof applyWgpuEffectBoxBlur).toBe('function');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('binds the exterior edge color when one is provided', () => {
|
|
28
|
+
applyWgpuEffectBoxBlur(createState(), createTarget('source'), createTarget('dest'), createTarget('temp'), {
|
|
29
|
+
blurX: 4,
|
|
30
|
+
blurY: 0,
|
|
31
|
+
edgeColor: [0.1, 0.2, 0.3, 0.4],
|
|
32
|
+
passes: 1,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(createWgpuEffectPipeline).toHaveBeenCalledWith(expect.anything(), expect.any(String), 'replace');
|
|
36
|
+
expect(mockState.uniformSnapshots[0]![4]).toBeCloseTo(0.1);
|
|
37
|
+
expect(mockState.uniformSnapshots[0]![5]).toBeCloseTo(0.2);
|
|
38
|
+
expect(mockState.uniformSnapshots[0]![6]).toBeCloseTo(0.3);
|
|
39
|
+
expect(mockState.uniformSnapshots[0]![7]).toBeCloseTo(0.4);
|
|
40
|
+
expect(mockState.uniformSnapshots[0]![9]).toBe(1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('uses the replacement blur pipeline for zero-radius copies', () => {
|
|
44
|
+
const dest = createTarget('dest');
|
|
45
|
+
|
|
46
|
+
applyWgpuEffectBoxBlur(createState(), createTarget('source'), dest, createTarget('temp'), {
|
|
47
|
+
blurX: 0,
|
|
48
|
+
blurY: 0,
|
|
49
|
+
passes: 1,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(drawWgpuEffectPass).toHaveBeenCalledTimes(1);
|
|
53
|
+
expect(vi.mocked(drawWgpuEffectPass).mock.calls[0]![2]).toBe(dest);
|
|
54
|
+
expect(mockState.uniformSnapshots[0]![8]).toBe(0);
|
|
55
|
+
expect(mockState.uniformSnapshots[0]![9]).toBe(0);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
vi.clearAllMocks();
|
|
61
|
+
mockState.uniformSnapshots.length = 0;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterAll(() => {
|
|
65
|
+
vi.doUnmock('./wgpuEffectPass');
|
|
66
|
+
vi.resetModules();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
function createState(): never {
|
|
70
|
+
return {} as never;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function createTarget(id: string): never {
|
|
74
|
+
return { id, width: 32, height: 16, format: 'rgba8', texture: {}, view: {} } as never;
|
|
75
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearWgpuEffectTarget,
|
|
3
|
+
createWgpuDualSourceEffectPipeline,
|
|
4
|
+
createWgpuEffectPipeline,
|
|
5
|
+
drawWgpuDualSourceEffectPass,
|
|
6
|
+
drawWgpuEffectPass,
|
|
7
|
+
EFFECT_VERTEX_WGSL,
|
|
8
|
+
getWgpuEffectPassState,
|
|
9
|
+
} from './wgpuEffectPass';
|
|
10
|
+
|
|
11
|
+
describe('clearWgpuEffectTarget', () => {
|
|
12
|
+
it('is a function', () => {
|
|
13
|
+
expect(typeof clearWgpuEffectTarget).toBe('function');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('createWgpuDualSourceEffectPipeline', () => {
|
|
18
|
+
it('is a function', () => {
|
|
19
|
+
expect(typeof createWgpuDualSourceEffectPipeline).toBe('function');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('createWgpuEffectPipeline', () => {
|
|
24
|
+
it('is a function', () => {
|
|
25
|
+
expect(typeof createWgpuEffectPipeline).toBe('function');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('drawWgpuDualSourceEffectPass', () => {
|
|
30
|
+
it('is a function', () => {
|
|
31
|
+
expect(typeof drawWgpuDualSourceEffectPass).toBe('function');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('drawWgpuEffectPass', () => {
|
|
36
|
+
it('is a function', () => {
|
|
37
|
+
expect(typeof drawWgpuEffectPass).toBe('function');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('EFFECT_VERTEX_WGSL', () => {
|
|
42
|
+
it('is a WGSL string', () => {
|
|
43
|
+
expect(typeof EFFECT_VERTEX_WGSL).toBe('string');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('getWgpuEffectPassState', () => {
|
|
48
|
+
it('is a function', () => {
|
|
49
|
+
expect(typeof getWgpuEffectPassState).toBe('function');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
vi.hoisted(() => {
|
|
2
|
+
vi.resetModules();
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
vi.mock('./wgpuEffectPass', () => ({
|
|
6
|
+
createWgpuDualSourceEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
7
|
+
createWgpuEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
8
|
+
drawWgpuDualSourceEffectPass: vi.fn(),
|
|
9
|
+
drawWgpuEffectPass: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
import { createWgpuDualSourceEffectPipeline, createWgpuEffectPipeline } from './wgpuEffectPass';
|
|
13
|
+
import {
|
|
14
|
+
applyWgpuEffectInnerClipPass,
|
|
15
|
+
applyWgpuEffectInvertTintPass,
|
|
16
|
+
applyWgpuEffectTintPass,
|
|
17
|
+
} from './wgpuEffectTintShader';
|
|
18
|
+
|
|
19
|
+
describe('applyWgpuEffectInnerClipPass', () => {
|
|
20
|
+
it('is a function', () => {
|
|
21
|
+
expect(typeof applyWgpuEffectInnerClipPass).toBe('function');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('uses replacement blending', () => {
|
|
25
|
+
applyWgpuEffectInnerClipPass(createState(), createTarget(), createTarget(), createTarget());
|
|
26
|
+
|
|
27
|
+
expect(createWgpuDualSourceEffectPipeline).toHaveBeenCalledWith(expect.anything(), expect.any(String), 'replace');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('applyWgpuEffectInvertTintPass', () => {
|
|
32
|
+
it('is a function', () => {
|
|
33
|
+
expect(typeof applyWgpuEffectInvertTintPass).toBe('function');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('uses replacement blending', () => {
|
|
37
|
+
applyWgpuEffectInvertTintPass(createState(), createTarget(), createTarget(), 0xff00cc, 0.5, 2);
|
|
38
|
+
|
|
39
|
+
expect(createWgpuEffectPipeline).toHaveBeenCalledWith(expect.anything(), expect.any(String), 'replace');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('applyWgpuEffectTintPass', () => {
|
|
44
|
+
it('is a function', () => {
|
|
45
|
+
expect(typeof applyWgpuEffectTintPass).toBe('function');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('uses replacement blending', () => {
|
|
49
|
+
applyWgpuEffectTintPass(createState(), createTarget(), createTarget(), 0xff00cc, 0.5, 2);
|
|
50
|
+
|
|
51
|
+
expect(createWgpuEffectPipeline).toHaveBeenCalledWith(expect.anything(), expect.any(String), 'replace');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterAll(() => {
|
|
56
|
+
vi.doUnmock('./wgpuEffectPass');
|
|
57
|
+
vi.resetModules();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
function createState(): never {
|
|
61
|
+
return {} as never;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createTarget(): never {
|
|
65
|
+
return {} as never;
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { applyGradientBevelEffectToWgpu, defaultWgpuGradientBevelEffectRunner } from './wgpuGradientBevelEffect';
|
|
2
|
+
|
|
3
|
+
describe('applyGradientBevelEffectToWgpu', () => {
|
|
4
|
+
it('is a function', () => {
|
|
5
|
+
expect(typeof applyGradientBevelEffectToWgpu).toBe('function');
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('defaultWgpuGradientBevelEffectRunner', () => {
|
|
10
|
+
it('is a function', () => {
|
|
11
|
+
expect(typeof defaultWgpuGradientBevelEffectRunner).toBe('function');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { applyGradientGlowEffectToWgpu, defaultWgpuGradientGlowEffectRunner } from './wgpuGradientGlowEffect';
|
|
2
|
+
|
|
3
|
+
describe('applyGradientGlowEffectToWgpu', () => {
|
|
4
|
+
it('is a function', () => {
|
|
5
|
+
expect(typeof applyGradientGlowEffectToWgpu).toBe('function');
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('defaultWgpuGradientGlowEffectRunner', () => {
|
|
10
|
+
it('is a function', () => {
|
|
11
|
+
expect(typeof defaultWgpuGradientGlowEffectRunner).toBe('function');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
vi.hoisted(() => {
|
|
2
|
+
vi.resetModules();
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
vi.mock('@flighthq/render-wgpu', () => {
|
|
6
|
+
let nextTargetId = 0;
|
|
7
|
+
return {
|
|
8
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
+
...descriptor,
|
|
10
|
+
id: `scratch-${nextTargetId++}`,
|
|
11
|
+
texture: {},
|
|
12
|
+
})),
|
|
13
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
22
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock('./wgpuEffectPass', () => ({
|
|
26
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
vi.mock('./wgpuEffectTintShader', () => ({
|
|
30
|
+
applyWgpuEffectInnerClipPass: vi.fn(),
|
|
31
|
+
applyWgpuEffectInvertTintPass: vi.fn(),
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
import { applyWgpuEffectBlitPass } from './wgpuEffectBlitShader';
|
|
35
|
+
import { applyWgpuEffectBoxBlur } from './wgpuEffectBoxBlur';
|
|
36
|
+
import { applyWgpuEffectInnerClipPass } from './wgpuEffectTintShader';
|
|
37
|
+
import { applyInnerGlowEffectToWgpu, defaultWgpuInnerGlowEffectRunner } from './wgpuInnerGlowEffect';
|
|
38
|
+
|
|
39
|
+
describe('applyInnerGlowEffectToWgpu', () => {
|
|
40
|
+
it('is a function', () => {
|
|
41
|
+
expect(typeof applyInnerGlowEffectToWgpu).toBe('function');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('composites the source before the clipped glow by default', () => {
|
|
45
|
+
const source = createTarget('source');
|
|
46
|
+
const dest = createTarget('dest');
|
|
47
|
+
|
|
48
|
+
applyInnerGlowEffectToWgpu(createState(), source, dest, createPool(), { kind: 'InnerGlowEffect' });
|
|
49
|
+
|
|
50
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenCalledTimes(2);
|
|
51
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenNthCalledWith(1, expect.anything(), source, dest);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('omits the source composite when sourceMode is hide', () => {
|
|
55
|
+
const source = createTarget('source');
|
|
56
|
+
const dest = createTarget('dest');
|
|
57
|
+
|
|
58
|
+
applyInnerGlowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
59
|
+
kind: 'InnerGlowEffect',
|
|
60
|
+
sourceMode: 'hide',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenCalledTimes(1);
|
|
64
|
+
expect(applyWgpuEffectBlitPass).not.toHaveBeenCalledWith(expect.anything(), source, dest);
|
|
65
|
+
const finalComposite = vi.mocked(applyWgpuEffectBlitPass).mock.calls[0];
|
|
66
|
+
expect(finalComposite[1]).not.toBe(source);
|
|
67
|
+
expect(finalComposite[2]).toBe(dest);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('uses an inverted exterior edge color for hidden-source blur', () => {
|
|
71
|
+
const source = createTarget('source');
|
|
72
|
+
const dest = createTarget('dest');
|
|
73
|
+
|
|
74
|
+
applyInnerGlowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
75
|
+
kind: 'InnerGlowEffect',
|
|
76
|
+
color: 0xff0000,
|
|
77
|
+
sourceMode: 'hide',
|
|
78
|
+
strength: 2,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(applyWgpuEffectBoxBlur).toHaveBeenCalledWith(
|
|
82
|
+
expect.anything(),
|
|
83
|
+
expect.anything(),
|
|
84
|
+
expect.anything(),
|
|
85
|
+
expect.anything(),
|
|
86
|
+
expect.objectContaining({ edgeColor: [1, 0, 0, 1] }),
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('clips the hidden-source glow against the source alpha', () => {
|
|
91
|
+
const source = createTarget('source');
|
|
92
|
+
const dest = createTarget('dest');
|
|
93
|
+
|
|
94
|
+
applyInnerGlowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
95
|
+
kind: 'InnerGlowEffect',
|
|
96
|
+
sourceMode: 'hide',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(applyWgpuEffectInnerClipPass).toHaveBeenCalledWith(
|
|
100
|
+
expect.anything(),
|
|
101
|
+
expect.anything(),
|
|
102
|
+
source,
|
|
103
|
+
expect.anything(),
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('defaultWgpuInnerGlowEffectRunner', () => {
|
|
109
|
+
it('is a function', () => {
|
|
110
|
+
expect(typeof defaultWgpuInnerGlowEffectRunner).toBe('function');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
vi.clearAllMocks();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
afterAll(() => {
|
|
119
|
+
vi.doUnmock('@flighthq/render-wgpu');
|
|
120
|
+
vi.doUnmock('./wgpuEffectBlitShader');
|
|
121
|
+
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
122
|
+
vi.doUnmock('./wgpuEffectPass');
|
|
123
|
+
vi.doUnmock('./wgpuEffectTintShader');
|
|
124
|
+
vi.resetModules();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
function createState(): never {
|
|
128
|
+
return {} as never;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function createPool(): never {
|
|
132
|
+
return { free: [] } as never;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function createTarget(id: string): never {
|
|
136
|
+
return { id, width: 32, height: 16, format: 'rgba8', texture: {} } as never;
|
|
137
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
vi.hoisted(() => {
|
|
2
|
+
vi.resetModules();
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
vi.mock('@flighthq/render-wgpu', () => {
|
|
6
|
+
let nextTargetId = 0;
|
|
7
|
+
return {
|
|
8
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
+
...descriptor,
|
|
10
|
+
id: `scratch-${nextTargetId++}`,
|
|
11
|
+
texture: {},
|
|
12
|
+
})),
|
|
13
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
+
applyWgpuEffectBlitOffsetPass: vi.fn(),
|
|
19
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
23
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
vi.mock('./wgpuEffectPass', () => ({
|
|
27
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
vi.mock('./wgpuEffectTintShader', () => ({
|
|
31
|
+
applyWgpuEffectInnerClipPass: vi.fn(),
|
|
32
|
+
applyWgpuEffectInvertTintPass: vi.fn(),
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
import { applyWgpuEffectBlitPass } from './wgpuEffectBlitShader';
|
|
36
|
+
import { applyWgpuEffectBoxBlur } from './wgpuEffectBoxBlur';
|
|
37
|
+
import { applyWgpuEffectInnerClipPass } from './wgpuEffectTintShader';
|
|
38
|
+
import { applyInnerShadowEffectToWgpu, defaultWgpuInnerShadowEffectRunner } from './wgpuInnerShadowEffect';
|
|
39
|
+
|
|
40
|
+
describe('applyInnerShadowEffectToWgpu', () => {
|
|
41
|
+
it('is a function', () => {
|
|
42
|
+
expect(typeof applyInnerShadowEffectToWgpu).toBe('function');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('composites the source before the clipped shadow by default', () => {
|
|
46
|
+
const source = createTarget('source');
|
|
47
|
+
const dest = createTarget('dest');
|
|
48
|
+
|
|
49
|
+
applyInnerShadowEffectToWgpu(createState(), source, dest, createPool(), { kind: 'InnerShadowEffect' });
|
|
50
|
+
|
|
51
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenCalledTimes(2);
|
|
52
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenNthCalledWith(1, expect.anything(), source, dest);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('omits the source composite when sourceMode is hide', () => {
|
|
56
|
+
const source = createTarget('source');
|
|
57
|
+
const dest = createTarget('dest');
|
|
58
|
+
|
|
59
|
+
applyInnerShadowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
60
|
+
kind: 'InnerShadowEffect',
|
|
61
|
+
sourceMode: 'hide',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
expect(applyWgpuEffectBlitPass).toHaveBeenCalledTimes(1);
|
|
65
|
+
expect(applyWgpuEffectBlitPass).not.toHaveBeenCalledWith(expect.anything(), source, dest);
|
|
66
|
+
const finalComposite = vi.mocked(applyWgpuEffectBlitPass).mock.calls[0];
|
|
67
|
+
expect(finalComposite[1]).not.toBe(source);
|
|
68
|
+
expect(finalComposite[2]).toBe(dest);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('uses an inverted exterior edge color for hidden-source blur', () => {
|
|
72
|
+
const source = createTarget('source');
|
|
73
|
+
const dest = createTarget('dest');
|
|
74
|
+
|
|
75
|
+
applyInnerShadowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
76
|
+
kind: 'InnerShadowEffect',
|
|
77
|
+
color: 0,
|
|
78
|
+
sourceMode: 'hide',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(applyWgpuEffectBoxBlur).toHaveBeenCalledWith(
|
|
82
|
+
expect.anything(),
|
|
83
|
+
expect.anything(),
|
|
84
|
+
expect.anything(),
|
|
85
|
+
expect.anything(),
|
|
86
|
+
expect.objectContaining({ edgeColor: [0, 0, 0, 1] }),
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('clips the hidden-source shadow against the source alpha', () => {
|
|
91
|
+
const source = createTarget('source');
|
|
92
|
+
const dest = createTarget('dest');
|
|
93
|
+
|
|
94
|
+
applyInnerShadowEffectToWgpu(createState(), source, dest, createPool(), {
|
|
95
|
+
kind: 'InnerShadowEffect',
|
|
96
|
+
sourceMode: 'hide',
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(applyWgpuEffectInnerClipPass).toHaveBeenCalledWith(
|
|
100
|
+
expect.anything(),
|
|
101
|
+
expect.anything(),
|
|
102
|
+
source,
|
|
103
|
+
expect.anything(),
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('defaultWgpuInnerShadowEffectRunner', () => {
|
|
109
|
+
it('is a function', () => {
|
|
110
|
+
expect(typeof defaultWgpuInnerShadowEffectRunner).toBe('function');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
vi.clearAllMocks();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
afterAll(() => {
|
|
119
|
+
vi.doUnmock('@flighthq/render-wgpu');
|
|
120
|
+
vi.doUnmock('./wgpuEffectBlitShader');
|
|
121
|
+
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
122
|
+
vi.doUnmock('./wgpuEffectPass');
|
|
123
|
+
vi.doUnmock('./wgpuEffectTintShader');
|
|
124
|
+
vi.resetModules();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
function createState(): never {
|
|
128
|
+
return {} as never;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function createPool(): never {
|
|
132
|
+
return { free: [] } as never;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function createTarget(id: string): never {
|
|
136
|
+
return { id, width: 32, height: 16, format: 'rgba8', texture: {} } as never;
|
|
137
|
+
}
|