@flighthq/effects-wgpu 0.1.0 → 0.2.0
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 +122 -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 +49 -0
- package/dist/wgpuDropShadowEffect.js.map +1 -0
- package/dist/wgpuEffectBlitShader.d.ts +15 -0
- package/dist/wgpuEffectBlitShader.d.ts.map +1 -0
- package/dist/wgpuEffectBlitShader.js +71 -0
- package/dist/wgpuEffectBlitShader.js.map +1 -0
- package/dist/wgpuEffectBoxBlur.d.ts +14 -0
- package/dist/wgpuEffectBoxBlur.d.ts.map +1 -0
- package/dist/wgpuEffectBoxBlur.js +81 -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 +41 -0
- package/dist/wgpuEffectPass.d.ts.map +1 -0
- package/dist/wgpuEffectPass.js +259 -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 +189 -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 +97 -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 +37 -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 +42 -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 +43 -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 +59 -9
- 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 +13 -0
- package/src/wgpuEffectBlitShader.test.ts +13 -0
- package/src/wgpuEffectBoxBlur.test.ts +7 -0
- package/src/wgpuEffectGradientRamp.test.ts +7 -0
- package/src/wgpuEffectPass.test.ts +51 -0
- package/src/wgpuEffectTintShader.test.ts +23 -0
- package/src/wgpuGradientBevelEffect.test.ts +13 -0
- package/src/wgpuGradientGlowEffect.test.ts +13 -0
- package/src/wgpuInnerGlowEffect.test.ts +13 -0
- package/src/wgpuInnerShadowEffect.test.ts +13 -0
- package/src/wgpuMedianEffect.test.ts +13 -0
- package/src/wgpuOuterGlowEffect.test.ts +13 -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,71 @@
|
|
|
1
|
+
import { createWgpuEffectPipeline, drawWgpuEffectPass } from './wgpuEffectPass';
|
|
2
|
+
// Blits a texture at a UV offset. Out-of-bounds samples produce transparent output.
|
|
3
|
+
const BLIT_OFFSET_WGSL = /* wgsl */ `
|
|
4
|
+
struct Uniforms {
|
|
5
|
+
offset : vec2f,
|
|
6
|
+
_pad : vec2f,
|
|
7
|
+
}
|
|
8
|
+
@group(0) @binding(0) var<uniform> uni : Uniforms;
|
|
9
|
+
@group(1) @binding(0) var tex : texture_2d<f32>;
|
|
10
|
+
@group(1) @binding(1) var smp : sampler;
|
|
11
|
+
|
|
12
|
+
@fragment
|
|
13
|
+
fn fs_main(@location(0) uv : vec2f) -> @location(0) vec4f {
|
|
14
|
+
let shifted = uv + uni.offset;
|
|
15
|
+
if (shifted.x < 0.0 || shifted.x > 1.0 || shifted.y < 0.0 || shifted.y > 1.0) {
|
|
16
|
+
return vec4f(0.0);
|
|
17
|
+
}
|
|
18
|
+
return textureSampleLevel(tex, smp, shifted, 0.0);
|
|
19
|
+
}`;
|
|
20
|
+
// Pass-through blit. Minimal uniform struct required by the pipeline layout.
|
|
21
|
+
const BLIT_WGSL = /* wgsl */ `
|
|
22
|
+
struct Uniforms { _u : f32, _pad0 : f32, _pad1 : f32, _pad2 : f32, }
|
|
23
|
+
@group(0) @binding(0) var<uniform> uni : Uniforms;
|
|
24
|
+
@group(1) @binding(0) var tex : texture_2d<f32>;
|
|
25
|
+
@group(1) @binding(1) var smp : sampler;
|
|
26
|
+
|
|
27
|
+
@fragment
|
|
28
|
+
fn fs_main(@location(0) uv : vec2f) -> @location(0) vec4f {
|
|
29
|
+
return textureSampleLevel(tex, smp, uv, 0.0);
|
|
30
|
+
}`;
|
|
31
|
+
/**
|
|
32
|
+
* Blits source into dest at a pixel offset (dx, dy in screen-space Y-down).
|
|
33
|
+
* Pixels sampling outside the source bounds produce transparent output.
|
|
34
|
+
*
|
|
35
|
+
* The offset matches the Gl path exactly — (-dx/w, +dy/h). The shader samples `uv + offset`, so a
|
|
36
|
+
* screen-space shift of (+dx,+dy) needs offset (-dx, +dy): the +dy is NOT negated for Wgpu. Wgpu's UV
|
|
37
|
+
* y=0 is top (opposite Gl's bottom-origin) but Wgpu render-target textures are also stored top-down, so
|
|
38
|
+
* the two inversions cancel. A previous extra Y negation put the shadow on the wrong side of the source
|
|
39
|
+
* (it landed up-left instead of down-right) — caught by filter-drop-shadow-parity.
|
|
40
|
+
*/
|
|
41
|
+
export function applyWgpuEffectBlitOffsetPass(state, source, dest, dx, dy) {
|
|
42
|
+
const pipeline = getWgpuBlitOffsetShader(state);
|
|
43
|
+
drawWgpuEffectPass(state, source, dest, pipeline, (f32) => {
|
|
44
|
+
f32[0] = -dx / source.width;
|
|
45
|
+
f32[1] = dy / source.height;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** Blits source directly into dest without modification. */
|
|
49
|
+
export function applyWgpuEffectBlitPass(state, source, dest) {
|
|
50
|
+
const pipeline = getWgpuBlitShader(state);
|
|
51
|
+
drawWgpuEffectPass(state, source, dest, pipeline, () => { });
|
|
52
|
+
}
|
|
53
|
+
function getWgpuBlitOffsetShader(state) {
|
|
54
|
+
let p = blitOffsetPipelines.get(state);
|
|
55
|
+
if (p === undefined) {
|
|
56
|
+
p = createWgpuEffectPipeline(state, BLIT_OFFSET_WGSL);
|
|
57
|
+
blitOffsetPipelines.set(state, p);
|
|
58
|
+
}
|
|
59
|
+
return p;
|
|
60
|
+
}
|
|
61
|
+
function getWgpuBlitShader(state) {
|
|
62
|
+
let p = blitPipelines.get(state);
|
|
63
|
+
if (p === undefined) {
|
|
64
|
+
p = createWgpuEffectPipeline(state, BLIT_WGSL);
|
|
65
|
+
blitPipelines.set(state, p);
|
|
66
|
+
}
|
|
67
|
+
return p;
|
|
68
|
+
}
|
|
69
|
+
const blitOffsetPipelines = new WeakMap();
|
|
70
|
+
const blitPipelines = new WeakMap();
|
|
71
|
+
//# sourceMappingURL=wgpuEffectBlitShader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuEffectBlitShader.js","sourceRoot":"","sources":["../src/wgpuEffectBlitShader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,oFAAoF;AACpF,MAAM,gBAAgB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;EAgBlC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,SAAS,GAAG,UAAU,CAAC;;;;;;;;;EAS3B,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,6BAA6B,CAC3C,KAAsB,EACtB,MAAwB,EACxB,IAAsB,EACtB,EAAU,EACV,EAAU;IAEV,MAAM,QAAQ,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAChD,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;QACxD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;QAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,uBAAuB,CACrC,KAAsB,EACtB,MAAwB,EACxB,IAAsB;IAEtB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC1C,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAsB;IACrD,IAAI,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,CAAC,GAAG,wBAAwB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACtD,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAsB;IAC/C,IAAI,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,CAAC,GAAG,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC/C,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAuC,CAAC;AAC/E,MAAM,aAAa,GAAG,IAAI,OAAO,EAAuC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WgpuRenderState, WgpuRenderTarget } from '@flighthq/types';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a separable box blur to `source`, writing to `dest`. `blurX`/`blurY` are
|
|
4
|
+
* the target Gaussian standard deviations; `passes` is the number of box passes per
|
|
5
|
+
* axis (more passes converge on a Gaussian — see `computeBoxBlurPassRadius`). A box
|
|
6
|
+
* blur is cheap and right for soft spreads. `temp` is a caller-provided ping-pong
|
|
7
|
+
* scratch target distinct from both `source` and `dest`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyWgpuEffectBoxBlur(state: WgpuRenderState, source: WgpuRenderTarget, dest: WgpuRenderTarget, temp: WgpuRenderTarget, options: Readonly<{
|
|
10
|
+
blurX?: number;
|
|
11
|
+
blurY?: number;
|
|
12
|
+
passes?: number;
|
|
13
|
+
}>): void;
|
|
14
|
+
//# sourceMappingURL=wgpuEffectBoxBlur.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuEffectBoxBlur.d.ts","sourceRoot":"","sources":["../src/wgpuEffectBoxBlur.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAkCzE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,QAAQ,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,IAAI,CA0BN"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { computeBoxBlurPassRadius } from '@flighthq/effects';
|
|
2
|
+
import { applyWgpuEffectBlitPass } from './wgpuEffectBlitShader';
|
|
3
|
+
import { createWgpuEffectPipeline, drawWgpuEffectPass } from './wgpuEffectPass';
|
|
4
|
+
// Uniforms layout:
|
|
5
|
+
// offset 0: texelSize (vec2f)
|
|
6
|
+
// offset 8: direction (vec2f)
|
|
7
|
+
// offset 16: radius (f32)
|
|
8
|
+
// offset 20-31: padding
|
|
9
|
+
const BOX_BLUR_WGSL = /* wgsl */ `
|
|
10
|
+
struct Uniforms {
|
|
11
|
+
texelSize : vec2f,
|
|
12
|
+
direction : vec2f,
|
|
13
|
+
radius : f32,
|
|
14
|
+
_pad0 : f32, _pad1 : f32, _pad2 : f32,
|
|
15
|
+
}
|
|
16
|
+
@group(0) @binding(0) var<uniform> uni : Uniforms;
|
|
17
|
+
@group(1) @binding(0) var tex : texture_2d<f32>;
|
|
18
|
+
@group(1) @binding(1) var smp : sampler;
|
|
19
|
+
|
|
20
|
+
@fragment
|
|
21
|
+
fn fs_main(@location(0) uv : vec2f) -> @location(0) vec4f {
|
|
22
|
+
let r = i32(uni.radius);
|
|
23
|
+
if (r == 0) { return textureSampleLevel(tex, smp, uv, 0.0); }
|
|
24
|
+
var sum = vec4f(0.0);
|
|
25
|
+
let count = f32(2 * r + 1);
|
|
26
|
+
for (var i = -r; i <= r; i++) {
|
|
27
|
+
sum += textureSampleLevel(tex, smp, uv + f32(i) * uni.texelSize * uni.direction, 0.0);
|
|
28
|
+
}
|
|
29
|
+
return sum / count;
|
|
30
|
+
}`;
|
|
31
|
+
/**
|
|
32
|
+
* Applies a separable box blur to `source`, writing to `dest`. `blurX`/`blurY` are
|
|
33
|
+
* the target Gaussian standard deviations; `passes` is the number of box passes per
|
|
34
|
+
* axis (more passes converge on a Gaussian — see `computeBoxBlurPassRadius`). A box
|
|
35
|
+
* blur is cheap and right for soft spreads. `temp` is a caller-provided ping-pong
|
|
36
|
+
* scratch target distinct from both `source` and `dest`.
|
|
37
|
+
*/
|
|
38
|
+
export function applyWgpuEffectBoxBlur(state, source, dest, temp, options) {
|
|
39
|
+
const passes = Math.max(1, Math.round(options.passes ?? 1));
|
|
40
|
+
const blurX = options.blurX ?? 4;
|
|
41
|
+
const blurY = options.blurY ?? 4;
|
|
42
|
+
let read = source;
|
|
43
|
+
let write = temp;
|
|
44
|
+
for (let pass = 0; pass < passes; pass++) {
|
|
45
|
+
const radiusX = computeBoxBlurPassRadius(blurX, passes, pass);
|
|
46
|
+
if (radiusX > 0) {
|
|
47
|
+
applyBoxBlurPass(state, read, write, radiusX, 1, 0);
|
|
48
|
+
read = write;
|
|
49
|
+
write = write === temp ? dest : temp;
|
|
50
|
+
}
|
|
51
|
+
const radiusY = computeBoxBlurPassRadius(blurY, passes, pass);
|
|
52
|
+
if (radiusY > 0) {
|
|
53
|
+
applyBoxBlurPass(state, read, write, radiusY, 0, 1);
|
|
54
|
+
read = write;
|
|
55
|
+
write = write === temp ? dest : temp;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (read !== dest) {
|
|
59
|
+
applyWgpuEffectBlitPass(state, read, dest);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function applyBoxBlurPass(state, source, dest, radius, dirX, dirY) {
|
|
63
|
+
const pipeline = getBoxBlurPipeline(state);
|
|
64
|
+
drawWgpuEffectPass(state, source, dest, pipeline, (f32) => {
|
|
65
|
+
f32[0] = 1 / source.width;
|
|
66
|
+
f32[1] = 1 / source.height;
|
|
67
|
+
f32[2] = dirX;
|
|
68
|
+
f32[3] = dirY;
|
|
69
|
+
f32[4] = radius;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function getBoxBlurPipeline(state) {
|
|
73
|
+
let p = boxBlurPipelines.get(state);
|
|
74
|
+
if (p === undefined) {
|
|
75
|
+
p = createWgpuEffectPipeline(state, BOX_BLUR_WGSL, 'replace');
|
|
76
|
+
boxBlurPipelines.set(state, p);
|
|
77
|
+
}
|
|
78
|
+
return p;
|
|
79
|
+
}
|
|
80
|
+
const boxBlurPipelines = new WeakMap();
|
|
81
|
+
//# sourceMappingURL=wgpuEffectBoxBlur.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuEffectBoxBlur.js","sourceRoot":"","sources":["../src/wgpuEffectBoxBlur.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,mBAAmB;AACnB,iCAAiC;AACjC,iCAAiC;AACjC,4BAA4B;AAC5B,0BAA0B;AAC1B,MAAM,aAAa,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**
|
|
3
|
+
* Returns a cached 256-entry RGBA gradient ramp texture for the given stops,
|
|
4
|
+
* building it on first use and reusing it on later calls with the same stops.
|
|
5
|
+
* The texture is owned by the render state and lives for its lifetime — callers
|
|
6
|
+
* must NOT destroy it. This is the form recipes should use: a recipe runs inside
|
|
7
|
+
* the frame's command encoder and does not control submit timing, so it cannot
|
|
8
|
+
* safely `destroy()` a per-call texture (the encoder still references it at
|
|
9
|
+
* submit, which discards the whole frame). Caching also avoids a per-frame
|
|
10
|
+
* allocation. Distinct stop sets get distinct textures, so multiple gradient
|
|
11
|
+
* recipes in one frame never alias each other's ramp.
|
|
12
|
+
*
|
|
13
|
+
* `ratios` are in byte scale [0,255]. Colors are packed RGB integers.
|
|
14
|
+
* `alphas` are in [0,1].
|
|
15
|
+
*/
|
|
16
|
+
export declare function getWgpuEffectGradientRampTexture(state: WgpuRenderState, colors: ReadonlyArray<number>, alphas: ReadonlyArray<number>, ratios: ReadonlyArray<number>): GPUTexture;
|
|
17
|
+
//# sourceMappingURL=wgpuEffectGradientRamp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuEffectGradientRamp.d.ts","sourceRoot":"","sources":["../src/wgpuEffectGradientRamp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAC5B,UAAU,CAaZ"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a cached 256-entry RGBA gradient ramp texture for the given stops,
|
|
3
|
+
* building it on first use and reusing it on later calls with the same stops.
|
|
4
|
+
* The texture is owned by the render state and lives for its lifetime — callers
|
|
5
|
+
* must NOT destroy it. This is the form recipes should use: a recipe runs inside
|
|
6
|
+
* the frame's command encoder and does not control submit timing, so it cannot
|
|
7
|
+
* safely `destroy()` a per-call texture (the encoder still references it at
|
|
8
|
+
* submit, which discards the whole frame). Caching also avoids a per-frame
|
|
9
|
+
* allocation. Distinct stop sets get distinct textures, so multiple gradient
|
|
10
|
+
* recipes in one frame never alias each other's ramp.
|
|
11
|
+
*
|
|
12
|
+
* `ratios` are in byte scale [0,255]. Colors are packed RGB integers.
|
|
13
|
+
* `alphas` are in [0,1].
|
|
14
|
+
*/
|
|
15
|
+
export function getWgpuEffectGradientRampTexture(state, colors, alphas, ratios) {
|
|
16
|
+
let cache = rampCaches.get(state);
|
|
17
|
+
if (cache === undefined) {
|
|
18
|
+
cache = new Map();
|
|
19
|
+
rampCaches.set(state, cache);
|
|
20
|
+
}
|
|
21
|
+
const key = `${colors.join(',')}|${alphas.join(',')}|${ratios.join(',')}`;
|
|
22
|
+
let texture = cache.get(key);
|
|
23
|
+
if (texture === undefined) {
|
|
24
|
+
texture = createWgpuEffectGradientRampTexture(state, colors, alphas, ratios);
|
|
25
|
+
cache.set(key, texture);
|
|
26
|
+
}
|
|
27
|
+
return texture;
|
|
28
|
+
}
|
|
29
|
+
function buildRampData(colors, alphas, ratios) {
|
|
30
|
+
const out = new Uint8ClampedArray(256 * 4);
|
|
31
|
+
if (colors.length === 0)
|
|
32
|
+
return out;
|
|
33
|
+
for (let i = 0; i < 256; i++) {
|
|
34
|
+
const t = i;
|
|
35
|
+
let r = 0, g = 0, b = 0, a = 0;
|
|
36
|
+
if (t <= ratios[0]) {
|
|
37
|
+
const c = colors[0];
|
|
38
|
+
r = (c >> 16) & 0xff;
|
|
39
|
+
g = (c >> 8) & 0xff;
|
|
40
|
+
b = c & 0xff;
|
|
41
|
+
a = Math.round(alphas[0] * 255);
|
|
42
|
+
}
|
|
43
|
+
else if (t >= ratios[ratios.length - 1]) {
|
|
44
|
+
const c = colors[colors.length - 1];
|
|
45
|
+
r = (c >> 16) & 0xff;
|
|
46
|
+
g = (c >> 8) & 0xff;
|
|
47
|
+
b = c & 0xff;
|
|
48
|
+
a = Math.round(alphas[alphas.length - 1] * 255);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
for (let j = 0; j < ratios.length - 1; j++) {
|
|
52
|
+
const r0 = ratios[j];
|
|
53
|
+
const r1 = ratios[j + 1];
|
|
54
|
+
if (t >= r0 && t <= r1) {
|
|
55
|
+
const blend = r1 > r0 ? (t - r0) / (r1 - r0) : 0;
|
|
56
|
+
const c0 = colors[j];
|
|
57
|
+
const c1 = colors[j + 1];
|
|
58
|
+
r = Math.round(((c0 >> 16) & 0xff) * (1 - blend) + ((c1 >> 16) & 0xff) * blend);
|
|
59
|
+
g = Math.round(((c0 >> 8) & 0xff) * (1 - blend) + ((c1 >> 8) & 0xff) * blend);
|
|
60
|
+
b = Math.round((c0 & 0xff) * (1 - blend) + (c1 & 0xff) * blend);
|
|
61
|
+
a = Math.round(alphas[j] * 255 * (1 - blend) + alphas[j + 1] * 255 * blend);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
out[i * 4] = r;
|
|
67
|
+
out[i * 4 + 1] = g;
|
|
68
|
+
out[i * 4 + 2] = b;
|
|
69
|
+
out[i * 4 + 3] = a;
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
// Builds a 256-entry RGBA gradient ramp texture on the GPU. The returned texture is cached and owned by
|
|
74
|
+
// the render state (see getWgpuEffectGradientRampTexture), so it is never destroyed mid-encoder.
|
|
75
|
+
function createWgpuEffectGradientRampTexture(state, colors, alphas, ratios) {
|
|
76
|
+
const data = buildRampData(colors, alphas, ratios);
|
|
77
|
+
const { device } = state;
|
|
78
|
+
const texture = device.createTexture({
|
|
79
|
+
size: [256, 1, 1],
|
|
80
|
+
format: 'rgba8unorm',
|
|
81
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST,
|
|
82
|
+
});
|
|
83
|
+
device.queue.writeTexture({ texture, origin: [0, 0, 0] }, data.buffer, { offset: 0, bytesPerRow: 256 * 4 }, [256, 1, 1]);
|
|
84
|
+
return texture;
|
|
85
|
+
}
|
|
86
|
+
// Per-render-state cache of ramp textures keyed by their stops. Textures live for the render state's
|
|
87
|
+
// lifetime; they are tiny (256×1) and the distinct-gradient set is bounded in practice.
|
|
88
|
+
const rampCaches = new WeakMap();
|
|
89
|
+
//# sourceMappingURL=wgpuEffectGradientRamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuEffectGradientRamp.js","sourceRoot":"","sources":["../src/wgpuEffectGradientRamp.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gCAAgC,CAC9C,KAAsB,EACtB,MAA6B,EAC7B,MAA6B,EAC7B,MAA6B;IAE7B,IAAI,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QAClB,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1E,IAAI,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,GAAG,mCAAmC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7E,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,C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MAAqB,EAC1B,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,EAAE,EACnC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CACZ,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,qGAAqG;AACrG,wFAAwF;AACxF,MAAM,UAAU,GAAG,IAAI,OAAO,EAA4C,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { WgpuRenderState, WgpuRenderTarget } from '@flighthq/types';
|
|
2
|
+
export declare const EFFECT_VERTEX_WGSL = "\nstruct VertexOut {\n @builtin(position) position : vec4f,\n @location(0) uv : vec2f,\n}\n\n@vertex\nfn vs_main(@builtin(vertex_index) vi : u32) -> VertexOut {\n let xi = vi == 1u || vi == 2u || vi == 4u;\n let yi = vi == 2u || vi == 4u || vi == 5u;\n var out : VertexOut;\n out.position = vec4f(select(-1.0, 1.0, xi), select(-1.0, 1.0, yi), 0.0, 1.0);\n out.uv = vec2f(select(0.0, 1.0, xi), select(1.0, 0.0, yi));\n return out;\n}\n";
|
|
3
|
+
export type WgpuEffectPipeline = {
|
|
4
|
+
pipeline: GPURenderPipeline;
|
|
5
|
+
blendMode: 'premul' | 'replace';
|
|
6
|
+
compileForFormat?: (format: GPUTextureFormat) => GPURenderPipeline;
|
|
7
|
+
variants?: Map<GPUTextureFormat, GPURenderPipeline>;
|
|
8
|
+
};
|
|
9
|
+
export type WgpuDualSourceEffectPipeline = WgpuEffectPipeline;
|
|
10
|
+
/** Clears a render target to fully transparent. Ends any active render pass. */
|
|
11
|
+
export declare function clearWgpuEffectTarget(state: WgpuRenderState, target: WgpuRenderTarget): void;
|
|
12
|
+
/** Compiles a dual-source WGSL effect pipeline (source0 = group 1, source1 = group 2). */
|
|
13
|
+
export declare function createWgpuDualSourceEffectPipeline(state: WgpuRenderState, fragmentWGSL: string, blend?: 'premul' | 'replace'): WgpuDualSourceEffectPipeline;
|
|
14
|
+
/** Compiles a WGSL effect pipeline, creating the combined vertex+fragment shader module. */
|
|
15
|
+
export declare function createWgpuEffectPipeline(state: WgpuRenderState, fragmentWGSL: string, blend?: 'premul' | 'replace'): WgpuEffectPipeline;
|
|
16
|
+
/**
|
|
17
|
+
* Draws a full-screen pass reading from two source textures.
|
|
18
|
+
* source0 binds to group 1, source1 to group 2.
|
|
19
|
+
*/
|
|
20
|
+
export declare function drawWgpuDualSourceEffectPass(state: WgpuRenderState, source0: WgpuRenderTarget, source1: WgpuRenderTarget, dest: WgpuRenderTarget | null, pipeline: WgpuDualSourceEffectPipeline, setUniforms: (f32: Float32Array, i32: Int32Array) => void): void;
|
|
21
|
+
/**
|
|
22
|
+
* Draws a full-screen effect pass: reads from source (group 1), writes to dest.
|
|
23
|
+
* `setUniforms` is called with Float32Array and Int32Array views into the current
|
|
24
|
+
* ring-buffer slot for per-pass uniform uploads. Blend is premultiplied-alpha compositing.
|
|
25
|
+
* Ends any active render pass; does not restore it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function drawWgpuEffectPass(state: WgpuRenderState, source: WgpuRenderTarget, dest: WgpuRenderTarget | null, pipeline: WgpuEffectPipeline, setUniforms: (f32: Float32Array, i32: Int32Array) => void): void;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the effect-pass state for the given render state, for use in shaders
|
|
30
|
+
* that need to bind a custom texture (e.g., a gradient ramp) as group 2 or 3.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getWgpuEffectPassState(state: WgpuRenderState): {
|
|
33
|
+
uniformBG: GPUBindGroup;
|
|
34
|
+
textureBGLayout: GPUBindGroupLayout;
|
|
35
|
+
uniformBGLayout: GPUBindGroupLayout;
|
|
36
|
+
sampler: GPUSampler;
|
|
37
|
+
acquireSlot: () => number;
|
|
38
|
+
writeSlot: (offset: number, fn: (f32: Float32Array, i32: Int32Array) => void) => void;
|
|
39
|
+
beginPass: (dest: WgpuRenderTarget | null, loadOp: GPULoadOp) => GPURenderPassEncoder;
|
|
40
|
+
};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AE,UAAU,KAAK,IAAI,GACxD,IAAI,CAiBN;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAC7B,QAAQ,EAAE,kBAAkB,EAC5B,WAAW,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,KAAK,IAAI,GACxD,IAAI,CAeN;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG;IAC9D,SAAS,EAAE,YAAY,CAAC;IACxB,eAAe,EAAE,kBAAkB,CAAC;IACpC,eAAe,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,KAAK,IAAI,KAAK,IAAI,CAAC;IACtF,SAAS,EAAE,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAAE,MAAM,EAAE,SAAS,KAAK,oBAAoB,CAAC;CACvF,CAWA"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu';
|
|
2
|
+
// Shared vertex shader: full-screen quad via vertex_index, no vertex buffer needed.
|
|
3
|
+
// UV convention: y=0 = texture top, y=1 = texture bottom (Wgpu top-left origin).
|
|
4
|
+
// NDC y=+1 (top) → uv.y=0, NDC y=-1 (bottom) → uv.y=1.
|
|
5
|
+
export const EFFECT_VERTEX_WGSL = /* wgsl */ `
|
|
6
|
+
struct VertexOut {
|
|
7
|
+
@builtin(position) position : vec4f,
|
|
8
|
+
@location(0) uv : vec2f,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@vertex
|
|
12
|
+
fn vs_main(@builtin(vertex_index) vi : u32) -> VertexOut {
|
|
13
|
+
let xi = vi == 1u || vi == 2u || vi == 4u;
|
|
14
|
+
let yi = vi == 2u || vi == 4u || vi == 5u;
|
|
15
|
+
var out : VertexOut;
|
|
16
|
+
out.position = vec4f(select(-1.0, 1.0, xi), select(-1.0, 1.0, yi), 0.0, 1.0);
|
|
17
|
+
out.uv = vec2f(select(0.0, 1.0, xi), select(1.0, 0.0, yi));
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
// Premultiplied-alpha compositing blend state, matching Gl's ONE + ONE_MINUS_SRC_ALPHA.
|
|
22
|
+
const PREMUL_BLEND = {
|
|
23
|
+
color: { srcFactor: 'one', dstFactor: 'one-minus-src-alpha', operation: 'add' },
|
|
24
|
+
alpha: { srcFactor: 'one', dstFactor: 'one-minus-src-alpha', operation: 'add' },
|
|
25
|
+
};
|
|
26
|
+
// Opaque / replace blend: writes the effect result directly without compositing.
|
|
27
|
+
const REPLACE_BLEND = {
|
|
28
|
+
color: { srcFactor: 'one', dstFactor: 'zero', operation: 'add' },
|
|
29
|
+
alpha: { srcFactor: 'one', dstFactor: 'zero', operation: 'add' },
|
|
30
|
+
};
|
|
31
|
+
const effectPassStates = new WeakMap();
|
|
32
|
+
function getOrCreateEffectPassState(state) {
|
|
33
|
+
let fs = effectPassStates.get(state);
|
|
34
|
+
if (fs !== undefined)
|
|
35
|
+
return fs;
|
|
36
|
+
const { device, format } = state;
|
|
37
|
+
// 512 slots × 256 bytes = 128 KB ring buffer for effect-pass uniforms.
|
|
38
|
+
// 256 bytes/slot is enough for the largest pass (convolution: ~244 bytes).
|
|
39
|
+
// Using separate slots per draw avoids writeBuffer ordering issues when
|
|
40
|
+
// multiple passes of the same type run within a single command encoder.
|
|
41
|
+
// Wrapping back to slot 0 within a frame is safe in practice: 512 pass
|
|
42
|
+
// draws per frame would require more than 512 active pass applications.
|
|
43
|
+
const SLOTS = 512;
|
|
44
|
+
const STRIDE = 256;
|
|
45
|
+
const uniformBuffer = device.createBuffer({
|
|
46
|
+
size: SLOTS * STRIDE,
|
|
47
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
48
|
+
});
|
|
49
|
+
const uniformData = new Float32Array((SLOTS * STRIDE) / 4);
|
|
50
|
+
const uniformDataI32 = new Int32Array(uniformData.buffer);
|
|
51
|
+
const uniformBGLayout = device.createBindGroupLayout({
|
|
52
|
+
entries: [
|
|
53
|
+
{
|
|
54
|
+
binding: 0,
|
|
55
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
56
|
+
// minBindingSize omitted (0): the bound range size (uniformStride) is validated at
|
|
57
|
+
// draw time instead of statically, so passes with structs larger than any fixed
|
|
58
|
+
// minimum (color matrix 80B, convolution 244B) share this one layout.
|
|
59
|
+
buffer: { type: 'uniform', hasDynamicOffset: true },
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
const uniformBG = device.createBindGroup({
|
|
64
|
+
layout: uniformBGLayout,
|
|
65
|
+
entries: [{ binding: 0, resource: { buffer: uniformBuffer, size: STRIDE } }],
|
|
66
|
+
});
|
|
67
|
+
const textureBGLayout = device.createBindGroupLayout({
|
|
68
|
+
entries: [
|
|
69
|
+
{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: {} },
|
|
70
|
+
{ binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} },
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
const sampler = device.createSampler({
|
|
74
|
+
minFilter: 'linear',
|
|
75
|
+
magFilter: 'linear',
|
|
76
|
+
addressModeU: 'clamp-to-edge',
|
|
77
|
+
addressModeV: 'clamp-to-edge',
|
|
78
|
+
});
|
|
79
|
+
fs = {
|
|
80
|
+
uniformBuffer,
|
|
81
|
+
uniformData,
|
|
82
|
+
uniformDataI32,
|
|
83
|
+
uniformOffset: 0,
|
|
84
|
+
uniformStride: STRIDE,
|
|
85
|
+
uniformSlots: SLOTS,
|
|
86
|
+
uniformBGLayout,
|
|
87
|
+
uniformBG,
|
|
88
|
+
textureBGLayout,
|
|
89
|
+
textureBGs: new WeakMap(),
|
|
90
|
+
sampler,
|
|
91
|
+
format,
|
|
92
|
+
};
|
|
93
|
+
effectPassStates.set(state, fs);
|
|
94
|
+
return fs;
|
|
95
|
+
}
|
|
96
|
+
function getOrCreateTextureBG(fs, device, view) {
|
|
97
|
+
let bg = fs.textureBGs.get(view);
|
|
98
|
+
if (bg === undefined) {
|
|
99
|
+
bg = device.createBindGroup({
|
|
100
|
+
layout: fs.textureBGLayout,
|
|
101
|
+
entries: [
|
|
102
|
+
{ binding: 0, resource: view },
|
|
103
|
+
{ binding: 1, resource: fs.sampler },
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
fs.textureBGs.set(view, bg);
|
|
107
|
+
}
|
|
108
|
+
return bg;
|
|
109
|
+
}
|
|
110
|
+
function acquireUniformSlot(fs) {
|
|
111
|
+
const offset = fs.uniformOffset;
|
|
112
|
+
fs.uniformOffset = (offset + fs.uniformStride) % (fs.uniformSlots * fs.uniformStride);
|
|
113
|
+
return offset;
|
|
114
|
+
}
|
|
115
|
+
function writeUniformSlot(state, fs, slotOffset, setUniforms) {
|
|
116
|
+
const f32Start = slotOffset / 4;
|
|
117
|
+
const slotF32 = fs.uniformData.subarray(f32Start, f32Start + fs.uniformStride / 4);
|
|
118
|
+
const slotI32 = fs.uniformDataI32.subarray(f32Start, f32Start + fs.uniformStride / 4);
|
|
119
|
+
setUniforms(slotF32, slotI32);
|
|
120
|
+
state.device.queue.writeBuffer(fs.uniformBuffer, slotOffset, fs.uniformData.buffer, slotOffset, fs.uniformStride);
|
|
121
|
+
}
|
|
122
|
+
function beginEffectPass(state, dest, loadOp) {
|
|
123
|
+
const runtime = getWgpuRenderStateRuntime(state);
|
|
124
|
+
if (runtime.commandEncoder === null)
|
|
125
|
+
throw new Error('No active command encoder — call renderWgpuBackground first');
|
|
126
|
+
if (runtime.renderPass !== null) {
|
|
127
|
+
runtime.renderPass.end();
|
|
128
|
+
runtime.renderPass = null;
|
|
129
|
+
}
|
|
130
|
+
const view = dest !== null ? dest.view : runtime.canvasTextureView;
|
|
131
|
+
const pass = runtime.commandEncoder.beginRenderPass({
|
|
132
|
+
colorAttachments: [{ view, loadOp, storeOp: 'store', clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
133
|
+
});
|
|
134
|
+
if (dest !== null) {
|
|
135
|
+
pass.setViewport(0, 0, dest.width, dest.height, 0, 1);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const w = runtime.renderTargetViewport?.width ?? state.canvas.width;
|
|
139
|
+
const h = runtime.renderTargetViewport?.height ?? state.canvas.height;
|
|
140
|
+
pass.setViewport(0, 0, w, h, 0, 1);
|
|
141
|
+
}
|
|
142
|
+
return pass;
|
|
143
|
+
}
|
|
144
|
+
// Returns the GPURenderPipeline whose color target format matches `dest` (the canvas format when dest is
|
|
145
|
+
// null). Compiles and caches a per-format variant on demand so a pipeline built for the canvas format can
|
|
146
|
+
// still draw into an HDR (rgba16float) effect target without an attachment-format mismatch.
|
|
147
|
+
function resolveEffectPipeline(state, pipeline, dest) {
|
|
148
|
+
const canvasFormat = getOrCreateEffectPassState(state).format;
|
|
149
|
+
const targetFormat = dest !== null ? dest.format : canvasFormat;
|
|
150
|
+
if (pipeline.compileForFormat === undefined || pipeline.variants === undefined || targetFormat === canvasFormat) {
|
|
151
|
+
return pipeline.pipeline;
|
|
152
|
+
}
|
|
153
|
+
let variant = pipeline.variants.get(targetFormat);
|
|
154
|
+
if (variant === undefined) {
|
|
155
|
+
variant = pipeline.compileForFormat(targetFormat);
|
|
156
|
+
pipeline.variants.set(targetFormat, variant);
|
|
157
|
+
}
|
|
158
|
+
return variant;
|
|
159
|
+
}
|
|
160
|
+
/** Clears a render target to fully transparent. Ends any active render pass. */
|
|
161
|
+
export function clearWgpuEffectTarget(state, target) {
|
|
162
|
+
const pass = beginEffectPass(state, target, 'clear');
|
|
163
|
+
pass.end();
|
|
164
|
+
}
|
|
165
|
+
/** Compiles a dual-source WGSL effect pipeline (source0 = group 1, source1 = group 2). */
|
|
166
|
+
export function createWgpuDualSourceEffectPipeline(state, fragmentWGSL, blend = 'premul') {
|
|
167
|
+
const fs = getOrCreateEffectPassState(state);
|
|
168
|
+
const { device } = state;
|
|
169
|
+
const shaderModule = device.createShaderModule({ code: EFFECT_VERTEX_WGSL + fragmentWGSL });
|
|
170
|
+
const pipelineLayout = device.createPipelineLayout({
|
|
171
|
+
bindGroupLayouts: [fs.uniformBGLayout, fs.textureBGLayout, fs.textureBGLayout],
|
|
172
|
+
});
|
|
173
|
+
const compileForFormat = (format) => device.createRenderPipeline({
|
|
174
|
+
layout: pipelineLayout,
|
|
175
|
+
vertex: { module: shaderModule, entryPoint: 'vs_main' },
|
|
176
|
+
fragment: {
|
|
177
|
+
module: shaderModule,
|
|
178
|
+
entryPoint: 'fs_main',
|
|
179
|
+
targets: [{ format, blend: blend === 'premul' ? PREMUL_BLEND : REPLACE_BLEND }],
|
|
180
|
+
},
|
|
181
|
+
primitive: { topology: 'triangle-list' },
|
|
182
|
+
});
|
|
183
|
+
return { pipeline: compileForFormat(fs.format), blendMode: blend, compileForFormat, variants: new Map() };
|
|
184
|
+
}
|
|
185
|
+
/** Compiles a WGSL effect pipeline, creating the combined vertex+fragment shader module. */
|
|
186
|
+
export function createWgpuEffectPipeline(state, fragmentWGSL, blend = 'premul') {
|
|
187
|
+
const fs = getOrCreateEffectPassState(state);
|
|
188
|
+
const { device } = state;
|
|
189
|
+
const shaderModule = device.createShaderModule({ code: EFFECT_VERTEX_WGSL + fragmentWGSL });
|
|
190
|
+
const pipelineLayout = device.createPipelineLayout({
|
|
191
|
+
bindGroupLayouts: [fs.uniformBGLayout, fs.textureBGLayout],
|
|
192
|
+
});
|
|
193
|
+
const compileForFormat = (format) => device.createRenderPipeline({
|
|
194
|
+
layout: pipelineLayout,
|
|
195
|
+
vertex: { module: shaderModule, entryPoint: 'vs_main' },
|
|
196
|
+
fragment: {
|
|
197
|
+
module: shaderModule,
|
|
198
|
+
entryPoint: 'fs_main',
|
|
199
|
+
targets: [{ format, blend: blend === 'premul' ? PREMUL_BLEND : REPLACE_BLEND }],
|
|
200
|
+
},
|
|
201
|
+
primitive: { topology: 'triangle-list' },
|
|
202
|
+
});
|
|
203
|
+
return { pipeline: compileForFormat(fs.format), blendMode: blend, compileForFormat, variants: new Map() };
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Draws a full-screen pass reading from two source textures.
|
|
207
|
+
* source0 binds to group 1, source1 to group 2.
|
|
208
|
+
*/
|
|
209
|
+
export function drawWgpuDualSourceEffectPass(state, source0, source1, dest, pipeline, setUniforms) {
|
|
210
|
+
const fs = getOrCreateEffectPassState(state);
|
|
211
|
+
const { device } = state;
|
|
212
|
+
const slotOffset = acquireUniformSlot(fs);
|
|
213
|
+
writeUniformSlot(state, fs, slotOffset, setUniforms);
|
|
214
|
+
const source0BG = getOrCreateTextureBG(fs, device, source0.view);
|
|
215
|
+
const source1BG = getOrCreateTextureBG(fs, device, source1.view);
|
|
216
|
+
const pass = beginEffectPass(state, dest, 'load');
|
|
217
|
+
pass.setPipeline(resolveEffectPipeline(state, pipeline, dest));
|
|
218
|
+
pass.setBindGroup(0, fs.uniformBG, [slotOffset]);
|
|
219
|
+
pass.setBindGroup(1, source0BG);
|
|
220
|
+
pass.setBindGroup(2, source1BG);
|
|
221
|
+
pass.draw(6);
|
|
222
|
+
pass.end();
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Draws a full-screen effect pass: reads from source (group 1), writes to dest.
|
|
226
|
+
* `setUniforms` is called with Float32Array and Int32Array views into the current
|
|
227
|
+
* ring-buffer slot for per-pass uniform uploads. Blend is premultiplied-alpha compositing.
|
|
228
|
+
* Ends any active render pass; does not restore it.
|
|
229
|
+
*/
|
|
230
|
+
export function drawWgpuEffectPass(state, source, dest, pipeline, setUniforms) {
|
|
231
|
+
const fs = getOrCreateEffectPassState(state);
|
|
232
|
+
const { device } = state;
|
|
233
|
+
const slotOffset = acquireUniformSlot(fs);
|
|
234
|
+
writeUniformSlot(state, fs, slotOffset, setUniforms);
|
|
235
|
+
const sourceBG = getOrCreateTextureBG(fs, device, source.view);
|
|
236
|
+
const pass = beginEffectPass(state, dest, 'load');
|
|
237
|
+
pass.setPipeline(resolveEffectPipeline(state, pipeline, dest));
|
|
238
|
+
pass.setBindGroup(0, fs.uniformBG, [slotOffset]);
|
|
239
|
+
pass.setBindGroup(1, sourceBG);
|
|
240
|
+
pass.draw(6);
|
|
241
|
+
pass.end();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Returns the effect-pass state for the given render state, for use in shaders
|
|
245
|
+
* that need to bind a custom texture (e.g., a gradient ramp) as group 2 or 3.
|
|
246
|
+
*/
|
|
247
|
+
export function getWgpuEffectPassState(state) {
|
|
248
|
+
const fs = getOrCreateEffectPassState(state);
|
|
249
|
+
return {
|
|
250
|
+
uniformBG: fs.uniformBG,
|
|
251
|
+
textureBGLayout: fs.textureBGLayout,
|
|
252
|
+
uniformBGLayout: fs.uniformBGLayout,
|
|
253
|
+
sampler: fs.sampler,
|
|
254
|
+
acquireSlot: () => acquireUniformSlot(fs),
|
|
255
|
+
writeSlot: (offset, fn) => writeUniformSlot(state, fs, offset, fn),
|
|
256
|
+
beginPass: (dest, loadOp) => beginEffectPass(state, dest, loadOp),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=wgpuEffectPass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgpuEffectPass.js","sourceRoot":"","sources":["../src/wgpuEffectPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,oFAAoF;AACpF,iFAAiF;AACjF,uDAAuD;AACvD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;;;;;;;;;;;;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from './wgpuEffectPass';
|
|
3
|
+
export declare function getWgpuEffectPipeline(state: WgpuRenderState, key: string, fragmentWGSL: string, blend?: 'premul' | 'replace'): WgpuEffectPipeline;
|
|
4
4
|
//# sourceMappingURL=wgpuEffectProgramCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuEffectProgramCache.d.ts","sourceRoot":"","sources":["../src/wgpuEffectProgramCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wgpuEffectProgramCache.d.ts","sourceRoot":"","sources":["../src/wgpuEffectProgramCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAc3D,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,KAAK,GAAE,QAAQ,GAAG,SAAqB,GACtC,kBAAkB,CAWpB"}
|