reze-engine 0.69.8 → 0.69.9

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.
@@ -12,52 +12,52 @@ import { sceneIdWriteWgsl } from "../shaders/passes/scene-contract";
12
12
  // ── Module-scope declarations ──
13
13
  // hair: the over-eyes pipeline-override constant (a second pipeline is compiled with
14
14
  // IS_OVER_EYES=1). hashed: the Wyman & McGuire object-space hashed-alpha helpers.
15
- const HAIR_OVER_EYES_DECL = `override IS_OVER_EYES: bool = false;
16
-
15
+ const HAIR_OVER_EYES_DECL = `override IS_OVER_EYES: bool = false;
16
+
17
17
  `;
18
- const HASHED_ALPHA_DECLS = `fn _hash3d_wm(a: vec3f) -> f32 {
19
- return _hash33(a).x * 0.5 + 0.5;
20
- }
21
- fn hashed_alpha_threshold(co: vec3f) -> f32 {
22
- let alphaHashScale: f32 = 1.0;
23
- let max_deriv = max(length(dpdx(co)), length(dpdy(co)));
24
- let pix_scale = 1.0 / max(alphaHashScale * max_deriv, 1e-6);
25
- let pix_scale_log = log2(pix_scale);
26
- let px_lo = exp2(floor(pix_scale_log));
27
- let px_hi = exp2(ceil(pix_scale_log));
28
- let a_lo = _hash3d_wm(floor(px_lo * co));
29
- let a_hi = _hash3d_wm(floor(px_hi * co));
30
- let fac = fract(pix_scale_log);
31
- let x = mix(a_lo, a_hi, fac);
32
- let a = min(fac, 1.0 - fac);
33
- let one_a = 1.0 - a;
34
- let denom = 1.0 / max(2.0 * a * one_a, 1e-6);
35
- let one_x = 1.0 - x;
36
- let case_lo = (x * x) * denom;
37
- let case_mid = (x - 0.5 * a) / max(one_a, 1e-6);
38
- let case_hi = 1.0 - (one_x * one_x) * denom;
39
- var threshold = select(case_hi, select(case_lo, case_mid, x >= a), x < one_a);
40
- return clamp(threshold, 1e-6, 1.0);
41
- }
42
-
18
+ const HASHED_ALPHA_DECLS = `fn _hash3d_wm(a: vec3f) -> f32 {
19
+ return _hash33(a).x * 0.5 + 0.5;
20
+ }
21
+ fn hashed_alpha_threshold(co: vec3f) -> f32 {
22
+ let alphaHashScale: f32 = 1.0;
23
+ let max_deriv = max(length(dpdx(co)), length(dpdy(co)));
24
+ let pix_scale = 1.0 / max(alphaHashScale * max_deriv, 1e-6);
25
+ let pix_scale_log = log2(pix_scale);
26
+ let px_lo = exp2(floor(pix_scale_log));
27
+ let px_hi = exp2(ceil(pix_scale_log));
28
+ let a_lo = _hash3d_wm(floor(px_lo * co));
29
+ let a_hi = _hash3d_wm(floor(px_hi * co));
30
+ let fac = fract(pix_scale_log);
31
+ let x = mix(a_lo, a_hi, fac);
32
+ let a = min(fac, 1.0 - fac);
33
+ let one_a = 1.0 - a;
34
+ let denom = 1.0 / max(2.0 * a * one_a, 1e-6);
35
+ let one_x = 1.0 - x;
36
+ let case_lo = (x * x) * denom;
37
+ let case_mid = (x - 0.5 * a) / max(one_a, 1e-6);
38
+ let case_hi = 1.0 - (one_x * one_x) * denom;
39
+ var threshold = select(case_hi, select(case_lo, case_mid, x >= a), x < one_a);
40
+ return clamp(threshold, 1e-6, 1.0);
41
+ }
42
+
43
43
  `;
44
44
  // Eye's built-in rear-view gate (open-shell PMX heads don't occlude the eye from behind,
45
45
  // so gate by camera-vs-face hemisphere via the 頭 bone; discard drops color + depth +
46
46
  // the stencil stamp together). Injected between the view vectors and the lighting setup.
47
- const EYE_REAR_GATE = `
48
- if (material.headBoneIndex >= 0.0) {
49
- let hm = skinMats[u32(material.headBoneIndex)];
50
- let faceDir = -normalize(hm[2].xyz);
51
- if (dot(faceDir, v) < -0.15) { discard; }
52
- }
47
+ const EYE_REAR_GATE = `
48
+ if (material.headBoneIndex >= 0.0) {
49
+ let hm = skinMats[u32(material.headBoneIndex)];
50
+ let faceDir = -normalize(hm[2].xyz);
51
+ if (dot(faceDir, v) < -0.15) { discard; }
52
+ }
53
53
  `;
54
- const PLAIN_SAMPLE = ` let tex_s = textureSample(diffuseTexture, diffuseSampler, input.uv);
54
+ const PLAIN_SAMPLE = ` let tex_s = textureSample(diffuseTexture, diffuseSampler, input.uv);
55
55
  `;
56
56
  // ── Adjust-tier uniforms — fixed 16-vec4f block (256 B) shared by the single material
57
57
  // bind group layout; non-graph draws bind a zero buffer. ──
58
- const STYLE_UNIFORMS_WGSL = `struct StyleUniforms { p: array<vec4f, 16> };
59
- @group(2) @binding(4) var<uniform> style: StyleUniforms;
60
-
58
+ const STYLE_UNIFORMS_WGSL = `struct StyleUniforms { p: array<vec4f, 16> };
59
+ @group(2) @binding(4) var<uniform> style: StyleUniforms;
60
+
61
61
  `;
62
62
  function decls(renderClass, alphaMode) {
63
63
  // The dissolve helpers are ALWAYS declared, unlike the hashed-alpha ones.
@@ -93,68 +93,68 @@ function prelude(renderClass, alphaMode, blend) {
93
93
  // shading near-black through sheer outer layers. Eye is exempt: its normals
94
94
  // shade as authored.
95
95
  const flip = renderClass === "eye" ? "" : "\n n = select(-n, n, dot(n, v) >= 0.0);";
96
- return `@fragment fn fs(input: VertexOutput) -> FSOut {
97
- ${PLAIN_SAMPLE} // The see-through window (#xray): her clothes are not drawn inside it.
98
- if (rz_xray_cut(input.position, material.materialId)) { discard; }
99
- // MMD alpha semantics: material alpha × texture alpha, capped at 1 as MMD
100
- // does (a PMX can author alpha above 1; blended, it burns the material white).
101
- let alpha = saturate(material.alpha * tex_s.a);
102
- ${discard}
103
-
104
- // ── Dissolve ──
105
- //
106
- // A fragment is either THERE or it is not: the flake is thrown away rather
107
- // than faded. A fade would be an opacity slider — she would go see-through
108
- // and you would read the wall through her hair — while a threshold takes her
109
- // apart in pieces, which is the thing being asked for. The depth prepass runs
110
- // this identical test (rz_dissolve_threshold, shared), so depth and colour
111
- // agree about which pieces are gone.
112
- //
113
- // The surviving edge glows: fragments within RZ_DISSOLVE_EDGE of the front
114
- // are the ones about to go, and lighting them is what makes the boundary read
115
- // as burning away rather than as a stencil moving over her.
116
- var rz_burn = 0.0;
117
- if (material.dissolve < 0.9995) {
118
- // PER FRAGMENT, from the bind-pose position: the pieces are the noise's,
119
- // grit inside clumps, never the mesh's triangles, so a large face comes
120
- // apart as finely as a small one. The prepass, the shadow map and the
121
- // outline hull run the same function on the same interpolated input, so
122
- // every pass agrees about which flakes are gone.
123
- let rz_t = rz_dissolve_threshold(input.restPos);
124
- if (rz_t > material.dissolve) { discard; }
125
- // Put OUT as the last of her goes. Near zero the front is wider than what
126
- // is left of the surface, so every surviving fragment sits inside it and
127
- // the final scraps are pure glow — a body that ends as a handful of white
128
- // specks rather than as a body. The taper costs nothing while she is mostly
129
- // there, because it is already 1 by a fifth of the way in.
130
- rz_burn = smoothstep(material.dissolve - RZ_DISSOLVE_EDGE, material.dissolve, rz_t)
131
- * smoothstep(0.0, 0.22, material.dissolve);
132
- }
133
-
134
- var n = safe_normal(input.normal);
135
- let v = normalize(camera.viewPos - input.worldPos);${flip}
136
- ${gate}
137
- // The key: the directional light this draw's layers take — the sun unless a
138
- // light on its own layer stands in. The shadow stays the sun's atlas, as the
139
- // game keeps the scene's shadow under a character's own key.
140
- let rz_key = rzMainLight();
141
- let l = -light.lights[rz_key].direction.xyz;
142
- // NO KEY WHERE NONE REACHES: rzMainLight falls back to the sun's slot, and
143
- // a sun kept off this draw's layers — the cast's alone, beside a stage lit
144
- // only by its own lamps — must not light it through the fallback.
145
- let rz_keyed = (light.dirLayers[rz_key] & objectLight.layers.x) != 0u;
146
- let sun = select(vec3f(0.0), light.lights[rz_key].color.xyz * light.lights[rz_key].color.w, rz_keyed);
147
- // Lit through the see-through window: what it reveals would otherwise wear
148
- // the shadow of the clothes it cut, which reads as dirt rather than as cloth.
149
- let shadow = select(sampleShadow(input.worldPos, n), 1.0, rz_xray_inside(input.position));
150
- // The ambient: this object's own where loaded data gave it one — the game
151
- // gives every renderer its own — else the world's flat colour or the HDRI's
152
- // irradiance at this normal.
153
- let amb = rzObjectAmbient(n);
154
- let tex_color = tex_s.rgb;
155
- // The normal the lamps' diffuse layer is lit by, for a principled walk to
156
- // compute it on the way (rzLightsDiffuseOnce). n is final from here on.
157
- _rzLampN = n;
96
+ return `@fragment fn fs(input: VertexOutput) -> FSOut {
97
+ ${PLAIN_SAMPLE} // The see-through window (#xray): her clothes are not drawn inside it.
98
+ if (rz_xray_cut(input.position, material.materialId)) { discard; }
99
+ // MMD alpha semantics: material alpha × texture alpha, capped at 1 as MMD
100
+ // does (a PMX can author alpha above 1; blended, it burns the material white).
101
+ let alpha = saturate(material.alpha * tex_s.a);
102
+ ${discard}
103
+
104
+ // ── Dissolve ──
105
+ //
106
+ // A fragment is either THERE or it is not: the flake is thrown away rather
107
+ // than faded. A fade would be an opacity slider — she would go see-through
108
+ // and you would read the wall through her hair — while a threshold takes her
109
+ // apart in pieces, which is the thing being asked for. The depth prepass runs
110
+ // this identical test (rz_dissolve_threshold, shared), so depth and colour
111
+ // agree about which pieces are gone.
112
+ //
113
+ // The surviving edge glows: fragments within RZ_DISSOLVE_EDGE of the front
114
+ // are the ones about to go, and lighting them is what makes the boundary read
115
+ // as burning away rather than as a stencil moving over her.
116
+ var rz_burn = 0.0;
117
+ if (material.dissolve < 0.9995) {
118
+ // PER FRAGMENT, from the bind-pose position: the pieces are the noise's,
119
+ // grit inside clumps, never the mesh's triangles, so a large face comes
120
+ // apart as finely as a small one. The prepass, the shadow map and the
121
+ // outline hull run the same function on the same interpolated input, so
122
+ // every pass agrees about which flakes are gone.
123
+ let rz_t = rz_dissolve_threshold(input.restPos);
124
+ if (rz_t > material.dissolve) { discard; }
125
+ // Put OUT as the last of her goes. Near zero the front is wider than what
126
+ // is left of the surface, so every surviving fragment sits inside it and
127
+ // the final scraps are pure glow — a body that ends as a handful of white
128
+ // specks rather than as a body. The taper costs nothing while she is mostly
129
+ // there, because it is already 1 by a fifth of the way in.
130
+ rz_burn = smoothstep(material.dissolve - RZ_DISSOLVE_EDGE, material.dissolve, rz_t)
131
+ * smoothstep(0.0, 0.22, material.dissolve);
132
+ }
133
+
134
+ var n = safe_normal(input.normal);
135
+ let v = normalize(camera.viewPos - input.worldPos);${flip}
136
+ ${gate}
137
+ // The key: the directional light this draw's layers take — the sun unless a
138
+ // light on its own layer stands in. The shadow stays the sun's atlas, as the
139
+ // game keeps the scene's shadow under a character's own key.
140
+ let rz_key = rzMainLight();
141
+ let l = -light.lights[rz_key].direction.xyz;
142
+ // NO KEY WHERE NONE REACHES: rzMainLight falls back to the sun's slot, and
143
+ // a sun kept off this draw's layers — the cast's alone, beside a stage lit
144
+ // only by its own lamps — must not light it through the fallback.
145
+ let rz_keyed = (light.dirLayers[rz_key] & rzDrawLayers()) != 0u;
146
+ let sun = select(vec3f(0.0), light.lights[rz_key].color.xyz * light.lights[rz_key].color.w, rz_keyed);
147
+ // Lit through the see-through window: what it reveals would otherwise wear
148
+ // the shadow of the clothes it cut, which reads as dirt rather than as cloth.
149
+ let shadow = select(sampleShadow(input.worldPos, n), 1.0, rz_xray_inside(input.position));
150
+ // The ambient: this object's own where loaded data gave it one — the game
151
+ // gives every renderer its own — else the world's flat colour or the HDRI's
152
+ // irradiance at this normal.
153
+ let amb = rzObjectAmbient(n);
154
+ let tex_color = tex_s.rgb;
155
+ // The normal the lamps' diffuse layer is lit by, for a principled walk to
156
+ // compute it on the way (rzLightsDiffuseOnce). n is final from here on.
157
+ _rzLampN = n;
158
158
  `;
159
159
  }
160
160
  // Tail of fs(): consumes `final_color` + locals, writes FSOut. hashed forces output
@@ -204,7 +204,7 @@ function epilogue(renderClass, alphaMode, hasOpacity, blend, takesLight) {
204
204
  const CAST = takesLight
205
205
  ? ` out.color = vec4f(out.color.rgb * mix(vec3f(1.0), light.castShadow.rgb, rzRoofedCastShadow(input.worldPos) * light.castShadow.w), out.color.a);\n`
206
206
  : "";
207
- const ALBEDO = ` let albedo = tex_color;
207
+ const ALBEDO = ` let albedo = tex_color;
208
208
  `;
209
209
  // The dissolve's burning edge, ADDED after the graph and after the lights —
210
210
  // it is emission, not a surface colour, so nothing may ramp or shadow it. Zero
@@ -231,28 +231,28 @@ function epilogue(renderClass, alphaMode, hasOpacity, blend, takesLight) {
231
231
  // is kept by the blend, so the mask written is never stored.
232
232
  if (blend === "multiply") {
233
233
  const filter = takesLight ? "tex_color * material.diffuseColor" : "final_color";
234
- return ` var out: FSOut;
235
- out.color = vec4f(mix(vec3f(1.0), saturate(${filter}), ${alphaBase}), ${alphaBase});
236
- out.mask = vec4f(0.0);
237
- ${ID_WRITE} return out;
234
+ return ` var out: FSOut;
235
+ out.color = vec4f(mix(vec3f(1.0), saturate(${filter}), ${alphaBase}), ${alphaBase});
236
+ out.mask = vec4f(0.0);
237
+ ${ID_WRITE} return out;
238
238
  `;
239
239
  }
240
240
  if (renderClass === "hair") {
241
- return `${ALBEDO} var outAlpha = ${alphaBase};
242
- if (IS_OVER_EYES) { outAlpha = ${alphaBase} * 0.25; }
243
-
244
- var out: FSOut;
245
- out.color = vec4f(final_color${LIT}${BURN}, outAlpha);
246
- ${CAST}${FOG} out.color = rz_finite(out.color);
247
- out.mask = vec4f(objectLight.bloom.x, 1.0, _rzSubsurface, out.color.a);
248
- ${ID_WRITE} return out;
241
+ return `${ALBEDO} var outAlpha = ${alphaBase};
242
+ if (IS_OVER_EYES) { outAlpha = ${alphaBase} * 0.25; }
243
+
244
+ var out: FSOut;
245
+ out.color = vec4f(final_color${LIT}${BURN}, outAlpha);
246
+ ${CAST}${FOG} out.color = rz_finite(out.color);
247
+ out.mask = vec4f(objectLight.bloom.x, 1.0, _rzSubsurface, out.color.a);
248
+ ${ID_WRITE} return out;
249
249
  `;
250
250
  }
251
- return `${ALBEDO} var out: FSOut;
252
- out.color = vec4f(final_color${LIT}${BURN}, ${alphaBase});
253
- ${CAST}${FOG} out.color = rz_finite(out.color);
254
- out.mask = vec4f(objectLight.bloom.x, 1.0, _rzSubsurface, out.color.a);
255
- ${ID_WRITE} return out;
251
+ return `${ALBEDO} var out: FSOut;
252
+ out.color = vec4f(final_color${LIT}${BURN}, ${alphaBase});
253
+ ${CAST}${FOG} out.color = rz_finite(out.color);
254
+ out.mask = vec4f(objectLight.bloom.x, 1.0, _rzSubsurface, out.color.a);
255
+ ${ID_WRITE} return out;
256
256
  `;
257
257
  }
258
258
  /**
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 ViewTransformName, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type ReflectionProbeRegion, type PixelFilterType, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectPointValue, type EffectBoneValue, type EffectParamKey, type EffectResult, type ViewLut, 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 ViewTransformName, type LoadModelFromFilesOptions, type MaterialPreset, type MaterialPresetMap, type ModelTransform, type SceneLight, type CastKey, RENDERING_LAYER_DEFAULT, RENDERING_LAYER_CHARACTER, type ModelAttachment, type SceneAovs, type LightProbe, type ReflectionProbeRegion, type PixelFilterType, type GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, type EffectPointValue, type EffectBoneValue, type EffectParamKey, type EffectResult, type ViewLut, 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";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,qBAAqB,EACrB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,QAAQ,GACd,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAIzC,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB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zB,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;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;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;AAClE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
@@ -6,7 +6,7 @@
6
6
  export declare const JELLY_VERTEX_WGSL = "\nfn _rzJellyTurn(q: vec2f, a: f32) -> vec2f {\n let c = cos(a);\n let s = sin(a);\n return vec2f(c * q.x - s * q.y, s * q.x + c * q.y);\n}\n\n/**\n * Where the jelly puts an iris vertex. The iris is the part of the eye the eye\n * bones carry, so it is moved as a whole, in bind space before skinning:\n * scaled about its centre (the CPU composes the blink's spring, the lid's\n * press and her motion's knock into one scale), turned and drifted a hair on\n * the spring, brought forward a hair, and rolled about the eye bone with a\n * closing expression \u2014 inside the white, which stays where it is. A highlight\n * layer (this draw's material is one of jelly[1].w's) takes the iris's move,\n * then its own scale, turn and tremble, before the roll. Vertices take it by their weight on the eye bones\n * (jelly[2].w, jelly[3].w), so nothing else on the face moves.\n */\nfn rzJellyVertex(p: vec3f, joints: vec4<u32>, nw: vec4f) -> vec3f {\n let j = objectLight.jelly;\n let ids = u32(j[1].w);\n let mid = u32(material.materialId);\n let hl = mid > 0u && (mid == (ids & 4095u) || mid == (ids >> 12u));\n var out = p;\n for (var e = 0u; e < 2u; e++) {\n let bone = j[2u + e].w;\n if (bone < 0.0) { continue; }\n let b = u32(bone);\n let w = dot(nw, select(vec4f(0.0), vec4f(1.0), joints == vec4<u32>(b)));\n if (w <= 0.0) { continue; }\n let c = j[e].xyz;\n // A rig that carries both eyes on one bone: each vertex follows its own side.\n if (j[2].w == j[3].w && e == 0u && distance(p.xy, j[1].xy) < distance(p.xy, j[0].xy)) { continue; }\n if (j[2].w == j[3].w && e == 1u && distance(p.xy, j[0].xy) <= distance(p.xy, j[1].xy)) { continue; }\n let t = j[4u + e];\n let m = j[6u + e];\n let h = j[10u + e];\n var q = _rzJellyTurn((p.xy - c.xy) * t.xy, t.z) + m.xy;\n // Forward is \u2212Z (MMD faces \u2212Z).\n var push = h.z;\n if (hl) {\n // Sliding over the iris's dome on its own, a highlight sheet a hair in\n // front of it would sink into it where the dome bulges more and the two\n // fight for depth; so it comes forward by as far as it slid \u2014 a slope of\n // one, steeper than the dome anywhere it draws.\n let before = q;\n q = _rzJellyTurn(q * h.xy, t.w) + m.zw;\n push += length(q - before);\n }\n var moved = vec3f(c.xy + q, p.z - push);\n let roll = j[8u + e];\n if (roll.w != 0.0) {\n let d = moved - roll.xyz;\n let rd = _rzJellyTurn(d.yz, roll.w);\n moved = roll.xyz + vec3f(d.x, rd.x, rd.y);\n }\n out = mix(p, moved, w);\n }\n return out;\n}\n";
7
7
  /** A model's ObjectLight as WGSL declares it (see the layout below). One copy
8
8
  * for every pass that binds it, so their layouts cannot drift. */
9
- export declare const OBJECT_LIGHT_STRUCT_WGSL = "struct ObjectLight { layers: vec4u, ambient: vec4f, sh: array<vec4f, 9>, fill: vec4f, jelly: array<vec4f, 12>, bloom: vec4f, xray: array<vec4f, 4>, xrayMask: array<vec4u, 16> }";
9
+ export declare const OBJECT_LIGHT_STRUCT_WGSL = "struct ObjectLight { layers: vec4u, ambient: vec4f, sh: array<vec4f, 9>, fill: vec4f, jelly: array<vec4f, 12>, bloom: vec4f, xray: array<vec4f, 4>, xrayMask: array<vec4u, 16>, matLayers: array<vec4u, 128> }";
10
10
  /**
11
11
  * The see-through window (#xray): a rectangle on the frame, in pixels —
12
12
  * xray[0] is (left, top, right, bottom), xray[3].x is 1 while a window is open
@@ -16,6 +16,16 @@ export declare const OBJECT_LIGHT_STRUCT_WGSL = "struct ObjectLight { layers: ve
16
16
  * behind it. Declared after the pass's own `objectLight` binding.
17
17
  */
18
18
  export declare const XRAY_WGSL = "\nfn rz_xray_inside(fp: vec4f) -> bool {\n if (objectLight.xray[3].x < 0.5) { return false; }\n let r = objectLight.xray[0];\n return fp.x >= r.x && fp.y >= r.y && fp.x <= r.z && fp.y <= r.w;\n}\nfn rz_xray_cut(fp: vec4f, materialId: f32) -> bool {\n let i = u32(materialId);\n if (i >= 512u) { return false; }\n let word = objectLight.xrayMask[i / 128u][(i / 32u) % 4u];\n if (((word >> (i % 32u)) & 1u) == 0u) { return false; }\n return rz_xray_inside(fp);\n}\n";
19
+ /**
20
+ * The rendering layers this draw is on: its material's own where the model
21
+ * gives it some (objectLight.matLayers, by the 1-based materialId, up to 511),
22
+ * else the model's. A game lights its renderers one by one — URP hands each
23
+ * object its own few lamps — and a converted stage is one model of many such
24
+ * renderers, so the bits a light is tested against have to be able to differ
25
+ * from material to material. Zero, which every model leaves there, is "the
26
+ * model's". Declared after the pass's own `objectLight` and `material` bindings.
27
+ */
28
+ export declare const DRAW_LAYERS_WGSL = "\nfn rzDrawLayers() -> u32 {\n let i = u32(material.materialId);\n if (i >= 512u) { return objectLight.layers.x; }\n let own = objectLight.matLayers[i / 4u][i % 4u];\n return select(objectLight.layers.x, own, own != 0u);\n}\n";
19
29
  export declare const COMMON_BINDINGS_WGSL: string;
20
30
  export declare function commonFsOutWgsl(): string;
21
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/shaders/materials/common.ts"],"names":[],"mappings":"AA4BA;;;;uBAIuB;AACvB,eAAO,MAAM,iBAAiB,8iFA4D7B,CAAA;AAED;mEACmE;AACnE,eAAO,MAAM,wBAAwB,qLAC+I,CAAA;AAEpL;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,4dAarB,CAAA;AAED,eAAO,MAAM,oBAAoB,QAkQhC,CAAC;AA2JF,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,orMAgHzB,CAAA;AAQD,eAAO,MAAM,4BAA4B,QAC6H,CAAA"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/shaders/materials/common.ts"],"names":[],"mappings":"AA4BA;;;;uBAIuB;AACvB,eAAO,MAAM,iBAAiB,8iFA4D7B,CAAA;AAED;mEACmE;AACnE,eAAO,MAAM,wBAAwB,mNAC6K,CAAA;AAElN;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,4dAarB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,0OAO5B,CAAA;AAED,eAAO,MAAM,oBAAoB,QAwQhC,CAAC;AA2JF,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,orMAgHzB,CAAA;AAQD,eAAO,MAAM,4BAA4B,QAC0I,CAAA"}