@flare-engine/postfx 0.4.10 → 0.4.12
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 +5 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +135 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -161
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -284,11 +284,11 @@ export declare const CHROMATIC_ABERRATION_SKSL = "\nuniform shader src;\nuniform
|
|
|
284
284
|
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
285
|
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
286
|
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
|
|
287
|
+
export declare const WEATHER_RAIN_SKSL: string;
|
|
288
|
+
export declare const WEATHER_SUN_SHAFT_SKSL: string;
|
|
289
|
+
export declare const WEATHER_DARK_VIGNETTE_SKSL: string;
|
|
290
|
+
export declare const WEATHER_CLOUDS_SKSL: string;
|
|
291
|
+
export declare const COMPOSITE_SKSL: string;
|
|
292
292
|
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
293
|
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
294
|
//# 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;;EAE7D,UAAU,OAAO,aAAa,eAAe,iBAAiB;;EAE9D;;UAGe;EACf;EACA,MAAM;EACN,QAAQ;EACR,UAAU;;;;;;;;;;;;;EAaV,mBAAmB;;;;;;;wBAuBL,oBACd,MAAM,6BACN;EAAS;IACR;KCrGS;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;wBAY5D,YAAY,aAAc,WAAU,QAAQ,iBAAsB;wBAYlE,cAAc,aAAiB,WAAU,QAAQ,mBAAwB;wBAkBzE,sBACd,YACA;EAAY,KAAK;EAAa;IAC7B;wBAYa,kBACd,aACA,WAAU,QAAQ,uBACjB;wBAgBa,sBACd,aACA,WAAU,QAAQ,2BACjB;wBAYa,0BACd,aACA,WAAU,QAAQ,+BACjB;wBAWa,oBACd,aACA,WAAU,QAAQ,yBACjB;wBAaa,sBACd,aACA,WAAU,QAAQ,qBACjB;;;;;qBC1RU;UACH;UACA;MAEJ;;;;;;;;;;;;;;;;;;MAqBA;MAIA,gBAAgB;;EAKpB,mBAAmB;;EAKnB,gBAAgB;;EAKhB,IAAI,QAAQ;;EAQZ,OAAO,eAAe,QAAQ;EAQ9B,OAAO;EAOP,IAAI,aAAa;
|
|
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;;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gBa,sBACd,aACA,WAAU,QAAQ,2BACjB;wBAYa,0BACd,aACA,WAAU,QAAQ,+BACjB;wBAWa,oBACd,aACA,WAAU,QAAQ,yBACjB;wBAaa,sBACd,aACA,WAAU,QAAQ,qBACjB;;;;;qBC1RU;UACH;UACA;MAEJ;;;;;;;;;;;;;;;;;;MAqBA;MAIA,gBAAgB;;EAKpB,mBAAmB;;EAKnB,gBAAgB;;EAKhB,IAAI,QAAQ;;EAQZ,OAAO,eAAe,QAAQ;EAQ9B,OAAO;EAOP,IAAI,aAAa;EASjB,WAAW,YAAY;;EAMvB,YAAY,YAAY,UAAU;EAWlC,KAAK,YAAY;EASjB;;EAKC,WAAW,iBAAiB;;UCjGd;;WAEN;;WAEA;;UAGM;;WAEN,kBAAkB;;WAElB,OAAO;;WAEP,QAAQ;;UAGF;WACN,OAAO;WACP,SAAS;;EAElB;;;;;;;EAOA,aAAa,kBAAkB;;EAE/B,OAAO;;EAEP,UAAU,eAAe,0BAA0B;;;;;EAKnD,eAAe;;wBAKD,uBAAuB,SAAS,0BAA0B;wBCvD1D,yBAAyB;;;;;;;;;;;qBCS5B;qBAiBA;qBAaA;qBAgBA;qBAqBA;qBAiBA;qBAsLA;qBAyBA;qBAcA;qBAYA;qBA8CA;qBAoGA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -284,11 +284,11 @@ export declare const CHROMATIC_ABERRATION_SKSL = "\nuniform shader src;\nuniform
|
|
|
284
284
|
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
285
|
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
286
|
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
|
|
287
|
+
export declare const WEATHER_RAIN_SKSL: string;
|
|
288
|
+
export declare const WEATHER_SUN_SHAFT_SKSL: string;
|
|
289
|
+
export declare const WEATHER_DARK_VIGNETTE_SKSL: string;
|
|
290
|
+
export declare const WEATHER_CLOUDS_SKSL: string;
|
|
291
|
+
export declare const COMPOSITE_SKSL: string;
|
|
292
292
|
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
293
|
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
294
|
//# 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;W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;wBAgBa,sBACd,aACA,WAAU,QAAQ,2BACjB;wBAYa,0BACd,aACA,WAAU,QAAQ,+BACjB;wBAWa,oBACd,aACA,WAAU,QAAQ,yBACjB;wBAaa,sBACd,aACA,WAAU,QAAQ,qBACjB;;;;;qBC1RU;UACH;UACA;MAEJ;;;;;;;;;;;;;;;;;;MAqBA;MAIA,gBAAgB;;EAKpB,mBAAmB;;EAKnB,gBAAgB;;EAKhB,IAAI,QAAQ;;EAQZ,OAAO,eAAe,QAAQ;EAQ9B,OAAO;EAOP,IAAI,aAAa;
|
|
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;;EAE7D,UAAU,OAAO,aAAa,eAAe,iBAAiB;;EAE9D;;UAGe;EACf;EACA,MAAM;EACN,QAAQ;EACR,UAAU;;;;;;;;;;;;;EAaV,mBAAmB;;;;;;;wBAuBL,oBACd,MAAM,6BACN;EAAS;IACR;KCrGS;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;I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AsLA;qBAyBA;qBAcA;qBAYA;qBA8CA;qBAoGA"}
|
package/dist/index.js
CHANGED
|
@@ -59,7 +59,12 @@ var EffectChain = class {
|
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
61
|
get(id) {
|
|
62
|
-
|
|
62
|
+
const effects = this._effects;
|
|
63
|
+
for (let i = 0; i < effects.length; i++) {
|
|
64
|
+
const e = effects[i];
|
|
65
|
+
if (e !== void 0 && e.id === id) return e;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
63
68
|
}
|
|
64
69
|
setEnabled(id, enabled) {
|
|
65
70
|
const e = this.get(id);
|
|
@@ -206,26 +211,18 @@ half4 main(float2 coord) {
|
|
|
206
211
|
return half4(result, scene.a);
|
|
207
212
|
}
|
|
208
213
|
`;
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
float hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }
|
|
223
|
-
|
|
224
|
-
half4 main(float2 coord) {
|
|
225
|
-
half4 scene = src.eval(coord);
|
|
226
|
-
float2 uv = coord / resolution;
|
|
227
|
-
float aspect = resolution.x / resolution.y;
|
|
228
|
-
float rad = direction * 3.14159 / 180.0;
|
|
214
|
+
const HASH_FN_SKSL = "float hash(float2 p) { return fract(sin(dot(p, float2(127.1, 311.7))) * 43758.5453); }";
|
|
215
|
+
const CLOUD_NOISE_FNS_SKSL = `float vnoise(float2 p) {
|
|
216
|
+
float2 i = floor(p); float2 f = fract(p);
|
|
217
|
+
float2 u = f * f * (3.0 - 2.0 * f);
|
|
218
|
+
return mix(mix(hash(i), hash(i + float2(1.0, 0.0)), u.x),
|
|
219
|
+
mix(hash(i + float2(0.0, 1.0)), hash(i + float2(1.0, 1.0)), u.x), u.y);
|
|
220
|
+
}
|
|
221
|
+
float fbm(float2 p) { return vnoise(p) * 0.6 + vnoise(p * 2.3) * 0.4; }`;
|
|
222
|
+
/** Indents a 2-space fragment to the depth of a composite weather branch. */
|
|
223
|
+
const nest = (fragment) => fragment.replace(/^(?=.)/gm, " ");
|
|
224
|
+
const rainBody = (n) => ` float aspect = resolution.x / resolution.y;
|
|
225
|
+
float rad = ${n.direction} * 3.14159 / 180.0;
|
|
229
226
|
float sinA = sin(rad);
|
|
230
227
|
float cosA = cos(rad);
|
|
231
228
|
// aspect-corrected rotated axes: fallAxis along drop travel, perpAxis across
|
|
@@ -241,12 +238,12 @@ half4 main(float2 coord) {
|
|
|
241
238
|
float brightness = 1.0;
|
|
242
239
|
float cid = floor(perpAxis * COLS);
|
|
243
240
|
float colHash = hash(float2(cid, 0.0));
|
|
244
|
-
if (colHash < density) {
|
|
241
|
+
if (colHash < ${n.density}) {
|
|
245
242
|
float phase = hash(float2(cid, 1.0));
|
|
246
243
|
float colBright = brightness * (0.6 + hash(float2(cid, 2.0)) * 0.4);
|
|
247
244
|
float center = 0.5 + (hash(float2(cid, 3.0)) - 0.5) * 0.4;
|
|
248
|
-
float seg = fract(fallAxis * tiling -
|
|
249
|
-
float coverageY = smoothstep(streakLen, 0.0, seg);
|
|
245
|
+
float seg = fract(fallAxis * tiling - ${n.scrollY} + phase);
|
|
246
|
+
float coverageY = smoothstep(${n.streakLen}, 0.0, seg);
|
|
250
247
|
float width = 0.04;
|
|
251
248
|
float xMask = smoothstep(width, 0.0, abs(fract(perpAxis * COLS) - center));
|
|
252
249
|
coverage = max(coverage, coverageY * xMask * colBright);
|
|
@@ -260,19 +257,87 @@ half4 main(float2 coord) {
|
|
|
260
257
|
float brightness = 0.5;
|
|
261
258
|
float cid = floor(perpAxis * COLS);
|
|
262
259
|
float colHash = hash(float2(cid, 10.0));
|
|
263
|
-
if (colHash < density) {
|
|
260
|
+
if (colHash < ${n.density}) {
|
|
264
261
|
float phase = hash(float2(cid, 11.0));
|
|
265
262
|
float colBright = brightness * (0.6 + hash(float2(cid, 12.0)) * 0.4);
|
|
266
263
|
float center = 0.5 + (hash(float2(cid, 13.0)) - 0.5) * 0.4;
|
|
267
|
-
float seg = fract(fallAxis * tiling -
|
|
268
|
-
float coverageY = smoothstep(streakLen, 0.0, seg);
|
|
264
|
+
float seg = fract(fallAxis * tiling - ${n.scrollY} + phase);
|
|
265
|
+
float coverageY = smoothstep(${n.streakLen}, 0.0, seg);
|
|
269
266
|
float width = 0.03;
|
|
270
267
|
float xMask = smoothstep(width, 0.0, abs(fract(perpAxis * COLS) - center));
|
|
271
268
|
coverage = max(coverage, coverageY * xMask * colBright);
|
|
272
269
|
}
|
|
273
|
-
}
|
|
270
|
+
}`;
|
|
271
|
+
const rainBlend = (rgb, color, intensity) => `mix(${rgb}, half3(${color}), half(coverage * ${intensity}))`;
|
|
272
|
+
const sunShaftBody = (direction, intensity) => ` float rad = ${direction} * 3.14159 / 180.0;
|
|
273
|
+
float2 src_point = float2(0.5 + sin(rad) * 0.3, -0.05);
|
|
274
|
+
float2 toFrag = uv - src_point;
|
|
275
|
+
float angle = atan(toFrag.x, toFrag.y);
|
|
276
|
+
float shafts = 0.5 + 0.5 * sin(angle * 8.0);
|
|
277
|
+
float dist = length(toFrag);
|
|
278
|
+
float falloff = 1.0 - smoothstep(0.0, 1.2, dist);
|
|
279
|
+
half shaft = half(shafts * falloff * ${intensity} * 0.35);`;
|
|
280
|
+
const sunShaftBlend = (rgb) => `${rgb} + half3(shaft * 0.95, shaft * 0.9, shaft * 0.6)`;
|
|
281
|
+
const darkVignetteBody = (centered, uvExpr, intensity) => ` float2 ${centered} = ${uvExpr} - 0.5;
|
|
282
|
+
float d = length(${centered});
|
|
283
|
+
float v = smoothstep(0.3, 0.85, d);
|
|
284
|
+
half dark = half(v * ${intensity});`;
|
|
285
|
+
const darkVignetteBlend = (rgb) => `${rgb} * (1.0 - dark)`;
|
|
286
|
+
const cloudsBody = (n) => ` // ${n.direction}=0 → pure horizontal scroll (cos=1, sin=0), matching the pre-${n.direction} default.
|
|
287
|
+
float rad = ${n.direction} * 3.14159 / 180.0;
|
|
288
|
+
float2 scrollDir = float2(cos(rad), sin(rad));
|
|
289
|
+
float2 cloudUv = float2(
|
|
290
|
+
uv.x + ${n.scrollX} * scrollDir.x / resolution.x,
|
|
291
|
+
uv.y * 0.5 + ${n.scrollX} * scrollDir.y / resolution.y
|
|
292
|
+
);
|
|
293
|
+
float cloud = fbm(cloudUv * 3.0);
|
|
294
|
+
float heightFade = smoothstep(0.6, 0.2, uv.y);
|
|
295
|
+
float alpha = cloud * heightFade * ${n.intensity} * 0.5;
|
|
296
|
+
half3 cloudColor = half3(0.9, 0.9, 0.95);`;
|
|
297
|
+
const cloudsBlend = (rgb) => `mix(${rgb}, cloudColor, half(alpha))`;
|
|
298
|
+
const RAIN_STANDALONE = {
|
|
299
|
+
direction: "direction",
|
|
300
|
+
scrollY: "scrollOffsetY",
|
|
301
|
+
density: "density",
|
|
302
|
+
streakLen: "streakLen"
|
|
303
|
+
};
|
|
304
|
+
const RAIN_COMPOSITE = {
|
|
305
|
+
direction: "weatherDirection",
|
|
306
|
+
scrollY: "weatherScrollY",
|
|
307
|
+
density: "weatherDensity",
|
|
308
|
+
streakLen: "weatherStreakLen"
|
|
309
|
+
};
|
|
310
|
+
const CLOUDS_STANDALONE = {
|
|
311
|
+
direction: "direction",
|
|
312
|
+
scrollX: "scrollOffsetX",
|
|
313
|
+
intensity: "intensity"
|
|
314
|
+
};
|
|
315
|
+
const CLOUDS_COMPOSITE = {
|
|
316
|
+
direction: "weatherDirection",
|
|
317
|
+
scrollX: "weatherScrollX",
|
|
318
|
+
intensity: "weatherIntensity"
|
|
319
|
+
};
|
|
320
|
+
const WEATHER_RAIN_SKSL = `
|
|
321
|
+
uniform shader src;
|
|
322
|
+
uniform float2 resolution;
|
|
323
|
+
uniform float intensity;
|
|
324
|
+
uniform float direction;
|
|
325
|
+
uniform float scrollOffsetY;
|
|
326
|
+
uniform float3 color;
|
|
327
|
+
uniform float density;
|
|
328
|
+
uniform float streakLen;
|
|
329
|
+
|
|
330
|
+
// scrollOffsetY is a normalized fall phase in [0,1). Increase it each tick
|
|
331
|
+
// by (speed * dt / screenHeight) and wrap with fract() on the game side.
|
|
332
|
+
|
|
333
|
+
${HASH_FN_SKSL}
|
|
334
|
+
|
|
335
|
+
half4 main(float2 coord) {
|
|
336
|
+
half4 scene = src.eval(coord);
|
|
337
|
+
float2 uv = coord / resolution;
|
|
338
|
+
${rainBody(RAIN_STANDALONE)}
|
|
274
339
|
|
|
275
|
-
half3 mixed =
|
|
340
|
+
half3 mixed = ${rainBlend("scene.rgb", "color", "intensity")};
|
|
276
341
|
return half4(mixed, scene.a);
|
|
277
342
|
}
|
|
278
343
|
`;
|
|
@@ -285,15 +350,8 @@ uniform float direction;
|
|
|
285
350
|
half4 main(float2 coord) {
|
|
286
351
|
half4 scene = src.eval(coord);
|
|
287
352
|
float2 uv = coord / resolution;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
float2 toFrag = uv - src_point;
|
|
291
|
-
float angle = atan(toFrag.x, toFrag.y);
|
|
292
|
-
float shafts = 0.5 + 0.5 * sin(angle * 8.0);
|
|
293
|
-
float dist = length(toFrag);
|
|
294
|
-
float falloff = 1.0 - smoothstep(0.0, 1.2, dist);
|
|
295
|
-
half shaft = half(shafts * falloff * intensity * 0.35);
|
|
296
|
-
return half4(scene.rgb + half3(shaft * 0.95, shaft * 0.9, shaft * 0.6), scene.a);
|
|
353
|
+
${sunShaftBody("direction", "intensity")}
|
|
354
|
+
return half4(${sunShaftBlend("scene.rgb")}, scene.a);
|
|
297
355
|
}
|
|
298
356
|
`;
|
|
299
357
|
const WEATHER_DARK_VIGNETTE_SKSL = `
|
|
@@ -303,11 +361,8 @@ uniform float intensity;
|
|
|
303
361
|
|
|
304
362
|
half4 main(float2 coord) {
|
|
305
363
|
half4 scene = src.eval(coord);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
float v = smoothstep(0.3, 0.85, d);
|
|
309
|
-
half dark = half(v * intensity);
|
|
310
|
-
return half4(scene.rgb * (1.0 - dark), scene.a);
|
|
364
|
+
${darkVignetteBody("uv", "coord / resolution", "intensity")}
|
|
365
|
+
return half4(${darkVignetteBlend("scene.rgb")}, scene.a);
|
|
311
366
|
}
|
|
312
367
|
`;
|
|
313
368
|
const WEATHER_CLOUDS_SKSL = `
|
|
@@ -317,30 +372,14 @@ uniform float intensity;
|
|
|
317
372
|
uniform float scrollOffsetX;
|
|
318
373
|
uniform float direction;
|
|
319
374
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
float2 i = floor(p); float2 f = fract(p);
|
|
323
|
-
float2 u = f * f * (3.0 - 2.0 * f);
|
|
324
|
-
return mix(mix(hash(i), hash(i + float2(1.0, 0.0)), u.x),
|
|
325
|
-
mix(hash(i + float2(0.0, 1.0)), hash(i + float2(1.0, 1.0)), u.x), u.y);
|
|
326
|
-
}
|
|
327
|
-
float fbm(float2 p) { return vnoise(p) * 0.6 + vnoise(p * 2.3) * 0.4; }
|
|
375
|
+
${HASH_FN_SKSL}
|
|
376
|
+
${CLOUD_NOISE_FNS_SKSL}
|
|
328
377
|
|
|
329
378
|
half4 main(float2 coord) {
|
|
330
379
|
half4 scene = src.eval(coord);
|
|
331
380
|
float2 uv = coord / resolution;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
float2 scrollDir = float2(cos(rad), sin(rad));
|
|
335
|
-
float2 cloudUv = float2(
|
|
336
|
-
uv.x + scrollOffsetX * scrollDir.x / resolution.x,
|
|
337
|
-
uv.y * 0.5 + scrollOffsetX * scrollDir.y / resolution.y
|
|
338
|
-
);
|
|
339
|
-
float cloud = fbm(cloudUv * 3.0);
|
|
340
|
-
float heightFade = smoothstep(0.6, 0.2, uv.y);
|
|
341
|
-
float alpha = cloud * heightFade * intensity * 0.5;
|
|
342
|
-
half3 cloudColor = half3(0.9, 0.9, 0.95);
|
|
343
|
-
return half4(mix(scene.rgb, cloudColor, half(alpha)), scene.a);
|
|
381
|
+
${cloudsBody(CLOUDS_STANDALONE)}
|
|
382
|
+
return half4(${cloudsBlend("scene.rgb")}, scene.a);
|
|
344
383
|
}
|
|
345
384
|
`;
|
|
346
385
|
const COMPOSITE_SKSL = `
|
|
@@ -366,14 +405,8 @@ uniform float3 weatherColor;
|
|
|
366
405
|
uniform float weatherDensity;
|
|
367
406
|
uniform float weatherStreakLen;
|
|
368
407
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
float2 i = floor(p); float2 f = fract(p);
|
|
372
|
-
float2 u = f * f * (3.0 - 2.0 * f);
|
|
373
|
-
return mix(mix(hash(i), hash(i + float2(1.0, 0.0)), u.x),
|
|
374
|
-
mix(hash(i + float2(0.0, 1.0)), hash(i + float2(1.0, 1.0)), u.x), u.y);
|
|
375
|
-
}
|
|
376
|
-
float fbm(float2 p) { return vnoise(p) * 0.6 + vnoise(p * 2.3) * 0.4; }
|
|
408
|
+
${HASH_FN_SKSL}
|
|
409
|
+
${CLOUD_NOISE_FNS_SKSL}
|
|
377
410
|
|
|
378
411
|
half4 main(float2 coord) {
|
|
379
412
|
// --- chromatic aberration ---
|
|
@@ -412,85 +445,21 @@ half4 main(float2 coord) {
|
|
|
412
445
|
if (wk >= 0.5 && wk < 1.5) {
|
|
413
446
|
// rain — falling sawtooth streaks, 2 parallax layers, alpha-over blend
|
|
414
447
|
// weatherScrollY is normalized [0,1) fall phase (increment speed*dt/screenH each tick)
|
|
415
|
-
|
|
416
|
-
float sinA = sin(rad);
|
|
417
|
-
float cosA = cos(rad);
|
|
418
|
-
float aspect = resolution.x / resolution.y;
|
|
419
|
-
float perpAxis = (cosA * uv.x - sinA * uv.y) * aspect;
|
|
420
|
-
float fallAxis = sinA * uv.x + cosA * uv.y;
|
|
421
|
-
|
|
422
|
-
float coverage = 0.0;
|
|
423
|
-
|
|
424
|
-
// near layer — COLS=45, tiling=6, brightness=1.0
|
|
425
|
-
{
|
|
426
|
-
float COLS = 45.0;
|
|
427
|
-
float tiling = 6.0;
|
|
428
|
-
float brightness = 1.0;
|
|
429
|
-
float cid = floor(perpAxis * COLS);
|
|
430
|
-
float colHash = hash(float2(cid, 0.0));
|
|
431
|
-
if (colHash < weatherDensity) {
|
|
432
|
-
float phase = hash(float2(cid, 1.0));
|
|
433
|
-
float colBright = brightness * (0.6 + hash(float2(cid, 2.0)) * 0.4);
|
|
434
|
-
float center = 0.5 + (hash(float2(cid, 3.0)) - 0.5) * 0.4;
|
|
435
|
-
float seg = fract(fallAxis * tiling - weatherScrollY + phase);
|
|
436
|
-
float coverageY = smoothstep(weatherStreakLen, 0.0, seg);
|
|
437
|
-
float width = 0.04;
|
|
438
|
-
float xMask = smoothstep(width, 0.0, abs(fract(perpAxis * COLS) - center));
|
|
439
|
-
coverage = max(coverage, coverageY * xMask * colBright);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
448
|
+
${nest(rainBody(RAIN_COMPOSITE))}
|
|
442
449
|
|
|
443
|
-
|
|
444
|
-
{
|
|
445
|
-
float COLS = 85.0;
|
|
446
|
-
float tiling = 11.0;
|
|
447
|
-
float brightness = 0.5;
|
|
448
|
-
float cid = floor(perpAxis * COLS);
|
|
449
|
-
float colHash = hash(float2(cid, 10.0));
|
|
450
|
-
if (colHash < weatherDensity) {
|
|
451
|
-
float phase = hash(float2(cid, 11.0));
|
|
452
|
-
float colBright = brightness * (0.6 + hash(float2(cid, 12.0)) * 0.4);
|
|
453
|
-
float center = 0.5 + (hash(float2(cid, 13.0)) - 0.5) * 0.4;
|
|
454
|
-
float seg = fract(fallAxis * tiling - weatherScrollY + phase);
|
|
455
|
-
float coverageY = smoothstep(weatherStreakLen, 0.0, seg);
|
|
456
|
-
float width = 0.03;
|
|
457
|
-
float xMask = smoothstep(width, 0.0, abs(fract(perpAxis * COLS) - center));
|
|
458
|
-
coverage = max(coverage, coverageY * xMask * colBright);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
c = mix(c, half3(weatherColor), half(coverage * weatherIntensity));
|
|
450
|
+
c = ${rainBlend("c", "weatherColor", "weatherIntensity")};
|
|
463
451
|
} else if (wk >= 1.5 && wk < 2.5) {
|
|
464
452
|
// sun-shaft
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
float2 toFrag = uv - srcPoint;
|
|
468
|
-
float angle = atan(toFrag.x, toFrag.y);
|
|
469
|
-
float shafts = 0.5 + 0.5 * sin(angle * 8.0);
|
|
470
|
-
float dist = length(toFrag);
|
|
471
|
-
float falloff = 1.0 - smoothstep(0.0, 1.2, dist);
|
|
472
|
-
half shaft = half(shafts * falloff * weatherIntensity * 0.35);
|
|
473
|
-
c = c + half3(shaft * 0.95, shaft * 0.9, shaft * 0.6);
|
|
453
|
+
${nest(sunShaftBody("weatherDirection", "weatherIntensity"))}
|
|
454
|
+
c = ${sunShaftBlend("c")};
|
|
474
455
|
} else if (wk >= 2.5 && wk < 3.5) {
|
|
475
456
|
// dark-vignette
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
float vd = smoothstep(0.3, 0.85, d2);
|
|
479
|
-
half dark = half(vd * weatherIntensity);
|
|
480
|
-
c = c * (1.0 - dark);
|
|
457
|
+
${nest(darkVignetteBody("uvShift", "uv", "weatherIntensity"))}
|
|
458
|
+
c = ${darkVignetteBlend("c")};
|
|
481
459
|
} else if (wk >= 3.5) {
|
|
482
|
-
// clouds
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
float2 cloudUv = float2(
|
|
486
|
-
uv.x + weatherScrollX * scrollDir.x / resolution.x,
|
|
487
|
-
uv.y * 0.5 + weatherScrollX * scrollDir.y / resolution.y
|
|
488
|
-
);
|
|
489
|
-
float cloud = fbm(cloudUv * 3.0);
|
|
490
|
-
float heightFade = smoothstep(0.6, 0.2, uv.y);
|
|
491
|
-
float alpha = cloud * heightFade * weatherIntensity * 0.5;
|
|
492
|
-
half3 cloudColor = half3(0.9, 0.9, 0.95);
|
|
493
|
-
c = mix(c, cloudColor, half(alpha));
|
|
460
|
+
// clouds
|
|
461
|
+
${nest(cloudsBody(CLOUDS_COMPOSITE))}
|
|
462
|
+
c = ${cloudsBlend("c")};
|
|
494
463
|
}
|
|
495
464
|
}
|
|
496
465
|
|
|
@@ -806,41 +775,46 @@ function createPostFxController(options) {
|
|
|
806
775
|
let flashIntensity = 0;
|
|
807
776
|
const timedRemaining = /* @__PURE__ */ new Map();
|
|
808
777
|
const timedRestore = /* @__PURE__ */ new Map();
|
|
778
|
+
const expired = [];
|
|
779
|
+
let stepMs = 0;
|
|
780
|
+
const stepTimed = (remaining, id) => {
|
|
781
|
+
const next = remaining - stepMs;
|
|
782
|
+
if (next <= 0) expired.push(id);
|
|
783
|
+
else timedRemaining.set(id, next);
|
|
784
|
+
};
|
|
785
|
+
const flashUniforms = {
|
|
786
|
+
kind: "grayscale-flash",
|
|
787
|
+
intensity: 0
|
|
788
|
+
};
|
|
809
789
|
return {
|
|
810
790
|
chain,
|
|
811
791
|
runtime,
|
|
812
792
|
triggerHitFlash() {
|
|
813
793
|
if (!flashCfg) return;
|
|
814
794
|
flashIntensity = 1;
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
intensity: 1
|
|
818
|
-
});
|
|
795
|
+
flashUniforms.intensity = 1;
|
|
796
|
+
chain.setUniforms(flashCfg.id, flashUniforms);
|
|
819
797
|
},
|
|
820
798
|
triggerTimed(effectId, decayMs) {
|
|
821
799
|
const effect = chain.get(effectId);
|
|
822
800
|
if (!effect) return;
|
|
823
|
-
timedRestore.set(effectId, { ...effect.uniforms });
|
|
801
|
+
if (!timedRemaining.has(effectId)) timedRestore.set(effectId, { ...effect.uniforms });
|
|
824
802
|
chain.setEnabled(effectId, true);
|
|
825
803
|
timedRemaining.set(effectId, decayMs);
|
|
826
804
|
},
|
|
827
805
|
update(dt) {
|
|
828
806
|
if (flashCfg && flashIntensity > 0) {
|
|
829
807
|
flashIntensity = Math.max(0, flashIntensity - dt * flashDecay);
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
intensity: flashIntensity
|
|
833
|
-
});
|
|
808
|
+
flashUniforms.intensity = flashIntensity;
|
|
809
|
+
chain.setUniforms(flashCfg.id, flashUniforms);
|
|
834
810
|
}
|
|
835
811
|
if (timedRemaining.size > 0) {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
}
|
|
843
|
-
if (expired.length > 0) for (const id of expired) {
|
|
812
|
+
stepMs = dt * 1e3;
|
|
813
|
+
expired.length = 0;
|
|
814
|
+
timedRemaining.forEach(stepTimed);
|
|
815
|
+
for (let i = 0; i < expired.length; i++) {
|
|
816
|
+
const id = expired[i];
|
|
817
|
+
if (id === void 0) continue;
|
|
844
818
|
const snapshot = timedRestore.get(id);
|
|
845
819
|
if (snapshot !== void 0) chain.setUniforms(id, snapshot);
|
|
846
820
|
chain.setEnabled(id, false);
|