reze-engine 0.20.0 → 0.21.1
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 +30 -14
- package/dist/engine.d.ts +0 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +12 -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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/shaders/materials/common.d.ts +1 -1
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +5 -4
- package/package.json +1 -1
- package/src/engine.ts +14 -21
- 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 +61 -62
- package/src/shaders/materials/common.ts +5 -4
- package/src/shaders/materials/body.ts +0 -97
- package/src/shaders/materials/cloth_rough.ts +0 -71
- package/src/shaders/materials/cloth_smooth.ts +0 -63
- package/src/shaders/materials/default.ts +0 -45
- package/src/shaders/materials/eye.ts +0 -62
- package/src/shaders/materials/face.ts +0 -97
- package/src/shaders/materials/hair.ts +0 -92
- package/src/shaders/materials/metal.ts +0 -79
- package/src/shaders/materials/mmd_classic.ts +0 -68
- package/src/shaders/materials/stockings.ts +0 -124
|
@@ -1,124 +0,0 @@
|
|
|
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
|
-
|
|
6
|
-
import { NODES_WGSL } from "./nodes"
|
|
7
|
-
import { COMMON_MATERIAL_PRELUDE_WGSL } from "./common"
|
|
8
|
-
|
|
9
|
-
export const STOCKINGS_SHADER_WGSL = /* wgsl */ `
|
|
10
|
-
|
|
11
|
-
${NODES_WGSL}
|
|
12
|
-
${COMMON_MATERIAL_PRELUDE_WGSL}
|
|
13
|
-
|
|
14
|
-
// Principled params from dump (Alpha=0.95 intentionally dropped — see hash note below).
|
|
15
|
-
const STOCK_METALLIC: f32 = 0.1;
|
|
16
|
-
const STOCK_SPECULAR: f32 = 1.0;
|
|
17
|
-
const STOCK_ROUGHNESS: f32 = 0.5;
|
|
18
|
-
const STOCK_SHEEN: f32 = 0.7017999887466431;
|
|
19
|
-
const STOCK_SHEEN_TINT: f32 = 0.5;
|
|
20
|
-
// NPR mask ramps
|
|
21
|
-
const STOCK_RAMP002_P1: f32 = 0.9565; // EASE [0→black, 0.9565→white]
|
|
22
|
-
const STOCK_RAMPFACE_P1: f32 = 0.5435; // EASE [0→black, 0.5435→white]
|
|
23
|
-
const STOCK_LW_BLEND: f32 = 0.4; // Layer Weight Blend
|
|
24
|
-
|
|
25
|
-
// Wyman & McGuire "Hashed Alpha Testing" (2017) — object-space hash with derivative-aware
|
|
26
|
-
// pixel-scale selection, matches Blender EEVEE prepass_frag.glsl::hashed_alpha_threshold.
|
|
27
|
-
// Key property: dither pattern is stable in object space (doesn't swim) and stays at
|
|
28
|
-
// one-pixel frequency regardless of view distance, which makes it tolerable without TAA.
|
|
29
|
-
// The hash grid is fed the bind-pose restPos (not worldPos), so the dots stay pinned to
|
|
30
|
-
// the fabric even under root (センター) motion — worldPos would crawl across the surface.
|
|
31
|
-
// Since MMD skinning is rigid, length(dpdx(restPos)) == length(dpdx(worldPos)), so the
|
|
32
|
-
// pixel-scale selection is unaffected by the space change.
|
|
33
|
-
// Grid samples reuse the PCG _hash33 from nodes.ts (integer-lattice inputs, Metal-friendly)
|
|
34
|
-
// instead of a fract(sin()) hash — sin compiles to a slow transcendental on Apple's Metal
|
|
35
|
-
// backend and this runs per-fragment on every stockings pixel.
|
|
36
|
-
fn _hash3d_wm(a: vec3f) -> f32 {
|
|
37
|
-
return _hash33(a).x * 0.5 + 0.5;
|
|
38
|
-
}
|
|
39
|
-
fn hashed_alpha_threshold(co: vec3f) -> f32 {
|
|
40
|
-
let alphaHashScale: f32 = 1.0;
|
|
41
|
-
let max_deriv = max(length(dpdx(co)), length(dpdy(co)));
|
|
42
|
-
let pix_scale = 1.0 / max(alphaHashScale * max_deriv, 1e-6);
|
|
43
|
-
let pix_scale_log = log2(pix_scale);
|
|
44
|
-
let px_lo = exp2(floor(pix_scale_log));
|
|
45
|
-
let px_hi = exp2(ceil(pix_scale_log));
|
|
46
|
-
let a_lo = _hash3d_wm(floor(px_lo * co));
|
|
47
|
-
let a_hi = _hash3d_wm(floor(px_hi * co));
|
|
48
|
-
let fac = fract(pix_scale_log);
|
|
49
|
-
let x = mix(a_lo, a_hi, fac);
|
|
50
|
-
// CDF remap so discard-probability = (1 - alpha) uniformly across scale transitions
|
|
51
|
-
let a = min(fac, 1.0 - fac);
|
|
52
|
-
let one_a = 1.0 - a;
|
|
53
|
-
let denom = 1.0 / max(2.0 * a * one_a, 1e-6);
|
|
54
|
-
let one_x = 1.0 - x;
|
|
55
|
-
let case_lo = (x * x) * denom;
|
|
56
|
-
let case_mid = (x - 0.5 * a) / max(one_a, 1e-6);
|
|
57
|
-
let case_hi = 1.0 - (one_x * one_x) * denom;
|
|
58
|
-
var threshold = select(case_hi, select(case_lo, case_mid, x >= a), x < one_a);
|
|
59
|
-
return clamp(threshold, 1e-6, 1.0);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Smoothstep-based EASE ramp (Blender VALTORGB EASE) — 2 stops, saturate+smoothstep between
|
|
63
|
-
fn ramp_ease_s(f: f32, p0: f32, p1: f32) -> f32 {
|
|
64
|
-
let t = saturate((f - p0) / max(p1 - p0, 1e-6));
|
|
65
|
-
return t * t * (3.0 - 2.0 * t);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
@fragment fn fs(input: VertexOutput) -> FSOut {
|
|
69
|
-
let n = safe_normal(input.normal);
|
|
70
|
-
let v = normalize(camera.viewPos - input.worldPos);
|
|
71
|
-
let l = -light.lights[0].direction.xyz;
|
|
72
|
-
let sun = light.lights[0].color.xyz * light.lights[0].color.w;
|
|
73
|
-
let amb = light.ambientColor.xyz;
|
|
74
|
-
let shadow = sampleShadow(input.worldPos, n);
|
|
75
|
-
|
|
76
|
-
let tex_s = textureSample(diffuseTexture, diffuseSampler, input.uv);
|
|
77
|
-
let tex_rgb = tex_s.rgb;
|
|
78
|
-
// Alpha HASHED (Blender EEVEE "Hashed" blend mode) per preset author's note — self-overlap
|
|
79
|
-
// on the stockings produces sort cracks under alpha blend. Wyman-style object-space hash +
|
|
80
|
-
// depth-write is sort-independent. NOTE: Principled.Alpha=0.95 from the dump is DROPPED;
|
|
81
|
-
// it relies on TAA to smooth the 5%-everywhere dither, and without TAA it shows as a
|
|
82
|
-
// pervasive dot pattern. Hash now gates only on texture/material alpha.
|
|
83
|
-
let combined_alpha = material.alpha * tex_s.a;
|
|
84
|
-
if (combined_alpha < hashed_alpha_threshold(input.restPos)) { discard; }
|
|
85
|
-
|
|
86
|
-
// ═══ NPR MASK ═══ TEX_COORD.Generated → Mapping(Rot=0,π/2,π/2, Loc=(1,1,1)) → Gradient.
|
|
87
|
-
// The Blender mapping reduces to gradient.x = 1 - input.y (rot swaps axes, loc offsets).
|
|
88
|
-
// We approximate Generated with UV since Y-up PMX has no object bbox in pipeline state.
|
|
89
|
-
let gen_coord = vec3f(input.uv, 0.0);
|
|
90
|
-
let mapped = mapping_point(gen_coord, vec3f(1.0), vec3f(0.0, 1.5708, 1.5708), vec3f(1.0));
|
|
91
|
-
let gradient = tex_gradient_linear(mapped);
|
|
92
|
-
|
|
93
|
-
// Ramp.001 LINEAR [0→black, 0.5→white, 1.0→black] — triangular peak at 0.5
|
|
94
|
-
let ramp001 = 1.0 - abs(2.0 * gradient - 1.0);
|
|
95
|
-
let ramp002 = ramp_ease_s(ramp001, 0.0, STOCK_RAMP002_P1);
|
|
96
|
-
|
|
97
|
-
let facing = layer_weight_facing(STOCK_LW_BLEND, n, v);
|
|
98
|
-
let ramp_face = ramp_ease_s(facing, 0.0, STOCK_RAMPFACE_P1);
|
|
99
|
-
|
|
100
|
-
// Mix.001: MIX blend Fac=0.5, A=white, B=ramp_face
|
|
101
|
-
let mix001 = mix(1.0, ramp_face, 0.5);
|
|
102
|
-
// Mix: LIGHTEN blend Fac=0.5, A=mix001, B=ramp002
|
|
103
|
-
let lighten = max(mix001, ramp002);
|
|
104
|
-
let mask = mix(mix001, lighten, 0.5);
|
|
105
|
-
|
|
106
|
-
// ═══ EMISSION SHADER ═══ Hue=0.5 (identity), Sat=1.0, Val=5.0 (5× brightness), Fac=1.
|
|
107
|
-
let emission = hue_sat_id(1.0, 5.0, 1.0, tex_rgb);
|
|
108
|
-
|
|
109
|
-
// ═══ PRINCIPLED BSDF with sheen ═══ metallic=0.1, sheen=0.7, sheen_tint=0.5.
|
|
110
|
-
let principled = eval_principled(
|
|
111
|
-
PrincipledIn(tex_rgb, STOCK_METALLIC, STOCK_SPECULAR, STOCK_ROUGHNESS, 1e30, STOCK_SHEEN, STOCK_SHEEN_TINT),
|
|
112
|
-
n, l, v, sun, amb, shadow
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// MIX SHADER: Shader=Emission, Shader_001=Principled, Fac=mask
|
|
116
|
-
let final_color = mix(emission, principled, mask);
|
|
117
|
-
|
|
118
|
-
var out: FSOut;
|
|
119
|
-
out.color = vec4f(final_color, 1.0);
|
|
120
|
-
out.mask = vec4f(1.0, 1.0, 0.0, out.color.a);
|
|
121
|
-
return out;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
`
|