reze-engine 0.20.0 → 0.21.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/README.md +21 -12
- package/dist/graph/compile.d.ts +3 -3
- package/dist/graph/compile.d.ts.map +1 -1
- package/dist/graph/presets/body.d.ts +2 -2
- package/dist/graph/presets/body.d.ts.map +1 -1
- package/dist/graph/presets/body.js +1 -1
- package/dist/graph/presets/cloth_rough.d.ts +2 -2
- package/dist/graph/presets/cloth_rough.d.ts.map +1 -1
- package/dist/graph/presets/cloth_rough.js +1 -1
- package/dist/graph/presets/cloth_smooth.d.ts +2 -2
- package/dist/graph/presets/cloth_smooth.d.ts.map +1 -1
- package/dist/graph/presets/cloth_smooth.js +1 -1
- package/dist/graph/presets/default.d.ts +2 -2
- package/dist/graph/presets/default.d.ts.map +1 -1
- package/dist/graph/presets/eye.d.ts +2 -2
- package/dist/graph/presets/eye.d.ts.map +1 -1
- package/dist/graph/presets/eye.js +1 -1
- package/dist/graph/presets/face.d.ts +2 -2
- package/dist/graph/presets/face.d.ts.map +1 -1
- package/dist/graph/presets/face.js +1 -1
- package/dist/graph/presets/hair.d.ts +2 -2
- package/dist/graph/presets/hair.d.ts.map +1 -1
- package/dist/graph/presets/hair.js +1 -1
- package/dist/graph/presets/metal.d.ts +2 -2
- package/dist/graph/presets/metal.d.ts.map +1 -1
- package/dist/graph/presets/metal.js +1 -1
- package/dist/graph/presets/stockings.d.ts +2 -2
- package/dist/graph/presets/stockings.d.ts.map +1 -1
- package/dist/graph/presets/stockings.js +1 -1
- package/dist/graph/render-class.js +1 -1
- package/dist/graph/schema.d.ts +1 -1
- package/dist/graph/schema.d.ts.map +1 -1
- package/dist/graph/schema.js +1 -1
- package/dist/graph/style-group.d.ts +3 -3
- package/dist/graph/style-group.d.ts.map +1 -1
- package/dist/graph/style-group.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine.ts +2 -2
- package/src/graph/compile.ts +3 -3
- package/src/graph/presets/body.ts +3 -3
- package/src/graph/presets/cloth_rough.ts +3 -3
- package/src/graph/presets/cloth_smooth.ts +3 -3
- package/src/graph/presets/default.ts +2 -2
- package/src/graph/presets/eye.ts +3 -3
- package/src/graph/presets/face.ts +3 -3
- package/src/graph/presets/hair.ts +3 -3
- package/src/graph/presets/metal.ts +3 -3
- package/src/graph/presets/stockings.ts +3 -3
- package/src/graph/render-class.ts +1 -1
- package/src/graph/schema.ts +2 -2
- package/src/graph/style-group.ts +4 -4
- package/src/index.ts +62 -62
package/README.md
CHANGED
|
@@ -13,8 +13,7 @@ npm install reze-engine
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
- Anime/MMD **hybrid renderer** — toon-ramp NPR over a Principled GGX BSDF, mixed per material
|
|
16
|
-
- **
|
|
17
|
-
- **Node-graph materials** — Blender-style style graphs (JSON) validated + compiled to WGSL at runtime; instant slider tier, async pipeline swap with fallback-on-error
|
|
16
|
+
- **Shader-graph materials + style groups** — every look is a Blender-style **shader graph** (JSON) compiled to WGSL at runtime; **style groups** bind any set of materials to any graph (unlimited, user-defined). 9 NPR graphs ship built-in (`face` / `hair` / `body` / `eye` / `stockings` / `metal` / `cloth_smooth` / `cloth_rough` / `default`); fully customizable — see [reze-design](https://reze.design) for the visual shader-graph editor
|
|
18
17
|
- **HDR pipeline** — bloom, Filmic tone mapping, 4× MSAA, Apple-TBDR-friendly targets
|
|
19
18
|
- **In-house TS physics** — sequential-impulse rigid bodies for PMX rigs, no external dependency
|
|
20
19
|
- **VMD animation** with MMD IK, morphs (GPU compute path), and VMD export
|
|
@@ -26,7 +25,7 @@ See [Physics](#physics) and [Rendering](#rendering) for the internals.
|
|
|
26
25
|
|
|
27
26
|
## Used by
|
|
28
27
|
|
|
29
|
-
- [Reze Design](https://reze.design) (web-native scene composer &
|
|
28
|
+
- [Reze Design](https://reze.design) (web-native scene composer & shader-graph styling)
|
|
30
29
|
- [Reze Studio](https://reze.studio) (MMD animation editor)
|
|
31
30
|
- [MiKaPo](https://mikapo.vercel.app) (motion capture)
|
|
32
31
|
- [Popo](https://popo.love) (LLM-generated poses)
|
|
@@ -48,8 +47,17 @@ engine/src/
|
|
|
48
47
|
pmx-loader.ts PMX parser: mesh, bones, morphs, rigid bodies, joints
|
|
49
48
|
vmd-loader.ts VMD motion parser · vmd-writer.ts VMD export (Shift-JIS)
|
|
50
49
|
asset-reader.ts URL + local-folder asset resolution · folder-upload.ts
|
|
50
|
+
tga-loader.ts TGA decoder (formats createImageBitmap can't read)
|
|
51
51
|
index.ts public exports
|
|
52
52
|
|
|
53
|
+
graph/ shader-graph → WGSL compiler — materials as data
|
|
54
|
+
schema.ts ShaderGraph / StyleGroup / param types + validation
|
|
55
|
+
registry.ts node registry (Blender node → WGSL) + socket conversions
|
|
56
|
+
compile.ts validate → prune → toposort → peephole → emit
|
|
57
|
+
render-class.ts RenderClass / AlphaMode + the RENDER_CLASSES manifest
|
|
58
|
+
slots.ts per-render-class fs() shell (stencil/alpha) around the graph body
|
|
59
|
+
presets/ the 9 built-in shader graphs (hair, face, eye, cloth, …)
|
|
60
|
+
|
|
53
61
|
physics/ in-house rigid-body solver (~2.5k lines)
|
|
54
62
|
physics.ts RezePhysics: bone↔body sync, fixed-step accumulator + interpolation
|
|
55
63
|
solver.ts sequential-impulse PGS (joint + contact rows)
|
|
@@ -58,8 +66,9 @@ engine/src/
|
|
|
58
66
|
body.ts SoA rigid-body store · types.ts
|
|
59
67
|
|
|
60
68
|
shaders/
|
|
61
|
-
materials/ nodes.ts (Blender-node WGSL library
|
|
62
|
-
|
|
69
|
+
materials/ nodes.ts (Blender-node WGSL library the graph compiler emits into) +
|
|
70
|
+
common.ts (bindings, skinning VS); the per-material .ts files are the
|
|
71
|
+
original hand shaders, kept as the graph-port reference
|
|
63
72
|
passes/ shadow, morph (GPU vertex-morph compute), bloom, composite (Filmic),
|
|
64
73
|
outline, selection, gizmo, pick, ground, mipmap
|
|
65
74
|
```
|
|
@@ -79,11 +88,11 @@ await engine.init()
|
|
|
79
88
|
|
|
80
89
|
const model = await engine.loadModel("reze", "/models/reze/reze.pmx")
|
|
81
90
|
|
|
82
|
-
// One-tap styling: bucket materials into the engine's built-in default
|
|
91
|
+
// One-tap styling: bucket materials into the engine's built-in default shader graphs
|
|
83
92
|
// (face / hair / eye / cloth / stockings / metal). These categories are just the shipped
|
|
84
93
|
// starter graphs — NOT fixed slots. `overrides` maps names the built-in JP/CN/EN hints
|
|
85
94
|
// miss; standard-named models need no map. Unmatched materials stay ungrouped (neutral).
|
|
86
|
-
// For arbitrary groups with any graph, use applyStyleGroups (see "
|
|
95
|
+
// For arbitrary groups with any graph, use applyStyleGroups (see "Shader graphs & style groups").
|
|
87
96
|
await engine.autoStyleGroups("reze", {
|
|
88
97
|
face: ["face01"],
|
|
89
98
|
body: ["skin"],
|
|
@@ -207,9 +216,9 @@ onGizmoDrag: (e) => {
|
|
|
207
216
|
|
|
208
217
|
Note the asymmetry: rotation goes through `rotateBones(…, 0)`, but translation uses `setBoneLocalTranslation(idx, v)` — `moveBones` converts VMD-relative→local, and the gizmo output is already local.
|
|
209
218
|
|
|
210
|
-
##
|
|
219
|
+
## Shader graphs & style groups
|
|
211
220
|
|
|
212
|
-
Materials are styled by **
|
|
221
|
+
Materials are styled by **shader graphs** — plain JSON (`ShaderGraph`) validated and compiled to WGSL at runtime. Node semantics are frozen **Blender 3.6 legacy-EEVEE**, so community Blender NPR presets port by transcription. Nine graphs ship built-in (`FACE_GRAPH`, `HAIR_GRAPH`, `BODY_GRAPH`, `EYE_GRAPH`, `METAL_GRAPH`, `STOCKINGS_GRAPH`, `CLOTH_SMOOTH_GRAPH`, `CLOTH_ROUGH_GRAPH`, `DEFAULT_GRAPH` — the neutral base) as a starter library; you can also author or import your own.
|
|
213
222
|
|
|
214
223
|
A **style group** binds `{ materials, graph, renderClass?, alphaMode? }` — a set of materials, the graph that shades them, and the engine's small pass-integration vocabulary (`renderClass`: `auto`/`eye`/`hair` for stencil/cull/draw-order; `alphaMode`: `opaque`/`hashed`). **Groups are user-defined and unlimited** — any materials, any graph. A graph is pure shading; `renderClass` carries the built-in effects (hair's over-eyes stencil, the eye see-through stamp), so any graph in an `eye`/`hair` group inherits them. **Every group needs a valid graph**; a material in no group renders the **neutral default** (`DEFAULT_GRAPH`).
|
|
215
224
|
|
|
@@ -255,20 +264,20 @@ Engine surface is just `setPhysicsEnabled` / `resetPhysics` — all tuning (mass
|
|
|
255
264
|
|
|
256
265
|
## Rendering
|
|
257
266
|
|
|
258
|
-
Each
|
|
267
|
+
Each built-in shader graph mixes an NPR stack with a Principled-style BSDF, so characters keep a flat illustrated look while highlights and reflections stay grounded. A graph compiles to a fragment shader following one 7-stage layout (node primitives from `nodes.ts`, the fs() shell from `common.ts`):
|
|
259
268
|
|
|
260
269
|
```
|
|
261
270
|
(A) setup → (B) texture + alpha → (C) NPR stack → (D) optional bump
|
|
262
271
|
→ (E) Principled BSDF → (F) NPR↔PBR mix → (G) FSOut
|
|
263
272
|
```
|
|
264
273
|
|
|
265
|
-
`default` uses only A/B/E/G; NPR
|
|
274
|
+
`default` uses only A/B/E/G; the NPR graphs add C (and sometimes D), with F choosing how NPR-leaning the result is.
|
|
266
275
|
|
|
267
276
|
- **PBR core** (`eval_principled`) — GGX + Schlick Fresnel, Walter–Smith G1, Fdez-Agüera 2019 multi-scatter, Karis split-sum DFG LUT, Heitz 2016 LTC direct-spec, optional sheen.
|
|
268
277
|
- **NPR toolbox** — toon ramps (constant / fwidth-AA'd), HSV warm-shadow / cool-light remaps, fresnel + layer-weight rims, value-noise bump, Voronoi metallic sparkle, BT.601-gated emission.
|
|
269
278
|
|
|
270
279
|
|
|
271
|
-
|
|
|
280
|
+
| Built-in graph | Notes |
|
|
272
281
|
| -------------- | ----------------------------------------------------------------------- |
|
|
273
282
|
| `default` | Plain Principled, metallic 0, rough 0.5 |
|
|
274
283
|
| `eye` | Plain + post-eval emission ×1.5 |
|
package/dist/graph/compile.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Diagnostic, ExposedParam,
|
|
1
|
+
import type { Diagnostic, ExposedParam, ShaderGraph } from "./schema";
|
|
2
2
|
import type { AlphaMode, RenderClass } from "./render-class";
|
|
3
3
|
export type CompileOptions = {
|
|
4
4
|
/** Fold exposed params to their defaults as consts (no StyleUniforms binding).
|
|
@@ -35,6 +35,6 @@ export type CompileResult = {
|
|
|
35
35
|
prunedNodes: string[];
|
|
36
36
|
};
|
|
37
37
|
export declare function assignStyleSlots(params: ExposedParam[]): StyleSlot[];
|
|
38
|
-
export declare function validateGraph(graph:
|
|
39
|
-
export declare function compileGraph(graph:
|
|
38
|
+
export declare function validateGraph(graph: ShaderGraph, opts?: CompileOptions): Diagnostic[];
|
|
39
|
+
export declare function compileGraph(graph: ShaderGraph, opts?: CompileOptions): CompileResult;
|
|
40
40
|
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -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,
|
|
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;AAI7F,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5D,MAAM,MAAM,cAAc,GAAG;IAC3B;8EAC0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;6DACyD;IACzD,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C;0EACsE;IACtE,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,wEAAwE;IACxE,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,CAAA;AAED,yFAAyF;AACzF,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,OAAO,GAAG,OAAO,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,OAAO,CAAA;IACX,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB,CAAA;AAcD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,CAuBpE;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,cAAmB,GAAG,UAAU,EAAE,CAqGzF;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,cAAmB,GAAG,aAAa,CA6JzF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const BODY_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const BODY_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/body.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/body.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,UAAU,EAAE,WA+FxB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Body as a
|
|
1
|
+
// M_Body as a ShaderGraph — port of shaders/materials/body.ts (仿深空之眼 "M_Body").
|
|
2
2
|
// Toon + warm rim + rim1/rim2 stack mixed 50/50 against a Principled BSDF with
|
|
3
3
|
// noise-bumped normal. The hand port's local ramp_ease is ramp_cardinal (identical
|
|
4
4
|
// smoothstep form); the Mapping node's zero loc/rot folds to a scale multiply.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const CLOTH_ROUGH_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const CLOTH_ROUGH_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=cloth_rough.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloth_rough.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/cloth_rough.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"cloth_rough.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/cloth_rough.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,iBAAiB,EAAE,WAwD/B,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Rough_Cloth as a
|
|
1
|
+
// M_Rough_Cloth as a ShaderGraph — port of shaders/materials/cloth_rough.ts.
|
|
2
2
|
// NPR graph identical to M_Smooth_Cloth, but the noise bump subtree IS live on
|
|
3
3
|
// Principled.Normal (weave bump in rest space) and Roughness is raised to 0.8187.
|
|
4
4
|
// The tex_noise node hits the detail=2 peephole → tex_noise_d2.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const CLOTH_SMOOTH_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const CLOTH_SMOOTH_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=cloth_smooth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloth_smooth.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/cloth_smooth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"cloth_smooth.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/cloth_smooth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,kBAAkB,EAAE,WAgDhC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Smooth_Cloth as a
|
|
1
|
+
// M_Smooth_Cloth as a ShaderGraph — port of shaders/materials/cloth_smooth.ts.
|
|
2
2
|
// NPR toon + bevel + overlay-boosted emission (18.2×) mixed 10/90 against a plain
|
|
3
3
|
// Principled BSDF. The Blender graph's dead bump subtree is omitted (as in the hand
|
|
4
4
|
// port). hue_sat nodes with hue=0.5 compile to the hue_sat_id specialization.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const DEFAULT_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const DEFAULT_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=default.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/default.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/default.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,aAAa,EAAE,WAoB3B,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const EYE_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const EYE_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=eye.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eye.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/eye.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"eye.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/eye.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,SAAS,EAAE,WAqBvB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Eye as a
|
|
1
|
+
// Eye as a ShaderGraph — port of shaders/materials/eye.ts. The published preset
|
|
2
2
|
// author's instruction: "keep eyes in the default nodegraph, add emission 1.5".
|
|
3
3
|
// So it's the default Principled BSDF plus an Emission of the diffuse texture at
|
|
4
4
|
// 1.5× (Blender's Principled Emission socket, decomposed as a separate Emission +
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const FACE_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const FACE_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=face.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"face.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/face.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"face.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/face.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,UAAU,EAAE,WA6HxB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Face as a
|
|
1
|
+
// M_Face as a ShaderGraph — port of shaders/materials/face.ts (仿深空之眼 "M_Face").
|
|
2
2
|
// Toon + warm rim + dual fresnel rim + BT.601 bright-tex gate, mixed 50/50 against a
|
|
3
3
|
// Principled BSDF with noise bump. Structurally close to body, but: the toon uses the
|
|
4
4
|
// edge-AA ramp, hue tints are 0.46 (full hue_sat, not the 0.5 _id specialization),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const HAIR_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const HAIR_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=hair.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hair.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/hair.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"hair.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/hair.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,UAAU,EAAE,WAmExB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Hair — 仿深空之眼渲染预设v1.0_by_小绿毛猫, as a
|
|
1
|
+
// M_Hair — 仿深空之眼渲染预设v1.0_by_小绿毛猫, as a ShaderGraph. Node ids mirror the
|
|
2
2
|
// Blender node names referenced in shaders/materials/hair.ts comments; compiled with
|
|
3
3
|
// { inlineParams: true } this graph must reproduce HAIR_SHADER_WGSL's fragment body
|
|
4
4
|
// (golden test #1 — see tests/graph.test.mjs).
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const METAL_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const METAL_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=metal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metal.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/metal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"metal.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/metal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,WAAW,EAAE,WAoDzB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Metal as a
|
|
1
|
+
// M_Metal as a ShaderGraph — port of shaders/materials/metal.ts.
|
|
2
2
|
// Metallic Principled (Metallic=1, Specular=1, Roughness=0.3) with a
|
|
3
3
|
// reflection-coord voronoi driving base color (metallic sparkle), plus an NPR
|
|
4
4
|
// toon/overlay emission stack mixed at Fac=0.6967. The voronoi Color→ramp Fac
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const STOCKINGS_GRAPH:
|
|
1
|
+
import type { ShaderGraph } from "../schema";
|
|
2
|
+
export declare const STOCKINGS_GRAPH: ShaderGraph;
|
|
3
3
|
//# sourceMappingURL=stockings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stockings.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/stockings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"stockings.d.ts","sourceRoot":"","sources":["../../../src/graph/presets/stockings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,eAAO,MAAM,eAAe,EAAE,WA8C7B,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Stockings as a
|
|
1
|
+
// M_Stockings as a ShaderGraph — port of shaders/materials/stockings.ts.
|
|
2
2
|
// A bbox-gradient × facing-rim mask drives a Mix Shader between an HSV-boosted
|
|
3
3
|
// emission (val 5×) and a sheen Principled. The hashed-alpha discard and the
|
|
4
4
|
// alpha=1 output are slot-owned (see STOCKINGS_TEMPLATE in slots.ts) — the graph
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Render-class + alpha-mode: the small, closed, engine-owned vocabularies that carry
|
|
2
|
-
// pass integration for a style group. A group's
|
|
2
|
+
// pass integration for a style group. A group's shader graph is pure shading; these select
|
|
3
3
|
// how the engine wires that shading into the passes. Not user-extensible — this is where
|
|
4
4
|
// rendering correctness lives (stencil, cull, draw order, alpha test). See
|
|
5
5
|
// docs/style-groups-spec.md §5.
|
package/dist/graph/schema.d.ts
CHANGED
|
@@ -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;IACZ,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACpC;mFAC+E;IAC/E,EAAE,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,E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ts.
|
|
2
2
|
// Engine-space (LH, Y-up): porting a Blender graph converts coordinates at authoring
|
|
3
3
|
// time (Blender Normal Z → engine Y), the compiler never sees Blender conventions.
|
|
4
4
|
// See docs/graph-compiler-spec.md.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Diagnostic,
|
|
1
|
+
import type { Diagnostic, ShaderGraph } from "./schema";
|
|
2
2
|
import type { AlphaMode, RenderClass } from "./render-class";
|
|
3
3
|
import type { StyleSlot } from "./compile";
|
|
4
4
|
export type StyleGroup = {
|
|
@@ -9,8 +9,8 @@ export type StyleGroup = {
|
|
|
9
9
|
label?: string;
|
|
10
10
|
/** Material names in this group; each material is in AT MOST one group. */
|
|
11
11
|
materials: string[];
|
|
12
|
-
/** Pure shading (
|
|
13
|
-
graph:
|
|
12
|
+
/** Pure shading (ShaderGraph has no `slot` — integration lives here on the group). */
|
|
13
|
+
graph: ShaderGraph;
|
|
14
14
|
/** Pass-integration class: stencil/cull/draw-order. Default "auto". */
|
|
15
15
|
renderClass?: RenderClass;
|
|
16
16
|
/** Alpha-handling axis, orthogonal to renderClass. Default "opaque". */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-group.d.ts","sourceRoot":"","sources":["../../src/graph/style-group.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"style-group.d.ts","sourceRoot":"","sources":["../../src/graph/style-group.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,MAAM,MAAM,UAAU,GAAG;IACvB,wFAAwF;IACxF,EAAE,EAAE,MAAM,CAAA;IACV;2CACuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2EAA2E;IAC3E,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,sFAAsF;IACtF,KAAK,EAAE,WAAW,CAAA;IAClB,uEAAuE;IACvE,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,wEAAwE;IACxE,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,CAAA;AAEzF,MAAM,MAAM,sBAAsB,GAAG;IACnC,sCAAsC;IACtC,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,iEAAiE;IACjE,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kFAAkF;IAClF,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAA;CAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Style groups — the user-facing unit of material styling. A group binds a set of
|
|
2
|
-
// materials to a
|
|
2
|
+
// materials to a shader graph (pure shading) plus the engine-owned pass-integration axes
|
|
3
3
|
// (renderClass + alphaMode). Each material belongs to at most one group; grouped
|
|
4
4
|
// materials render via the group's compiled-graph pipeline, ungrouped ones fall back to
|
|
5
5
|
// the hand-written preset path. See docs/style-groups-spec.md.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Engine, DEFAULT_BLOOM_OPTIONS, DEFAULT_VIEW_TRANSFORM, type EngineStats, type EngineOptions, type BloomOptions, type ViewTransformOptions, type LoadModelFromFilesOptions, type MaterialPreset, type ResolvedMaterialPreset, type MaterialPresetMap, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, } from "./engine";
|
|
2
2
|
export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload";
|
|
3
3
|
export { compileGraph, validateGraph, assignStyleSlots, type CompileOptions, type CompileResult, type StyleSlot, } from "./graph/compile";
|
|
4
|
-
export type {
|
|
4
|
+
export type { ShaderGraph, GraphNode, GraphLink, ExposedParam, SocketValue, Diagnostic, } from "./graph/schema";
|
|
5
5
|
export { NODE_REGISTRY, type NodeSpec, type SockT } from "./graph/registry";
|
|
6
6
|
export { RENDER_CLASSES, type RenderClass, type AlphaMode, type RenderClassInfo } from "./graph/render-class";
|
|
7
7
|
export type { StyleGroup, GroupDiagnostic, ApplyStyleGroupsResult, ApplyStyleGroupResult, } from "./graph/style-group";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACvG,OAAO,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB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E,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACzC,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA"}
|
package/package.json
CHANGED
package/src/engine.ts
CHANGED
|
@@ -31,7 +31,7 @@ import { COMPOSITE_SHADER_WGSL } from "./shaders/passes/composite"
|
|
|
31
31
|
import { PICK_SHADER_WGSL } from "./shaders/passes/pick"
|
|
32
32
|
import { MIPMAP_BLIT_SHADER_WGSL } from "./shaders/passes/mipmap"
|
|
33
33
|
import { compileGraph, type CompileOptions, type StyleSlot } from "./graph/compile"
|
|
34
|
-
import type { Diagnostic,
|
|
34
|
+
import type { Diagnostic, ShaderGraph } from "./graph/schema"
|
|
35
35
|
import type { AlphaMode, RenderClass } from "./graph/render-class"
|
|
36
36
|
import type {
|
|
37
37
|
ApplyStyleGroupResult,
|
|
@@ -136,7 +136,7 @@ function resolvePreset(materialName: string, map: MaterialPresetMap | undefined)
|
|
|
136
136
|
// (renderClass, alphaMode). This is the auto-default-groups mapping (docs §8) — the same
|
|
137
137
|
// label→integration knowledge the old fixed slots encoded, now producing editable groups.
|
|
138
138
|
// mmd_classic has no entry — those materials stay ungrouped (hand-shader path).
|
|
139
|
-
const PRESET_GROUP_INFO: Partial<Record<MaterialPreset, { graph:
|
|
139
|
+
const PRESET_GROUP_INFO: Partial<Record<MaterialPreset, { graph: ShaderGraph; renderClass: RenderClass; alphaMode: AlphaMode }>> = {
|
|
140
140
|
default: { graph: DEFAULT_GRAPH, renderClass: "auto", alphaMode: "opaque" },
|
|
141
141
|
face: { graph: FACE_GRAPH, renderClass: "auto", alphaMode: "opaque" },
|
|
142
142
|
hair: { graph: HAIR_GRAPH, renderClass: "hair", alphaMode: "opaque" },
|
package/src/graph/compile.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// See docs/graph-compiler-spec.md.
|
|
5
5
|
|
|
6
6
|
import { MAX_NODES, MAX_PARAMS } from "./schema"
|
|
7
|
-
import type { Diagnostic, ExposedParam, GraphNode, SocketValue,
|
|
7
|
+
import type { Diagnostic, ExposedParam, GraphNode, SocketValue, ShaderGraph } from "./schema"
|
|
8
8
|
import { NODE_REGISTRY, canConvert, convert, fmtValue, literalFits } from "./registry"
|
|
9
9
|
import type { NodeSpec, SockT } from "./registry"
|
|
10
10
|
import { assembleModule } from "./slots"
|
|
@@ -83,7 +83,7 @@ export function assignStyleSlots(params: ExposedParam[]): StyleSlot[] {
|
|
|
83
83
|
|
|
84
84
|
// ─── Validation ─────────────────────────────────────────────────────
|
|
85
85
|
|
|
86
|
-
export function validateGraph(graph:
|
|
86
|
+
export function validateGraph(graph: ShaderGraph, opts: CompileOptions = {}): Diagnostic[] {
|
|
87
87
|
const d: Diagnostic[] = []
|
|
88
88
|
const nodes = new Map<string, GraphNode>()
|
|
89
89
|
|
|
@@ -188,7 +188,7 @@ export function validateGraph(graph: StyleGraph, opts: CompileOptions = {}): Dia
|
|
|
188
188
|
|
|
189
189
|
// ─── Compile ────────────────────────────────────────────────────────
|
|
190
190
|
|
|
191
|
-
export function compileGraph(graph:
|
|
191
|
+
export function compileGraph(graph: ShaderGraph, opts: CompileOptions = {}): CompileResult {
|
|
192
192
|
const fail = (diagnostics: Diagnostic[]): CompileResult => ({
|
|
193
193
|
ok: false,
|
|
194
194
|
wgsl: "",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// M_Body as a
|
|
1
|
+
// M_Body as a ShaderGraph — port of shaders/materials/body.ts (仿深空之眼 "M_Body").
|
|
2
2
|
// Toon + warm rim + rim1/rim2 stack mixed 50/50 against a Principled BSDF with
|
|
3
3
|
// noise-bumped normal. The hand port's local ramp_ease is ramp_cardinal (identical
|
|
4
4
|
// smoothstep form); the Mapping node's zero loc/rot folds to a scale multiply.
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { ShaderGraph } from "../schema"
|
|
7
7
|
|
|
8
|
-
export const BODY_GRAPH:
|
|
8
|
+
export const BODY_GRAPH: ShaderGraph = {
|
|
9
9
|
version: 1,
|
|
10
10
|
name: "Body",
|
|
11
11
|
tags: ["body"],
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// M_Rough_Cloth as a
|
|
1
|
+
// M_Rough_Cloth as a ShaderGraph — port of shaders/materials/cloth_rough.ts.
|
|
2
2
|
// NPR graph identical to M_Smooth_Cloth, but the noise bump subtree IS live on
|
|
3
3
|
// Principled.Normal (weave bump in rest space) and Roughness is raised to 0.8187.
|
|
4
4
|
// The tex_noise node hits the detail=2 peephole → tex_noise_d2.
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { ShaderGraph } from "../schema"
|
|
7
7
|
|
|
8
|
-
export const CLOTH_ROUGH_GRAPH:
|
|
8
|
+
export const CLOTH_ROUGH_GRAPH: ShaderGraph = {
|
|
9
9
|
version: 1,
|
|
10
10
|
name: "Rough Cloth",
|
|
11
11
|
tags: ["cloth_rough"],
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// M_Smooth_Cloth as a
|
|
1
|
+
// M_Smooth_Cloth as a ShaderGraph — port of shaders/materials/cloth_smooth.ts.
|
|
2
2
|
// NPR toon + bevel + overlay-boosted emission (18.2×) mixed 10/90 against a plain
|
|
3
3
|
// Principled BSDF. The Blender graph's dead bump subtree is omitted (as in the hand
|
|
4
4
|
// port). hue_sat nodes with hue=0.5 compile to the hue_sat_id specialization.
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { ShaderGraph } from "../schema"
|
|
7
7
|
|
|
8
|
-
export const CLOTH_SMOOTH_GRAPH:
|
|
8
|
+
export const CLOTH_SMOOTH_GRAPH: ShaderGraph = {
|
|
9
9
|
version: 1,
|
|
10
10
|
name: "Smooth Cloth",
|
|
11
11
|
tags: ["cloth_smooth"],
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
// The material-color multiply is what keeps untextured/solid-color materials from
|
|
6
6
|
// rendering white (they carry their color in material.diffuse, not a texture).
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { ShaderGraph } from "../schema"
|
|
9
9
|
|
|
10
|
-
export const DEFAULT_GRAPH:
|
|
10
|
+
export const DEFAULT_GRAPH: ShaderGraph = {
|
|
11
11
|
version: 1,
|
|
12
12
|
name: "Principled BSDF",
|
|
13
13
|
tags: ["default"],
|
package/src/graph/presets/eye.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Eye as a
|
|
1
|
+
// Eye as a ShaderGraph — port of shaders/materials/eye.ts. The published preset
|
|
2
2
|
// author's instruction: "keep eyes in the default nodegraph, add emission 1.5".
|
|
3
3
|
// So it's the default Principled BSDF plus an Emission of the diffuse texture at
|
|
4
4
|
// 1.5× (Blender's Principled Emission socket, decomposed as a separate Emission +
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
// The rear-view gate and the see-through stencil stamp are slot-owned (built-in eye
|
|
8
8
|
// behavior, see EYE_TEMPLATE in slots.ts + createSlotPipeline) — not in this graph.
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { ShaderGraph } from "../schema"
|
|
11
11
|
|
|
12
|
-
export const EYE_GRAPH:
|
|
12
|
+
export const EYE_GRAPH: ShaderGraph = {
|
|
13
13
|
version: 1,
|
|
14
14
|
name: "Eye",
|
|
15
15
|
tags: ["eye"],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Face as a
|
|
1
|
+
// M_Face as a ShaderGraph — port of shaders/materials/face.ts (仿深空之眼 "M_Face").
|
|
2
2
|
// Toon + warm rim + dual fresnel rim + BT.601 bright-tex gate, mixed 50/50 against a
|
|
3
3
|
// Principled BSDF with noise bump. Structurally close to body, but: the toon uses the
|
|
4
4
|
// edge-AA ramp, hue tints are 0.46 (full hue_sat, not the 0.5 _id specialization),
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// near-white texture gate that emits (freckle/highlight paint). Plain material — no
|
|
7
7
|
// built-in slot effect, so it uses the default prelude/epilogue.
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { ShaderGraph } from "../schema"
|
|
10
10
|
|
|
11
|
-
export const FACE_GRAPH:
|
|
11
|
+
export const FACE_GRAPH: ShaderGraph = {
|
|
12
12
|
version: 1,
|
|
13
13
|
name: "Face",
|
|
14
14
|
tags: ["face"],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Hair — 仿深空之眼渲染预设v1.0_by_小绿毛猫, as a
|
|
1
|
+
// M_Hair — 仿深空之眼渲染预设v1.0_by_小绿毛猫, as a ShaderGraph. Node ids mirror the
|
|
2
2
|
// Blender node names referenced in shaders/materials/hair.ts comments; compiled with
|
|
3
3
|
// { inlineParams: true } this graph must reproduce HAIR_SHADER_WGSL's fragment body
|
|
4
4
|
// (golden test #1 — see tests/graph.test.mjs).
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
// The object is pure JSON (no functions/undefined) — JSON.stringify round-trips it,
|
|
11
11
|
// which is how reze.design will ship additional presets.
|
|
12
12
|
|
|
13
|
-
import type {
|
|
13
|
+
import type { ShaderGraph } from "../schema"
|
|
14
14
|
|
|
15
|
-
export const HAIR_GRAPH:
|
|
15
|
+
export const HAIR_GRAPH: ShaderGraph = {
|
|
16
16
|
version: 1,
|
|
17
17
|
name: "Hair",
|
|
18
18
|
tags: ["hair"],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// M_Metal as a
|
|
1
|
+
// M_Metal as a ShaderGraph — port of shaders/materials/metal.ts.
|
|
2
2
|
// Metallic Principled (Metallic=1, Specular=1, Roughness=0.3) with a
|
|
3
3
|
// reflection-coord voronoi driving base color (metallic sparkle), plus an NPR
|
|
4
4
|
// toon/overlay emission stack mixed at Fac=0.6967. The voronoi Color→ramp Fac
|
|
5
5
|
// link goes through Blender's implicit BT.601 conversion (color_to_value).
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { ShaderGraph } from "../schema"
|
|
8
8
|
|
|
9
|
-
export const METAL_GRAPH:
|
|
9
|
+
export const METAL_GRAPH: ShaderGraph = {
|
|
10
10
|
version: 1,
|
|
11
11
|
name: "Metal",
|
|
12
12
|
tags: ["metal"],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// M_Stockings as a
|
|
1
|
+
// M_Stockings as a ShaderGraph — port of shaders/materials/stockings.ts.
|
|
2
2
|
// A bbox-gradient × facing-rim mask drives a Mix Shader between an HSV-boosted
|
|
3
3
|
// emission (val 5×) and a sheen Principled. The hashed-alpha discard and the
|
|
4
4
|
// alpha=1 output are slot-owned (see STOCKINGS_TEMPLATE in slots.ts) — the graph
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// as in the hand port. The grayscale mask feeds Mix Shader Fac through Blender's
|
|
7
7
|
// implicit BT.601 color→float conversion (equal-component vector → same scalar).
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { ShaderGraph } from "../schema"
|
|
10
10
|
|
|
11
|
-
export const STOCKINGS_GRAPH:
|
|
11
|
+
export const STOCKINGS_GRAPH: ShaderGraph = {
|
|
12
12
|
version: 1,
|
|
13
13
|
name: "Stockings",
|
|
14
14
|
tags: ["stockings"],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Render-class + alpha-mode: the small, closed, engine-owned vocabularies that carry
|
|
2
|
-
// pass integration for a style group. A group's
|
|
2
|
+
// pass integration for a style group. A group's shader graph is pure shading; these select
|
|
3
3
|
// how the engine wires that shading into the passes. Not user-extensible — this is where
|
|
4
4
|
// rendering correctness lives (stencil, cull, draw order, alpha test). See
|
|
5
5
|
// docs/style-groups-spec.md §5.
|
package/src/graph/schema.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ShaderGraph — a JSON-serializable graph of shading nodes, compiled to WGSL by compile.ts.
|
|
2
2
|
// Engine-space (LH, Y-up): porting a Blender graph converts coordinates at authoring
|
|
3
3
|
// time (Blender Normal Z → engine Y), the compiler never sees Blender conventions.
|
|
4
4
|
// See docs/graph-compiler-spec.md.
|
|
@@ -34,7 +34,7 @@ export type ExposedParam = {
|
|
|
34
34
|
default: SocketValue
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export type
|
|
37
|
+
export type ShaderGraph = {
|
|
38
38
|
version: 1
|
|
39
39
|
name: string
|
|
40
40
|
nodes: GraphNode[]
|
package/src/graph/style-group.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Style groups — the user-facing unit of material styling. A group binds a set of
|
|
2
|
-
// materials to a
|
|
2
|
+
// materials to a shader graph (pure shading) plus the engine-owned pass-integration axes
|
|
3
3
|
// (renderClass + alphaMode). Each material belongs to at most one group; grouped
|
|
4
4
|
// materials render via the group's compiled-graph pipeline, ungrouped ones fall back to
|
|
5
5
|
// the hand-written preset path. See docs/style-groups-spec.md.
|
|
6
6
|
|
|
7
|
-
import type { Diagnostic,
|
|
7
|
+
import type { Diagnostic, ShaderGraph } from "./schema"
|
|
8
8
|
import type { AlphaMode, RenderClass } from "./render-class"
|
|
9
9
|
import type { StyleSlot } from "./compile"
|
|
10
10
|
|
|
@@ -16,8 +16,8 @@ export type StyleGroup = {
|
|
|
16
16
|
label?: string
|
|
17
17
|
/** Material names in this group; each material is in AT MOST one group. */
|
|
18
18
|
materials: string[]
|
|
19
|
-
/** Pure shading (
|
|
20
|
-
graph:
|
|
19
|
+
/** Pure shading (ShaderGraph has no `slot` — integration lives here on the group). */
|
|
20
|
+
graph: ShaderGraph
|
|
21
21
|
/** Pass-integration class: stencil/cull/draw-order. Default "auto". */
|
|
22
22
|
renderClass?: RenderClass
|
|
23
23
|
/** Alpha-handling axis, orthogonal to renderClass. Default "opaque". */
|
package/src/index.ts
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
export {
|
|
2
|
-
Engine,
|
|
3
|
-
DEFAULT_BLOOM_OPTIONS,
|
|
4
|
-
DEFAULT_VIEW_TRANSFORM,
|
|
5
|
-
type EngineStats,
|
|
6
|
-
type EngineOptions,
|
|
7
|
-
type BloomOptions,
|
|
8
|
-
type ViewTransformOptions,
|
|
9
|
-
type LoadModelFromFilesOptions,
|
|
10
|
-
type MaterialPreset,
|
|
11
|
-
type ResolvedMaterialPreset,
|
|
12
|
-
type MaterialPresetMap,
|
|
13
|
-
type GizmoDragEvent,
|
|
14
|
-
type GizmoDragCallback,
|
|
15
|
-
type GizmoDragKind,
|
|
16
|
-
} from "./engine"
|
|
17
|
-
export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload"
|
|
18
|
-
export {
|
|
19
|
-
compileGraph,
|
|
20
|
-
validateGraph,
|
|
21
|
-
assignStyleSlots,
|
|
22
|
-
type CompileOptions,
|
|
23
|
-
type CompileResult,
|
|
24
|
-
type StyleSlot,
|
|
25
|
-
} from "./graph/compile"
|
|
26
|
-
export type {
|
|
27
|
-
|
|
28
|
-
GraphNode,
|
|
29
|
-
GraphLink,
|
|
30
|
-
ExposedParam,
|
|
31
|
-
SocketValue,
|
|
32
|
-
Diagnostic,
|
|
33
|
-
} from "./graph/schema"
|
|
34
|
-
export { NODE_REGISTRY, type NodeSpec, type SockT } from "./graph/registry"
|
|
35
|
-
export { RENDER_CLASSES, type RenderClass, type AlphaMode, type RenderClassInfo } from "./graph/render-class"
|
|
36
|
-
export type {
|
|
37
|
-
StyleGroup,
|
|
38
|
-
GroupDiagnostic,
|
|
39
|
-
ApplyStyleGroupsResult,
|
|
40
|
-
ApplyStyleGroupResult,
|
|
41
|
-
} from "./graph/style-group"
|
|
42
|
-
export { HAIR_GRAPH } from "./graph/presets/hair"
|
|
43
|
-
export { DEFAULT_GRAPH } from "./graph/presets/default"
|
|
44
|
-
export { CLOTH_SMOOTH_GRAPH } from "./graph/presets/cloth_smooth"
|
|
45
|
-
export { CLOTH_ROUGH_GRAPH } from "./graph/presets/cloth_rough"
|
|
46
|
-
export { METAL_GRAPH } from "./graph/presets/metal"
|
|
47
|
-
export { BODY_GRAPH } from "./graph/presets/body"
|
|
48
|
-
export { STOCKINGS_GRAPH } from "./graph/presets/stockings"
|
|
49
|
-
export { EYE_GRAPH } from "./graph/presets/eye"
|
|
50
|
-
export { FACE_GRAPH } from "./graph/presets/face"
|
|
51
|
-
export { Model } from "./model"
|
|
52
|
-
export { Vec3, Quat, Mat4 } from "./math"
|
|
53
|
-
export type {
|
|
54
|
-
AnimationClip,
|
|
55
|
-
AnimationPlayOptions,
|
|
56
|
-
AnimationProgress,
|
|
57
|
-
BoneKeyframe,
|
|
58
|
-
MorphKeyframe,
|
|
59
|
-
BoneInterpolation,
|
|
60
|
-
ControlPoint,
|
|
61
|
-
} from "./animation"
|
|
62
|
-
export { FPS } from "./animation"
|
|
1
|
+
export {
|
|
2
|
+
Engine,
|
|
3
|
+
DEFAULT_BLOOM_OPTIONS,
|
|
4
|
+
DEFAULT_VIEW_TRANSFORM,
|
|
5
|
+
type EngineStats,
|
|
6
|
+
type EngineOptions,
|
|
7
|
+
type BloomOptions,
|
|
8
|
+
type ViewTransformOptions,
|
|
9
|
+
type LoadModelFromFilesOptions,
|
|
10
|
+
type MaterialPreset,
|
|
11
|
+
type ResolvedMaterialPreset,
|
|
12
|
+
type MaterialPresetMap,
|
|
13
|
+
type GizmoDragEvent,
|
|
14
|
+
type GizmoDragCallback,
|
|
15
|
+
type GizmoDragKind,
|
|
16
|
+
} from "./engine"
|
|
17
|
+
export { parsePmxFolderInput, pmxFileAtRelativePath, type PmxFolderInputResult } from "./folder-upload"
|
|
18
|
+
export {
|
|
19
|
+
compileGraph,
|
|
20
|
+
validateGraph,
|
|
21
|
+
assignStyleSlots,
|
|
22
|
+
type CompileOptions,
|
|
23
|
+
type CompileResult,
|
|
24
|
+
type StyleSlot,
|
|
25
|
+
} from "./graph/compile"
|
|
26
|
+
export type {
|
|
27
|
+
ShaderGraph,
|
|
28
|
+
GraphNode,
|
|
29
|
+
GraphLink,
|
|
30
|
+
ExposedParam,
|
|
31
|
+
SocketValue,
|
|
32
|
+
Diagnostic,
|
|
33
|
+
} from "./graph/schema"
|
|
34
|
+
export { NODE_REGISTRY, type NodeSpec, type SockT } from "./graph/registry"
|
|
35
|
+
export { RENDER_CLASSES, type RenderClass, type AlphaMode, type RenderClassInfo } from "./graph/render-class"
|
|
36
|
+
export type {
|
|
37
|
+
StyleGroup,
|
|
38
|
+
GroupDiagnostic,
|
|
39
|
+
ApplyStyleGroupsResult,
|
|
40
|
+
ApplyStyleGroupResult,
|
|
41
|
+
} from "./graph/style-group"
|
|
42
|
+
export { HAIR_GRAPH } from "./graph/presets/hair"
|
|
43
|
+
export { DEFAULT_GRAPH } from "./graph/presets/default"
|
|
44
|
+
export { CLOTH_SMOOTH_GRAPH } from "./graph/presets/cloth_smooth"
|
|
45
|
+
export { CLOTH_ROUGH_GRAPH } from "./graph/presets/cloth_rough"
|
|
46
|
+
export { METAL_GRAPH } from "./graph/presets/metal"
|
|
47
|
+
export { BODY_GRAPH } from "./graph/presets/body"
|
|
48
|
+
export { STOCKINGS_GRAPH } from "./graph/presets/stockings"
|
|
49
|
+
export { EYE_GRAPH } from "./graph/presets/eye"
|
|
50
|
+
export { FACE_GRAPH } from "./graph/presets/face"
|
|
51
|
+
export { Model } from "./model"
|
|
52
|
+
export { Vec3, Quat, Mat4 } from "./math"
|
|
53
|
+
export type {
|
|
54
|
+
AnimationClip,
|
|
55
|
+
AnimationPlayOptions,
|
|
56
|
+
AnimationProgress,
|
|
57
|
+
BoneKeyframe,
|
|
58
|
+
MorphKeyframe,
|
|
59
|
+
BoneInterpolation,
|
|
60
|
+
ControlPoint,
|
|
61
|
+
} from "./animation"
|
|
62
|
+
export { FPS } from "./animation"
|
|
63
63
|
export { RezePhysics } from "./physics"
|