reze-engine 0.12.0 → 0.12.2
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 +99 -58
- package/dist/bezier-interpolate.d.ts +15 -0
- package/dist/bezier-interpolate.d.ts.map +1 -0
- package/dist/bezier-interpolate.js +40 -0
- package/dist/engine_ts.d.ts +143 -0
- package/dist/engine_ts.d.ts.map +1 -0
- package/dist/engine_ts.js +1575 -0
- package/dist/ik.d.ts +32 -0
- package/dist/ik.d.ts.map +1 -0
- package/dist/ik.js +337 -0
- package/dist/player.d.ts +64 -0
- package/dist/player.d.ts.map +1 -0
- package/dist/player.js +220 -0
- package/dist/pool-scene.d.ts +52 -0
- package/dist/pool-scene.d.ts.map +1 -0
- package/dist/pool-scene.js +1122 -0
- package/dist/pool.d.ts +38 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +422 -0
- package/dist/rzm-converter.d.ts +12 -0
- package/dist/rzm-converter.d.ts.map +1 -0
- package/dist/rzm-converter.js +40 -0
- package/dist/rzm-loader.d.ts +24 -0
- package/dist/rzm-loader.d.ts.map +1 -0
- package/dist/rzm-loader.js +488 -0
- package/dist/rzm-writer.d.ts +27 -0
- package/dist/rzm-writer.d.ts.map +1 -0
- package/dist/rzm-writer.js +701 -0
- package/dist/shaders/body.d.ts +1 -1
- package/dist/shaders/body.d.ts.map +1 -1
- package/dist/shaders/body.js +28 -7
- package/dist/shaders/cloth_rough.d.ts +1 -1
- package/dist/shaders/cloth_rough.d.ts.map +1 -1
- package/dist/shaders/cloth_rough.js +16 -4
- package/dist/shaders/cloth_smooth.d.ts +1 -1
- package/dist/shaders/cloth_smooth.d.ts.map +1 -1
- package/dist/shaders/cloth_smooth.js +17 -5
- package/dist/shaders/default.d.ts +1 -1
- package/dist/shaders/default.d.ts.map +1 -1
- package/dist/shaders/eye.d.ts +1 -1
- package/dist/shaders/eye.d.ts.map +1 -1
- package/dist/shaders/face.d.ts +1 -1
- package/dist/shaders/face.d.ts.map +1 -1
- package/dist/shaders/face.js +57 -21
- package/dist/shaders/hair.d.ts +1 -1
- package/dist/shaders/hair.d.ts.map +1 -1
- package/dist/shaders/hair.js +27 -7
- package/dist/shaders/materials/body.d.ts +1 -1
- package/dist/shaders/materials/body.d.ts.map +1 -1
- package/dist/shaders/materials/body.js +86 -197
- package/dist/shaders/materials/cloth_rough.d.ts +1 -1
- package/dist/shaders/materials/cloth_rough.d.ts.map +1 -1
- package/dist/shaders/materials/cloth_rough.js +10 -121
- package/dist/shaders/materials/cloth_smooth.d.ts +1 -1
- package/dist/shaders/materials/cloth_smooth.d.ts.map +1 -1
- package/dist/shaders/materials/cloth_smooth.js +59 -172
- package/dist/shaders/materials/common.d.ts +6 -0
- package/dist/shaders/materials/common.d.ts.map +1 -0
- package/dist/shaders/materials/common.js +144 -0
- package/dist/shaders/materials/default.d.ts +1 -1
- package/dist/shaders/materials/default.d.ts.map +1 -1
- package/dist/shaders/materials/default.js +12 -145
- package/dist/shaders/materials/eye.d.ts +1 -1
- package/dist/shaders/materials/eye.d.ts.map +1 -1
- package/dist/shaders/materials/eye.js +12 -117
- package/dist/shaders/materials/face.d.ts +1 -1
- package/dist/shaders/materials/face.d.ts.map +1 -1
- package/dist/shaders/materials/face.js +85 -197
- package/dist/shaders/materials/hair.d.ts +1 -1
- package/dist/shaders/materials/hair.d.ts.map +1 -1
- package/dist/shaders/materials/hair.js +78 -183
- package/dist/shaders/materials/metal.d.ts +1 -1
- package/dist/shaders/materials/metal.d.ts.map +1 -1
- package/dist/shaders/materials/metal.js +15 -121
- 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 +77 -0
- package/dist/shaders/materials/stockings.d.ts +1 -1
- package/dist/shaders/materials/stockings.d.ts.map +1 -1
- package/dist/shaders/materials/stockings.js +26 -152
- package/dist/shaders/metal.d.ts +1 -1
- package/dist/shaders/metal.d.ts.map +1 -1
- package/dist/shaders/metal.js +17 -4
- package/dist/shaders/nodes.d.ts +1 -1
- package/dist/shaders/nodes.d.ts.map +1 -1
- package/dist/shaders/nodes.js +9 -0
- package/dist/shaders/stockings.d.ts +1 -1
- package/dist/shaders/stockings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shaders/materials/body.ts +90 -201
- package/src/shaders/materials/cloth_rough.ts +10 -121
- package/src/shaders/materials/cloth_smooth.ts +63 -176
- package/src/shaders/materials/common.ts +155 -0
- package/src/shaders/materials/default.ts +12 -145
- package/src/shaders/materials/eye.ts +12 -117
- package/src/shaders/materials/face.ts +89 -201
- package/src/shaders/materials/hair.ts +82 -187
- package/src/shaders/materials/metal.ts +15 -121
- package/src/shaders/materials/nodes.ts +77 -0
- package/src/shaders/materials/stockings.ts +27 -153
|
@@ -1,79 +1,17 @@
|
|
|
1
|
-
// M_Stockings — 仿深空之眼渲染预设v1.0_by_小绿毛猫
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// M_Stockings — 仿深空之眼渲染预设v1.0_by_小绿毛猫 "M_Stockings". A bbox-gradient ×
|
|
2
|
+
// facing-rim mask drives a Mix Shader between an HSV-boosted emission and a sheen
|
|
3
|
+
// Principled BSDF. Wyman hashed-alpha testing replaces the graph's Alpha=0.95 (which
|
|
4
|
+
// would require TAA to hide the dither dots across every pixel).
|
|
5
5
|
|
|
6
6
|
import { NODES_WGSL } from "./nodes"
|
|
7
|
+
import { COMMON_MATERIAL_PRELUDE_WGSL } from "./common"
|
|
7
8
|
|
|
8
9
|
export const STOCKINGS_SHADER_WGSL = /* wgsl */ `
|
|
9
10
|
|
|
10
11
|
${NODES_WGSL}
|
|
12
|
+
${COMMON_MATERIAL_PRELUDE_WGSL}
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
view: mat4x4f,
|
|
14
|
-
projection: mat4x4f,
|
|
15
|
-
viewPos: vec3f,
|
|
16
|
-
_padding: f32,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
struct Light {
|
|
20
|
-
direction: vec4f,
|
|
21
|
-
color: vec4f,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
struct LightUniforms {
|
|
25
|
-
ambientColor: vec4f,
|
|
26
|
-
lights: array<Light, 4>,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
struct MaterialUniforms {
|
|
30
|
-
diffuseColor: vec3f,
|
|
31
|
-
alpha: f32,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
struct VertexOutput {
|
|
35
|
-
@builtin(position) position: vec4f,
|
|
36
|
-
@location(0) normal: vec3f,
|
|
37
|
-
@location(1) uv: vec2f,
|
|
38
|
-
@location(2) worldPos: vec3f,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
struct LightVP { viewProj: mat4x4f, };
|
|
42
|
-
|
|
43
|
-
@group(0) @binding(0) var<uniform> camera: CameraUniforms;
|
|
44
|
-
@group(0) @binding(1) var<uniform> light: LightUniforms;
|
|
45
|
-
@group(0) @binding(2) var diffuseSampler: sampler;
|
|
46
|
-
@group(0) @binding(3) var shadowMap: texture_depth_2d;
|
|
47
|
-
@group(0) @binding(4) var shadowSampler: sampler_comparison;
|
|
48
|
-
@group(0) @binding(5) var<uniform> lightVP: LightVP;
|
|
49
|
-
@group(1) @binding(0) var<storage, read> skinMats: array<mat4x4f>;
|
|
50
|
-
@group(2) @binding(0) var diffuseTexture: texture_2d<f32>;
|
|
51
|
-
@group(2) @binding(1) var<uniform> material: MaterialUniforms;
|
|
52
|
-
|
|
53
|
-
fn sampleShadow(worldPos: vec3f, n: vec3f) -> f32 {
|
|
54
|
-
// Back-facing to key light: direct contribution is zero anyway, skip 9 texture samples.
|
|
55
|
-
if (dot(n, -light.lights[0].direction.xyz) <= 0.0) { return 0.0; }
|
|
56
|
-
let biasedPos = worldPos + n * 0.08;
|
|
57
|
-
let lclip = lightVP.viewProj * vec4f(biasedPos, 1.0);
|
|
58
|
-
let ndc = lclip.xyz / max(lclip.w, 1e-6);
|
|
59
|
-
let suv = vec2f(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5);
|
|
60
|
-
let cmpZ = ndc.z - 0.001;
|
|
61
|
-
let ts = 1.0 / 2048.0;
|
|
62
|
-
// 3x3 PCF unrolled — Safari's Metal backend doesn't unroll nested shadow loops reliably.
|
|
63
|
-
let s00 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f(-ts, -ts), cmpZ);
|
|
64
|
-
let s10 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f(0.0, -ts), cmpZ);
|
|
65
|
-
let s20 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f( ts, -ts), cmpZ);
|
|
66
|
-
let s01 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f(-ts, 0.0), cmpZ);
|
|
67
|
-
let s11 = textureSampleCompareLevel(shadowMap, shadowSampler, suv, cmpZ);
|
|
68
|
-
let s21 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f( ts, 0.0), cmpZ);
|
|
69
|
-
let s02 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f(-ts, ts), cmpZ);
|
|
70
|
-
let s12 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f(0.0, ts), cmpZ);
|
|
71
|
-
let s22 = textureSampleCompareLevel(shadowMap, shadowSampler, suv + vec2f( ts, ts), cmpZ);
|
|
72
|
-
return (s00 + s10 + s20 + s01 + s11 + s21 + s02 + s12 + s22) * (1.0 / 9.0);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const PI_S: f32 = 3.141592653589793;
|
|
76
|
-
// Principled BSDF params from dump (Alpha=0.95 is intentionally dropped — see alpha-hash note below)
|
|
14
|
+
// Principled params from dump (Alpha=0.95 intentionally dropped — see hash note below).
|
|
77
15
|
const STOCK_METALLIC: f32 = 0.1;
|
|
78
16
|
const STOCK_SPECULAR: f32 = 1.0;
|
|
79
17
|
const STOCK_ROUGHNESS: f32 = 0.5;
|
|
@@ -84,12 +22,6 @@ const STOCK_RAMP002_P1: f32 = 0.9565; // EASE [0→black, 0.9565→white]
|
|
|
84
22
|
const STOCK_RAMPFACE_P1: f32 = 0.5435; // EASE [0→black, 0.5435→white]
|
|
85
23
|
const STOCK_LW_BLEND: f32 = 0.4; // Layer Weight Blend
|
|
86
24
|
|
|
87
|
-
// principled_sheen (gpu_shader_material_principled.glsl:8-14) — empirical NV curve
|
|
88
|
-
fn principled_sheen(NV: f32) -> f32 {
|
|
89
|
-
let f = 1.0 - NV;
|
|
90
|
-
return f * f * f * 0.077 + f * 0.01 + 0.00026;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
25
|
// Wyman & McGuire "Hashed Alpha Testing" (2017) — world-space hash with derivative-aware
|
|
94
26
|
// pixel-scale selection, matches Blender EEVEE prepass_frag.glsl::hashed_alpha_threshold.
|
|
95
27
|
// Key property: dither pattern is stable in object/world space (doesn't swim) and stays
|
|
@@ -111,7 +43,7 @@ fn hashed_alpha_threshold(co: vec3f) -> f32 {
|
|
|
111
43
|
let a_hi = _hash3d_wm(floor(px_hi * co));
|
|
112
44
|
let fac = fract(pix_scale_log);
|
|
113
45
|
let x = mix(a_lo, a_hi, fac);
|
|
114
|
-
// CDF remap so
|
|
46
|
+
// CDF remap so discard-probability = (1 - alpha) uniformly across scale transitions
|
|
115
47
|
let a = min(fac, 1.0 - fac);
|
|
116
48
|
let one_a = 1.0 - a;
|
|
117
49
|
let denom = 1.0 / max(2.0 * a * one_a, 1e-6);
|
|
@@ -129,39 +61,6 @@ fn ramp_ease_s(f: f32, p0: f32, p1: f32) -> f32 {
|
|
|
129
61
|
return t * t * (3.0 - 2.0 * t);
|
|
130
62
|
}
|
|
131
63
|
|
|
132
|
-
@vertex fn vs(
|
|
133
|
-
@location(0) position: vec3f,
|
|
134
|
-
@location(1) normal: vec3f,
|
|
135
|
-
@location(2) uv: vec2f,
|
|
136
|
-
@location(3) joints0: vec4<u32>,
|
|
137
|
-
@location(4) weights0: vec4<f32>
|
|
138
|
-
) -> VertexOutput {
|
|
139
|
-
var output: VertexOutput;
|
|
140
|
-
let pos4 = vec4f(position, 1.0);
|
|
141
|
-
let weightSum = weights0.x + weights0.y + weights0.z + weights0.w;
|
|
142
|
-
let invWeightSum = select(1.0, 1.0 / weightSum, weightSum > 0.0001);
|
|
143
|
-
let nw = select(vec4f(1.0, 0.0, 0.0, 0.0), weights0 * invWeightSum, weightSum > 0.0001);
|
|
144
|
-
var skinnedPos = vec4f(0.0);
|
|
145
|
-
var skinnedNrm = vec3f(0.0);
|
|
146
|
-
for (var i = 0u; i < 4u; i++) {
|
|
147
|
-
let m = skinMats[joints0[i]];
|
|
148
|
-
let w = nw[i];
|
|
149
|
-
skinnedPos += (m * pos4) * w;
|
|
150
|
-
skinnedNrm += (mat3x3f(m[0].xyz, m[1].xyz, m[2].xyz) * normal) * w;
|
|
151
|
-
}
|
|
152
|
-
output.position = camera.projection * camera.view * vec4f(skinnedPos.xyz, 1.0);
|
|
153
|
-
// Skip VS normalize — interpolation denormalizes anyway, and FS always does normalize(input.normal).
|
|
154
|
-
output.normal = skinnedNrm;
|
|
155
|
-
output.uv = uv;
|
|
156
|
-
output.worldPos = skinnedPos.xyz;
|
|
157
|
-
return output;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
struct FSOut {
|
|
161
|
-
@location(0) color: vec4f,
|
|
162
|
-
@location(1) bloom_mask: f32,
|
|
163
|
-
};
|
|
164
|
-
|
|
165
64
|
@fragment fn fs(input: VertexOutput) -> FSOut {
|
|
166
65
|
let n = normalize(input.normal);
|
|
167
66
|
let v = normalize(camera.viewPos - input.worldPos);
|
|
@@ -172,18 +71,16 @@ struct FSOut {
|
|
|
172
71
|
|
|
173
72
|
let tex_s = textureSample(diffuseTexture, diffuseSampler, input.uv);
|
|
174
73
|
let tex_rgb = tex_s.rgb;
|
|
175
|
-
// Alpha HASHED (Blender EEVEE "Hashed" blend mode) per preset author's note —
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
// on texture/material alpha, so solid stockings regions stay fully opaque.
|
|
74
|
+
// Alpha HASHED (Blender EEVEE "Hashed" blend mode) per preset author's note — self-overlap
|
|
75
|
+
// on the stockings produces sort cracks under alpha blend. Wyman-style worldPos hash +
|
|
76
|
+
// depth-write is sort-independent. NOTE: Principled.Alpha=0.95 from the dump is DROPPED;
|
|
77
|
+
// it relies on TAA to smooth the 5%-everywhere dither, and without TAA it shows as a
|
|
78
|
+
// pervasive dot pattern. Hash now gates only on texture/material alpha.
|
|
181
79
|
let combined_alpha = material.alpha * tex_s.a;
|
|
182
80
|
if (combined_alpha < hashed_alpha_threshold(input.worldPos)) { discard; }
|
|
183
|
-
let out_alpha = 1.0;
|
|
184
81
|
|
|
185
|
-
// ═══ NPR MASK
|
|
186
|
-
// The Blender mapping reduces to gradient.x = 1 - input.y (rot swaps axes, loc offsets
|
|
82
|
+
// ═══ NPR MASK ═══ TEX_COORD.Generated → Mapping(Rot=0,π/2,π/2, Loc=(1,1,1)) → Gradient.
|
|
83
|
+
// The Blender mapping reduces to gradient.x = 1 - input.y (rot swaps axes, loc offsets).
|
|
187
84
|
// We approximate Generated with UV since Y-up PMX has no object bbox in pipeline state.
|
|
188
85
|
let gen_coord = vec3f(input.uv, 0.0);
|
|
189
86
|
let mapped = mapping_point(gen_coord, vec3f(1.0), vec3f(0.0, 1.5708, 1.5708), vec3f(1.0));
|
|
@@ -191,55 +88,32 @@ struct FSOut {
|
|
|
191
88
|
|
|
192
89
|
// Ramp.001 LINEAR [0→black, 0.5→white, 1.0→black] — triangular peak at 0.5
|
|
193
90
|
let ramp001 = 1.0 - abs(2.0 * gradient - 1.0);
|
|
194
|
-
// Ramp.002 EASE [0→black, 0.9565→white]
|
|
195
91
|
let ramp002 = ramp_ease_s(ramp001, 0.0, STOCK_RAMP002_P1);
|
|
196
92
|
|
|
197
|
-
// Layer Weight.Facing (Blend=0.4) → Ramp EASE [0→black, 0.5435→white]
|
|
198
93
|
let facing = layer_weight_facing(STOCK_LW_BLEND, n, v);
|
|
199
94
|
let ramp_face = ramp_ease_s(facing, 0.0, STOCK_RAMPFACE_P1);
|
|
200
95
|
|
|
201
|
-
// Mix.001: MIX blend Fac=0.5, A=white, B=ramp_face
|
|
96
|
+
// Mix.001: MIX blend Fac=0.5, A=white, B=ramp_face
|
|
202
97
|
let mix001 = mix(1.0, ramp_face, 0.5);
|
|
203
|
-
// Mix: LIGHTEN blend Fac=0.5, A=mix001, B=ramp002
|
|
98
|
+
// Mix: LIGHTEN blend Fac=0.5, A=mix001, B=ramp002
|
|
204
99
|
let lighten = max(mix001, ramp002);
|
|
205
100
|
let mask = mix(mix001, lighten, 0.5);
|
|
206
101
|
|
|
207
|
-
// ═══ EMISSION SHADER ═══
|
|
208
|
-
// Hue=0.5 (identity rotation), Sat=1.0, Val=5.0 (5× brightness boost), Fac=1; Strength=1
|
|
102
|
+
// ═══ EMISSION SHADER ═══ Hue=0.5 (identity), Sat=1.0, Val=5.0 (5× brightness), Fac=1.
|
|
209
103
|
let emission = hue_sat_id(1.0, 5.0, 1.0, tex_rgb);
|
|
210
104
|
|
|
211
|
-
// ═══ PRINCIPLED BSDF
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
let f0 = mix(dielectric_f0, tex_rgb, STOCK_METALLIC);
|
|
219
|
-
let f90 = mix(f0, vec3f(1.0), sqrt(STOCK_SPECULAR));
|
|
220
|
-
let brdf_lut = brdf_lut_sample(NV, STOCK_ROUGHNESS);
|
|
221
|
-
let reflection_color = F_brdf_multi_scatter(f0, f90, brdf_lut.xy);
|
|
222
|
-
|
|
223
|
-
let spec_direct = bsdf_ggx(n, l, v, NL, NV, STOCK_ROUGHNESS) * sun * shadow * ltc_brdf_scale_from_lut(brdf_lut);
|
|
224
|
-
let spec_indirect = amb;
|
|
225
|
-
let spec_radiance = (spec_direct + spec_indirect) * reflection_color;
|
|
226
|
-
|
|
227
|
-
// Sheen coarse: diffuse_color += sheen * sheen_color * principled_sheen(NV).
|
|
228
|
-
let base_tint = tint_from_color(tex_rgb);
|
|
229
|
-
let sheen_color = mix(vec3f(1.0), base_tint, STOCK_SHEEN_TINT);
|
|
230
|
-
let diffuse_color = tex_rgb + STOCK_SHEEN * sheen_color * principled_sheen(NV);
|
|
231
|
-
|
|
232
|
-
// diffuse_weight = (1 - metallic). Indirect diffuse uses L_w (no π; see closure_eval_surface_lib:302).
|
|
233
|
-
let diffuse_weight = 1.0 - STOCK_METALLIC;
|
|
234
|
-
let diffuse_radiance = diffuse_color * (sun * NL * shadow / PI_S + amb) * diffuse_weight;
|
|
235
|
-
let principled = diffuse_radiance + spec_radiance;
|
|
236
|
-
|
|
237
|
-
// ═══ MIX SHADER: Shader=Emission, Shader_001=Principled, Fac=mask ═══
|
|
105
|
+
// ═══ PRINCIPLED BSDF with sheen ═══ metallic=0.1, sheen=0.7, sheen_tint=0.5.
|
|
106
|
+
let principled = eval_principled(
|
|
107
|
+
PrincipledIn(tex_rgb, STOCK_METALLIC, STOCK_SPECULAR, STOCK_ROUGHNESS, 1e30, STOCK_SHEEN, STOCK_SHEEN_TINT),
|
|
108
|
+
n, l, v, sun, amb, shadow
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// MIX SHADER: Shader=Emission, Shader_001=Principled, Fac=mask
|
|
238
112
|
let final_color = mix(emission, principled, mask);
|
|
239
113
|
|
|
240
114
|
var out: FSOut;
|
|
241
|
-
out.color = vec4f(final_color,
|
|
242
|
-
out.
|
|
115
|
+
out.color = vec4f(final_color, 1.0);
|
|
116
|
+
out.mask = 1.0;
|
|
243
117
|
return out;
|
|
244
118
|
}
|
|
245
119
|
|