reze-engine 0.62.1 → 0.64.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/engine.d.ts +95 -57
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +466 -162
- package/dist/graph/compile.d.ts.map +1 -1
- package/dist/graph/compile.js +4 -1
- package/dist/graph/registry.d.ts +3 -0
- package/dist/graph/registry.d.ts.map +1 -1
- package/dist/graph/registry.js +133 -0
- package/dist/graph/schema.d.ts +12 -0
- package/dist/graph/schema.d.ts.map +1 -1
- package/dist/graph/slots.d.ts.map +1 -1
- package/dist/graph/slots.js +11 -20
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/shaders/lights.d.ts +3 -2
- package/dist/shaders/lights.d.ts.map +1 -1
- package/dist/shaders/lights.js +16 -3
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +63 -56
- package/dist/shaders/materials/nodes.d.ts +1 -1
- package/dist/shaders/materials/nodes.d.ts.map +1 -1
- package/dist/shaders/materials/nodes.js +210 -0
- package/dist/shaders/passes/composite.d.ts.map +1 -1
- package/dist/shaders/passes/composite.js +13 -1
- package/dist/shaders/passes/cull.d.ts +1 -1
- package/dist/shaders/passes/cull.d.ts.map +1 -1
- package/dist/shaders/passes/cull.js +7 -3
- package/dist/shaders/passes/ground.d.ts.map +1 -1
- package/dist/shaders/passes/ground.js +32 -55
- package/dist/shaders/passes/particles.d.ts +11 -1
- package/dist/shaders/passes/particles.d.ts.map +1 -1
- package/dist/shaders/passes/particles.js +9 -4
- package/dist/shaders/scene-light-api.d.ts +18 -10
- package/dist/shaders/scene-light-api.d.ts.map +1 -1
- package/dist/shaders/scene-light-api.js +58 -46
- package/dist/shadow-cascades.d.ts +47 -20
- package/dist/shadow-cascades.d.ts.map +1 -1
- package/dist/shadow-cascades.js +36 -13
- package/dist/unity/character.d.ts +59 -0
- package/dist/unity/character.d.ts.map +1 -0
- package/dist/unity/character.js +120 -0
- package/dist/unity/globals.d.ts +93 -0
- package/dist/unity/globals.d.ts.map +1 -0
- package/dist/unity/globals.js +340 -0
- package/dist/unity/host.d.ts +137 -0
- package/dist/unity/host.d.ts.map +1 -0
- package/dist/unity/host.js +489 -0
- package/dist/unity/looks.d.ts +88 -0
- package/dist/unity/looks.d.ts.map +1 -0
- package/dist/unity/looks.js +295 -0
- package/dist/unity/skin.d.ts +9 -0
- package/dist/unity/skin.d.ts.map +1 -0
- package/dist/unity/skin.js +117 -0
- package/dist/unity/stage.d.ts +148 -0
- package/dist/unity/stage.d.ts.map +1 -0
- package/dist/unity/stage.js +375 -0
- package/dist/unity/state.d.ts +22 -0
- package/dist/unity/state.d.ts.map +1 -0
- package/dist/unity/state.js +170 -0
- package/package.json +1 -1
- package/src/engine.ts +504 -176
- package/src/graph/compile.ts +3 -1
- package/src/graph/registry.ts +142 -0
- package/src/graph/schema.ts +9 -0
- package/src/graph/slots.ts +11 -20
- package/src/index.ts +11 -0
- package/src/shaders/lights.ts +16 -3
- package/src/shaders/materials/common.ts +63 -57
- package/src/shaders/materials/nodes.ts +210 -0
- package/src/shaders/passes/composite.ts +13 -1
- package/src/shaders/passes/cull.ts +7 -3
- package/src/shaders/passes/ground.ts +32 -55
- package/src/shaders/passes/particles.ts +19 -5
- package/src/shaders/scene-light-api.ts +59 -46
- package/src/shadow-cascades.ts +61 -32
- package/src/unity/character.ts +169 -0
- package/src/unity/globals.ts +443 -0
- package/src/unity/host.ts +587 -0
- package/src/unity/looks.ts +372 -0
- package/src/unity/skin.ts +128 -0
- package/src/unity/stage.ts +568 -0
- package/src/unity/state.ts +172 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/graph/compile.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAA0B,WAAW,EAAE,MAAM,UAAU,CAAA;AAI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EAAE,IAAI,GAAE,cAAmB,GAAG,UAAU,EAAE,CA4GzF;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,cAAmB,GAAG,aAAa,CAwKzF"}
|
package/dist/graph/compile.js
CHANGED
|
@@ -294,9 +294,12 @@ export function compileGraph(graph, opts = {}) {
|
|
|
294
294
|
return spec(node).emit(raw);
|
|
295
295
|
};
|
|
296
296
|
const lines = [];
|
|
297
|
+
let nodeTakesLight = false;
|
|
297
298
|
for (const id of order) {
|
|
298
299
|
const node = nodes.get(id);
|
|
299
300
|
const s = spec(node);
|
|
301
|
+
if (s.takesLight)
|
|
302
|
+
nodeTakesLight = true;
|
|
300
303
|
if (s.contextOutputs)
|
|
301
304
|
continue;
|
|
302
305
|
const args = {};
|
|
@@ -311,7 +314,7 @@ export function compileGraph(graph, opts = {}) {
|
|
|
311
314
|
const fsBody = lines.join("\n");
|
|
312
315
|
// A graph takes light when its body reads any: the four shading nodes all
|
|
313
316
|
// pass `sun, amb`, and a hand-written node reaching for the lamps names them.
|
|
314
|
-
const takesLight = /\bsun\b|\bamb\b|rzLight|rzLamp/.test(fsBody);
|
|
317
|
+
const takesLight = nodeTakesLight || /\bsun\b|\bamb\b|rzLight|rzLamp/.test(fsBody);
|
|
315
318
|
const wgsl = assembleModule(opts.renderClass ?? "auto", opts.alphaMode ?? "opaque", fsBody, usesStyle.current, !!opacity, opts.blend ?? "over", takesLight);
|
|
316
319
|
return { ok: true, wgsl, fsBody, slotMap, diagnostics, prunedNodes };
|
|
317
320
|
}
|
package/dist/graph/registry.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ export type NodeSpec = {
|
|
|
17
17
|
contextOutputs?: Record<string, string>;
|
|
18
18
|
/** Swizzle applied to the node's variable per output socket (default: none). */
|
|
19
19
|
outputSelect?: Record<string, string>;
|
|
20
|
+
/** The node shades by the scene's light without naming it: its graph takes
|
|
21
|
+
* the lamps and the fog as the four shading nodes' graphs do. */
|
|
22
|
+
takesLight?: boolean;
|
|
20
23
|
};
|
|
21
24
|
export declare function fmtValue(value: SocketValue, type: SockT): string;
|
|
22
25
|
/** Does a literal's shape fit a socket type? (Scalar splats onto color/vector/vec4.) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/graph/registry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEzD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,KAAK,CAAA;IACX,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,4FAA4F;IAC5F,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC9B,2FAA2F;IAC3F,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAA;IAC/C,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/graph/registry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEzD,KAAK,SAAS,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ader harder to read.
|
|
107
107
|
return fmtFloat(Number(((r * r * 2 * Math.max(l, 0)) / 0.08).toPrecision(9)));
|
|
108
108
|
}
|
|
109
|
+
const uberNode = (slot) => ({
|
|
110
|
+
inputs: {
|
|
111
|
+
base: C([1, 1, 1], true),
|
|
112
|
+
metallic: F(0),
|
|
113
|
+
roughness: F(0.6),
|
|
114
|
+
occlusion: F(1),
|
|
115
|
+
normal: { type: "vector", contextDefault: "n" },
|
|
116
|
+
direction: { type: "vector", requiresLink: true },
|
|
117
|
+
// Unity's v into the ramp: the property map's alpha, which picks a
|
|
118
|
+
// surface's band (skin 0.702, hair and pale cloth 0.506).
|
|
119
|
+
row: F(0.702),
|
|
120
|
+
receive_shadow: F(1),
|
|
121
|
+
rim_mask: F(1),
|
|
122
|
+
rim_mid: F(0.448),
|
|
123
|
+
rim_width: F(0.11),
|
|
124
|
+
rim_tint: C([0.9623, 0.9214, 0.9214]),
|
|
125
|
+
rim_intensity: F(1),
|
|
126
|
+
rim_albedo: F(0.9),
|
|
127
|
+
rim_in_light: F(1),
|
|
128
|
+
emission: C([0, 0, 0]),
|
|
129
|
+
reflection: F(1),
|
|
130
|
+
// A face's SDF shade (ag_face_sdf); left at -1, the material reads N·L.
|
|
131
|
+
shade: F(-1),
|
|
132
|
+
// 1: the game's FACE_MODE — no GGX, the environment at a flat 0.0157.
|
|
133
|
+
face: F(0),
|
|
134
|
+
},
|
|
135
|
+
outputs: { color: "color" },
|
|
136
|
+
emit: (a) => `ag_uber(${slot}u, ${a.base}, ${a.metallic}, ${a.roughness}, ${a.occlusion}, ${a.normal}, ${a.direction}, ${a.row}, ${a.receive_shadow}, ` +
|
|
137
|
+
`${a.rim_mask}, ${a.rim_mid}, ${a.rim_width}, ${a.rim_tint}, ${a.rim_intensity}, ${a.rim_albedo}, ${a.rim_in_light}, ${a.emission}, ${a.reflection}, ${a.shade}, ${a.face}, input.worldPos, v)`,
|
|
138
|
+
takesLight: true,
|
|
139
|
+
});
|
|
140
|
+
const UBER_NODES = Object.fromEntries([0, 1, 2, 3].map((s) => [`ag_uber/${s}`, uberNode(s)]));
|
|
141
|
+
// The face's SDF shade, the image on the slot the type names — 104903's face
|
|
142
|
+
// template (SDF_04_shaonv) by default in the AG pack.
|
|
143
|
+
const faceSdfNode = (slot) => ({
|
|
144
|
+
inputs: {
|
|
145
|
+
uv: { type: "vector", contextDefault: "vec3f(input.uv, 0.0)" },
|
|
146
|
+
direction: { type: "vector", requiresLink: true },
|
|
147
|
+
normal: { type: "vector", contextDefault: "n" },
|
|
148
|
+
smoothness: F(0.1),
|
|
149
|
+
invert: F(0),
|
|
150
|
+
},
|
|
151
|
+
outputs: { value: "float" },
|
|
152
|
+
emit: (a) => `ag_face_sdf(${slot}u, ${a.uv}.xy, ${a.direction}, ${a.normal}, ${a.smoothness}, ${a.invert})`,
|
|
153
|
+
});
|
|
154
|
+
const FACE_SDF_NODES = Object.fromEntries([0, 1, 2, 3].map((s) => [`ag_face_sdf/${s}`, faceSdfNode(s)]));
|
|
109
155
|
export const NODE_REGISTRY = {
|
|
110
156
|
// ── Context inputs (template locals; no emission) ──
|
|
111
157
|
texture: {
|
|
@@ -420,6 +466,93 @@ export const NODE_REGISTRY = {
|
|
|
420
466
|
outputSelect: { color: ".rgb", alpha: ".a" },
|
|
421
467
|
emit: (a) => `group_tex3(${a.uv}.xy)`,
|
|
422
468
|
},
|
|
469
|
+
// ── Aether Gazer's character shading ──
|
|
470
|
+
// The game's character shader (SimPipeline/Character/Debug, which most of its
|
|
471
|
+
// characters wear), taken apart into the steps it runs — see ag_* in
|
|
472
|
+
// nodes.ts for each step's derivation from the decompiled pass. A graph
|
|
473
|
+
// composes them as the game did: a ramp lookup driven by the key light, a
|
|
474
|
+
// matcap, a reflection, the rim and the fill, with the ramp and matcap
|
|
475
|
+
// images on the style group's slots.
|
|
476
|
+
// The key light: CharacterEffect's direction, held in a frame that turns
|
|
477
|
+
// with the camera about the vertical (sim_TowardMatrix) — the game lights a
|
|
478
|
+
// character from where the viewer is, not from the scene's sun.
|
|
479
|
+
ag_key_light: {
|
|
480
|
+
inputs: { inclination: F(24), azimuth: F(-28) },
|
|
481
|
+
outputs: { direction: "vector" },
|
|
482
|
+
emit: (a) => `ag_key_light(${a.inclination}, ${a.azimuth})`,
|
|
483
|
+
},
|
|
484
|
+
// Where on the shadow ramp this point falls: N·L under the mask's occlusion,
|
|
485
|
+
// and the sun's cast shadow on top when the character receives it.
|
|
486
|
+
ag_shade_term: {
|
|
487
|
+
inputs: {
|
|
488
|
+
normal: { type: "vector", contextDefault: "n" },
|
|
489
|
+
direction: { type: "vector", requiresLink: true },
|
|
490
|
+
occlusion: F(1),
|
|
491
|
+
occlusion_scale: F(1),
|
|
492
|
+
receive_shadow: F(1),
|
|
493
|
+
},
|
|
494
|
+
outputs: { value: "float" },
|
|
495
|
+
emit: (a) => `ag_shade_term(${a.normal}, ${a.direction}, ${a.occlusion}, ${a.occlusion_scale}, ${a.receive_shadow}, input.worldPos)`,
|
|
496
|
+
takesLight: true,
|
|
497
|
+
},
|
|
498
|
+
// A ramp image's coordinate: u from the shade term, v the ramp's row (the
|
|
499
|
+
// game's property map picks it per texel; a PMX carries one per material).
|
|
500
|
+
ag_ramp_uv: {
|
|
501
|
+
inputs: { value: F(0), row: F(0.5) },
|
|
502
|
+
outputs: { uv: "vector" },
|
|
503
|
+
emit: (a) => `ag_ramp_uv(${a.value}, ${a.row})`,
|
|
504
|
+
},
|
|
505
|
+
// The view-space reflection the matcap, the reflection map, the rim and the
|
|
506
|
+
// fill all read: its uv into a sphere image, and how much it faces the eye.
|
|
507
|
+
ag_view_reflection: {
|
|
508
|
+
inputs: { normal: { type: "vector", contextDefault: "n" } },
|
|
509
|
+
outputs: { uv: "vector", facing: "float" },
|
|
510
|
+
outputSelect: { uv: ".xyz", facing: ".w" },
|
|
511
|
+
emit: (a) => `ag_view_reflection(${a.normal}, v)`,
|
|
512
|
+
},
|
|
513
|
+
// The matcap's lift: a metal's shine, at least 1, where the mask says.
|
|
514
|
+
ag_matcap: {
|
|
515
|
+
inputs: { color: C([1, 1, 1], true), matcap: C([1, 1, 1]), strength: F(1), mask: F(1) },
|
|
516
|
+
outputs: { color: "color" },
|
|
517
|
+
emit: (a) => `ag_matcap(${a.color}, ${a.matcap}, ${a.strength}, ${a.mask})`,
|
|
518
|
+
},
|
|
519
|
+
// The rim: the two fixed screen-side directions CharacterEffect sets, cut to
|
|
520
|
+
// the silhouette, laid on as a colour dodge where the mask allows.
|
|
521
|
+
ag_rim: {
|
|
522
|
+
inputs: {
|
|
523
|
+
color: C([1, 1, 1], true),
|
|
524
|
+
facing: F(1),
|
|
525
|
+
uv: { type: "vector", requiresLink: true },
|
|
526
|
+
rim_color: C([0.8584906, 0.8584906, 0.8584906]),
|
|
527
|
+
threshold: F(0.1),
|
|
528
|
+
fade: F(0.113),
|
|
529
|
+
range: F(0.444),
|
|
530
|
+
inclination: F(0),
|
|
531
|
+
azimuth1: F(0.8499963),
|
|
532
|
+
azimuth2: F(1),
|
|
533
|
+
mask: F(1),
|
|
534
|
+
},
|
|
535
|
+
outputs: { color: "color" },
|
|
536
|
+
emit: (a) => `ag_rim(${a.color}, ${a.facing}, ${a.uv}, ${a.rim_color}, ${a.threshold}, ${a.fade}, ${a.range}, ${a.inclination}, ${a.azimuth1}, ${a.azimuth2}, ${a.mask})`,
|
|
537
|
+
},
|
|
538
|
+
// The fill: a colour laid toward the silhouette, inner to outer.
|
|
539
|
+
ag_fill: {
|
|
540
|
+
inputs: {
|
|
541
|
+
color: C([1, 1, 1], true),
|
|
542
|
+
facing: F(1),
|
|
543
|
+
inner: C([0, 0, 0]),
|
|
544
|
+
outer: C([0, 0, 0]),
|
|
545
|
+
amount: F(0),
|
|
546
|
+
softness: F(0),
|
|
547
|
+
},
|
|
548
|
+
outputs: { color: "color" },
|
|
549
|
+
emit: (a) => `ag_fill(${a.color}, ${a.facing}, ${a.inner}, ${a.outer}, ${a.amount}, ${a.softness})`,
|
|
550
|
+
},
|
|
551
|
+
// Aether Gazer's current character shading (PBR/Uber) as one closure, the way
|
|
552
|
+
// Principled is one: the ramp image on the group slot named by the type.
|
|
553
|
+
// Defaults are 104903's skin.
|
|
554
|
+
...UBER_NODES,
|
|
555
|
+
...FACE_SDF_NODES,
|
|
423
556
|
// ── Blender 5.2 colour utilities ──
|
|
424
557
|
separate_color: {
|
|
425
558
|
inputs: { color: C([1, 1, 1], true) },
|
package/dist/graph/schema.d.ts
CHANGED
|
@@ -77,6 +77,18 @@ export type ShaderGraph = {
|
|
|
77
77
|
* matching (e.g. ["hair"]). Ignored by the compiler; round-tripped. A graph is pure
|
|
78
78
|
* shading — pass integration lives on the style group's renderClass, not here. */
|
|
79
79
|
tags?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* The images this look samples on `tex_image/0`…`tex_image/3`, by URL —
|
|
82
|
+
* a ramp, a matcap, the maps a game's look is built on. They belong to the
|
|
83
|
+
* LOOK, not to the model it is put on: they are read at coordinates the
|
|
84
|
+
* shading computes (a light amount, a reflection), never at the mesh's uvs,
|
|
85
|
+
* so one graph carries them to any model. A style group that brings its own
|
|
86
|
+
* images keeps those.
|
|
87
|
+
*/
|
|
88
|
+
images?: ({
|
|
89
|
+
url: string;
|
|
90
|
+
srgb?: boolean;
|
|
91
|
+
} | null)[];
|
|
80
92
|
};
|
|
81
93
|
export type Diagnostic = {
|
|
82
94
|
severity: "error" | "warning";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/graph/schema.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE9F,MAAM,MAAM,SAAS,GAAG;IACtB,kFAAkF;IAClF,EAAE,EAAE,MAAM,CAAA;IACV,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA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Z,OAAO,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,CAAC,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,uEAAuE;IACvE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACxC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1C,MAAM,CAAC,EAAE,YAAY,EAAE,CAAA;IACvB;;uFAEmF;IACnF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC,EAAE,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAID,eAAO,MAAM,SAAS,MAAM,CAAA;AAC5B,eAAO,MAAM,UAAU,KAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../src/graph/slots.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../src/graph/slots.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAoNxE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,OAAO,EAC7B,UAAU,UAAQ,EAClB,KAAK,GAAE,UAAmB,EAC1B,UAAU,UAAO,GAChB,MAAM,CAgBR"}
|
package/dist/graph/slots.js
CHANGED
|
@@ -125,20 +125,17 @@ ${discard}
|
|
|
125
125
|
var n = safe_normal(input.normal);
|
|
126
126
|
let v = normalize(camera.viewPos - input.worldPos);${flip}
|
|
127
127
|
${gate}
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
// The key: the directional light this draw's layers take — the sun unless a
|
|
129
|
+
// light on its own layer stands in. The shadow stays the sun's atlas, as the
|
|
130
|
+
// game keeps the scene's shadow under a character's own key.
|
|
131
|
+
let rz_key = rzMainLight();
|
|
132
|
+
let l = -light.lights[rz_key].direction.xyz;
|
|
133
|
+
let sun = light.lights[rz_key].color.xyz * light.lights[rz_key].color.w;
|
|
130
134
|
let shadow = sampleShadow(input.worldPos, n);
|
|
131
|
-
// The
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
// A model given a flat sky (setModelFlatSky - the cast, for an anime look)
|
|
136
|
-
// takes the sky's AVERAGE instead: its colour and brightness from every
|
|
137
|
-
// direction alike. The directional sky shaded a face like PBR - soft
|
|
138
|
-
// realistic gradients the toon ramp never drew - where the game gives its
|
|
139
|
-
// characters one flat base light. A flat World is its own average, so a
|
|
140
|
-
// scene without an HDRI renders exactly as before.
|
|
141
|
-
let amb = select(rzWorldAmbient(n), rzWorldAmbientAvg(), modelLight.opts.x > 0.5);
|
|
135
|
+
// The ambient: this object's own where loaded data gave it one — the game
|
|
136
|
+
// gives every renderer its own — else the world's flat colour or the HDRI's
|
|
137
|
+
// irradiance at this normal.
|
|
138
|
+
let amb = rzObjectAmbient(n);
|
|
142
139
|
let tex_color = tex_s.rgb;
|
|
143
140
|
// The normal the lamps' diffuse layer is lit by, for a principled walk to
|
|
144
141
|
// compute it on the way (rzLightsDiffuseOnce). n is final from here on.
|
|
@@ -180,13 +177,7 @@ function epilogue(renderClass, alphaMode, hasOpacity, blend, takesLight) {
|
|
|
180
177
|
// painted sheet — is Blender's Emission shader, which no lamp reaches; adding
|
|
181
178
|
// the lamps to it turned X340's floor shadow, a white-RGB picture at a soft
|
|
182
179
|
// alpha, into a glowing disc under the spot above it.
|
|
183
|
-
|
|
184
|
-
// The model's fill (Engine.setModelFill) rides here too, as brightness: the
|
|
185
|
-
// surface colour times the fill, on every pixel of her alike. It used to
|
|
186
|
-
// enter the graph's ambient, where an NPR ramp read it as LIGHT — sliding it
|
|
187
|
-
// moved her shadows, and under a hard step flipped whole regions at once.
|
|
188
|
-
// After the graph it lifts her evenly and leaves every shadow where it is.
|
|
189
|
-
const LIT = takesLight ? ` + (rzLightsDiffuseOnce(input.worldPos, n) + modelLight.fill.rgb) * albedo` : "";
|
|
180
|
+
const LIT = takesLight ? ` + rzLightsDiffuseOnce(input.worldPos, n) * albedo` : "";
|
|
190
181
|
const ALBEDO = ` let albedo = tex_color;
|
|
191
182
|
`;
|
|
192
183
|
// The dissolve's burning edge, ADDED after the graph and after the lights —
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type StageGradeLut, type SceneFog, type StageCastShadow, type SceneFogLayer, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, type ModelAttachment, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, type CullDiagnostics, type MidiNote, } from "./engine";
|
|
1
|
+
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, type ColorGradingOptions, type StageGradeLut, type SceneFog, type StageCastShadow, type SceneFogLayer, type EngineStats, type EngineOptions, type BloomOptions, type DepthOfFieldOptions, type ViewTransformOptions, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectResult, type CullDiagnostics, type MidiNote, } from "./engine";
|
|
2
2
|
export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload";
|
|
3
3
|
export { parseMidi } from "./midi-loader";
|
|
4
4
|
export { parseHDR, type HdrImage } from "./hdr";
|
|
@@ -51,4 +51,12 @@ export { boneOverlay, boneMarkerPositions, rigidbodyOverlay, jointOverlay, build
|
|
|
51
51
|
*/
|
|
52
52
|
export { EFFECT_MATH_API, PARTICLE_STRUCT_WGSL } from "./shaders/passes/hosted-api";
|
|
53
53
|
export type { EyeTrackingOptions } from "./model";
|
|
54
|
+
/**
|
|
55
|
+
* The game's own materials (src/unity): a stage package drawn by its translated
|
|
56
|
+
* shaders (Engine.setNativeStage) and a model dressed in a native look
|
|
57
|
+
* (Engine.setModelNativeLook) — the shapes their files take.
|
|
58
|
+
*/
|
|
59
|
+
export type { NativeStagePackage, NativeStageReader } from "./unity/stage";
|
|
60
|
+
export type { NativeLook, NativeMaterialSpec, NativeTexture } from "./unity/looks";
|
|
61
|
+
export type { NativeShader, NativeShaderInfo } from "./unity/host";
|
|
54
62
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sour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AAK,EAAE,MAAM,iBAAiB,CAAA;AAI3F,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,SAAS,GACf,MAAM,WAAW,CAAA;AAElB;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACnF,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD;;;;GAIG;AACH,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAC1E,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClF,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, } from "./engine";
|
|
1
|
+
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_DEPTH_OF_FIELD_OPTIONS, DEFAULT_VIEW_TRANSFORM, DEFAULT_COLOR_GRADING, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, } from "./engine";
|
|
2
2
|
export { parsePmxFolderInput, pmxFileAtRelativePath } from "./folder-upload";
|
|
3
3
|
export { parseMidi } from "./midi-loader";
|
|
4
4
|
// Radiance .hdr, for HDRI worlds — the host fetches the file and hands the
|
package/dist/shaders/lights.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export declare function hasLightEmit(wgsl: string): boolean;
|
|
|
72
72
|
export declare function buildLightEmitShader(wgsl: string, sceneApi: string, cast: {
|
|
73
73
|
trailCount: number;
|
|
74
74
|
}, paramsDecl?: string): string;
|
|
75
|
-
/** The rz*Light accessors, with the buffer declared at the given binding.
|
|
76
|
-
|
|
75
|
+
/** The rz*Light accessors, with the buffer declared at the given binding.
|
|
76
|
+
* `layers` is the WGSL expression for the drawing's rendering-layer bits. */
|
|
77
|
+
export declare function lightsApi(group: number, binding: number, layers: string): string;
|
|
77
78
|
//# sourceMappingURL=lights.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../src/shaders/lights.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../src/shaders/lights.ts"],"names":[],"mappings":"AA4DA;uDACuD;AACvD,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,+CAA+C;AAC/C,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,MAAM,CAAA;AAC7B,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,QAAkB,CAAA;AAC/C;0EAC0E;AAC1E,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,uCAAuC;AACvC,eAAO,MAAM,eAAe,QAA2C,CAAA;AACvE,wDAAwD;AACxD,eAAO,MAAM,aAAa,QAAwD,CAAA;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,qJAQhC,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,QAA4B,CAAA;AAE3D,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAC5B,UAAU,SAAK,GACd,MAAM,CAoGR;AAED;8EAC8E;AAC9E,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAgKhF"}
|
package/dist/shaders/lights.js
CHANGED
|
@@ -28,7 +28,8 @@ import { subjectMaskApi } from "./cast-api";
|
|
|
28
28
|
// [0..2] position, world space [3] radius
|
|
29
29
|
// [4..6] colour PREMULTIPLIED by intensity [7] type
|
|
30
30
|
// [8..10] aim, unit, pointing away from the light [11] cos of the outer angle
|
|
31
|
-
// [12] cos of the inner angle
|
|
31
|
+
// [12] cos of the inner angle
|
|
32
|
+
// [13] the rendering layers it does NOT reach (u32 bits) [14..15] spare
|
|
32
33
|
//
|
|
33
34
|
// then the grid: LIGHT_MASK_WORDS words of lamp bits per cell.
|
|
34
35
|
//
|
|
@@ -40,6 +41,12 @@ import { subjectMaskApi } from "./cast-api";
|
|
|
40
41
|
// branchless: it stores aim (0,0,0) and both cosines at -1, which makes the
|
|
41
42
|
// cone term below saturate to exactly 1. `type` says which a light is for
|
|
42
43
|
// anyone reading the buffer; the shading never asks.
|
|
44
|
+
//
|
|
45
|
+
// LAYERS, as the game's pipeline (URP's rendering layers) gates its lights: a
|
|
46
|
+
// draw carries layer bits, and a light reaches it only where its own mask
|
|
47
|
+
// shares one. Stored INVERTED — the layers a light does not reach — so the
|
|
48
|
+
// zero every writer that predates layers leaves in [13] reaches everything,
|
|
49
|
+
// which is what an effect's lamp and a plain document light mean.
|
|
43
50
|
import { castDistanceStub } from "./passes/cast-distance";
|
|
44
51
|
import { audioApi } from "./audio-api";
|
|
45
52
|
import { midiApi } from "./midi-api";
|
|
@@ -231,8 +238,9 @@ fn lightEmitMain(@builtin(global_invocation_id) gid: vec3u) {
|
|
|
231
238
|
}
|
|
232
239
|
`;
|
|
233
240
|
}
|
|
234
|
-
/** The rz*Light accessors, with the buffer declared at the given binding.
|
|
235
|
-
|
|
241
|
+
/** The rz*Light accessors, with the buffer declared at the given binding.
|
|
242
|
+
* `layers` is the WGSL expression for the drawing's rendering-layer bits. */
|
|
243
|
+
export function lightsApi(group, binding, layers) {
|
|
236
244
|
const R = LIGHT_HEADER / 4;
|
|
237
245
|
const S = LIGHT_STRIDE / 4;
|
|
238
246
|
return /* wgsl */ `
|
|
@@ -274,6 +282,10 @@ fn rzLightAim(i: u32) -> vec3f { return _rzLightVec(i, 2u).xyz; }
|
|
|
274
282
|
* light stores (-1, -1), which saturates the cone term to 1. */
|
|
275
283
|
fn rzLightCone(i: u32) -> vec2f { return vec2f(_rzLightVec(i, 2u).w, _rzLightVec(i, 3u).x); }
|
|
276
284
|
|
|
285
|
+
/** Does light i reach this drawing's rendering layers? Read as bits, never as
|
|
286
|
+
* a float — see the layout. */
|
|
287
|
+
fn _rzLightReaches(i: u32) -> bool { return ((${layers}) & ~_rzLights[${R}u + i * ${S}u + 3u].y) != 0u; }
|
|
288
|
+
|
|
277
289
|
/** The document lamps that can reach p: its grid cell's bits, or the outside
|
|
278
290
|
* mask beyond the grid. Written so a NaN position fails the inside test. */
|
|
279
291
|
fn _rzLightCellMask(p: vec3f) -> vec4u {
|
|
@@ -300,6 +312,7 @@ fn _rzLightCellMask(p: vec3f) -> vec4u {
|
|
|
300
312
|
* writes in candela over 683.
|
|
301
313
|
*/
|
|
302
314
|
fn _rzLightOne(i: u32, p: vec3f, n: vec3f) -> vec3f {
|
|
315
|
+
if (!_rzLightReaches(i)) { return vec3f(0.0); }
|
|
303
316
|
let pr = _rzLightVec(i, 0u);
|
|
304
317
|
let d = pr.xyz - p;
|
|
305
318
|
let dist = length(d);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/shaders/materials/common.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/shaders/materials/common.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,oBAAoB,QA4NhC,CAAC;AAkHF,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,orMAgHzB,CAAA;AAQD,eAAO,MAAM,4BAA4B,QACkF,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sceneFsOutWgsl } from "../passes/scene-contract";
|
|
2
2
|
import { lightsApi } from "../lights";
|
|
3
3
|
import { SHADOW_CASCADES } from "../../shadow-cascades";
|
|
4
|
-
import {
|
|
4
|
+
import { sunShadowWgsl } from "../scene-light-api";
|
|
5
5
|
import { WORLD_AMBIENT_WGSL } from "../lights";
|
|
6
6
|
// Shared WGSL blocks concatenated by every material shader.
|
|
7
7
|
// Splits the boilerplate (uniform structs, bind group layout, skinning VS, PCF shadow)
|
|
@@ -58,6 +58,9 @@ struct LightUniforms {
|
|
|
58
58
|
* amount 0 is off. Then the view-projection its map was drawn with. */
|
|
59
59
|
castShadow: vec4f,
|
|
60
60
|
castVP: mat4x4f,
|
|
61
|
+
/** The rendering layers each directional light reaches, slot by slot — a
|
|
62
|
+
* draw is lit by the first whose bits it shares (rzMainLight). */
|
|
63
|
+
dirLayers: vec4u,
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
// Per-material uniforms. Every material binds this layout even if it ignores fields;
|
|
@@ -145,13 +148,10 @@ struct LightVP { viewProj: array<mat4x4f, ${SHADOW_CASCADES.length}>, };
|
|
|
145
148
|
@group(0) @binding(0) var<uniform> camera: CameraUniforms;
|
|
146
149
|
@group(0) @binding(1) var<uniform> light: LightUniforms;
|
|
147
150
|
@group(0) @binding(2) var diffuseSampler: sampler;
|
|
148
|
-
|
|
151
|
+
// The sun's shadow atlas: every cascade in its own tile — see shadow-cascades.ts.
|
|
152
|
+
@group(0) @binding(3) var shadowAtlas: texture_depth_2d;
|
|
149
153
|
@group(0) @binding(4) var shadowSampler: sampler_comparison;
|
|
150
154
|
@group(0) @binding(5) var<uniform> lightVP: LightVP;
|
|
151
|
-
// The far cascade's map — coarser texels over a much wider box, so the stage
|
|
152
|
-
// keeps its shadows when the crisp near volume ends. Binding 7: 6 is the
|
|
153
|
-
// positional lights, 9 the BRDF LUT.
|
|
154
|
-
@group(0) @binding(7) var shadowMapFar: texture_depth_2d;
|
|
155
155
|
// The world's own sky, for a surface that REFLECTS it rather than merely being
|
|
156
156
|
// lit by it. Equirect, in the same layout and the same linear radiance the
|
|
157
157
|
// composite draws the dome from, and mipped — a rough surface reads a coarser
|
|
@@ -185,14 +185,37 @@ fn _rzCastShadow(wp: vec3f) -> f32 {
|
|
|
185
185
|
}
|
|
186
186
|
// binding(9) brdfLut is declared inside NODES_WGSL (nodes.ts).
|
|
187
187
|
@group(1) @binding(0) var<storage, read> skinMats: array<mat4x4f>;
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
188
|
+
// What this object's lighting is, apart from the scene's, as the game's
|
|
189
|
+
// pipeline gives each renderer its own:
|
|
190
|
+
// layers.x its rendering-layer bits, which decide the lights that reach it —
|
|
191
|
+
// a stage's daylight and the cast's key are two lights on two
|
|
192
|
+
// layers, as the game lights them;
|
|
193
|
+
// ambient.x 1 while it has an ambient of its own (Engine.setModelAmbient),
|
|
194
|
+
// 0 for the world's;
|
|
195
|
+
// sh that ambient's irradiance, folded as the world's (ibl.ts).
|
|
196
|
+
struct ObjectLight { layers: vec4u, ambient: vec4f, sh: array<vec4f, 9> }
|
|
197
|
+
@group(1) @binding(1) var<uniform> objectLight: ObjectLight;
|
|
198
|
+
|
|
199
|
+
/** The light arriving at a surface of this object facing n: its own ambient
|
|
200
|
+
* where loaded data gave it one (a stage's probes, a character's), else the
|
|
201
|
+
* world's. The same polynomial rzWorldAmbient evaluates. */
|
|
202
|
+
fn rzObjectAmbient(n: vec3f) -> vec3f {
|
|
203
|
+
if (objectLight.ambient.x < 0.5) { return rzWorldAmbient(n); }
|
|
204
|
+
let s = objectLight.sh;
|
|
205
|
+
let c = s[0].xyz + s[1].xyz * n.y + s[2].xyz * n.z + s[3].xyz * n.x
|
|
206
|
+
+ s[4].xyz * (n.x * n.y) + s[5].xyz * (n.y * n.z) + s[6].xyz * (3.0 * n.z * n.z - 1.0)
|
|
207
|
+
+ s[7].xyz * (n.x * n.z) + s[8].xyz * (n.x * n.x - n.y * n.y);
|
|
208
|
+
return max(c, vec3f(0.0));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The directional light slot that lights this draw: the first whose layers
|
|
212
|
+
* it shares, else the sun's. */
|
|
213
|
+
fn rzMainLight() -> u32 {
|
|
214
|
+
for (var k = 0u; k < 4u; k++) {
|
|
215
|
+
if ((light.dirLayers[k] & objectLight.layers.x) != 0u) { return k; }
|
|
216
|
+
}
|
|
217
|
+
return 0u;
|
|
218
|
+
}
|
|
196
219
|
@group(2) @binding(0) var diffuseTexture: texture_2d<f32>;
|
|
197
220
|
@group(2) @binding(1) var<uniform> material: MaterialUniforms;
|
|
198
221
|
// Reserved for future sphere/toon graph nodes; graphs that don't read them get the
|
|
@@ -222,56 +245,40 @@ fn safe_normal(nIn: vec3f) -> vec3f {
|
|
|
222
245
|
|
|
223
246
|
`;
|
|
224
247
|
// ─── Shadow sampler (3×3 PCF, cascade-selected) ─────────────────────
|
|
225
|
-
// Normal-bias 0.08, depth-bias 0.001 NDC; the
|
|
226
|
-
// shared with
|
|
227
|
-
// from SHADOW_CASCADES so they cannot go stale the way the hardcoded 1/2048
|
|
228
|
-
// once did (PCF taps landed TWO texels apart after the map grew to 4096,
|
|
229
|
-
// quantizing self-shadow edges into crawling gray squares).
|
|
248
|
+
// Normal-bias 0.08, depth-bias 0.001 NDC; the lookup is sunShadowWgsl in
|
|
249
|
+
// scene-light-api.ts, shared with the ground and effects.
|
|
230
250
|
//
|
|
231
|
-
// Selection: the
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
// shadowing any stage deeper than the box.
|
|
251
|
+
// Selection: the first cascade whose box covers the point — with a margin that
|
|
252
|
+
// keeps the whole PCF kernel inside its tile — else LIT. Lit is a fix, not
|
|
253
|
+
// merely a default: past every cascade there is no occlusion information, and
|
|
254
|
+
// comparing against unrelated depths would silently shadow any stage deeper
|
|
255
|
+
// than the boxes.
|
|
237
256
|
const SAMPLE_SHADOW_WGSL = /* wgsl */ `
|
|
257
|
+
${sunShadowWgsl("_rzSun", "shadowAtlas", "shadowSampler", "lightVP.viewProj")}
|
|
238
258
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
259
|
+
/** The sun's cast shadow alone, without sampleShadow's facing test: what a
|
|
260
|
+
* character's ramp is min'd with (its own N·L carries the terminator). */
|
|
261
|
+
fn rzSunOcclusion(worldPos: vec3f, n: vec3f) -> f32 {
|
|
262
|
+
let castAmt = light.lights[0].direction.w;
|
|
263
|
+
if (castAmt <= 0.0) { return 1.0; }
|
|
264
|
+
let a = _rzSunLocate(worldPos + n * 0.08);
|
|
265
|
+
if (a.w < 0.0) { return 1.0; }
|
|
266
|
+
return mix(1.0, _rzSunTaps(a), castAmt);
|
|
245
267
|
}
|
|
246
268
|
|
|
247
269
|
fn sampleShadow(worldPos: vec3f, n: vec3f) -> f32 {
|
|
248
270
|
// THE SCENE'S ONE SHADOW SWITCH, and it lives on the sun because the sun is
|
|
249
|
-
// the only thing that casts.
|
|
250
|
-
//
|
|
251
|
-
// is, on the ground and on the cast alike. Gated here rather than by not
|
|
252
|
-
// rendering the map: the map is also what the ground catcher reads, and a host
|
|
253
|
-
// that wants a figure lit with no shadow still wants everything else about the
|
|
254
|
-
// frame unchanged.
|
|
255
|
-
//
|
|
256
|
-
// Lit is the answer when it is off. Returning 0 would be "fully shadowed",
|
|
257
|
-
// which is the opposite of what a disabled shadow means.
|
|
271
|
+
// the only thing that casts. Lit is the answer when it is off: returning 0
|
|
272
|
+
// would be "fully shadowed", the opposite of what a disabled shadow means.
|
|
258
273
|
let castAmt = light.lights[0].direction.w;
|
|
259
274
|
if (castAmt <= 0.0) { return 1.0; }
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
let c1 = lightVP.viewProj[1] * vec4f(biasedPos, 1.0);
|
|
268
|
-
let n1 = c1.xyz / max(c1.w, 1e-6);
|
|
269
|
-
if (all(abs(n1.xy) < vec2f(0.98)) && n1.z > 0.0 && n1.z < 1.0) {
|
|
270
|
-
return mix(1.0, sampleShadowFar(n1), castAmt);
|
|
271
|
-
}
|
|
272
|
-
// Outside every cascade there is no occlusion information; lit is the only
|
|
273
|
-
// honest answer.
|
|
274
|
-
return 1.0;
|
|
275
|
+
// A surface turned from the sun is in its own shade — when the sun is what
|
|
276
|
+
// keys it. Under a key of its own layer the atlas is only the occluders'
|
|
277
|
+
// shadow, and the key's N·L decides its terminator.
|
|
278
|
+
if (rzMainLight() == 0u && dot(n, -light.lights[0].direction.xyz) <= 0.0) { return 0.0; }
|
|
279
|
+
let a = _rzSunLocate(worldPos + n * 0.08);
|
|
280
|
+
if (a.w < 0.0) { return 1.0; }
|
|
281
|
+
return mix(1.0, _rzSunTaps(a), castAmt);
|
|
275
282
|
}
|
|
276
283
|
|
|
277
284
|
`;
|
|
@@ -485,4 +492,4 @@ fn rz_dissolve_threshold(restPos: vec3f) -> f32 {
|
|
|
485
492
|
// pull in everything structural. Each material then adds its own constants + fs().
|
|
486
493
|
// The FSOut struct is NOT in here any more — see commonFsOutWgsl above. Every
|
|
487
494
|
// consumer of this constant appends it immediately, which is where it was.
|
|
488
|
-
export const COMMON_MATERIAL_PRELUDE_WGSL = COMMON_BINDINGS_WGSL + WORLD_AMBIENT_WGSL + lightsApi(0, 6) + SAMPLE_SHADOW_WGSL + COMMON_VS_WGSL;
|
|
495
|
+
export const COMMON_MATERIAL_PRELUDE_WGSL = COMMON_BINDINGS_WGSL + WORLD_AMBIENT_WGSL + lightsApi(0, 6, "objectLight.layers.x") + SAMPLE_SHADOW_WGSL + COMMON_VS_WGSL;
|