@flare-engine/postfx 0.4.11 → 0.4.13
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.mts +14 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +293 -291
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +293 -291
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -34,7 +34,15 @@ interface PostFxRuntime {
|
|
|
34
34
|
compile(kind: EffectKind): CompiledShader | null;
|
|
35
35
|
/** Pack an effect's uniforms into a Float32Array in the order the shader declares. */
|
|
36
36
|
packUniforms(effect: Effect, width: number, height: number): Float32Array;
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Build a list of compiled pass descriptors in chain order for enabled effects.
|
|
39
|
+
*
|
|
40
|
+
* The returned array, its pass objects and their `uniforms` buffers belong to
|
|
41
|
+
* the runtime and are rewritten by the next `buildPass` call on it, whichever
|
|
42
|
+
* chain that call is given; copy what must outlive the call. A `uniforms`
|
|
43
|
+
* buffer is replaced only when its slot needs a different length, and a
|
|
44
|
+
* `children` array is replaced, never written into, when its contents change.
|
|
45
|
+
*/
|
|
38
46
|
buildPass(chain: EffectChain, width: number, height: number): CompiledPass[];
|
|
39
47
|
/** Drop all cached compiled shaders. */
|
|
40
48
|
reset(): void;
|
|
@@ -284,11 +292,11 @@ export declare const CHROMATIC_ABERRATION_SKSL = "\nuniform shader src;\nuniform
|
|
|
284
292
|
export declare const CRT_SKSL = "\nuniform shader src;\nuniform float2 resolution;\nuniform float scanlineIntensity;\nuniform float curvature;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / resolution;\n float2 centered = uv - 0.5;\n float2 warp = centered * (1.0 + dot(centered, centered) * curvature);\n float2 warpedUv = warp + 0.5;\n if (warpedUv.x < 0.0 || warpedUv.x > 1.0 || warpedUv.y < 0.0 || warpedUv.y > 1.0) {\n return half4(0.0, 0.0, 0.0, 1.0);\n }\n half4 c = src.eval(warpedUv * resolution);\n float scan = 0.5 + 0.5 * sin(warpedUv.y * resolution.y * 3.14159);\n float dim = mix(1.0, scan, scanlineIntensity);\n return half4(c.rgb * dim, c.a);\n}\n";
|
|
285
293
|
export declare const BLOOM_SKSL = "\nuniform shader src;\nuniform float2 resolution;\nuniform float threshold;\nuniform float intensity;\n\nhalf4 main(float2 coord) {\n half4 c = src.eval(coord);\n float luma = dot(c.rgb, half3(0.299, 0.587, 0.114));\n float mask = smoothstep(threshold, 1.0, luma);\n half3 boost = c.rgb * mask * intensity;\n return half4(c.rgb + boost, c.a);\n}\n";
|
|
286
294
|
export declare const COLOR_GRADING_LUT_SKSL = "\nuniform shader src;\nuniform shader lut;\nuniform float intensity;\n\nhalf4 main(float2 coord) {\n half4 scene = src.eval(coord);\n\n float r = float(scene.r) * 63.0;\n float g = float(scene.g) * 63.0;\n float b = float(scene.b) * 63.0;\n\n float bFloor = floor(b);\n float bCeil = min(bFloor + 1.0, 63.0);\n float bFrac = b - bFloor;\n\n float2 uvFloor = float2((bFloor * 64.0 + r + 0.5) / 4096.0,\n (g + 0.5) / 64.0);\n float2 uvCeil = float2((bCeil * 64.0 + r + 0.5) / 4096.0,\n (g + 0.5) / 64.0);\n\n half3 lutFloor = lut.eval(uvFloor * float2(4096.0, 64.0)).rgb;\n half3 lutCeil = lut.eval(uvCeil * float2(4096.0, 64.0)).rgb;\n\n half3 graded = mix(lutFloor, lutCeil, half(bFrac));\n half3 result = mix(scene.rgb, graded, half(intensity));\n\n return half4(result, scene.a);\n}\n";
|
|
287
|
-
export declare const WEATHER_RAIN_SKSL
|
|
288
|
-
export declare const WEATHER_SUN_SHAFT_SKSL
|
|
289
|
-
export declare const WEATHER_DARK_VIGNETTE_SKSL
|
|
290
|
-
export declare const WEATHER_CLOUDS_SKSL
|
|
291
|
-
export declare const COMPOSITE_SKSL
|
|
295
|
+
export declare const WEATHER_RAIN_SKSL: string;
|
|
296
|
+
export declare const WEATHER_SUN_SHAFT_SKSL: string;
|
|
297
|
+
export declare const WEATHER_DARK_VIGNETTE_SKSL: string;
|
|
298
|
+
export declare const WEATHER_CLOUDS_SKSL: string;
|
|
299
|
+
export declare const COMPOSITE_SKSL: string;
|
|
292
300
|
export declare const GOD_RAYS_SKSL = "\nuniform shader src;\nuniform float2 resolution;\nuniform float2 u_lightPos;\nuniform float3 u_color;\nuniform float u_intensity;\nuniform float u_decay;\nuniform float u_density;\nuniform float u_weight;\nuniform float u_samples;\n\nconst int MAX_SAMPLES = 64;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / resolution;\n float2 delta = (u_lightPos - uv) * u_density / float(MAX_SAMPLES);\n float2 sampleUv = uv;\n float illuminationDecay = 1.0;\n half3 accumulated = half3(0.0);\n\n for (int i = 0; i < MAX_SAMPLES; i++) {\n if (float(i) >= u_samples) break;\n sampleUv += delta;\n half3 s = src.eval(sampleUv * resolution).rgb;\n accumulated += s * half(illuminationDecay) * half(u_weight);\n illuminationDecay *= u_decay;\n }\n\n half4 orig = src.eval(coord);\n half3 rays = accumulated * half3(u_color) * half(u_weight) * half(u_intensity);\n return half4(orig.rgb + rays, orig.a);\n}\n";
|
|
293
301
|
export type { BloomUniforms, ChromaticAberrationUniforms, ColorGradingLutUniforms, CompiledPass, CompiledShader, CompositeUniforms, CrtUniforms, Effect, EffectKind, EffectUniforms, GodRaysUniforms, GrayscaleFlashUniforms, PostFxController, PostFxControllerOptions, PostFxFlashConfig, PostFxRuntime, SkImageLike, SkiaPostFxModuleLike, SkiaRuntimeEffectFactory, SkiaRuntimeEffectLike, VignetteUniforms, WeatherCloudsUniforms, WeatherDarkVignetteUniforms, WeatherRainUniforms, WeatherSunShaftUniforms };
|
|
294
302
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/runtime.ts","../src/effect.ts","../src/chain.ts","../src/controller.ts","../src/lut.ts","../src/shaders.ts"],"mappings":";;;;;;;;;;;UA6BiB;WACN;;UAMM;EACf,uBAAuB,UAAU,yBAAyB;;EAE1D;;UAGe;EACf,KAAK,eAAe;;UAGL;EACf,eAAe;;UAGA;EACf,MAAM;EACN,QAAQ;;UAGO;;WAEN;;EAET,QAAQ,MAAM,aAAa;;EAE3B,aAAa,QAAQ,QAAQ,eAAe,iBAAiB
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/runtime.ts","../src/effect.ts","../src/chain.ts","../src/controller.ts","../src/lut.ts","../src/shaders.ts"],"mappings":";;;;;;;;;;;UA6BiB;WACN;;UAMM;EACf,uBAAuB,UAAU,yBAAyB;;EAE1D;;UAGe;EACf,KAAK,eAAe;;UAGL;EACf,eAAe;;UAGA;EACf,MAAM;EACN,QAAQ;;UAGO;;WAEN;;EAET,QAAQ,MAAM,aAAa;;EAE3B,aAAa,QAAQ,QAAQ,eAAe,iBAAiB;;;;;;;;;;EAU7D,UAAU,OAAO,aAAa,eAAe,iBAAiB;;EAE9D;;UAGe;EACf;EACA,MAAM;EACN,QAAQ;EACR,UAAU;;;;;;;;;;;;;EAaV,mBAAmB;;;;;;;wBAuBL,oBACd,MAAM,6BACN;EAAS;IACR;KC7GS;UAcK;EACf;EACA;EACA;;UAGe;EACf;;UAGe;EACf;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,KAAK;EACL;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACL;IAAqB;EACrB;IAA4B;EAC5B;IAAiC;EACjC;IAAgB;EAChB;IAAkB;E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CA;qBAoGA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,15 @@ interface PostFxRuntime {
|
|
|
34
34
|
compile(kind: EffectKind): CompiledShader | null;
|
|
35
35
|
/** Pack an effect's uniforms into a Float32Array in the order the shader declares. */
|
|
36
36
|
packUniforms(effect: Effect, width: number, height: number): Float32Array;
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Build a list of compiled pass descriptors in chain order for enabled effects.
|
|
39
|
+
*
|
|
40
|
+
* The returned array, its pass objects and their `uniforms` buffers belong to
|
|
41
|
+
* the runtime and are rewritten by the next `buildPass` call on it, whichever
|
|
42
|
+
* chain that call is given; copy what must outlive the call. A `uniforms`
|
|
43
|
+
* buffer is replaced only when its slot needs a different length, and a
|
|
44
|
+
* `children` array is replaced, never written into, when its contents change.
|
|
45
|
+
*/
|
|
38
46
|
buildPass(chain: EffectChain, width: number, height: number): CompiledPass[];
|
|
39
47
|
/** Drop all cached compiled shaders. */
|
|
40
48
|
reset(): void;
|
|
@@ -284,11 +292,11 @@ export declare const CHROMATIC_ABERRATION_SKSL = "\nuniform shader src;\nuniform
|
|
|
284
292
|
export declare const CRT_SKSL = "\nuniform shader src;\nuniform float2 resolution;\nuniform float scanlineIntensity;\nuniform float curvature;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / resolution;\n float2 centered = uv - 0.5;\n float2 warp = centered * (1.0 + dot(centered, centered) * curvature);\n float2 warpedUv = warp + 0.5;\n if (warpedUv.x < 0.0 || warpedUv.x > 1.0 || warpedUv.y < 0.0 || warpedUv.y > 1.0) {\n return half4(0.0, 0.0, 0.0, 1.0);\n }\n half4 c = src.eval(warpedUv * resolution);\n float scan = 0.5 + 0.5 * sin(warpedUv.y * resolution.y * 3.14159);\n float dim = mix(1.0, scan, scanlineIntensity);\n return half4(c.rgb * dim, c.a);\n}\n";
|
|
285
293
|
export declare const BLOOM_SKSL = "\nuniform shader src;\nuniform float2 resolution;\nuniform float threshold;\nuniform float intensity;\n\nhalf4 main(float2 coord) {\n half4 c = src.eval(coord);\n float luma = dot(c.rgb, half3(0.299, 0.587, 0.114));\n float mask = smoothstep(threshold, 1.0, luma);\n half3 boost = c.rgb * mask * intensity;\n return half4(c.rgb + boost, c.a);\n}\n";
|
|
286
294
|
export declare const COLOR_GRADING_LUT_SKSL = "\nuniform shader src;\nuniform shader lut;\nuniform float intensity;\n\nhalf4 main(float2 coord) {\n half4 scene = src.eval(coord);\n\n float r = float(scene.r) * 63.0;\n float g = float(scene.g) * 63.0;\n float b = float(scene.b) * 63.0;\n\n float bFloor = floor(b);\n float bCeil = min(bFloor + 1.0, 63.0);\n float bFrac = b - bFloor;\n\n float2 uvFloor = float2((bFloor * 64.0 + r + 0.5) / 4096.0,\n (g + 0.5) / 64.0);\n float2 uvCeil = float2((bCeil * 64.0 + r + 0.5) / 4096.0,\n (g + 0.5) / 64.0);\n\n half3 lutFloor = lut.eval(uvFloor * float2(4096.0, 64.0)).rgb;\n half3 lutCeil = lut.eval(uvCeil * float2(4096.0, 64.0)).rgb;\n\n half3 graded = mix(lutFloor, lutCeil, half(bFrac));\n half3 result = mix(scene.rgb, graded, half(intensity));\n\n return half4(result, scene.a);\n}\n";
|
|
287
|
-
export declare const WEATHER_RAIN_SKSL
|
|
288
|
-
export declare const WEATHER_SUN_SHAFT_SKSL
|
|
289
|
-
export declare const WEATHER_DARK_VIGNETTE_SKSL
|
|
290
|
-
export declare const WEATHER_CLOUDS_SKSL
|
|
291
|
-
export declare const COMPOSITE_SKSL
|
|
295
|
+
export declare const WEATHER_RAIN_SKSL: string;
|
|
296
|
+
export declare const WEATHER_SUN_SHAFT_SKSL: string;
|
|
297
|
+
export declare const WEATHER_DARK_VIGNETTE_SKSL: string;
|
|
298
|
+
export declare const WEATHER_CLOUDS_SKSL: string;
|
|
299
|
+
export declare const COMPOSITE_SKSL: string;
|
|
292
300
|
export declare const GOD_RAYS_SKSL = "\nuniform shader src;\nuniform float2 resolution;\nuniform float2 u_lightPos;\nuniform float3 u_color;\nuniform float u_intensity;\nuniform float u_decay;\nuniform float u_density;\nuniform float u_weight;\nuniform float u_samples;\n\nconst int MAX_SAMPLES = 64;\n\nhalf4 main(float2 coord) {\n float2 uv = coord / resolution;\n float2 delta = (u_lightPos - uv) * u_density / float(MAX_SAMPLES);\n float2 sampleUv = uv;\n float illuminationDecay = 1.0;\n half3 accumulated = half3(0.0);\n\n for (int i = 0; i < MAX_SAMPLES; i++) {\n if (float(i) >= u_samples) break;\n sampleUv += delta;\n half3 s = src.eval(sampleUv * resolution).rgb;\n accumulated += s * half(illuminationDecay) * half(u_weight);\n illuminationDecay *= u_decay;\n }\n\n half4 orig = src.eval(coord);\n half3 rays = accumulated * half3(u_color) * half(u_weight) * half(u_intensity);\n return half4(orig.rgb + rays, orig.a);\n}\n";
|
|
293
301
|
export type { BloomUniforms, ChromaticAberrationUniforms, ColorGradingLutUniforms, CompiledPass, CompiledShader, CompositeUniforms, CrtUniforms, Effect, EffectKind, EffectUniforms, GodRaysUniforms, GrayscaleFlashUniforms, PostFxController, PostFxControllerOptions, PostFxFlashConfig, PostFxRuntime, SkImageLike, SkiaPostFxModuleLike, SkiaRuntimeEffectFactory, SkiaRuntimeEffectLike, VignetteUniforms, WeatherCloudsUniforms, WeatherDarkVignetteUniforms, WeatherRainUniforms, WeatherSunShaftUniforms };
|
|
294
302
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/runtime.ts","../src/effect.ts","../src/chain.ts","../src/controller.ts","../src/lut.ts","../src/shaders.ts"],"mappings":";;;;;;;;;;;UA6BiB;WACN;;UAMM;EACf,uBAAuB,UAAU,yBAAyB;;EAE1D;;UAGe;EACf,KAAK,eAAe;;UAGL;EACf,eAAe;;UAGA;EACf,MAAM;EACN,QAAQ;;UAGO;;WAEN;;EAET,QAAQ,MAAM,aAAa;;EAE3B,aAAa,QAAQ,QAAQ,eAAe,iBAAiB
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/runtime.ts","../src/effect.ts","../src/chain.ts","../src/controller.ts","../src/lut.ts","../src/shaders.ts"],"mappings":";;;;;;;;;;;UA6BiB;WACN;;UAMM;EACf,uBAAuB,UAAU,yBAAyB;;EAE1D;;UAGe;EACf,KAAK,eAAe;;UAGL;EACf,eAAe;;UAGA;EACf,MAAM;EACN,QAAQ;;UAGO;;WAEN;;EAET,QAAQ,MAAM,aAAa;;EAE3B,aAAa,QAAQ,QAAQ,eAAe,iBAAiB;;;;;;;;;;EAU7D,UAAU,OAAO,aAAa,eAAe,iBAAiB;;EAE9D;;UAGe;EACf;EACA,MAAM;EACN,QAAQ;EACR,UAAU;;;;;;;;;;;;;EAaV,mBAAmB;;;;;;;wBAuBL,oBACd,MAAM,6BACN;EAAS;IACR;KC7GS;UAcK;EACf;EACA;EACA;;UAGe;EACf;;UAGe;EACf;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,KAAK;EACL;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACL;IAAqB;EACrB;IAA4B;EAC5B;IAAiC;EACjC;IAAgB;EAChB;IAAkB;EAClB;IAAqB;EACrB;IAA8B;EAC9B;IAAyB;EACzB;IAA8B;EAC9B;IAAkC;EAClC;IAA2B;EAC3B;IAAsB;UAEZ;EACf;EACA;EACA,UAAU;;wBAGI,eAAe,aAAiB,WAAU,QAAQ,oBAAyB;wBAa3E,qBACd,aACA,WAAU,QAAQ,0BACjB;wBAQa,0BACd,aACA,WAAU,QAAQ,+BACjB;wBAQa,UAAU,aAAY,WAAU,QAAQ,eAAoB;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