shaders 2.3.73 → 2.3.75
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/core/{AngularBlur-BBVuS72B.js → AngularBlur-BgZWbEjj.js} +1 -1
- package/dist/core/{Ascii-C57qusEP.js → Ascii-BwSMmD6Z.js} +1 -1
- package/dist/core/{Aurora-LKsAmrmY.js → Aurora-BPHeGEZ_.js} +2 -2
- package/dist/core/{Beam-BkYNheGX.js → Beam-CAnoOWgt.js} +1 -1
- package/dist/core/{Blob-CWfHiQeb.js → Blob-56vuq_qL.js} +2 -2
- package/dist/core/{Blur-BguzqgHU.js → Blur-DTyNQt1R.js} +1 -1
- package/dist/core/{Bulge-B8jPaomW.js → Bulge-DN2R75Hp.js} +1 -1
- package/dist/core/{CRTScreen-C5v58BPh.js → CRTScreen-BUsz0O_H.js} +1 -1
- package/dist/core/{ChannelBlur-BAq9PV6G.js → ChannelBlur-CCaPXjka.js} +1 -1
- package/dist/core/{Checkerboard-BtVQVtsL.js → Checkerboard-_IUtUrDv.js} +1 -1
- package/dist/core/{ChromaticAberration-Ck4Zd3W1.js → ChromaticAberration-G8_bwQtD.js} +1 -1
- package/dist/core/{Circle-DdVVbdgQ.js → Circle-CMeFMTtC.js} +1 -1
- package/dist/core/{ConcentricSpin-BQTBqzyV.js → ConcentricSpin-BzxzMieZ.js} +2 -2
- package/dist/core/{CursorRipples-CI8y0So9.js → CursorRipples-DHWY-hfP.js} +1 -1
- package/dist/core/{CursorTrail-BBTqzAWC.js → CursorTrail-BuULQ8qV.js} +1 -1
- package/dist/core/{DiffuseBlur-Qz6vgZgZ.js → DiffuseBlur-BiC31OND.js} +1 -1
- package/dist/core/{Dither-Csho-L_O.js → Dither-D6A9bH8T.js} +1 -1
- package/dist/core/{Duotone-haec3FrU.js → Duotone-sWs1rKEF.js} +2 -2
- package/dist/core/{FloatingParticles-D6fgcEbH.js → FloatingParticles-DFVXk0yT.js} +1 -1
- package/dist/core/{FlowField-C2KW9_D1.js → FlowField-CgGVA2lm.js} +2 -2
- package/dist/core/{GlassTiles-4nBI82dT.js → GlassTiles-Db7rr0eG.js} +1 -1
- package/dist/core/{Glitch-DoFQeNTD.js → Glitch-bQ7EdNTc.js} +1 -1
- package/dist/core/{Glow-CURvWSnB.js → Glow-DcYaI9pS.js} +1 -1
- package/dist/core/{Godrays-BWEMe4dJ.js → Godrays-kZhTEIHA.js} +1 -1
- package/dist/core/{GridDistortion-BjfEpWUs.js → GridDistortion-Bo3YMHwn.js} +1 -1
- package/dist/core/{Kaleidoscope-Wq5CGMiP.js → Kaleidoscope-ADmVP39h.js} +1 -1
- package/dist/core/{LensFlare-BvU6_Rjd.js → LensFlare-BChYlgBL.js} +1 -1
- package/dist/core/{LinearBlur-WcJbCWwj.js → LinearBlur-Bkjns5jv.js} +1 -1
- package/dist/core/{LinearGradient-CCTJoXKq.js → LinearGradient-CBtyQ7pS.js} +1 -1
- package/dist/core/{Liquify-Ad7waFTE.js → Liquify-DhAt-Zjw.js} +1 -1
- package/dist/core/{Mirror-QfQBv7v_.js → Mirror-P5PQHRqq.js} +1 -1
- package/dist/core/{Perspective-CZiW61kj.js → Perspective-P0odWfct.js} +1 -1
- package/dist/core/{Pixelate-DCUPU8V-.js → Pixelate-jzWGa_BV.js} +1 -1
- package/dist/core/{Plasma-CEs9bH1D.js → Plasma-D5SzUyO1.js} +2 -2
- package/dist/core/{PolarCoordinates-ituaMXaH.js → PolarCoordinates-CjJBXXYn.js} +1 -1
- package/dist/core/{ProgressiveBlur-DEfvy5dW.js → ProgressiveBlur-Bn6TW_Nm.js} +1 -1
- package/dist/core/{RadialGradient-Di_VuDot.js → RadialGradient-DPIwryzD.js} +1 -1
- package/dist/core/{RectangularCoordinates-xmILlyac.js → RectangularCoordinates-_wuy_3lH.js} +1 -1
- package/dist/core/{Ripples-rV1yHHuE.js → Ripples-DEhu4BiP.js} +2 -2
- package/dist/core/{Sharpness-DeD2T2-a.js → Sharpness-C3xiyyR2.js} +1 -1
- package/dist/core/{Shatter-DpPRGA0l.js → Shatter-DKKKjn-j.js} +1 -1
- package/dist/core/{SimplexNoise-C648ofLb.js → SimplexNoise-BrTbyAF8.js} +2 -2
- package/dist/core/{SineWave-t5aPlKh4.js → SineWave-C_J_VMwO.js} +1 -1
- package/dist/core/{Spherize-CkHw6wfO.js → Spherize-QQs5j4pJ.js} +1 -1
- package/dist/core/{Spiral-C4xcFRWd.js → Spiral-eZqdB4az.js} +2 -2
- package/dist/core/{Strands-FVw1VjAV.js → Strands-Dix27a_B.js} +1 -1
- package/dist/core/{Stretch-BmPCPWY8.js → Stretch-Bz3LETyz.js} +1 -1
- package/dist/core/{Stripes-D-fIDK48.js → Stripes-ClDdoKOx.js} +2 -2
- package/dist/core/{StudioBackground-BqIq7k14.js → StudioBackground-CmFJwN8P.js} +1 -1
- package/dist/core/{Swirl-C137NvM7.js → Swirl-Bx8HwjR-.js} +2 -2
- package/dist/core/{TiltShift-vr8k-bAX.js → TiltShift-YwQVnxTS.js} +1 -1
- package/dist/core/{Tritone-NDERRh_N.js → Tritone-BouzdhuC.js} +2 -2
- package/dist/core/{Twirl-BFocvCoq.js → Twirl-IM8zffEY.js} +1 -1
- package/dist/core/{WaveDistortion-HrmY6hF5.js → WaveDistortion-CO_2EMbJ.js} +2 -2
- package/dist/core/{ZoomBlur-DSCQQerF.js → ZoomBlur-DEy-f1iL.js} +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +217 -10
- package/dist/core/presetRenderer.d.ts +75 -0
- package/dist/core/presetRenderer.d.ts.map +1 -0
- package/dist/core/registry.js +78 -188
- package/dist/core/renderer.d.ts +10 -2
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/shaderRegistry-C2JWSXay.js +186 -0
- package/dist/core/shaders/AngularBlur/index.js +2 -2
- package/dist/core/shaders/Ascii/index.js +2 -2
- package/dist/core/shaders/Aurora/index.js +3 -3
- package/dist/core/shaders/Beam/index.js +2 -2
- package/dist/core/shaders/Blob/index.js +3 -3
- package/dist/core/shaders/Blur/index.js +2 -2
- package/dist/core/shaders/Bulge/index.js +2 -2
- package/dist/core/shaders/CRTScreen/index.js +2 -2
- package/dist/core/shaders/ChannelBlur/index.js +2 -2
- package/dist/core/shaders/Checkerboard/index.js +2 -2
- package/dist/core/shaders/ChromaticAberration/index.js +2 -2
- package/dist/core/shaders/Circle/index.js +2 -2
- package/dist/core/shaders/ConcentricSpin/index.js +3 -3
- package/dist/core/shaders/CursorRipples/index.js +2 -2
- package/dist/core/shaders/CursorTrail/index.js +2 -2
- package/dist/core/shaders/DiffuseBlur/index.js +2 -2
- package/dist/core/shaders/Dither/index.js +2 -2
- package/dist/core/shaders/Duotone/index.js +3 -3
- package/dist/core/shaders/FloatingParticles/index.js +2 -2
- package/dist/core/shaders/FlowField/index.js +3 -3
- package/dist/core/shaders/GlassTiles/index.js +2 -2
- package/dist/core/shaders/Glitch/index.js +2 -2
- package/dist/core/shaders/Glow/index.js +2 -2
- package/dist/core/shaders/Godrays/index.js +2 -2
- package/dist/core/shaders/GridDistortion/index.js +2 -2
- package/dist/core/shaders/Kaleidoscope/index.js +2 -2
- package/dist/core/shaders/LensFlare/index.js +2 -2
- package/dist/core/shaders/LinearBlur/index.js +2 -2
- package/dist/core/shaders/LinearGradient/index.js +2 -2
- package/dist/core/shaders/Liquify/index.js +2 -2
- package/dist/core/shaders/Mirror/index.js +2 -2
- package/dist/core/shaders/Perspective/index.js +2 -2
- package/dist/core/shaders/Pixelate/index.js +2 -2
- package/dist/core/shaders/Plasma/index.js +3 -3
- package/dist/core/shaders/PolarCoordinates/index.js +2 -2
- package/dist/core/shaders/ProgressiveBlur/index.js +2 -2
- package/dist/core/shaders/RadialGradient/index.js +2 -2
- package/dist/core/shaders/RectangularCoordinates/index.js +2 -2
- package/dist/core/shaders/Ripples/index.js +3 -3
- package/dist/core/shaders/Sharpness/index.js +2 -2
- package/dist/core/shaders/Shatter/index.js +2 -2
- package/dist/core/shaders/SimplexNoise/index.js +3 -3
- package/dist/core/shaders/SineWave/index.js +2 -2
- package/dist/core/shaders/Spherize/index.js +2 -2
- package/dist/core/shaders/Spiral/index.js +3 -3
- package/dist/core/shaders/Strands/index.js +2 -2
- package/dist/core/shaders/Stretch/index.js +2 -2
- package/dist/core/shaders/Stripes/index.js +3 -3
- package/dist/core/shaders/StudioBackground/index.js +2 -2
- package/dist/core/shaders/Swirl/index.js +3 -3
- package/dist/core/shaders/TiltShift/index.js +2 -2
- package/dist/core/shaders/Tritone/index.js +3 -3
- package/dist/core/shaders/Twirl/index.js +2 -2
- package/dist/core/shaders/WaveDistortion/index.js +3 -3
- package/dist/core/shaders/ZoomBlur/index.js +2 -2
- package/dist/pixi/createShaderSprite.d.ts +54 -0
- package/dist/pixi/createShaderSprite.d.ts.map +1 -0
- package/dist/pixi/index.d.ts +20 -0
- package/dist/pixi/index.d.ts.map +1 -0
- package/dist/pixi/index.js +153 -0
- package/package.json +15 -3
- /package/dist/core/{alpha-Byel9eTg.js → alpha-C4ptedXe.js} +0 -0
- /package/dist/core/{colorMixing-jSm3tbMv.js → colorMixing-BPpDnR5I.js} +0 -0
- /package/dist/core/{time-BZqyVJXt.js → time-DUqSFWvT.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../time-
|
|
3
|
-
import { n as componentDefinition, t as SineWave_default } from "../../SineWave-
|
|
2
|
+
import "../../time-DUqSFWvT.js";
|
|
3
|
+
import { n as componentDefinition, t as SineWave_default } from "../../SineWave-C_J_VMwO.js";
|
|
4
4
|
export { componentDefinition, SineWave_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../alpha-
|
|
3
|
-
import { n as componentDefinition, t as Spherize_default } from "../../Spherize-
|
|
2
|
+
import "../../alpha-C4ptedXe.js";
|
|
3
|
+
import { n as componentDefinition, t as Spherize_default } from "../../Spherize-QQs5j4pJ.js";
|
|
4
4
|
export { componentDefinition, Spherize_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import "../../
|
|
4
|
-
import { n as componentDefinition, t as Spiral_default } from "../../Spiral-
|
|
2
|
+
import "../../colorMixing-BPpDnR5I.js";
|
|
3
|
+
import "../../time-DUqSFWvT.js";
|
|
4
|
+
import { n as componentDefinition, t as Spiral_default } from "../../Spiral-eZqdB4az.js";
|
|
5
5
|
export { componentDefinition, Spiral_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../time-
|
|
3
|
-
import { n as componentDefinition, t as Strands_default } from "../../Strands-
|
|
2
|
+
import "../../time-DUqSFWvT.js";
|
|
3
|
+
import { n as componentDefinition, t as Strands_default } from "../../Strands-Dix27a_B.js";
|
|
4
4
|
export { componentDefinition, Strands_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../edges-CfGcQniB.js";
|
|
2
2
|
import "../../transformations-B5lM6fYX.js";
|
|
3
|
-
import "../../alpha-
|
|
4
|
-
import { n as componentDefinition, t as Stretch_default } from "../../Stretch-
|
|
3
|
+
import "../../alpha-C4ptedXe.js";
|
|
4
|
+
import { n as componentDefinition, t as Stretch_default } from "../../Stretch-Bz3LETyz.js";
|
|
5
5
|
export { componentDefinition, Stretch_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import "../../
|
|
4
|
-
import { n as componentDefinition, t as Stripes_default } from "../../Stripes-
|
|
2
|
+
import "../../colorMixing-BPpDnR5I.js";
|
|
3
|
+
import "../../time-DUqSFWvT.js";
|
|
4
|
+
import { n as componentDefinition, t as Stripes_default } from "../../Stripes-ClDdoKOx.js";
|
|
5
5
|
export { componentDefinition, Stripes_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../time-
|
|
3
|
-
import { n as componentDefinition, t as StudioBackground_default } from "../../StudioBackground-
|
|
2
|
+
import "../../time-DUqSFWvT.js";
|
|
3
|
+
import { n as componentDefinition, t as StudioBackground_default } from "../../StudioBackground-CmFJwN8P.js";
|
|
4
4
|
export { componentDefinition, StudioBackground_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../
|
|
3
|
-
import "../../
|
|
4
|
-
import { n as componentDefinition, t as Swirl_default } from "../../Swirl-
|
|
2
|
+
import "../../colorMixing-BPpDnR5I.js";
|
|
3
|
+
import "../../time-DUqSFWvT.js";
|
|
4
|
+
import { n as componentDefinition, t as Swirl_default } from "../../Swirl-Bx8HwjR-.js";
|
|
5
5
|
export { componentDefinition, Swirl_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../alpha-
|
|
3
|
-
import { n as componentDefinition, t as TiltShift_default } from "../../TiltShift-
|
|
2
|
+
import "../../alpha-C4ptedXe.js";
|
|
3
|
+
import { n as componentDefinition, t as TiltShift_default } from "../../TiltShift-YwQVnxTS.js";
|
|
4
4
|
export { componentDefinition, TiltShift_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../alpha-
|
|
3
|
-
import "../../colorMixing-
|
|
4
|
-
import { n as componentDefinition, t as Tritone_default } from "../../Tritone-
|
|
2
|
+
import "../../alpha-C4ptedXe.js";
|
|
3
|
+
import "../../colorMixing-BPpDnR5I.js";
|
|
4
|
+
import { n as componentDefinition, t as Tritone_default } from "../../Tritone-BouzdhuC.js";
|
|
5
5
|
export { componentDefinition, Tritone_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../edges-CfGcQniB.js";
|
|
2
2
|
import "../../transformations-B5lM6fYX.js";
|
|
3
|
-
import "../../alpha-
|
|
4
|
-
import { n as componentDefinition, t as Twirl_default } from "../../Twirl-
|
|
3
|
+
import "../../alpha-C4ptedXe.js";
|
|
4
|
+
import { n as componentDefinition, t as Twirl_default } from "../../Twirl-IM8zffEY.js";
|
|
5
5
|
export { componentDefinition, Twirl_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../edges-CfGcQniB.js";
|
|
2
2
|
import "../../transformations-B5lM6fYX.js";
|
|
3
|
-
import "../../
|
|
4
|
-
import "../../
|
|
5
|
-
import { n as componentDefinition, t as WaveDistortion_default } from "../../WaveDistortion-
|
|
3
|
+
import "../../alpha-C4ptedXe.js";
|
|
4
|
+
import "../../time-DUqSFWvT.js";
|
|
5
|
+
import { n as componentDefinition, t as WaveDistortion_default } from "../../WaveDistortion-CO_2EMbJ.js";
|
|
6
6
|
export { componentDefinition, WaveDistortion_default as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "../../transformations-B5lM6fYX.js";
|
|
2
|
-
import "../../alpha-
|
|
3
|
-
import { n as componentDefinition, t as ZoomBlur_default } from "../../ZoomBlur-
|
|
2
|
+
import "../../alpha-C4ptedXe.js";
|
|
3
|
+
import { n as componentDefinition, t as ZoomBlur_default } from "../../ZoomBlur-DEy-f1iL.js";
|
|
4
4
|
export { componentDefinition, ZoomBlur_default as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PresetConfig } from '../core';
|
|
2
|
+
import { Sprite, Application } from 'pixi.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a shader sprite
|
|
5
|
+
*/
|
|
6
|
+
export interface ShaderSpriteOptions {
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A shader instance that renders to a PixiJS sprite
|
|
12
|
+
*/
|
|
13
|
+
export interface ShaderSprite {
|
|
14
|
+
sprite: Sprite;
|
|
15
|
+
update: () => Promise<void>;
|
|
16
|
+
updatePreset: (preset: PresetConfig) => void;
|
|
17
|
+
resize: (width: number, height: number) => void;
|
|
18
|
+
dispose: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a PixiJS sprite that renders a Shaders preset.
|
|
22
|
+
*
|
|
23
|
+
* This approach:
|
|
24
|
+
* 1. Creates a hidden canvas for Three.js/Shaders rendering
|
|
25
|
+
* 2. Shares the WebGPU device from PixiJS
|
|
26
|
+
* 3. Renders shaders to the canvas
|
|
27
|
+
* 4. Wraps the canvas as a PixiJS texture/sprite
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createShaderSprite } from 'shaders-pixi'
|
|
32
|
+
*
|
|
33
|
+
* const preset = {
|
|
34
|
+
* components: [
|
|
35
|
+
* { type: 'LinearGradient', props: { colorA: '#ff0000', colorB: '#0000ff' } }
|
|
36
|
+
* ]
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* const shaderSprite = await createShaderSprite(preset, pixiApp, {
|
|
40
|
+
* width: 512,
|
|
41
|
+
* height: 512
|
|
42
|
+
* })
|
|
43
|
+
*
|
|
44
|
+
* // Position in scene
|
|
45
|
+
* shaderSprite.sprite.x = 100
|
|
46
|
+
* shaderSprite.sprite.y = 100
|
|
47
|
+
* pixiApp.stage.addChild(shaderSprite.sprite)
|
|
48
|
+
*
|
|
49
|
+
* // In render loop (before PixiJS render)
|
|
50
|
+
* await shaderSprite.update()
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function createShaderSprite(preset: PresetConfig, pixiApp: Application, options?: ShaderSpriteOptions): Promise<ShaderSprite>;
|
|
54
|
+
//# sourceMappingURL=createShaderSprite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createShaderSprite.d.ts","sourceRoot":"","sources":["../src/createShaderSprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AACxE,OAAO,EAAyB,MAAM,EAAgB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAA;AAEvF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;IAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,YAAY,CAAC,CAiNvB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shaders PixiJS Integration
|
|
3
|
+
*
|
|
4
|
+
* Render WebGPU shaders as native PixiJS sprites.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { createShaderSprite } from 'shaders-pixi'
|
|
9
|
+
*
|
|
10
|
+
* const shader = await createShaderSprite(preset, pixiApp, { width: 512, height: 512 })
|
|
11
|
+
* pixiApp.stage.addChild(shader.sprite)
|
|
12
|
+
*
|
|
13
|
+
* pixiApp.ticker.add(async () => {
|
|
14
|
+
* await shader.update()
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { createShaderSprite, type ShaderSprite, type ShaderSpriteOptions } from './createShaderSprite';
|
|
19
|
+
export type { PresetConfig, ComponentConfig } from '../core';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACzB,MAAM,sBAAsB,CAAA;AAG7B,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { createRendererFromJSON } from "../core/index.js";
|
|
2
|
+
import { RendererType, CanvasSource, Texture, Sprite } from "pixi.js";
|
|
3
|
+
async function createShaderSprite(preset, pixiApp, options = {}) {
|
|
4
|
+
const width = options.width || 512;
|
|
5
|
+
const height = options.height || 512;
|
|
6
|
+
const dpr = window.devicePixelRatio || 1;
|
|
7
|
+
if (pixiApp.renderer.type !== RendererType.WEBGPU) {
|
|
8
|
+
throw new Error('Shaders requires PixiJS to be initialized with WebGPU (preference: "webgpu")');
|
|
9
|
+
}
|
|
10
|
+
const pixiGpu = pixiApp.renderer.gpu;
|
|
11
|
+
const device = pixiGpu.device;
|
|
12
|
+
const adapter = pixiGpu.adapter;
|
|
13
|
+
if (!device || !adapter) {
|
|
14
|
+
throw new Error("Shaders could not access the WebGPU device from the PixiJS renderer");
|
|
15
|
+
}
|
|
16
|
+
const wrapper = document.createElement("div");
|
|
17
|
+
wrapper.style.position = "absolute";
|
|
18
|
+
wrapper.style.left = "-9999px";
|
|
19
|
+
wrapper.style.top = "-9999px";
|
|
20
|
+
wrapper.style.width = `${width}px`;
|
|
21
|
+
wrapper.style.height = `${height}px`;
|
|
22
|
+
wrapper.style.overflow = "hidden";
|
|
23
|
+
wrapper.style.pointerEvents = "none";
|
|
24
|
+
document.body.appendChild(wrapper);
|
|
25
|
+
const canvas = document.createElement("canvas");
|
|
26
|
+
canvas.width = width * dpr;
|
|
27
|
+
canvas.height = height * dpr;
|
|
28
|
+
canvas.style.width = `${width}px`;
|
|
29
|
+
canvas.style.height = `${height}px`;
|
|
30
|
+
wrapper.appendChild(canvas);
|
|
31
|
+
const gpuContext = canvas.getContext("webgpu");
|
|
32
|
+
if (!gpuContext) {
|
|
33
|
+
throw new Error("Could not get WebGPU context from canvas");
|
|
34
|
+
}
|
|
35
|
+
gpuContext.configure({
|
|
36
|
+
device,
|
|
37
|
+
format: navigator.gpu.getPreferredCanvasFormat(),
|
|
38
|
+
alphaMode: "premultiplied",
|
|
39
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC | GPUTextureUsage.TEXTURE_BINDING
|
|
40
|
+
});
|
|
41
|
+
const shadersRenderer = createRendererFromJSON(preset, {
|
|
42
|
+
gpu: { device, adapter },
|
|
43
|
+
forceFullFrameRate: true
|
|
44
|
+
});
|
|
45
|
+
await shadersRenderer.initialize(canvas);
|
|
46
|
+
let canvasSource = new CanvasSource({
|
|
47
|
+
resource: canvas,
|
|
48
|
+
resolution: dpr,
|
|
49
|
+
antialias: false,
|
|
50
|
+
autoDensity: false
|
|
51
|
+
});
|
|
52
|
+
let texture = new Texture({
|
|
53
|
+
source: canvasSource
|
|
54
|
+
});
|
|
55
|
+
const sprite = new Sprite(texture);
|
|
56
|
+
sprite.width = width;
|
|
57
|
+
sprite.height = height;
|
|
58
|
+
let currentWidth = width;
|
|
59
|
+
let currentHeight = height;
|
|
60
|
+
let pendingCanvasSource = null;
|
|
61
|
+
let pendingTexture = null;
|
|
62
|
+
let resizeSeq = 0;
|
|
63
|
+
return {
|
|
64
|
+
sprite,
|
|
65
|
+
/**
|
|
66
|
+
* Update shader rendering and sync to PixiJS
|
|
67
|
+
* Call this in your render loop BEFORE rendering PixiJS
|
|
68
|
+
*/
|
|
69
|
+
update: async () => {
|
|
70
|
+
await shadersRenderer.renderFrame();
|
|
71
|
+
if (!pendingCanvasSource) {
|
|
72
|
+
canvasSource.update();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Update the shader preset dynamically
|
|
77
|
+
*/
|
|
78
|
+
updatePreset: (newPreset) => {
|
|
79
|
+
shadersRenderer.updatePreset(newPreset);
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Resize the shader to new dimensions
|
|
83
|
+
* This updates the offscreen canvas, triggering the renderer's resize logic.
|
|
84
|
+
* The texture swap is deferred until after Three.js's resize RAF fires, so the
|
|
85
|
+
* sprite continues to show the last good frame instead of flashing blank.
|
|
86
|
+
*/
|
|
87
|
+
resize: (newWidth, newHeight) => {
|
|
88
|
+
if (newWidth === currentWidth && newHeight === currentHeight) return;
|
|
89
|
+
currentWidth = newWidth;
|
|
90
|
+
currentHeight = newHeight;
|
|
91
|
+
if (pendingCanvasSource) {
|
|
92
|
+
pendingCanvasSource.destroy();
|
|
93
|
+
pendingTexture.destroy();
|
|
94
|
+
pendingCanvasSource = null;
|
|
95
|
+
pendingTexture = null;
|
|
96
|
+
}
|
|
97
|
+
const seq = ++resizeSeq;
|
|
98
|
+
wrapper.style.width = `${newWidth}px`;
|
|
99
|
+
wrapper.style.height = `${newHeight}px`;
|
|
100
|
+
canvas.width = newWidth * dpr;
|
|
101
|
+
canvas.height = newHeight * dpr;
|
|
102
|
+
canvas.style.width = `${newWidth}px`;
|
|
103
|
+
canvas.style.height = `${newHeight}px`;
|
|
104
|
+
gpuContext.configure({
|
|
105
|
+
device,
|
|
106
|
+
format: navigator.gpu.getPreferredCanvasFormat(),
|
|
107
|
+
alphaMode: "premultiplied",
|
|
108
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC | GPUTextureUsage.TEXTURE_BINDING
|
|
109
|
+
});
|
|
110
|
+
pendingCanvasSource = new CanvasSource({
|
|
111
|
+
resource: canvas,
|
|
112
|
+
resolution: dpr,
|
|
113
|
+
antialias: false,
|
|
114
|
+
autoDensity: false
|
|
115
|
+
});
|
|
116
|
+
pendingTexture = new Texture({ source: pendingCanvasSource });
|
|
117
|
+
requestAnimationFrame(() => {
|
|
118
|
+
requestAnimationFrame(() => {
|
|
119
|
+
if (seq !== resizeSeq) return;
|
|
120
|
+
if (pendingCanvasSource && pendingTexture) {
|
|
121
|
+
pendingCanvasSource.update();
|
|
122
|
+
const oldTexture = texture;
|
|
123
|
+
const oldCanvasSource = canvasSource;
|
|
124
|
+
canvasSource = pendingCanvasSource;
|
|
125
|
+
texture = pendingTexture;
|
|
126
|
+
sprite.texture = texture;
|
|
127
|
+
pendingCanvasSource = null;
|
|
128
|
+
pendingTexture = null;
|
|
129
|
+
oldTexture.destroy();
|
|
130
|
+
oldCanvasSource.destroy();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* Clean up resources
|
|
137
|
+
*/
|
|
138
|
+
dispose: () => {
|
|
139
|
+
if (pendingCanvasSource) {
|
|
140
|
+
pendingCanvasSource.destroy();
|
|
141
|
+
pendingTexture == null ? void 0 : pendingTexture.destroy();
|
|
142
|
+
pendingCanvasSource = null;
|
|
143
|
+
pendingTexture = null;
|
|
144
|
+
}
|
|
145
|
+
shadersRenderer.dispose();
|
|
146
|
+
texture.destroy(true);
|
|
147
|
+
wrapper.remove();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
createShaderSprite
|
|
153
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaders",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.75",
|
|
4
4
|
"description": "Shader magic for modern frontends",
|
|
5
5
|
"author": "Shader Effects Inc.",
|
|
6
6
|
"homepage": "https://shaders.com/",
|
|
@@ -51,6 +51,10 @@
|
|
|
51
51
|
"types": "./dist/solid/codegen.d.ts",
|
|
52
52
|
"import": "./dist/solid/codegen.js"
|
|
53
53
|
},
|
|
54
|
+
"./pixi": {
|
|
55
|
+
"types": "./dist/pixi/index.d.ts",
|
|
56
|
+
"import": "./dist/pixi/index.js"
|
|
57
|
+
},
|
|
54
58
|
"./core": {
|
|
55
59
|
"types": "./dist/core/index.d.ts",
|
|
56
60
|
"import": "./dist/core/index.js",
|
|
@@ -458,6 +462,9 @@
|
|
|
458
462
|
"solid/codegen": [
|
|
459
463
|
"./dist/solid/codegen.d.ts"
|
|
460
464
|
],
|
|
465
|
+
"pixi": [
|
|
466
|
+
"./dist/pixi/index.d.ts"
|
|
467
|
+
],
|
|
461
468
|
"core": [
|
|
462
469
|
"./dist/core/index.d.ts"
|
|
463
470
|
],
|
|
@@ -710,7 +717,8 @@
|
|
|
710
717
|
"react": "^18.0.0 || ^19.0.0",
|
|
711
718
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
712
719
|
"svelte": "^5",
|
|
713
|
-
"solid-js": "^1.8.0"
|
|
720
|
+
"solid-js": "^1.8.0",
|
|
721
|
+
"pixi.js": "^8.0.0"
|
|
714
722
|
},
|
|
715
723
|
"peerDependenciesMeta": {
|
|
716
724
|
"vue": {
|
|
@@ -727,6 +735,9 @@
|
|
|
727
735
|
},
|
|
728
736
|
"solid-js": {
|
|
729
737
|
"optional": true
|
|
738
|
+
},
|
|
739
|
+
"pixi.js": {
|
|
740
|
+
"optional": true
|
|
730
741
|
}
|
|
731
742
|
},
|
|
732
743
|
"dependencies": {
|
|
@@ -742,7 +753,8 @@
|
|
|
742
753
|
"shaders-vue": "workspace:*",
|
|
743
754
|
"shaders-react": "workspace:*",
|
|
744
755
|
"shaders-svelte": "workspace:*",
|
|
745
|
-
"shaders-solid": "workspace:*"
|
|
756
|
+
"shaders-solid": "workspace:*",
|
|
757
|
+
"shaders-pixi": "workspace:*"
|
|
746
758
|
},
|
|
747
759
|
"keywords": [
|
|
748
760
|
"vue",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|