reze-engine 0.68.1 → 0.68.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/dist/_dbg-loader.mjs +1100 -0
- package/dist/engine.d.ts +100 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +194 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/shaders/passes/aov.d.ts +37 -0
- package/dist/shaders/passes/aov.d.ts.map +1 -0
- package/dist/shaders/passes/aov.js +180 -0
- package/package.json +1 -1
- package/src/engine.ts +229 -2
- package/src/index.ts +4 -0
- package/src/shaders/passes/aov.ts +187 -0
- package/dist/graph/presets/pool_floor.d.ts +0 -3
- package/dist/graph/presets/pool_floor.d.ts.map +0 -1
- package/dist/graph/presets/pool_floor.js +0 -42
- package/dist/graph/presets/water.d.ts +0 -3
- package/dist/graph/presets/water.d.ts.map +0 -1
- package/dist/graph/presets/water.js +0 -31
- package/dist/physics/autofit.d.ts +0 -147
- package/dist/physics/autofit.d.ts.map +0 -1
- package/dist/physics/autofit.js +0 -501
- package/dist/shaders/agx-lut.d.ts +0 -11
- package/dist/shaders/agx-lut.d.ts.map +0 -1
- package/dist/shaders/agx-lut.js +0 -29
- package/dist/shaders/dfg_lut.d.ts +0 -3
- package/dist/shaders/dfg_lut.d.ts.map +0 -1
- package/dist/shaders/dfg_lut.js +0 -129
- package/dist/shaders/ltc_mag_lut.d.ts +0 -3
- package/dist/shaders/ltc_mag_lut.d.ts.map +0 -1
- package/dist/shaders/ltc_mag_lut.js +0 -1033
- package/dist/shaders/passes/field-blit.d.ts +0 -26
- package/dist/shaders/passes/field-blit.d.ts.map +0 -1
- package/dist/shaders/passes/field-blit.js +0 -65
- package/dist/shaders/passes/ghosts.d.ts +0 -22
- package/dist/shaders/passes/ghosts.d.ts.map +0 -1
- package/dist/shaders/passes/ghosts.js +0 -75
- package/dist/shaders/passes/ground-noise.d.ts +0 -7
- package/dist/shaders/passes/ground-noise.d.ts.map +0 -1
- package/dist/shaders/passes/ground-noise.js +0 -88
- package/dist/shaders/passes/sim.d.ts +0 -34
- package/dist/shaders/passes/sim.d.ts.map +0 -1
- package/dist/shaders/passes/sim.js +0 -169
- package/dist/shaders/score-api.d.ts +0 -10
- package/dist/shaders/score-api.d.ts.map +0 -1
- package/dist/shaders/score-api.js +0 -114
- package/dist/shaders/shadow-api.d.ts +0 -29
- package/dist/shaders/shadow-api.d.ts.map +0 -1
- package/dist/shaders/shadow-api.js +0 -112
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 3×3 PCF over one cascade's map, for a point already in that cascade's NDC.
|
|
3
|
-
*
|
|
4
|
-
* Shared with the materials, so an effect's shadow and her own shadow soften
|
|
5
|
-
* alike. The sampler is linear-filtered, which makes each tap a 2×2 bilinear
|
|
6
|
-
* compare. Unrolled — Safari's Metal backend doesn't unroll nested shadow
|
|
7
|
-
* loops reliably. The body expects `ndc` in scope and returns.
|
|
8
|
-
*/
|
|
9
|
-
export declare const pcf9: (map: string, ts: string, sampler?: string) => string;
|
|
10
|
-
/** Bindings the real accessor takes, from `binding` upward. */
|
|
11
|
-
export declare const SHADOW_API_BINDINGS = 5;
|
|
12
|
-
/**
|
|
13
|
-
* `rzShadow(p)`: how much of the sun reaches world point `p` — 1 lit, 0 in a
|
|
14
|
-
* caster's shadow, soft in between.
|
|
15
|
-
*
|
|
16
|
-
* With `on`, declares five bindings from `binding`:
|
|
17
|
-
* +0 the light uniform (the sun's direction, and in .w the shadow switch)
|
|
18
|
-
* +1 the cascade view-projections, then the caster sphere
|
|
19
|
-
* +2 the near cascade's map +3 the far cascade's map
|
|
20
|
-
* +4 the comparison sampler
|
|
21
|
-
*
|
|
22
|
-
* It takes a POINT and no normal. The materials' sampleShadow also rejects a
|
|
23
|
-
* surface facing away from the sun, which is right for skin and wrong for a
|
|
24
|
-
* blade of grass or a petal: those are thin, lit through, and shaded by their
|
|
25
|
-
* own N·L. The point is nudged toward the sun instead, which lifts a blade's
|
|
26
|
-
* root off a stage floor that casts into the same map.
|
|
27
|
-
*/
|
|
28
|
-
export declare function shadowApi(on: boolean, group: number, binding: number): string;
|
|
29
|
-
//# sourceMappingURL=shadow-api.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shadow-api.d.ts","sourceRoot":"","sources":["../../src/shaders/shadow-api.ts"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,gBAAyB,WActE,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,IAAI,CAAA;AAEpC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAyD7E"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { SHADOW_CASCADES } from "../shadow-cascades";
|
|
2
|
-
// The sun's shadow, as an effect author sees it.
|
|
3
|
-
//
|
|
4
|
-
// A lawn standing in a character's shadow has to darken where the floor under
|
|
5
|
-
// it does, or the figure floats: the ground catcher draws her shadow, and the
|
|
6
|
-
// blades drawn over it hide it. The map is already there — the materials and
|
|
7
|
-
// the ground read it every frame — so this hands the same lookup to effects.
|
|
8
|
-
//
|
|
9
|
-
// Bound for real in the particle SHADING stage only. That is where geometry an
|
|
10
|
-
// effect draws inside the scene pass is shaded, and the shadow pass has already
|
|
11
|
-
// run by then. Every other module that compiles the author's file gets the
|
|
12
|
-
// stub, which answers 1: lit is what a point with no occlusion information is,
|
|
13
|
-
// the same answer sampleShadow gives outside every cascade.
|
|
14
|
-
/**
|
|
15
|
-
* 3×3 PCF over one cascade's map, for a point already in that cascade's NDC.
|
|
16
|
-
*
|
|
17
|
-
* Shared with the materials, so an effect's shadow and her own shadow soften
|
|
18
|
-
* alike. The sampler is linear-filtered, which makes each tap a 2×2 bilinear
|
|
19
|
-
* compare. Unrolled — Safari's Metal backend doesn't unroll nested shadow
|
|
20
|
-
* loops reliably. The body expects `ndc` in scope and returns.
|
|
21
|
-
*/
|
|
22
|
-
export const pcf9 = (map, ts, sampler = "shadowSampler") => /* wgsl */ `
|
|
23
|
-
let suv = vec2f(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5);
|
|
24
|
-
let cmpZ = ndc.z - 0.001;
|
|
25
|
-
let ts = ${ts};
|
|
26
|
-
let s00 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f(-ts, -ts), cmpZ);
|
|
27
|
-
let s10 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f(0.0, -ts), cmpZ);
|
|
28
|
-
let s20 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f( ts, -ts), cmpZ);
|
|
29
|
-
let s01 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f(-ts, 0.0), cmpZ);
|
|
30
|
-
let s11 = textureSampleCompareLevel(${map}, ${sampler}, suv, cmpZ);
|
|
31
|
-
let s21 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f( ts, 0.0), cmpZ);
|
|
32
|
-
let s02 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f(-ts, ts), cmpZ);
|
|
33
|
-
let s12 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f(0.0, ts), cmpZ);
|
|
34
|
-
let s22 = textureSampleCompareLevel(${map}, ${sampler}, suv + vec2f( ts, ts), cmpZ);
|
|
35
|
-
return (s00 + s10 + s20 + s01 + s11 + s21 + s02 + s12 + s22) * (1.0 / 9.0);
|
|
36
|
-
`;
|
|
37
|
-
/** Bindings the real accessor takes, from `binding` upward. */
|
|
38
|
-
export const SHADOW_API_BINDINGS = 5;
|
|
39
|
-
/**
|
|
40
|
-
* `rzShadow(p)`: how much of the sun reaches world point `p` — 1 lit, 0 in a
|
|
41
|
-
* caster's shadow, soft in between.
|
|
42
|
-
*
|
|
43
|
-
* With `on`, declares five bindings from `binding`:
|
|
44
|
-
* +0 the light uniform (the sun's direction, and in .w the shadow switch)
|
|
45
|
-
* +1 the cascade view-projections, then the caster sphere
|
|
46
|
-
* +2 the near cascade's map +3 the far cascade's map
|
|
47
|
-
* +4 the comparison sampler
|
|
48
|
-
*
|
|
49
|
-
* It takes a POINT and no normal. The materials' sampleShadow also rejects a
|
|
50
|
-
* surface facing away from the sun, which is right for skin and wrong for a
|
|
51
|
-
* blade of grass or a petal: those are thin, lit through, and shaded by their
|
|
52
|
-
* own N·L. The point is nudged toward the sun instead, which lifts a blade's
|
|
53
|
-
* root off a stage floor that casts into the same map.
|
|
54
|
-
*/
|
|
55
|
-
export function shadowApi(on, group, binding) {
|
|
56
|
-
if (!on) {
|
|
57
|
-
return /* wgsl */ `
|
|
58
|
-
fn rzShadow(p: vec3f) -> f32 { return 1.0; }
|
|
59
|
-
`;
|
|
60
|
-
}
|
|
61
|
-
const n = SHADOW_CASCADES.length;
|
|
62
|
-
return /* wgsl */ `
|
|
63
|
-
// The first two vec4s of the light uniform: world ambient, then the sun.
|
|
64
|
-
struct _RzShadowSun { ambient: vec4f, direction: vec4f, }
|
|
65
|
-
// The cascades' matrices, inner to outer, then every caster in one sphere
|
|
66
|
-
// (x, y, z, radius): radius 0 = nothing casts, negative = do not test.
|
|
67
|
-
struct _RzShadowBlock { viewProj: array<mat4x4f, ${n}>, casters: vec4f, }
|
|
68
|
-
@group(${group}) @binding(${binding}) var<uniform> _rzShadowSun: _RzShadowSun;
|
|
69
|
-
@group(${group}) @binding(${binding + 1}) var<uniform> _rzShadowVP: _RzShadowBlock;
|
|
70
|
-
@group(${group}) @binding(${binding + 2}) var _rzShadowNear: texture_depth_2d;
|
|
71
|
-
@group(${group}) @binding(${binding + 3}) var _rzShadowFar: texture_depth_2d;
|
|
72
|
-
@group(${group}) @binding(${binding + 4}) var _rzShadowCmp: sampler_comparison;
|
|
73
|
-
|
|
74
|
-
fn _rzShadowNearTaps(ndc: vec3f) -> f32 {
|
|
75
|
-
${pcf9("_rzShadowNear", `1.0 / ${SHADOW_CASCADES[0].mapSize}.0`, "_rzShadowCmp")}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
fn _rzShadowFarTaps(ndc: vec3f) -> f32 {
|
|
79
|
-
${pcf9("_rzShadowFar", `1.0 / ${SHADOW_CASCADES[n - 1].mapSize}.0`, "_rzShadowCmp")}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fn rzShadow(p: vec3f) -> f32 {
|
|
83
|
-
// The scene's one shadow switch, on the sun — see sampleShadow.
|
|
84
|
-
let castAmt = _rzShadowSun.direction.w;
|
|
85
|
-
if (castAmt <= 0.0) { return 1.0; }
|
|
86
|
-
let toSun = normalize(-_rzShadowSun.direction.xyz);
|
|
87
|
-
// Can anything cast onto this point at all? The ground's test, for the same
|
|
88
|
-
// two reasons: most of a lawn is nowhere near her, and a scene with no
|
|
89
|
-
// models never renders the map, whose untouched zeroes compare as shadowed.
|
|
90
|
-
let cs = _rzShadowVP.casters;
|
|
91
|
-
if (cs.w == 0.0) { return 1.0; }
|
|
92
|
-
if (cs.w > 0.0) {
|
|
93
|
-
let toCaster = cs.xyz - p;
|
|
94
|
-
let along = dot(toCaster, toSun);
|
|
95
|
-
let perp = length(toCaster - toSun * along);
|
|
96
|
-
if (along <= -cs.w || perp > cs.w) { return 1.0; }
|
|
97
|
-
}
|
|
98
|
-
let q = p + toSun * 0.08;
|
|
99
|
-
let c0 = _rzShadowVP.viewProj[0] * vec4f(q, 1.0);
|
|
100
|
-
let n0 = c0.xyz / max(c0.w, 1e-6);
|
|
101
|
-
if (all(abs(n0.xy) < vec2f(0.98)) && n0.z > 0.0 && n0.z < 1.0) {
|
|
102
|
-
return mix(1.0, _rzShadowNearTaps(n0), castAmt);
|
|
103
|
-
}
|
|
104
|
-
let c1 = _rzShadowVP.viewProj[${n - 1}] * vec4f(q, 1.0);
|
|
105
|
-
let n1 = c1.xyz / max(c1.w, 1e-6);
|
|
106
|
-
if (all(abs(n1.xy) < vec2f(0.98)) && n1.z > 0.0 && n1.z < 1.0) {
|
|
107
|
-
return mix(1.0, _rzShadowFarTaps(n1), castAmt);
|
|
108
|
-
}
|
|
109
|
-
return 1.0;
|
|
110
|
-
}
|
|
111
|
-
`;
|
|
112
|
-
}
|