reze-engine 0.68.14 → 0.68.16
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 +78 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +126 -11
- 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/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/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/package.json +1 -1
- package/src/engine.ts +152 -11
- 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/engine.js
CHANGED
|
@@ -1148,6 +1148,12 @@ export class Engine {
|
|
|
1148
1148
|
/** The frame the current run of requests began — the cap's start. */
|
|
1149
1149
|
this.probeAskedFrame = 0;
|
|
1150
1150
|
this.probeFrame = 0;
|
|
1151
|
+
/** Off: no capture, and every reader falls back to the sky — see
|
|
1152
|
+
* setReflectionProbe. */
|
|
1153
|
+
this.probeEnabled = true;
|
|
1154
|
+
/** A local probe's capture point and box, world space — see
|
|
1155
|
+
* setReflectionProbe. Null: the stage's middle and bounds. */
|
|
1156
|
+
this.probeRegion = null;
|
|
1151
1157
|
this.probeCapture = null;
|
|
1152
1158
|
this.skyPrefilterPipeline = null;
|
|
1153
1159
|
// The scene's user WGSL effect (setEffect). ONE per scene, mounted under the
|
|
@@ -1373,6 +1379,9 @@ export class Engine {
|
|
|
1373
1379
|
};
|
|
1374
1380
|
/** Sensor grain: how much. */
|
|
1375
1381
|
this.grain = { amount: 0 };
|
|
1382
|
+
/** The pixel filter: its width in pixels (0 off) and the 1D weights of
|
|
1383
|
+
* offsets 0, ±1, ±2 it comes to — see setPixelFilter. */
|
|
1384
|
+
this.pixelFilter = { width: 0, type: "blackman-harris", weights: [1, 0, 0] };
|
|
1376
1385
|
/** Debug/diagnostic: skip every inverted-hull outline draw. */
|
|
1377
1386
|
// OFF by default — the product aesthetic. Modern high-detail models read
|
|
1378
1387
|
// better without hulls (babylon-mmd's own demos disable its outline renderer
|
|
@@ -1971,6 +1980,55 @@ export class Engine {
|
|
|
1971
1980
|
getFilmGrain() {
|
|
1972
1981
|
return this.grain;
|
|
1973
1982
|
}
|
|
1983
|
+
/**
|
|
1984
|
+
* A renderer's pixel filter, over the rendered scene: how Cycles builds a
|
|
1985
|
+
* pixel from the light around it rather than from its own square alone.
|
|
1986
|
+
* Off (width 0) the engine's pixels are their own box, which is what it has
|
|
1987
|
+
* always drawn.
|
|
1988
|
+
*
|
|
1989
|
+
* Cycles samples each pixel through a Blackman-Harris window twice the
|
|
1990
|
+
* filter width across (1.5 px by default, so 3 px), or a box that width
|
|
1991
|
+
* across. It is invisible on ordinary surfaces and decides what a thing
|
|
1992
|
+
* smaller than a pixel and far brighter than white looks like: a 3 cm ember
|
|
1993
|
+
* glowing at twenty times white spreads into the pixels around it and reads
|
|
1994
|
+
* as a coloured square, and a neon edge gets its coloured fringe. The engine
|
|
1995
|
+
* resolves its samples to a box first, so the filter here is that window
|
|
1996
|
+
* integrated over each neighbour's square — the nearest staircase to it —
|
|
1997
|
+
* applied to the scene's HDR light before the view transform, coverage
|
|
1998
|
+
* alongside, so the sky behind it composites as before. Up to 2.5 px wide
|
|
1999
|
+
* (5×5 taps), one more pass of reads in the composite, none when off.
|
|
2000
|
+
*/
|
|
2001
|
+
setPixelFilter(width, type = "blackman-harris") {
|
|
2002
|
+
const w = Number.isFinite(width) ? Math.min(Math.max(width, 0), 2.5) : 0;
|
|
2003
|
+
// The window's full span in pixels and its shape over u in 0..1.
|
|
2004
|
+
const span = type === "box" ? w : w * 2;
|
|
2005
|
+
const shape = (u) => type === "box"
|
|
2006
|
+
? 1
|
|
2007
|
+
: 0.35875 - 0.48829 * Math.cos(2 * Math.PI * u) + 0.14128 * Math.cos(4 * Math.PI * u) - 0.01168 * Math.cos(6 * Math.PI * u);
|
|
2008
|
+
const weights = [1, 0, 0];
|
|
2009
|
+
if (span > 1e-3) {
|
|
2010
|
+
// Each offset's square, [d − ½, d + ½], integrated over the window.
|
|
2011
|
+
const n = 64;
|
|
2012
|
+
for (let d = 0; d < 3; d++) {
|
|
2013
|
+
let sum = 0;
|
|
2014
|
+
for (let i = 0; i < n; i++) {
|
|
2015
|
+
const x = d - 0.5 + (i + 0.5) / n;
|
|
2016
|
+
if (Math.abs(x) < span / 2)
|
|
2017
|
+
sum += shape(x / span + 0.5) / n;
|
|
2018
|
+
}
|
|
2019
|
+
weights[d] = sum;
|
|
2020
|
+
}
|
|
2021
|
+
const total = weights[0] + 2 * weights[1] + 2 * weights[2];
|
|
2022
|
+
for (let d = 0; d < 3; d++)
|
|
2023
|
+
weights[d] /= total;
|
|
2024
|
+
}
|
|
2025
|
+
this.pixelFilter = { width: w, type, weights };
|
|
2026
|
+
if (this.device && this.compositeUniformBuffer)
|
|
2027
|
+
this.writeCompositeViewUniforms();
|
|
2028
|
+
}
|
|
2029
|
+
getPixelFilter() {
|
|
2030
|
+
return { width: this.pixelFilter.width, type: this.pixelFilter.type };
|
|
2031
|
+
}
|
|
1974
2032
|
setViewTransformOptions(patch) {
|
|
1975
2033
|
const v = this.viewTransform;
|
|
1976
2034
|
if (patch.exposure !== undefined)
|
|
@@ -2052,6 +2110,11 @@ export class Engine {
|
|
|
2052
2110
|
// The soft curve's power (viewU[15].x), the scene's own (SceneSetting._contrast).
|
|
2053
2111
|
// Its own vec4: viewU[11..14] are the cast's positions whenever an effect runs.
|
|
2054
2112
|
u[60] = v.contrast;
|
|
2113
|
+
// The pixel filter's 1D weights for offsets 0, ±1, ±2 (viewU[15].yzw);
|
|
2114
|
+
// 1, 0, 0 is off — see setPixelFilter.
|
|
2115
|
+
u[61] = this.pixelFilter.weights[0];
|
|
2116
|
+
u[62] = this.pixelFilter.weights[1];
|
|
2117
|
+
u[63] = this.pixelFilter.weights[2];
|
|
2055
2118
|
// ── Grade (viewU[7..9]) ── The UI's three tonal COLORS map to ASC CDL here,
|
|
2056
2119
|
// on the CPU, so the shader only ever sees slope/offset/power. Mid-gray is
|
|
2057
2120
|
// neutral in all three; the signed distance from it is the amount.
|
|
@@ -9111,6 +9174,24 @@ export class Engine {
|
|
|
9111
9174
|
this.probeDirtyFrame = this.probeFrame;
|
|
9112
9175
|
this.probeDirty = true;
|
|
9113
9176
|
}
|
|
9177
|
+
/** Whether the stage reflects its own capture (the default) or the sky. Off
|
|
9178
|
+
* is for a stage whose sky was measured from inside it — a Blender export's
|
|
9179
|
+
* world — where a capture lit without the lamps' shadows comes out too
|
|
9180
|
+
* bright on a shiny floor.
|
|
9181
|
+
*
|
|
9182
|
+
* With a region the probe is LOCAL, as a room's box probe is in Unity:
|
|
9183
|
+
* captured from region.center, box-projected onto region.min..max, and a
|
|
9184
|
+
* surface outside that box reflects the sky — a tunnel's glossy walls
|
|
9185
|
+
* mirror its neon while the floor around it keeps the world. Null: the
|
|
9186
|
+
* stage's middle and bounds, every surface. */
|
|
9187
|
+
setReflectionProbe(enabled, region = null) {
|
|
9188
|
+
const same = (a, b) => a === b || (!!a && !!b && [0, 1, 2].every((k) => a.center[k] === b.center[k] && a.min[k] === b.min[k] && a.max[k] === b.max[k]));
|
|
9189
|
+
if (this.probeEnabled === enabled && same(this.probeRegion, region))
|
|
9190
|
+
return;
|
|
9191
|
+
this.probeEnabled = enabled;
|
|
9192
|
+
this.probeRegion = region && [region.center, region.min, region.max].every((v) => v.length >= 3 && v.every(Number.isFinite)) ? region : null;
|
|
9193
|
+
this.captureReflectionProbe();
|
|
9194
|
+
}
|
|
9114
9195
|
/** The stage's world-space bounds: every stage model's material boxes
|
|
9115
9196
|
* through its placement. Null without a stage. */
|
|
9116
9197
|
stageBounds() {
|
|
@@ -9152,15 +9233,17 @@ export class Engine {
|
|
|
9152
9233
|
if (!settled && this.probeFrame - this.probeAskedFrame < Engine.PROBE_MAX_WAIT_FRAMES)
|
|
9153
9234
|
return;
|
|
9154
9235
|
this.probeDirty = false;
|
|
9155
|
-
const
|
|
9236
|
+
const region = this.probeRegion;
|
|
9237
|
+
const bounds = !this.probeEnabled ? null : region ? { min: region.min, max: region.max } : this.stageBounds();
|
|
9156
9238
|
if (!bounds) {
|
|
9157
|
-
// No stage
|
|
9239
|
+
// No stage, or the probe is off: it goes dark and every reader falls
|
|
9240
|
+
// back to the sky.
|
|
9158
9241
|
this.probeData.fill(0);
|
|
9159
9242
|
this.device.queue.writeBuffer(this.probeUniformBuffer, 0, this.probeData);
|
|
9160
9243
|
return;
|
|
9161
9244
|
}
|
|
9162
9245
|
try {
|
|
9163
|
-
this.renderProbe(bounds);
|
|
9246
|
+
this.renderProbe(bounds, region?.center ?? null);
|
|
9164
9247
|
}
|
|
9165
9248
|
catch (e) {
|
|
9166
9249
|
console.warn("[reze-engine] reflection probe capture failed:", e);
|
|
@@ -9281,19 +9364,22 @@ export class Engine {
|
|
|
9281
9364
|
* the MMD convention, else their bottom) — where a game puts the probe of a
|
|
9282
9365
|
* room the player stands in. The box it projects onto is the bounds.
|
|
9283
9366
|
*
|
|
9367
|
+
* A LOCAL probe (setReflectionProbe's region) is captured from the point
|
|
9368
|
+
* it names and projects onto its own box; a surface outside that box
|
|
9369
|
+
* reflects the sky, as Unity's box probes fall back to the skybox past
|
|
9370
|
+
* their bounds.
|
|
9371
|
+
*
|
|
9284
9372
|
* WHAT: the stage alone, in its own looks, lit by the scene's sun, lamps
|
|
9285
9373
|
* and sky as they stand. The cast is not in it (a baked probe never holds
|
|
9286
9374
|
* the characters), nor are effects.
|
|
9287
9375
|
*/
|
|
9288
|
-
renderProbe(bounds) {
|
|
9376
|
+
renderProbe(bounds, at) {
|
|
9289
9377
|
const cap = this.ensureProbeCapture();
|
|
9290
9378
|
const { min, max } = bounds;
|
|
9291
9379
|
const floor = min[1] <= 0 && max[1] >= 0 ? 0 : min[1];
|
|
9292
|
-
const eye =
|
|
9293
|
-
|
|
9294
|
-
Math.min(floor + 12, (min[1] + max[1]) * 0.5),
|
|
9295
|
-
(min[2] + max[2]) * 0.5,
|
|
9296
|
-
];
|
|
9380
|
+
const eye = at
|
|
9381
|
+
? [at[0], at[1], at[2]]
|
|
9382
|
+
: [(min[0] + max[0]) * 0.5, Math.min(floor + 12, (min[1] + max[1]) * 0.5), (min[2] + max[2]) * 0.5];
|
|
9297
9383
|
const span = Math.hypot(max[0] - min[0], max[1] - min[1], max[2] - min[2]);
|
|
9298
9384
|
const near = 0.25;
|
|
9299
9385
|
const far = Math.max(span * 2, 100);
|
|
@@ -9419,7 +9505,8 @@ export class Engine {
|
|
|
9419
9505
|
for (let f = 0; f < 6; f++)
|
|
9420
9506
|
run(face(this.probeTexture, m, f), cap.filterPipeline, cap.filterGroups[m * 6 + f]);
|
|
9421
9507
|
this.device.queue.submit([encoder.finish()]);
|
|
9422
|
-
|
|
9508
|
+
// boxMax.w: 1 for a local probe, whose outside reflects the sky.
|
|
9509
|
+
this.probeData.set([eye[0], eye[1], eye[2], 1, min[0], min[1], min[2], 1, max[0], max[1], max[2], at ? 1 : 0]);
|
|
9423
9510
|
this.device.queue.writeBuffer(this.probeUniformBuffer, 0, this.probeData);
|
|
9424
9511
|
}
|
|
9425
9512
|
/**
|
|
@@ -9941,13 +10028,22 @@ export class Engine {
|
|
|
9941
10028
|
// rewrites the lamps when it lands).
|
|
9942
10029
|
const cookie = l.cookie !== undefined ? this.cookieLayers.get(l.cookie) : undefined;
|
|
9943
10030
|
this.lightsData[b + 15] = cookie !== undefined ? cookie + 1 : 0;
|
|
10031
|
+
// A tube's half-axis; zero for a point (a non-finite one is a point too)
|
|
10032
|
+
const tube = l.tube && [l.tube.x, l.tube.y, l.tube.z].every(Number.isFinite) && l.kind !== "directional" ? l.tube : null;
|
|
10033
|
+
this.lightsData[b + 16] = tube ? tube.x : 0;
|
|
10034
|
+
this.lightsData[b + 17] = tube ? tube.y : 0;
|
|
10035
|
+
this.lightsData[b + 18] = tube ? tube.z : 0;
|
|
10036
|
+
this.lightsData[b + 19] = 0;
|
|
9944
10037
|
}
|
|
9945
10038
|
// The grid, from the records as STORED — normalised aim, clamped reach, the
|
|
9946
10039
|
// cosines in f32 — so it indexes exactly what the shader will evaluate.
|
|
9947
10040
|
const grid = buildLightGrid(list.map((_, i) => {
|
|
9948
10041
|
const b = LIGHT_HEADER + i * LIGHT_STRIDE;
|
|
9949
10042
|
const d = this.lightsData;
|
|
9950
|
-
|
|
10043
|
+
// a tube reaches its radius from any point of its segment: past the
|
|
10044
|
+
// middle by its half-length, and a cone is no bound along it
|
|
10045
|
+
const half = Math.hypot(d[b + 16], d[b + 17], d[b + 18]);
|
|
10046
|
+
return { x: d[b], y: d[b + 1], z: d[b + 2], radius: d[b + 3] + half, ax: d[b + 8], ay: d[b + 9], az: d[b + 10], cosOuter: half > 0 ? -1 : d[b + 11] };
|
|
9951
10047
|
}));
|
|
9952
10048
|
this.lightHeader.set(grid.origin, 4);
|
|
9953
10049
|
this.lightHeader[7] = 1 / grid.cell;
|
|
@@ -11601,6 +11697,22 @@ export class Engine {
|
|
|
11601
11697
|
else
|
|
11602
11698
|
inst.hiddenMaterials.add(materialName);
|
|
11603
11699
|
}
|
|
11700
|
+
/**
|
|
11701
|
+
* Whether the reflection probe captures a material. Off for a glowing strip
|
|
11702
|
+
* whose light a TUBE LAMP already carries (SceneLight.tube): the lamp draws
|
|
11703
|
+
* its reflection in every glossy surface, exactly, and the probe's picture
|
|
11704
|
+
* of the same strip would put it there a second time. Re-captures the probe.
|
|
11705
|
+
*/
|
|
11706
|
+
setMaterialInProbe(modelName, materialName, inProbe) {
|
|
11707
|
+
const inst = this.modelInstances.get(modelName);
|
|
11708
|
+
if (!inst || inst.probeHiddenMaterials.has(materialName) === !inProbe)
|
|
11709
|
+
return;
|
|
11710
|
+
if (inProbe)
|
|
11711
|
+
inst.probeHiddenMaterials.delete(materialName);
|
|
11712
|
+
else
|
|
11713
|
+
inst.probeHiddenMaterials.add(materialName);
|
|
11714
|
+
this.captureReflectionProbe();
|
|
11715
|
+
}
|
|
11604
11716
|
toggleMaterialVisible(modelName, materialName) {
|
|
11605
11717
|
const inst = this.modelInstances.get(modelName);
|
|
11606
11718
|
if (!inst)
|
|
@@ -13180,6 +13292,7 @@ export class Engine {
|
|
|
13180
13292
|
skinMatricesDirty: true,
|
|
13181
13293
|
hiddenMaterials: new Set(),
|
|
13182
13294
|
morphHiddenMaterials: new Set(),
|
|
13295
|
+
probeHiddenMaterials: new Set(),
|
|
13183
13296
|
materialMorphTargets: null,
|
|
13184
13297
|
materialMorphByIndex: null,
|
|
13185
13298
|
physics,
|
|
@@ -16480,6 +16593,8 @@ export class Engine {
|
|
|
16480
16593
|
// The probe draws directly, past the cull: honour the switches it holds.
|
|
16481
16594
|
if (view.args === "probe" && !this.shouldRenderDrawCall(inst, draw))
|
|
16482
16595
|
continue;
|
|
16596
|
+
if (view.args === "probe" && inst.probeHiddenMaterials.has(draw.materialName))
|
|
16597
|
+
continue;
|
|
16483
16598
|
if (!bound) {
|
|
16484
16599
|
pass.setBindGroup(0, view.perFrame);
|
|
16485
16600
|
pass.setBindGroup(1, inst.mainPerInstanceBindGroup);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/graph/registry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;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EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAuzBlD,CAAA"}
|
package/dist/graph/registry.js
CHANGED
|
@@ -688,11 +688,14 @@ export const NODE_REGISTRY = {
|
|
|
688
688
|
occlusion: F(1),
|
|
689
689
|
emission: C([0, 0, 0]),
|
|
690
690
|
alpha: F(1),
|
|
691
|
+
/** 1: the lamps' and sun's highlights rise toward white at grazing
|
|
692
|
+
* (Schlick), as Blender's Principled; 0 is URP's fixed reflectance. */
|
|
693
|
+
fresnel: F(0),
|
|
691
694
|
normal: { type: "vector", contextDefault: "n" },
|
|
692
695
|
},
|
|
693
696
|
outputs: { color: "color", alpha: "float" },
|
|
694
697
|
outputSelect: { color: ".rgb", alpha: ".a" },
|
|
695
|
-
emit: (a) => `urp_lit(${a.base_color}, ${a.metallic}, ${a.smoothness}, ${a.specular}, ${a.occlusion}, ${a.emission}, ${a.alpha}, ` +
|
|
698
|
+
emit: (a) => `urp_lit(${a.base_color}, ${a.metallic}, ${a.smoothness}, ${a.specular}, ${a.occlusion}, ${a.emission}, ${a.alpha}, ${a.fresnel}, ` +
|
|
696
699
|
`${a.normal}, l, v, sun, amb, shadow, input.worldPos, true)`,
|
|
697
700
|
takesLight: true,
|
|
698
701
|
},
|
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 GizmoDragEvent, type GizmoDragCallback, type GizmoDragKind, type DissolveCycle, type EffectParamValue, 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, 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 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";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,uBAA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C9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/shaders/lights.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* outside mask, five vec4s — see the layout above. */
|
|
3
3
|
export declare const LIGHT_HEADER = 20;
|
|
4
4
|
/** Floats per light — see the layout above. */
|
|
5
|
-
export declare const LIGHT_STRIDE =
|
|
5
|
+
export declare const LIGHT_STRIDE = 20;
|
|
6
6
|
/**
|
|
7
7
|
* The cap. The loop below runs per fragment over the lights a scene HAS, so
|
|
8
8
|
* this bounds the worst case rather than the ordinary one, and the buffer is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../src/shaders/lights.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../src/shaders/lights.ts"],"names":[],"mappings":"AAgEA;uDACuD;AACvD,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,+CAA+C;AAC/C,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,MAAM,CAAA;AAC7B,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,QAAkB,CAAA;AAC/C;0EAC0E;AAC1E,eAAO,MAAM,gBAAgB,QAAQ,CAAA;AACrC,uCAAuC;AACvC,eAAO,MAAM,eAAe,QAA2C,CAAA;AACvE,wDAAwD;AACxD,eAAO,MAAM,aAAa,QAAwD,CAAA;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,oUAWhC,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,QAA4B,CAAA;AAE3D,8CAA8C;AAC9C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,EAC5B,UAAU,SAAK,GACd,MAAM,CAwGR;AAED;8EAC8E;AAC9E,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC5C,MAAM,CAsRR"}
|
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.
|
|
@@ -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,eAAO,MAAM,oBAAoB,
|
|
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,eAAO,MAAM,oBAAoB,QAiQhC,CAAC;AAwHF,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,orMAgHzB,CAAA;AAQD,eAAO,MAAM,4BAA4B,QAC6H,CAAA"}
|
|
@@ -237,7 +237,8 @@ struct LightVP { viewProj: array<mat4x4f, ${SHADOW_CASCADES.length}>, };
|
|
|
237
237
|
|
|
238
238
|
/** The stage's reflection probe (Engine.captureReflectionProbe): where it was
|
|
239
239
|
* captured (xyz) and its strength (w); the box it projects onto, min with the
|
|
240
|
-
* on-flag in w, then max
|
|
240
|
+
* on-flag in w, then max with the local flag in w (1: outside the box the
|
|
241
|
+
* sky stands in). Off (boxMin.w 0) the sky stands in everywhere. */
|
|
241
242
|
struct ProbeUniforms {
|
|
242
243
|
center: vec4f,
|
|
243
244
|
boxMin: vec4f,
|