reze-engine 0.68.15 → 0.68.17
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/engine.d.ts +77 -6
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +129 -31
- package/dist/graph/presets/pool_floor.d.ts +3 -0
- package/dist/graph/presets/pool_floor.d.ts.map +1 -0
- package/dist/graph/presets/pool_floor.js +42 -0
- package/dist/graph/presets/water.d.ts +3 -0
- package/dist/graph/presets/water.d.ts.map +1 -0
- package/dist/graph/presets/water.js +31 -0
- package/dist/graph/registry.d.ts.map +1 -1
- package/dist/graph/registry.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/physics/autofit.d.ts +147 -0
- package/dist/physics/autofit.d.ts.map +1 -0
- package/dist/physics/autofit.js +501 -0
- package/dist/shaders/agx-lut.d.ts +11 -0
- package/dist/shaders/agx-lut.d.ts.map +1 -0
- package/dist/shaders/agx-lut.js +29 -0
- package/dist/shaders/dfg_lut.d.ts +3 -0
- package/dist/shaders/dfg_lut.d.ts.map +1 -0
- package/dist/shaders/dfg_lut.js +129 -0
- package/dist/shaders/lights.d.ts +1 -1
- package/dist/shaders/lights.d.ts.map +1 -1
- package/dist/shaders/lights.js +89 -6
- package/dist/shaders/ltc_mag_lut.d.ts +3 -0
- package/dist/shaders/ltc_mag_lut.d.ts.map +1 -0
- package/dist/shaders/ltc_mag_lut.js +1033 -0
- package/dist/shaders/materials/common.d.ts.map +1 -1
- package/dist/shaders/materials/common.js +2 -1
- 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 +182 -13
- package/dist/shaders/passes/composite.d.ts.map +1 -1
- package/dist/shaders/passes/composite.js +59 -4
- package/dist/shaders/passes/field-blit.d.ts +26 -0
- package/dist/shaders/passes/field-blit.d.ts.map +1 -0
- package/dist/shaders/passes/field-blit.js +65 -0
- package/dist/shaders/passes/ghosts.d.ts +22 -0
- package/dist/shaders/passes/ghosts.d.ts.map +1 -0
- package/dist/shaders/passes/ghosts.js +75 -0
- package/dist/shaders/passes/ground-noise.d.ts +7 -0
- package/dist/shaders/passes/ground-noise.d.ts.map +1 -0
- package/dist/shaders/passes/ground-noise.js +88 -0
- package/dist/shaders/passes/sim.d.ts +34 -0
- package/dist/shaders/passes/sim.d.ts.map +1 -0
- package/dist/shaders/passes/sim.js +169 -0
- package/dist/shaders/score-api.d.ts +10 -0
- package/dist/shaders/score-api.d.ts.map +1 -0
- package/dist/shaders/score-api.js +114 -0
- package/dist/shaders/shadow-api.d.ts +29 -0
- package/dist/shaders/shadow-api.d.ts.map +1 -0
- package/dist/shaders/shadow-api.js +112 -0
- package/package.json +1 -1
- package/src/engine.ts +154 -31
- package/src/graph/registry.ts +4 -1
- package/src/index.ts +2 -0
- package/src/shaders/lights.ts +89 -6
- package/src/shaders/materials/common.ts +2 -1
- package/src/shaders/materials/nodes.ts +182 -13
- package/src/shaders/passes/composite.ts +59 -4
- package/dist/_dbg-loader.mjs +0 -1100
package/dist/shaders/lights.js
CHANGED
|
@@ -23,7 +23,7 @@ import { subjectMaskApi } from "./cast-api";
|
|
|
23
23
|
// [4..6] grid origin (f32) [7] 1 / cell edge (f32)
|
|
24
24
|
// [8..10] grid dims (u32) [12..19] the OUTSIDE mask (u32 bits)
|
|
25
25
|
//
|
|
26
|
-
// then MAX_LIGHTS records of
|
|
26
|
+
// then MAX_LIGHTS records of 20 floats — five vec4s:
|
|
27
27
|
//
|
|
28
28
|
// [0..2] position, world space [3] radius
|
|
29
29
|
// [4..6] colour PREMULTIPLIED by intensity [7] type: bits, 1 spot, 2 diffuse only
|
|
@@ -32,6 +32,8 @@ import { subjectMaskApi } from "./cast-api";
|
|
|
32
32
|
// [13] the rendering layers it does NOT reach (u32 bits)
|
|
33
33
|
// [14] its bulb: the distance inside which the inverse square is held flat
|
|
34
34
|
// (0 = RZ_LAMP_NEAR) [15] its cookie: layer + 1, 0 none
|
|
35
|
+
// [16..18] a TUBE's half-axis, world space: the lamp is the segment
|
|
36
|
+
// position ± this, (0,0,0) for a point [19] unused
|
|
35
37
|
//
|
|
36
38
|
// then the grid: LIGHT_MASK_WORDS words of lamp bits per cell.
|
|
37
39
|
//
|
|
@@ -62,7 +64,7 @@ import { textureApi } from "./texture-api";
|
|
|
62
64
|
* outside mask, five vec4s — see the layout above. */
|
|
63
65
|
export const LIGHT_HEADER = 20;
|
|
64
66
|
/** Floats per light — see the layout above. */
|
|
65
|
-
export const LIGHT_STRIDE =
|
|
67
|
+
export const LIGHT_STRIDE = 20;
|
|
66
68
|
/**
|
|
67
69
|
* The cap. The loop below runs per fragment over the lights a scene HAS, so
|
|
68
70
|
* this bounds the worst case rather than the ordinary one, and the buffer is
|
|
@@ -241,6 +243,10 @@ fn lightEmitMain(@builtin(global_invocation_id) gid: vec3u) {
|
|
|
241
243
|
_rzLightsOut[b + 13u] = 0.0;
|
|
242
244
|
_rzLightsOut[b + 14u] = select(0.0, max(l.near, 0.0), finite && l.near == l.near);
|
|
243
245
|
_rzLightsOut[b + 15u] = 0.0;
|
|
246
|
+
_rzLightsOut[b + 16u] = 0.0;
|
|
247
|
+
_rzLightsOut[b + 17u] = 0.0;
|
|
248
|
+
_rzLightsOut[b + 18u] = 0.0;
|
|
249
|
+
_rzLightsOut[b + 19u] = 0.0;
|
|
244
250
|
}
|
|
245
251
|
`;
|
|
246
252
|
}
|
|
@@ -282,9 +288,9 @@ fn rzLightPos(i: u32) -> vec3f { return _rzLightVec(i, 0u).xyz; }
|
|
|
282
288
|
fn rzLightRadius(i: u32) -> f32 { return _rzLightVec(i, 0u).w; }
|
|
283
289
|
|
|
284
290
|
/** Light i's colour, already multiplied by its intensity. */
|
|
285
|
-
fn rzLightColor(i: u32) -> vec3f { return _rzLightVec(i, 1u).xyz; }
|
|
286
|
-
/** 0 for a lamp that lights diffuse only (type bit 2), else 1 — the weight on
|
|
287
|
-
* its highlight. */
|
|
291
|
+
fn rzLightColor(i: u32) -> vec3f { return _rzLightVec(i, 1u).xyz; }
|
|
292
|
+
/** 0 for a lamp that lights diffuse only (type bit 2), else 1 — the weight on
|
|
293
|
+
* its highlight. */
|
|
288
294
|
fn rzLightSpecular(i: u32) -> f32 { return select(1.0, 0.0, (u32(max(_rzLightVec(i, 1u).w, 0.0)) & 2u) != 0u); }
|
|
289
295
|
|
|
290
296
|
/** Where light i points, away from itself. The zero vector for a point light. */
|
|
@@ -318,6 +324,68 @@ fn rzLightCookie(i: u32, toLight: vec3f) -> vec3f {
|
|
|
318
324
|
* a soft sphere, which a single global bulb cannot spell. */
|
|
319
325
|
fn rzLightNear(i: u32) -> f32 { let r = _rzLightVec(i, 3u).z; return select(RZ_LAMP_NEAR, r, r > 0.0); }
|
|
320
326
|
|
|
327
|
+
/** A tube lamp's half-axis: the lamp is the segment rzLightPos ± this. The
|
|
328
|
+
* zero vector for a point or a spot, which is every lamp but a tube. */
|
|
329
|
+
fn rzLightTube(i: u32) -> vec3f { return _rzLightVec(i, 4u).xyz; }
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* A TUBE: a glowing strip, a neon line — light along a segment, not from a
|
|
333
|
+
* point. A row of points stood in for one puts a dot of highlight per point on
|
|
334
|
+
* a glossy wall where the strip's reflection is a band, and lights the panel
|
|
335
|
+
* beside the strip as if from half a metre away.
|
|
336
|
+
*
|
|
337
|
+
* Its irradiance is the segment's, its total intensity spread along it, per
|
|
338
|
+
* unit of that intensity (far off it is n·l/d², the point lamp's):
|
|
339
|
+
*
|
|
340
|
+
* - WITH AN AIM, a glowing strip facing it — Lambertian, cos θₑ at every
|
|
341
|
+
* point of it. Since the aim is square to the segment, cos θₑ/r is hₑ/r²
|
|
342
|
+
* all along it (hₑ the height of p over the strip's plane), and the
|
|
343
|
+
* integral of hₑ·n·(x − p)/r⁴ along it is closed: with t along the axis
|
|
344
|
+
* and D the distance off it, ∫(A + B·t)/(D² + t²)² dt =
|
|
345
|
+
* A·(t/(2D²(D² + t²)) + atan(t/D)/(2D³)) − B/(2(D² + t²)). Exact for a
|
|
346
|
+
* thin strip (within 0.4% of the integral over a 2 × 0.1 m face); a spot
|
|
347
|
+
* cone's fit to the cosine gave a quarter too much 30° off its axis.
|
|
348
|
+
* - Without one, a line glowing every way (Picott's, as Karis gives it):
|
|
349
|
+
* (n·L0/|L0| + n·L1/|L1|) / (|L0||L1| + L0·L1), the ends L0 and L1 from p;
|
|
350
|
+
* beside a long line at h it is 2/(h·length).
|
|
351
|
+
*
|
|
352
|
+
* The bulb floors D (2·bulb² the Picott denominator), as max(d², bulb²)
|
|
353
|
+
* floors a point. Clamped at zero: both assume the whole segment above p's
|
|
354
|
+
* horizon.
|
|
355
|
+
*/
|
|
356
|
+
fn _rzTubeIrradiance(p: vec3f, n: vec3f, c: vec3f, h: vec3f, aim: vec3f, bulb: f32) -> f32 {
|
|
357
|
+
if (dot(aim, aim) > 0.5) {
|
|
358
|
+
let len = length(h);
|
|
359
|
+
let u = h / max(len, 1e-6);
|
|
360
|
+
let w = c - p;
|
|
361
|
+
let wu = dot(w, u);
|
|
362
|
+
let wp = w - u * wu;
|
|
363
|
+
let he = -dot(aim, w);
|
|
364
|
+
if (he <= 0.0) { return 0.0; }
|
|
365
|
+
let D2 = max(dot(wp, wp), bulb * bulb);
|
|
366
|
+
let D = sqrt(D2);
|
|
367
|
+
let A = dot(n, wp);
|
|
368
|
+
let B = dot(n, u);
|
|
369
|
+
let t1 = wu + len;
|
|
370
|
+
let t0 = wu - len;
|
|
371
|
+
let f1 = A * (t1 / (2.0 * D2 * (D2 + t1 * t1)) + atan(t1 / D) / (2.0 * D2 * D)) - B / (2.0 * (D2 + t1 * t1));
|
|
372
|
+
let f0 = A * (t0 / (2.0 * D2 * (D2 + t0 * t0)) + atan(t0 / D) / (2.0 * D2 * D)) - B / (2.0 * (D2 + t0 * t0));
|
|
373
|
+
return max(he * (f1 - f0) / max(2.0 * len, 1e-6), 0.0);
|
|
374
|
+
}
|
|
375
|
+
let L0 = c - h - p;
|
|
376
|
+
let L1 = c + h - p;
|
|
377
|
+
let l0 = max(length(L0), 1e-4);
|
|
378
|
+
let l1 = max(length(L1), 1e-4);
|
|
379
|
+
let e = (dot(n, L0) / l0 + dot(n, L1) / l1) / max(l0 * l1 + dot(L0, L1), 2.0 * bulb * bulb);
|
|
380
|
+
return max(e, 0.0);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** The point of a tube nearest p: where its reach, cone and cookie are read. */
|
|
384
|
+
fn _rzTubeNearest(p: vec3f, c: vec3f, h: vec3f) -> vec3f {
|
|
385
|
+
let t = clamp(dot(p - c, h) / max(dot(h, h), 1e-8), -1.0, 1.0);
|
|
386
|
+
return c + h * t;
|
|
387
|
+
}
|
|
388
|
+
|
|
321
389
|
/** The cosines a spot fades between: x its outer edge, y its inner one. A point
|
|
322
390
|
* light stores (-1, -1), which saturates the cone term to 1. */
|
|
323
391
|
fn rzLightCone(i: u32) -> vec2f { return vec2f(_rzLightVec(i, 2u).w, _rzLightVec(i, 3u).x); }
|
|
@@ -362,8 +430,23 @@ fn _rzLightOne(i: u32, p: vec3f, n: vec3f) -> vec3f {
|
|
|
362
430
|
let dist = length(d);
|
|
363
431
|
// Out of reach before anything else is computed. The grid is conservative —
|
|
364
432
|
// a cell's bit means the lamp CAN reach part of it — so this still runs.
|
|
365
|
-
|
|
433
|
+
// a tube's reach is from its segment: past it by its half-length
|
|
434
|
+
let h = rzLightTube(i);
|
|
435
|
+
if (dist >= pr.w + length(h)) { return vec3f(0.0); }
|
|
366
436
|
let toLight = d / max(dist, 1e-4);
|
|
437
|
+
// A tube (see _rzTubeIrradiance): its reach from the point of it nearest
|
|
438
|
+
// p, its light the segment's whole — an aimed one's cosine included, so it
|
|
439
|
+
// takes no cone and no cookie.
|
|
440
|
+
if (dot(h, h) > 0.0) {
|
|
441
|
+
let q = _rzTubeNearest(p, pr.xyz, h);
|
|
442
|
+
let qd = length(q - p);
|
|
443
|
+
if (qd >= pr.w) { return vec3f(0.0); }
|
|
444
|
+
let qt = clamp(qd / max(pr.w, 1e-4), 0.0, 1.0);
|
|
445
|
+
let qt2 = qt * qt;
|
|
446
|
+
let qw = 1.0 - qt2 * qt2;
|
|
447
|
+
let e = _rzTubeIrradiance(p, n, pr.xyz, h, rzLightAim(i), rzLightNear(i));
|
|
448
|
+
return rzLightColor(i) * (e * qw * qw);
|
|
449
|
+
}
|
|
367
450
|
// Facing the light, and nothing behind it. No wrap or half-lambert: this
|
|
368
451
|
// layer adds light, and a wrapped term would lift the shadow side, which is
|
|
369
452
|
// the ramp's business and not this one's.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ltc_mag_lut.d.ts","sourceRoot":"","sources":["../../src/shaders/ltc_mag_lut.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAGlC,eAAO,MAAM,gBAAgB,EAAE,YAigC7B,CAAA"}
|