@woosh/meep-engine 2.119.58 → 2.119.59
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/editor/ecs/component/createObjectEditor.js +2 -0
- package/editor/tools/TransformTool.js +6 -5
- package/editor/tools/v2/TransformMode.d.ts +7 -0
- package/editor/tools/v2/TransformMode.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/core/collection/array/array_shift_back.d.ts +9 -0
- package/src/core/collection/array/array_shift_back.d.ts.map +1 -0
- package/src/core/collection/array/array_shift_back.js +20 -0
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +55 -1
- package/src/core/events/signal/SignalHandler.d.ts +5 -0
- package/src/core/events/signal/SignalHandler.d.ts.map +1 -1
- package/src/core/events/signal/SignalHandler.js +6 -0
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js +2 -1
- package/src/engine/EngineHarness.d.ts +2 -2
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +1 -1
- package/src/engine/graphics/material/manager/MaterialManager.d.ts +6 -0
- package/src/engine/graphics/material/manager/MaterialManager.d.ts.map +1 -1
- package/src/engine/graphics/material/manager/MaterialManager.js +9 -0
- package/src/engine/graphics/sh3/gi/material/common.d.ts +1 -1
- package/src/engine/graphics/sh3/gi/material/common.js +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +7 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +60 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +1 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +8 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +38 -27
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +2 -0
- package/src/engine/graphics/sh3/lpv/util/lpv_visualise_probes.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/util/lpv_visualise_probes.js +6 -2
- package/src/engine/graphics/sh3/lpv_build_editor.d.ts +9 -0
- package/src/engine/graphics/sh3/lpv_build_editor.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv_build_editor.js +695 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +14 -1
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts +1 -0
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -1
- package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +9 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +1 -1
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -1
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +2 -5
- package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
- package/src/engine/input/devices/KeyboardDevice.js +23 -1
- package/editor/tools/SelectionTool.d.ts +0 -27
|
@@ -114,6 +114,8 @@ function extract_object_fields_reflection(object, result, object_proto) {
|
|
|
114
114
|
result.push(descriptor);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
// TODO exclude value fields that belong to the prototype, such as .isTransform
|
|
118
|
+
|
|
117
119
|
if (!reserved_prototypes.includes(object_proto)) {
|
|
118
120
|
|
|
119
121
|
const descriptors = Object.getOwnPropertyDescriptors(object_proto);
|
|
@@ -235,16 +235,17 @@ export class TransformTool extends Tool {
|
|
|
235
235
|
|
|
236
236
|
/**
|
|
237
237
|
*
|
|
238
|
-
* @
|
|
238
|
+
* @return {EntityComponentDataset}
|
|
239
239
|
*/
|
|
240
|
-
function
|
|
241
|
-
return self.editor.engine.entityManager;
|
|
240
|
+
function getECD(){
|
|
241
|
+
return self.editor.engine.entityManager.dataset;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
function handleSelectionAdded(entity) {
|
|
245
|
-
const
|
|
245
|
+
const ecd = getECD();
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
|
|
248
|
+
const t = ecd.getComponent(entity, Transform);
|
|
248
249
|
|
|
249
250
|
if (t === null) {
|
|
250
251
|
return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformMode.d.ts","sourceRoot":"","sources":["TransformMode.js"],"names":[],"mappings":"4BACU,MAAM"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {number} offset
|
|
5
|
+
* @param {number} distance
|
|
6
|
+
* @param {number} count
|
|
7
|
+
*/
|
|
8
|
+
export function array_shift_back<T>(array: T[], offset: number, distance: number, count: number): void;
|
|
9
|
+
//# sourceMappingURL=array_shift_back.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_shift_back.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_shift_back.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wDAJW,MAAM,YACN,MAAM,SACN,MAAM,QAchB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {number} offset
|
|
5
|
+
* @param {number} distance
|
|
6
|
+
* @param {number} count
|
|
7
|
+
*/
|
|
8
|
+
export function array_shift_back(array, offset, distance, count) {
|
|
9
|
+
|
|
10
|
+
const end = Math.min(array.length, offset + count);
|
|
11
|
+
|
|
12
|
+
for (let i = offset; i < end; i++) {
|
|
13
|
+
|
|
14
|
+
const target = i - distance;
|
|
15
|
+
|
|
16
|
+
array[target] = array[i];
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH;IACI;;;;OAIG;IACH,iBAAqB;IAErB;;;;OAIG;IACH,cAAU;
|
|
1
|
+
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH;IACI;;;;OAIG;IACH,iBAAqB;IAErB;;;;OAIG;IACH,cAAU;IAEV;;;OAGG;IACH,YAFU,MAAM,CAED;IAWf;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAcnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAOC;IA8BD;;;;;OAKG;IACH,oCAFa,OAAO,CA2CnB;IAED;;;;;;OAMG;IACH,kBAEC;IAqDD;;;OAGG;IACH,+BA0CC;IAGD;;;OAGG;IACH,cA0CC;IAED;;;;OAIG;IACH,sBA0CC;IAED;;;;OAIG;IACH,4BAyCC;IAED;;;;;OAKG;IACH,oCAyCC;IAED;;;;;;OAMG;IACH,4CAyCC;IAED;;;;;;;;OAQG;IACH,4DAyCC;IAED;;;;;;;;;;OAUG;IACH,4EA0CC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;;CAPxB"}
|
|
@@ -25,6 +25,12 @@ export class Signal {
|
|
|
25
25
|
*/
|
|
26
26
|
flags = 0;
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Used to track dispatches, handlers that have the same generation ID as the signal will not be dispatched
|
|
30
|
+
* @type {number}
|
|
31
|
+
*/
|
|
32
|
+
generation = 0;
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
*
|
|
30
36
|
* @returns {boolean}
|
|
@@ -155,6 +161,8 @@ export class Signal {
|
|
|
155
161
|
*/
|
|
156
162
|
#add_handler(handler) {
|
|
157
163
|
|
|
164
|
+
handler.generation = this.generation;
|
|
165
|
+
|
|
158
166
|
const f = handler.handle;
|
|
159
167
|
const first = this.handlers.get(f);
|
|
160
168
|
|
|
@@ -163,7 +171,7 @@ export class Signal {
|
|
|
163
171
|
} else {
|
|
164
172
|
|
|
165
173
|
handler.next = first;
|
|
166
|
-
this.handlers.set(f,handler);
|
|
174
|
+
this.handlers.set(f, handler);
|
|
167
175
|
|
|
168
176
|
// const last = signal_handler_list_last(first);
|
|
169
177
|
|
|
@@ -296,6 +304,8 @@ export class Signal {
|
|
|
296
304
|
return;
|
|
297
305
|
}
|
|
298
306
|
|
|
307
|
+
this.generation++;
|
|
308
|
+
|
|
299
309
|
const handlers = this.handlers;
|
|
300
310
|
|
|
301
311
|
for (const handle of handlers.values()) {
|
|
@@ -304,6 +314,10 @@ export class Signal {
|
|
|
304
314
|
|
|
305
315
|
do {
|
|
306
316
|
|
|
317
|
+
if (_h.generation >= this.generation) {
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
|
|
307
321
|
const next = _h.next;
|
|
308
322
|
|
|
309
323
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -339,6 +353,8 @@ export class Signal {
|
|
|
339
353
|
return;
|
|
340
354
|
}
|
|
341
355
|
|
|
356
|
+
this.generation++;
|
|
357
|
+
|
|
342
358
|
const handlers = this.handlers;
|
|
343
359
|
|
|
344
360
|
for (const handle of handlers.values()) {
|
|
@@ -347,6 +363,10 @@ export class Signal {
|
|
|
347
363
|
|
|
348
364
|
do {
|
|
349
365
|
|
|
366
|
+
if (_h.generation >= this.generation) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
|
|
350
370
|
const next = _h.next;
|
|
351
371
|
|
|
352
372
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -382,6 +402,8 @@ export class Signal {
|
|
|
382
402
|
return;
|
|
383
403
|
}
|
|
384
404
|
|
|
405
|
+
this.generation++;
|
|
406
|
+
|
|
385
407
|
const handlers = this.handlers;
|
|
386
408
|
|
|
387
409
|
for (const handle of handlers.values()) {
|
|
@@ -390,6 +412,10 @@ export class Signal {
|
|
|
390
412
|
|
|
391
413
|
do {
|
|
392
414
|
|
|
415
|
+
if (_h.generation >= this.generation) {
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
|
|
393
419
|
const next = _h.next;
|
|
394
420
|
|
|
395
421
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -425,6 +451,8 @@ export class Signal {
|
|
|
425
451
|
return;
|
|
426
452
|
}
|
|
427
453
|
|
|
454
|
+
this.generation++;
|
|
455
|
+
|
|
428
456
|
const handlers = this.handlers;
|
|
429
457
|
|
|
430
458
|
for (const handle of handlers.values()) {
|
|
@@ -433,6 +461,10 @@ export class Signal {
|
|
|
433
461
|
|
|
434
462
|
do {
|
|
435
463
|
|
|
464
|
+
if (_h.generation >= this.generation) {
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
|
|
436
468
|
const next = _h.next;
|
|
437
469
|
|
|
438
470
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -468,6 +500,7 @@ export class Signal {
|
|
|
468
500
|
return;
|
|
469
501
|
}
|
|
470
502
|
|
|
503
|
+
this.generation++;
|
|
471
504
|
|
|
472
505
|
const handlers = this.handlers;
|
|
473
506
|
|
|
@@ -477,6 +510,10 @@ export class Signal {
|
|
|
477
510
|
|
|
478
511
|
do {
|
|
479
512
|
|
|
513
|
+
if (_h.generation >= this.generation) {
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
|
|
480
517
|
const next = _h.next;
|
|
481
518
|
|
|
482
519
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -513,6 +550,7 @@ export class Signal {
|
|
|
513
550
|
return;
|
|
514
551
|
}
|
|
515
552
|
|
|
553
|
+
this.generation++;
|
|
516
554
|
|
|
517
555
|
const handlers = this.handlers;
|
|
518
556
|
|
|
@@ -522,6 +560,10 @@ export class Signal {
|
|
|
522
560
|
|
|
523
561
|
do {
|
|
524
562
|
|
|
563
|
+
if (_h.generation >= this.generation) {
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
|
|
525
567
|
const next = _h.next;
|
|
526
568
|
|
|
527
569
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -560,6 +602,7 @@ export class Signal {
|
|
|
560
602
|
return;
|
|
561
603
|
}
|
|
562
604
|
|
|
605
|
+
this.generation++;
|
|
563
606
|
|
|
564
607
|
const handlers = this.handlers;
|
|
565
608
|
|
|
@@ -569,6 +612,10 @@ export class Signal {
|
|
|
569
612
|
|
|
570
613
|
do {
|
|
571
614
|
|
|
615
|
+
if (_h.generation >= this.generation) {
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
|
|
572
619
|
const next = _h.next;
|
|
573
620
|
|
|
574
621
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -609,6 +656,8 @@ export class Signal {
|
|
|
609
656
|
return;
|
|
610
657
|
}
|
|
611
658
|
|
|
659
|
+
this.generation++;
|
|
660
|
+
|
|
612
661
|
const handlers = this.handlers;
|
|
613
662
|
|
|
614
663
|
for (const handle of handlers.values()) {
|
|
@@ -617,6 +666,11 @@ export class Signal {
|
|
|
617
666
|
|
|
618
667
|
do {
|
|
619
668
|
|
|
669
|
+
if (_h.generation >= this.generation) {
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
|
|
620
674
|
const next = _h.next;
|
|
621
675
|
|
|
622
676
|
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignalHandler.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/SignalHandler.js"],"names":[],"mappings":"iCAIU,MAAM;;;;AAShB;
|
|
1
|
+
{"version":3,"file":"SignalHandler.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/SignalHandler.js"],"names":[],"mappings":"iCAIU,MAAM;;;;AAShB;IAmBI;;;;OAIG;IACH,6CAOC;IA9BD;;;OAGG;IACH,MAFU,aAAa,GAAC,IAAI,CAEhB;IAEZ;;;OAGG;IACH,cAAU;IAEV;;;OAGG;IACH,YAFU,MAAM,CAEA;IAWZ,iBAAoB;IACpB,aAAsB;IAI1B;;;;OAIG;IACH,cAHW,MAAM,GAAC,kBAAkB,GACvB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,kBAAkB,GACvB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,kBAAkB,SACzB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM,GAAC,kBAAkB,GACvB,OAAO,CAInB;IAIL;;;OAGG;IACH,0BAFU,OAAO,CAEsB;CANtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_delaunay_tetrahedral_mesh.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_delaunay_tetrahedral_mesh.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,wDALW,eAAe,SACf,MAAM,EAAE,MACR,MAAM,GACJ,OAAO,CAuEnB;gCAtF+B,uBAAuB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { assert } from "../../../../assert.js";
|
|
4
4
|
import { BitSet } from "../../../../binary/BitSet.js";
|
|
5
|
+
import { typed_array_copy } from "../../../../collection/array/typed/typed_array_copy.js";
|
|
5
6
|
import { compute_bounding_simplex_3d } from "../compute_bounding_simplex_3d.js";
|
|
6
7
|
import { TetrahedralMesh } from "../TetrahedralMesh.js";
|
|
7
8
|
import { Cavity } from "./Cavity.js";
|
|
@@ -53,7 +54,7 @@ export function compute_delaunay_tetrahedral_mesh(mesh, input, n = input.length
|
|
|
53
54
|
|
|
54
55
|
const points = new Float32Array((n + 4) * 3);
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
typed_array_copy(input,points);
|
|
57
58
|
|
|
58
59
|
/*
|
|
59
60
|
create bounding volume tetrahedron over input set
|
|
@@ -113,14 +113,14 @@ export class EngineHarness {
|
|
|
113
113
|
* @param {Engine} param.engine
|
|
114
114
|
* @param {number} [param.sensitivity]
|
|
115
115
|
* @param {EntityComponentDataset} [param.ecd]
|
|
116
|
-
* @returns {Entity}
|
|
116
|
+
* @returns {Promise<Entity>}
|
|
117
117
|
*/
|
|
118
118
|
static buildOrbitalCameraController({ cameraEntity, engine, ecd, sensitivity }: {
|
|
119
119
|
cameraEntity?: number;
|
|
120
120
|
engine: Engine;
|
|
121
121
|
sensitivity?: number;
|
|
122
122
|
ecd?: EntityComponentDataset;
|
|
123
|
-
}): Entity
|
|
123
|
+
}): Promise<Entity>;
|
|
124
124
|
/**
|
|
125
125
|
*
|
|
126
126
|
* @param {Engine} engine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineHarness.d.ts","sourceRoot":"","sources":["../../../src/engine/EngineHarness.js"],"names":[],"mappings":"AA6DA;IAmBI;;;;OAIG;IACH,8CAHmB,mBAAmB,UAAQ,MAAM,WACxC,QAAQ,MAAM,CAAC,CAM1B;IAED;;;OAGG;IACH,6BAFW,MAAM,QAYhB;IAmED;;;;;;;;;;;;;OAaG;IACH;QAZyB,MAAM,EAApB,MAAM;QACyB,GAAG;QAClB,MAAM,GAAtB,OAAO;QACQ,QAAQ,GAAvB,MAAM;QACS,KAAK,GAApB,MAAM;QACS,GAAG,GAAlB,MAAM;QACU,QAAQ,GAAxB,OAAO;QACQ,WAAW,GAA1B,MAAM;QACS,WAAW,GAA1B,MAAM;QACS,WAAW,GAA1B,MAAM;QACJ,MAAM,CA+DlB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH;QAnB0B,MAAM,EAArB,MAAM;QACgC,KAAK,GAA3C;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;QACrB,SAAS;QACT,WAAW;QACF,KAAK,GAArB,MAAM;QACU,GAAG,GAAnB,MAAM;QACU,QAAQ,GAAxB,MAAM;QACwB,WAAW,GAAzC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAC,CAAC,EAAC,MAAM,CAAA;SAAC;QACJ,iBAAiB,GAAjC,MAAM;QACW,WAAW,GAA5B,OAAO;QACU,aAAa,GAA9B,OAAO;QACU,YAAY,GAA7B,OAAO;QACS,iBAAiB,GAAjC,MAAM;QACU,iBAAiB,GAAjC,MAAM;QACW,gBAAgB,GAAjC,OAAO;QACU,cAAc,GAA/B,OAAO;QACS,mBAAmB,GAAnC,MAAM;QACW,OAAO,GAAxB,OAAO;sBAqEjB;IAGD;;;;;;;;;;;OAWG;IACH;QAVyB,MAAM,EAApB,MAAM;QACyB,GAAG;QACnB,mBAAmB,GAAlC,MAAM;QACU,UAAU,GAA1B,OAAO;QACO,GAAG,GAAjB,KAAK;QACU,YAAY,GAA3B,MAAM;QACU,YAAY,GAA5B,OAAO;QACO,OAAO,GAArB,KAAK;QACU,gBAAgB,GAA/B,MAAM;sBAqDhB;IAED;;;;;;;OAOG;IACH;QAN0B,YAAY,GAA3B,MAAM;QACQ,MAAM,EAApB,MAAM;QACS,WAAW,GAA1B,MAAM;QACyB,GAAG;QAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"EngineHarness.d.ts","sourceRoot":"","sources":["../../../src/engine/EngineHarness.js"],"names":[],"mappings":"AA6DA;IAmBI;;;;OAIG;IACH,8CAHmB,mBAAmB,UAAQ,MAAM,WACxC,QAAQ,MAAM,CAAC,CAM1B;IAED;;;OAGG;IACH,6BAFW,MAAM,QAYhB;IAmED;;;;;;;;;;;;;OAaG;IACH;QAZyB,MAAM,EAApB,MAAM;QACyB,GAAG;QAClB,MAAM,GAAtB,OAAO;QACQ,QAAQ,GAAvB,MAAM;QACS,KAAK,GAApB,MAAM;QACS,GAAG,GAAlB,MAAM;QACU,QAAQ,GAAxB,OAAO;QACQ,WAAW,GAA1B,MAAM;QACS,WAAW,GAA1B,MAAM;QACS,WAAW,GAA1B,MAAM;QACJ,MAAM,CA+DlB;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH;QAnB0B,MAAM,EAArB,MAAM;QACgC,KAAK,GAA3C;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;QACrB,SAAS;QACT,WAAW;QACF,KAAK,GAArB,MAAM;QACU,GAAG,GAAnB,MAAM;QACU,QAAQ,GAAxB,MAAM;QACwB,WAAW,GAAzC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAC,CAAC,EAAC,MAAM,CAAA;SAAC;QACJ,iBAAiB,GAAjC,MAAM;QACW,WAAW,GAA5B,OAAO;QACU,aAAa,GAA9B,OAAO;QACU,YAAY,GAA7B,OAAO;QACS,iBAAiB,GAAjC,MAAM;QACU,iBAAiB,GAAjC,MAAM;QACW,gBAAgB,GAAjC,OAAO;QACU,cAAc,GAA/B,OAAO;QACS,mBAAmB,GAAnC,MAAM;QACW,OAAO,GAAxB,OAAO;sBAqEjB;IAGD;;;;;;;;;;;OAWG;IACH;QAVyB,MAAM,EAApB,MAAM;QACyB,GAAG;QACnB,mBAAmB,GAAlC,MAAM;QACU,UAAU,GAA1B,OAAO;QACO,GAAG,GAAjB,KAAK;QACU,YAAY,GAA3B,MAAM;QACU,YAAY,GAA5B,OAAO;QACO,OAAO,GAArB,KAAK;QACU,gBAAgB,GAA/B,MAAM;sBAqDhB;IAED;;;;;;;OAOG;IACH;QAN0B,YAAY,GAA3B,MAAM;QACQ,MAAM,EAApB,MAAM;QACS,WAAW,GAA1B,MAAM;QACyB,GAAG;QAChC,QAAQ,MAAM,CAAC,CA2C3B;IAGD;;;;;;;;;;;OAWG;IACH,mGAVW,MAAM,GAQJ,OAAO,CAuDnB;IA3cG;;;OAGG;IACH,QAFU,MAAM,CAEiC;IAMjD;;;OAGG;IACH,YAFU,eAAQ,IAAI,CAET;IA8BjB;;;;;OAKG;IACH;iCAJmB,mBAAmB,UAAQ,MAAM;8BACzC,OAAO;QACL,QAAQ,MAAM,CAAC,CA2D3B;CAiWJ;;IAID;;;OAGG;IACH,uCAMC;;mBA1gBkB,aAAa;oCACI,0BAA0B;oBAX1C,yBAAyB;mBAK1B,iBAAiB;sBATd,wBAAwB;oBAW1B,8BAA8B"}
|
|
@@ -409,7 +409,7 @@ export class EngineHarness {
|
|
|
409
409
|
* @param {Engine} param.engine
|
|
410
410
|
* @param {number} [param.sensitivity]
|
|
411
411
|
* @param {EntityComponentDataset} [param.ecd]
|
|
412
|
-
* @returns {Entity}
|
|
412
|
+
* @returns {Promise<Entity>}
|
|
413
413
|
*/
|
|
414
414
|
static async buildOrbitalCameraController({
|
|
415
415
|
cameraEntity,
|
|
@@ -36,6 +36,12 @@ export class MaterialManager {
|
|
|
36
36
|
* @private
|
|
37
37
|
*/
|
|
38
38
|
private __handle_last_reference_removed;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {Function} klass
|
|
42
|
+
* @return {AbstractMaterialTransformer[]}
|
|
43
|
+
*/
|
|
44
|
+
getCompilationSteps(klass: Function): AbstractMaterialTransformer[];
|
|
39
45
|
/**
|
|
40
46
|
*
|
|
41
47
|
* @param {AbstractMaterialTransformer} def
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/material/manager/MaterialManager.js"],"names":[],"mappings":"AAMA;IAGQ;;;;OAIG;IACH,kBAIE;IAEF;;;;OAIG;IACH,gBAIE;IAEF;;;;OAIG;IACH,0BAIE;IAIF;;;;OAIG;IACH,0BAA2B;IAG/B;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,wCAUC;IAED;;;OAGG;IACH,uDAEC;IAED;;;;OAIG;IACH,qDAFa,OAAO,CAYnB;IAED;;;;;OAKG;IACH,kBAcC;IAGD;;;;OAIG;IACH,8CAmCC;CACJ"}
|
|
1
|
+
{"version":3,"file":"MaterialManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/material/manager/MaterialManager.js"],"names":[],"mappings":"AAMA;IAGQ;;;;OAIG;IACH,kBAIE;IAEF;;;;OAIG;IACH,gBAIE;IAEF;;;;OAIG;IACH,0BAIE;IAIF;;;;OAIG;IACH,0BAA2B;IAG/B;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,wCAUC;IAED;;;;OAIG;IACH,sCAFY,6BAA6B,CAIxC;IAED;;;OAGG;IACH,uDAEC;IAED;;;;OAIG;IACH,qDAFa,OAAO,CAYnB;IAED;;;;;OAKG;IACH,kBAcC;IAGD;;;;OAIG;IACH,8CAmCC;CACJ"}
|
|
@@ -77,6 +77,15 @@ export class MaterialManager {
|
|
|
77
77
|
this.__cache.put(source, material);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @param {Function} klass
|
|
83
|
+
* @return {AbstractMaterialTransformer[]}
|
|
84
|
+
*/
|
|
85
|
+
getCompilationSteps(klass){
|
|
86
|
+
return this.__transform_chain.filter(x => x instanceof klass);
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
/**
|
|
81
90
|
*
|
|
82
91
|
* @param {AbstractMaterialTransformer} def
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const _default: "\n#ifndef LPV_SHADER_CHUNK_COMMON\n#define LPV_SHADER_CHUNK_COMMON\n\n\nuniform usampler2D lpv_t_mesh_vertices;\nuniform usampler2D lpv_t_mesh_neighbours;\nuniform usampler3D lpv_t_mesh_lookup;\n\nuniform sampler2D lpv_t_probe_positions;\nuniform sampler2D lpv_t_probe_data;\n\nuniform sampler2D lpv_t_probe_depth;\nuniform uint lpv_u_probe_depth_resolution;\n\nuniform uint lpv_u_mesh_tet_count;\nuniform vec3 lpv_v3_bounds_min;\nuniform vec3 lpv_v3_bounds_max;\n\n\nconst float lpv_min_thickness = 0.03; // in Meters\nconst float lpv_max_thickness = 0.50; // in Meters\n\n\n#define SEARCH_STEP_LIMIT 32u\n#define INVALID_TET 1073741823u\n\n\n/** Slightly bump the location of the shadow test point away from the shadow casting surface.\n The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is\n to it the more the light leaks.\n*/\n#define LPV_NORMAL_BIAS 0.0001f\n\nivec2 lpv_index_to_256_coordinate(uint index) {\n\n uint pixel_x = index % 256u;\n uint pixel_y = index / 256u;\n\n return ivec2(int(pixel_x), int(pixel_y));\n}\n\nuvec4 lpv_mesh_getVertices(uint tet_index) {\n ivec2 p = lpv_index_to_256_coordinate(tet_index);\n\n return texelFetch(lpv_t_mesh_vertices, p, 0);\n\n}\n\nuvec4 lpv_mesh_getNeighbours(uint tet_index) {\n ivec2 p = lpv_index_to_256_coordinate(tet_index);\n\n return texelFetch(lpv_t_mesh_neighbours, p, 0);\n}\n\nvec3[9] lpv_probe_getData(uint probe_index) {\n\n\n int slot = int(probe_index % 256u);\n int column = int(probe_index / 256u);\n\n int offset_x = int(slot * 9);\n\n vec3[9] result;\n\n for (int i = 0; i < 9; i++) {\n result[i] = texelFetch(lpv_t_probe_data, ivec2(offset_x + i, column), 0).rgb;\n }\n\n return result;\n}\n\nfloat sign_not_zero(float x) {\n return x >= 0.0 ? 1.0 : -1.0;\n}\n\nvec2 sign_not_zero(vec2 x) {\n return vec2(\n sign_not_zero(x.x),\n sign_not_zero(x.y)\n );\n}\n\nvec3 sign_not_zero(vec3 x) {\n return vec3(\n sign_not_zero(x.x),\n sign_not_zero(x.y),\n sign_not_zero(x.z)\n );\n}\n\nvec4 quadBlendWieghts(vec2 coords)\n{\n vec4 res;\n/* 0 0 0\n 0 0 0\n 1 0 0 */\n res.x = min(1.0f - coords.x, 1.0f - coords.y);\n/* 1 0 0\n 0 0 0\n 0 0 1 */\n res.y = abs(coords.x - coords.y);\n/* 0 0 1\n 0 0 0\n 0 0 0 */\n res.z = min(coords.x, coords.y);\n/* 0 0 0\n 0 0 1\n 0 1 1 */\n res.w = ceil(coords.x - coords.y);\n //res.xyz /= (res.x + res.y + res.z);\n return res;\n}\n\nvec2 VecToSphereOct(vec3 v)\n{\n float l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\n vec2 result = v.xz / l1norm;\n\n if (v.y < 0.0) {\n result = (1.0 - abs(result.yx)) * sign_not_zero(result.xy);\n }\n\n return result;\n}\n\nfloat SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {\n\n float samp0 = textureLod(tex, uv0, 0.0).r;\n float samp1 = textureLod(tex, uv1, 0.0).r;\n float samp2 = textureLod(tex, uv2, 0.0).r;\n\n return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;\n}\n\nvec2 lpv_probe_getDepthTriangular(uint probe_index, vec3 direction) {\n // get offset\n uint depth_tile_resolution = lpv_u_probe_depth_resolution;\n uvec2 atlas_size = uvec2(4096u);\n\n uint tiles_per_row = atlas_size.x / depth_tile_resolution;\n\n uint tile_x = probe_index % tiles_per_row;\n uint tile_y = probe_index / tiles_per_row;\n\n vec2 tile_offset = vec2(\n tile_x * depth_tile_resolution,\n tile_y * depth_tile_resolution\n );\n\n // convert direction to UV\n vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);\n vec2 grid = octahedral_uv * vec2(depth_tile_resolution - 1u);\n\n vec2 gridFrac = fract(grid);\n vec2 gridFloor = floor(grid);\n\n vec4 weights = quadBlendWieghts(gridFrac);\n\n //3 nearest frames\n vec2 frame0 = gridFloor;\n vec2 frame1 = gridFloor + mix(vec2(0, 1), vec2(1, 0), weights.w);\n vec2 frame2 = gridFloor + vec2(1.0, 1.0);\n\n // move frames to atlas space\n frame0 += tile_offset;\n frame1 += tile_offset;\n frame2 += tile_offset;\n\n vec2 samp0 = texelFetch(lpv_t_probe_depth, ivec2(frame0), 0).rg;\n vec2 samp1 = texelFetch(lpv_t_probe_depth, ivec2(frame1), 0).rg;\n vec2 samp2 = texelFetch(lpv_t_probe_depth, ivec2(frame2), 0).rg;\n\n vec2 d0 = samp0 * weights.x;\n vec2 d1 = samp1 * weights.y;\n vec2 d2 = samp2 * weights.z;\n\n return (d0 + d1 + d2);\n}\n\nfloat lpv_bilinear_lerp(float v00, float v01, float v10, float v11, vec2 fraction) {\n\n float x0 = mix(v00, v01, fraction.x);\n float x1 = mix(v10, v11, fraction.x);\n\n return mix(x0, x1, fraction.y);\n}\n\nvec2 lpv_bilinear_lerp(vec2 v00, vec2 v01, vec2 v10, vec2 v11, vec2 fraction) {\n\n vec2 x0 = mix(v00, v01, fraction.x);\n vec2 x1 = mix(v10, v11, fraction.x);\n\n return mix(x0, x1, fraction.y);\n}\n\nvec2 lpv_sample_bilinear(sampler2D tex, ivec2 texel_position, vec2 fraction) {\n\n float texel_00 = texelFetch(tex, texel_position, 0).r;\n float texel_01 = texelFetch(tex, texel_position + ivec2(1, 0), 0).r;\n float texel_10 = texelFetch(tex, texel_position + ivec2(0, 1), 0).r;\n float texel_11 = texelFetch(tex, texel_position + ivec2(1, 1), 0).r;\n\n return vec2(\n lpv_bilinear_lerp(\n texel_00, texel_01,\n texel_10, texel_11,\n fraction\n ),\n lpv_bilinear_lerp(\n texel_00 * texel_00, texel_01 * texel_01,\n texel_10 * texel_10, texel_11 * texel_11,\n fraction\n )\n );\n}\n\nivec2 wrapOctahedralTexelCoordinates(const in ivec2 texel, const in int texture_size) {\n ivec2 wrapped = ((texel % texture_size) + texture_size) % texture_size;\n\n int fx = (abs(texel.x / texture_size) + int(texel.x < 0));\n int fy = (abs(texel.y / texture_size) + int(texel.y < 0));\n\n if (((fx ^ fy) & 1) != 0) {\n return (texture_size - (wrapped + ivec2(1)));\n return wrapped;\n } else {\n return wrapped;\n }\n}\n\nvec2 lpv_probe_getDepthBilinear(uint probe_index, vec3 direction) {\n // get offset\n int depth_tile_resolution = int(lpv_u_probe_depth_resolution);\n ivec2 tile_resolution = ivec2(depth_tile_resolution);\n const ivec2 atlas_size = ivec2(4096);\n\n int tiles_per_row = atlas_size.x / depth_tile_resolution;\n\n int tile_x = int(probe_index) % tiles_per_row;\n int tile_y = int(probe_index) / tiles_per_row;\n\n ivec2 tile_offset = ivec2(\n tile_x * depth_tile_resolution,\n tile_y * depth_tile_resolution\n );\n\n // convert direction to UV\n vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);\n vec2 grid = octahedral_uv * vec2(depth_tile_resolution) - 0.5;\n\n vec2 gridFrac = fract(grid);\n\n ivec2 texel_position = ivec2(floor(grid));\n\n ivec2 tile_p_00;\n ivec2 tile_p_01;\n ivec2 tile_p_10;\n ivec2 tile_p_11;\n\n tile_p_00 = wrapOctahedralTexelCoordinates(texel_position, depth_tile_resolution);\n tile_p_01 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 0), depth_tile_resolution);\n tile_p_10 = wrapOctahedralTexelCoordinates(texel_position + ivec2(0, 1), depth_tile_resolution);\n tile_p_11 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 1), depth_tile_resolution);\n\n vec2 texel_00 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_00, 0).rg;\n vec2 texel_01 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_01, 0).rg;\n vec2 texel_10 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_10, 0).rg;\n vec2 texel_11 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_11, 0).rg;\n\n return lpv_bilinear_lerp(\n texel_00, texel_01,\n texel_10, texel_11,\n gridFrac\n );\n}\n\nvec3 lpv_probe_getPosition(uint probe_index) {\n return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;\n}\n\nmat3 lpv_mesh_makeMatrix(vec3 p0, vec3 p1, vec3 p2, vec3 p3) {\n\n return inverse(\n mat3(\n p0 - p3,\n p1 - p3,\n p2 - p3\n )\n );\n\n}\n\nvec4 lpv_mesh_getBarycentricCoordinates(uint tet_index, vec3 position) {\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec3 p0 = lpv_probe_getPosition(vertices[0]);\n vec3 p1 = lpv_probe_getPosition(vertices[1]);\n vec3 p2 = lpv_probe_getPosition(vertices[2]);\n vec3 p3 = lpv_probe_getPosition(vertices[3]);\n\n mat3 matrix = lpv_mesh_makeMatrix(p0, p1, p2, p3);\n\n vec3 mult = matrix * (position - p3);\n\n return vec4(mult, 1.0 - mult.x - mult.y - mult.z);\n}\n\nvoid lpv_walk_to_tetrahedron(\nin vec3 position,\nin uint tet_guess,\nout uint tet_index,\nout vec4 weights\n) {\n tet_index = tet_guess;\n\n for (uint i = 0u; i < SEARCH_STEP_LIMIT; i++) {\n\n weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);\n\n // Check if we're in the current \"best guess\" tetrahedron\n if (weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0) {\n // success\n return;\n }\n\n uvec4 neighbors = lpv_mesh_getNeighbours(tet_index);\n\n uint next_tet;\n\n // Otherwise find the smallest barycentric coord and move in that direction\n if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) {\n next_tet = neighbors[0];\n } else if (weights.y < weights.z && weights.y < weights.w) {\n next_tet = neighbors[1];\n } else if (weights.z < weights.w) {\n next_tet = neighbors[2];\n } else {\n next_tet = neighbors[3];\n }\n\n tet_index = next_tet;\n }\n\n tet_index = INVALID_TET;\n}\n\nfloat lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {\n\n vec3 probe_position = lpv_probe_getPosition(probe_index);\n\n vec3 local_probe_offset = position - probe_position;\n\n float distToProbe = length(local_probe_offset);\n\n vec3 direction = local_probe_offset / distToProbe;\n\n vec2 temp = lpv_probe_getDepthBilinear(probe_index, direction);\n\n float mean = temp.x;\n float mean2 = temp.y; // mean of squared distances\n\n float variance = abs(mean * mean - mean2);\n\n // http://www.punkuser.net/vsm/vsm_paper.pdf; equation 5\n // Need the max in the denominator because biasing can cause a negative displacement\n float distance_delta = max(distToProbe - mean, 0.0);\n\n float chebyshevWeight = variance / (variance + distance_delta * distance_delta);\n\n // Increase contrast in the weight\n chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);\n\n return (distToProbe <= mean) ? 1.0 : chebyshevWeight;\n}\n\nvec4 lvp_mask_weights_by_visibility_by_depth(vec3 position, uint tet_index, vec4 weights) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec4 visibility = vec4(\n lpv_probe_getVisibilityMask(position, vertices[0]),\n lpv_probe_getVisibilityMask(position, vertices[1]),\n lpv_probe_getVisibilityMask(position, vertices[2]),\n lpv_probe_getVisibilityMask(position, vertices[3])\n );\n\n return visibility * weights;\n}\n\n\nvec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint tet_index, vec4 weights) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec4 visibility;\n\n for (int i = 0; i < 4; i++) {\n vec3 probe_position = lpv_probe_getPosition(vertices[i]);\n\n vec3 direction_to_probe = position - probe_position;\n\n visibility[i] = step(dot(direction_to_probe, normal), 0.0);\n }\n\n return visibility * weights;\n}\n\n\nvec4 lvp_mask_weights_by_visibility(in vec3 position, in vec3 normal, in vec3 view_direction, in uint tet_index, in vec4 barycentric) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec4 visibility;\n\n // Bias the position at which visibility is computed; this\n // avoids performing a shadow test *at* a surface, which is a\n // dangerous location because that is exactly the line between\n // shadowed and unshadowed. If the normal bias is too small,\n // there will be light and dark leaks. If it is too large,\n // then samples can pass through thin occluders to the other\n // side (this can only happen if there are MULTIPLE occluders\n // near each other, a wall surface won't pass through itself.)\n vec3 lookup_position = position + (normal - view_direction * 3.0) * LPV_NORMAL_BIAS;\n\n float weight_sum = 0.0;\n\n for (uint i = 0u; i < 4u; i++) {\n\n float weight = 1.0;\n\n uint probe_index = vertices[i];\n\n vec3 probe_position = lpv_probe_getPosition(probe_index);\n\n\n // Smooth backface test\n {\n\n // Computed without the biasing applied to the \"dir\" variable.\n // This test can cause reflection-map looking errors in the image\n // (stuff looks shiny) if the transition is poor.\n vec3 direction_to_probe = normalize(probe_position - position);\n\n // The naive soft backface weight would ignore a probe when\n // it is behind the surface. That's good for walls. But for small details inside of a\n // room, the normals on the details might rule out all of the probes that have mutual\n // visibility to the point. So, we instead use a \"wrap shading\" test below inspired by\n // NPR work.\n// float backface_term = max(0.0001, dot(direction_to_probe, normal));\n\n // The small offset at the end reduces the \"going to zero\" impact\n // where this is really close to exactly opposite\n float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);\n weight *= backface_term * backface_term + 0.05;\n// weight *= backface_term;\n\n }\n\n // Moment visibility test (depth)\n {\n\n weight *= lpv_probe_getVisibilityMask(lookup_position, probe_index);\n\n }\n\n\n // A tiny bit of light is really visible due to log perception, so\n // crush tiny weights but keep the curve continuous. This must be done\n // before the trilinear weights, because those should be preserved.\n const float crushThreshold = 0.2;\n\n if (weight < crushThreshold) {\n weight *= weight * weight * (1.0 / (crushThreshold * crushThreshold));\n }\n\n // Avoid zero weight\n weight = max(0.000001, weight);\n\n weight *= barycentric[i];\n\n weight_sum += weight;\n\n visibility[i] = weight;\n }\n\n // normalize\n visibility /= weight_sum;\n\n return visibility;\n}\n\nvec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec3[9] probe0 = lpv_probe_getData(vertices[0]);\n vec3[9] probe1 = lpv_probe_getData(vertices[1]);\n vec3[9] probe2 = lpv_probe_getData(vertices[2]);\n vec3[9] probe3 = lpv_probe_getData(vertices[3]);\n\n vec3[9] result;\n\n for (int i = 0; i < 9; i++) {\n\n result[i] = probe0[i] * weights[0]\n + probe1[i] * weights[1]\n + probe2[i] * weights[2]\n + probe3[i] * weights[3];\n\n }\n\n return result;\n}\n\nuint lpv_guess_initial_tet(vec3 position) {\n\n vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;\n vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;\n\n vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);\n\n return textureLod(lpv_t_mesh_lookup, lookup_coordinates, 0.0).r;\n\n}\n\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 lpv_get_irradiance_at(in vec3 normal, in vec3 shCoefficients[9]) {\n // normal is assumed to have unit length\n float x = normal.x, y = normal.y, z = normal.z;\n\n // band 0\n vec3 result = shCoefficients[0] * 0.8862269254527579;\n\n // band 1\n result -= shCoefficients[1] * 1.0233267079464885 * y;\n result += shCoefficients[2] * 1.0233267079464885 * z;\n result -= shCoefficients[3] * 1.0233267079464885 * x;\n\n // band 2\n result += shCoefficients[4] * 0.8580855308097834 * x * y;\n result -= shCoefficients[5] * 0.8580855308097834 * y * z;\n result += shCoefficients[6] * (0.7431238683011272 * z * z - 0.24770795610037571);\n result -= shCoefficients[7] * 0.8580855308097834 * x * z;\n result += shCoefficients[8] * 0.4290427654048917 * (x * x - y * y);\n\n return result;\n}\n\nvec4 lpv_renormalize_weights(in vec4 source) {\n\n float sum = source.x + source.y + source.z + source.w;\n\n if (sum <= 0.0001) {\n return vec4(0.0);\n }\n\n return source / sum;\n\n}\n\nvec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {\n\n // lookup nearby tet\n vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;\n vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;\n vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);\n\n\n uint nearest_tet = lpv_guess_initial_tet(position);\n\n uint tet;\n vec4 barycentric_coordinates;\n lpv_walk_to_tetrahedron(position, nearest_tet, tet, barycentric_coordinates);\n\n // apply visibility term\n vec4 weights = lvp_mask_weights_by_visibility(position, normal, view_direction, tet, barycentric_coordinates);\n\n if (tet == INVALID_TET) {\n // do nothing\n return vec3(0.0);\n\n } else {\n\n vec3[9] lpv_values = lpv_interpolate_probes(weights, tet);\n\n return lpv_get_irradiance_at(normal, lpv_values);\n\n }\n}\n\n#endif\n";
|
|
1
|
+
declare const _default: "\n#ifndef LPV_SHADER_CHUNK_COMMON\n#define LPV_SHADER_CHUNK_COMMON\n\n\nuniform usampler2D lpv_t_mesh_vertices;\nuniform usampler2D lpv_t_mesh_neighbours;\nuniform usampler3D lpv_t_mesh_lookup;\n\nuniform sampler2D lpv_t_probe_positions;\nuniform sampler2D lpv_t_probe_data;\n\nuniform sampler2D lpv_t_probe_depth;\nuniform uint lpv_u_probe_depth_resolution;\n\nuniform uint lpv_u_mesh_tet_count;\nuniform vec3 lpv_v3_bounds_min;\nuniform vec3 lpv_v3_bounds_max;\n\n\nconst float lpv_min_thickness = 0.03; // in Meters\nconst float lpv_max_thickness = 0.50; // in Meters\n\n\n#define SEARCH_STEP_LIMIT 32u\n#define INVALID_TET 1073741823u\n\n\n/** Slightly bump the location of the shadow test point away from the shadow casting surface.\n The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is\n to it the more the light leaks.\n*/\n#define LPV_NORMAL_BIAS 0.0001f\n\nivec2 lpv_index_to_256_coordinate(uint index) {\n\n uint pixel_x = index % 256u;\n uint pixel_y = index / 256u;\n\n return ivec2(int(pixel_x), int(pixel_y));\n}\n\nuvec4 lpv_mesh_getVertices(uint tet_index) {\n ivec2 p = lpv_index_to_256_coordinate(tet_index);\n\n return texelFetch(lpv_t_mesh_vertices, p, 0);\n\n}\n\nuvec4 lpv_mesh_getNeighbours(uint tet_index) {\n ivec2 p = lpv_index_to_256_coordinate(tet_index);\n\n return texelFetch(lpv_t_mesh_neighbours, p, 0);\n}\n\nvec3[9] lpv_probe_getData(uint probe_index) {\n\n\n int slot = int(probe_index % 256u);\n int column = int(probe_index / 256u);\n\n int offset_x = int(slot * 9);\n\n vec3[9] result;\n\n for (int i = 0; i < 9; i++) {\n result[i] = texelFetch(lpv_t_probe_data, ivec2(offset_x + i, column), 0).rgb;\n }\n\n return result;\n}\n\nfloat sign_not_zero(float x) {\n return x >= 0.0 ? 1.0 : -1.0;\n}\n\nvec2 sign_not_zero(vec2 x) {\n return vec2(\n sign_not_zero(x.x),\n sign_not_zero(x.y)\n );\n}\n\nvec3 sign_not_zero(vec3 x) {\n return vec3(\n sign_not_zero(x.x),\n sign_not_zero(x.y),\n sign_not_zero(x.z)\n );\n}\n\nvec4 quadBlendWieghts(vec2 coords)\n{\n vec4 res;\n/* 0 0 0\n 0 0 0\n 1 0 0 */\n res.x = min(1.0f - coords.x, 1.0f - coords.y);\n/* 1 0 0\n 0 0 0\n 0 0 1 */\n res.y = abs(coords.x - coords.y);\n/* 0 0 1\n 0 0 0\n 0 0 0 */\n res.z = min(coords.x, coords.y);\n/* 0 0 0\n 0 0 1\n 0 1 1 */\n res.w = ceil(coords.x - coords.y);\n //res.xyz /= (res.x + res.y + res.z);\n return res;\n}\n\nvec2 VecToSphereOct(vec3 v)\n{\n float l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\n vec2 result = v.xz / l1norm;\n\n if (v.y < 0.0) {\n result = (1.0 - abs(result.yx)) * sign_not_zero(result.xy);\n }\n\n return result;\n}\n\nfloat SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {\n\n float samp0 = textureLod(tex, uv0, 0.0).r;\n float samp1 = textureLod(tex, uv1, 0.0).r;\n float samp2 = textureLod(tex, uv2, 0.0).r;\n\n return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;\n}\n\nvec2 lpv_probe_getDepthTriangular(uint probe_index, vec3 direction) {\n // get offset\n uint depth_tile_resolution = lpv_u_probe_depth_resolution;\n uvec2 atlas_size = uvec2(4096u);\n\n uint tiles_per_row = atlas_size.x / depth_tile_resolution;\n\n uint tile_x = probe_index % tiles_per_row;\n uint tile_y = probe_index / tiles_per_row;\n\n vec2 tile_offset = vec2(\n tile_x * depth_tile_resolution,\n tile_y * depth_tile_resolution\n );\n\n // convert direction to UV\n vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);\n vec2 grid = octahedral_uv * vec2(depth_tile_resolution - 1u);\n\n vec2 gridFrac = fract(grid);\n vec2 gridFloor = floor(grid);\n\n vec4 weights = quadBlendWieghts(gridFrac);\n\n //3 nearest frames\n vec2 frame0 = gridFloor;\n vec2 frame1 = gridFloor + mix(vec2(0, 1), vec2(1, 0), weights.w);\n vec2 frame2 = gridFloor + vec2(1.0, 1.0);\n\n // move frames to atlas space\n frame0 += tile_offset;\n frame1 += tile_offset;\n frame2 += tile_offset;\n\n vec2 samp0 = texelFetch(lpv_t_probe_depth, ivec2(frame0), 0).rg;\n vec2 samp1 = texelFetch(lpv_t_probe_depth, ivec2(frame1), 0).rg;\n vec2 samp2 = texelFetch(lpv_t_probe_depth, ivec2(frame2), 0).rg;\n\n vec2 d0 = samp0 * weights.x;\n vec2 d1 = samp1 * weights.y;\n vec2 d2 = samp2 * weights.z;\n\n return (d0 + d1 + d2);\n}\n\nfloat lpv_bilinear_lerp(float v00, float v01, float v10, float v11, vec2 fraction) {\n\n float x0 = mix(v00, v01, fraction.x);\n float x1 = mix(v10, v11, fraction.x);\n\n return mix(x0, x1, fraction.y);\n}\n\nvec2 lpv_bilinear_lerp(vec2 v00, vec2 v01, vec2 v10, vec2 v11, vec2 fraction) {\n\n vec2 x0 = mix(v00, v01, fraction.x);\n vec2 x1 = mix(v10, v11, fraction.x);\n\n return mix(x0, x1, fraction.y);\n}\n\nvec2 lpv_sample_bilinear(sampler2D tex, ivec2 texel_position, vec2 fraction) {\n\n float texel_00 = texelFetch(tex, texel_position, 0).r;\n float texel_01 = texelFetch(tex, texel_position + ivec2(1, 0), 0).r;\n float texel_10 = texelFetch(tex, texel_position + ivec2(0, 1), 0).r;\n float texel_11 = texelFetch(tex, texel_position + ivec2(1, 1), 0).r;\n\n return vec2(\n lpv_bilinear_lerp(\n texel_00, texel_01,\n texel_10, texel_11,\n fraction\n ),\n lpv_bilinear_lerp(\n texel_00 * texel_00, texel_01 * texel_01,\n texel_10 * texel_10, texel_11 * texel_11,\n fraction\n )\n );\n}\n\nivec2 wrapOctahedralTexelCoordinates(const in ivec2 texel, const in int texture_size) {\n ivec2 wrapped = ((texel % texture_size) + texture_size) % texture_size;\n\n int fx = (abs(texel.x / texture_size) + int(texel.x < 0));\n int fy = (abs(texel.y / texture_size) + int(texel.y < 0));\n\n if (((fx ^ fy) & 1) != 0) {\n return (texture_size - (wrapped + ivec2(1)));\n return wrapped;\n } else {\n return wrapped;\n }\n}\n\nvec2 lpv_probe_getDepthBilinear(uint probe_index, vec3 direction) {\n // get offset\n int depth_tile_resolution = int(lpv_u_probe_depth_resolution);\n ivec2 tile_resolution = ivec2(depth_tile_resolution);\n const ivec2 atlas_size = ivec2(4096);\n\n int tiles_per_row = atlas_size.x / depth_tile_resolution;\n\n int tile_x = int(probe_index) % tiles_per_row;\n int tile_y = int(probe_index) / tiles_per_row;\n\n ivec2 tile_offset = ivec2(\n tile_x * depth_tile_resolution,\n tile_y * depth_tile_resolution\n );\n\n // convert direction to UV\n vec2 octahedral_uv = clamp(VecToSphereOct(direction) * 0.5 + 0.5, 0.0, 1.0);\n vec2 grid = octahedral_uv * vec2(depth_tile_resolution) - 0.5;\n\n vec2 gridFrac = fract(grid);\n\n ivec2 texel_position = ivec2(floor(grid));\n\n ivec2 tile_p_00;\n ivec2 tile_p_01;\n ivec2 tile_p_10;\n ivec2 tile_p_11;\n\n tile_p_00 = wrapOctahedralTexelCoordinates(texel_position, depth_tile_resolution);\n tile_p_01 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 0), depth_tile_resolution);\n tile_p_10 = wrapOctahedralTexelCoordinates(texel_position + ivec2(0, 1), depth_tile_resolution);\n tile_p_11 = wrapOctahedralTexelCoordinates(texel_position + ivec2(1, 1), depth_tile_resolution);\n\n vec2 texel_00 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_00, 0).rg;\n vec2 texel_01 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_01, 0).rg;\n vec2 texel_10 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_10, 0).rg;\n vec2 texel_11 = texelFetch(lpv_t_probe_depth, tile_offset + tile_p_11, 0).rg;\n\n return lpv_bilinear_lerp(\n texel_00, texel_01,\n texel_10, texel_11,\n gridFrac\n );\n}\n\nvec3 lpv_probe_getPosition(uint probe_index) {\n return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;\n}\n\nmat3 lpv_mesh_makeMatrix(vec3 p0, vec3 p1, vec3 p2, vec3 p3) {\n\n return inverse(\n mat3(\n p0 - p3,\n p1 - p3,\n p2 - p3\n )\n );\n\n}\n\nvec4 lpv_mesh_getBarycentricCoordinates(uint tet_index, vec3 position) {\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec3 p0 = lpv_probe_getPosition(vertices[0]);\n vec3 p1 = lpv_probe_getPosition(vertices[1]);\n vec3 p2 = lpv_probe_getPosition(vertices[2]);\n vec3 p3 = lpv_probe_getPosition(vertices[3]);\n\n mat3 matrix = lpv_mesh_makeMatrix(p0, p1, p2, p3);\n\n vec3 mult = matrix * (position - p3);\n\n return vec4(mult, 1.0 - mult.x - mult.y - mult.z);\n}\n\nvoid lpv_walk_to_tetrahedron(\nin vec3 position,\nin uint tet_guess,\nout uint tet_index,\nout vec4 weights\n) {\n tet_index = tet_guess;\n\n for (uint i = 0u; i < SEARCH_STEP_LIMIT; i++) {\n\n weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);\n\n // Check if we're in the current \"best guess\" tetrahedron\n if (weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0) {\n // success\n return;\n }\n\n uvec4 neighbors = lpv_mesh_getNeighbours(tet_index);\n\n uint next_tet;\n\n // Otherwise find the smallest barycentric coord and move in that direction\n if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) {\n next_tet = neighbors[0];\n } else if (weights.y < weights.z && weights.y < weights.w) {\n next_tet = neighbors[1];\n } else if (weights.z < weights.w) {\n next_tet = neighbors[2];\n } else {\n next_tet = neighbors[3];\n }\n\n tet_index = next_tet;\n }\n\n tet_index = INVALID_TET;\n}\n\nfloat lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {\n\n vec3 probe_position = lpv_probe_getPosition(probe_index);\n\n vec3 local_probe_offset = position - probe_position;\n\n float distToProbe = length(local_probe_offset);\n\n vec3 direction = local_probe_offset / distToProbe;\n\n vec2 temp = lpv_probe_getDepthBilinear(probe_index, direction);\n\n float mean = temp.x;\n float mean2 = temp.y; // mean of squared distances\n\n float variance = abs(mean * mean - mean2);\n\n // http://www.punkuser.net/vsm/vsm_paper.pdf; equation 5\n // Need the max in the denominator because biasing can cause a negative displacement\n float distance_delta = max(distToProbe - mean, 0.0);\n\n float chebyshevWeight = variance / (variance + distance_delta * distance_delta);\n\n // Increase contrast in the weight\n chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);\n\n return (distToProbe <= mean) ? 1.0 : chebyshevWeight;\n}\n\nvec4 lvp_mask_weights_by_visibility_by_depth(vec3 position, uint tet_index, vec4 weights) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec4 visibility = vec4(\n lpv_probe_getVisibilityMask(position, vertices[0]),\n lpv_probe_getVisibilityMask(position, vertices[1]),\n lpv_probe_getVisibilityMask(position, vertices[2]),\n lpv_probe_getVisibilityMask(position, vertices[3])\n );\n\n return visibility * weights;\n}\n\n\nvec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint tet_index, vec4 weights) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec4 visibility;\n\n for (int i = 0; i < 4; i++) {\n vec3 probe_position = lpv_probe_getPosition(vertices[i]);\n\n vec3 direction_to_probe = position - probe_position;\n\n visibility[i] = step(dot(direction_to_probe, normal), 0.0);\n }\n\n return visibility * weights;\n}\n\n\nvec4 lvp_mask_weights_by_visibility(in vec3 position, in vec3 normal, in vec3 view_direction, in uint tet_index, in vec4 barycentric) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec4 visibility;\n\n // Bias the position at which visibility is computed; this\n // avoids performing a shadow test *at* a surface, which is a\n // dangerous location because that is exactly the line between\n // shadowed and unshadowed. If the normal bias is too small,\n // there will be light and dark leaks. If it is too large,\n // then samples can pass through thin occluders to the other\n // side (this can only happen if there are MULTIPLE occluders\n // near each other, a wall surface won't pass through itself.)\n vec3 lookup_position = position + (normal - view_direction * 3.0) * LPV_NORMAL_BIAS;\n\n float weight_sum = 0.0;\n\n for (uint i = 0u; i < 4u; i++) {\n\n float weight = 1.0;\n\n uint probe_index = vertices[i];\n\n vec3 probe_position = lpv_probe_getPosition(probe_index);\n\n\n // Smooth backface test\n {\n\n // Computed without the biasing applied to the \"dir\" variable.\n // This test can cause reflection-map looking errors in the image\n // (stuff looks shiny) if the transition is poor.\n vec3 direction_to_probe = normalize(probe_position - position);\n\n // The naive soft backface weight would ignore a probe when\n // it is behind the surface. That's good for walls. But for small details inside of a\n // room, the normals on the details might rule out all of the probes that have mutual\n // visibility to the point. So, we instead use a \"wrap shading\" test below inspired by\n // NPR work.\n// float backface_term = max(0.0001, dot(direction_to_probe, normal));\n\n // The small offset at the end reduces the \"going to zero\" impact\n // where this is really close to exactly opposite\n float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);\n weight *= backface_term * backface_term + 0.05;\n// weight *= backface_term;\n\n }\n\n // Moment visibility test (depth)\n {\n\n// weight *= lpv_probe_getVisibilityMask(lookup_position, probe_index);\n\n }\n\n\n // A tiny bit of light is really visible due to log perception, so\n // crush tiny weights but keep the curve continuous. This must be done\n // before the trilinear weights, because those should be preserved.\n const float crushThreshold = 0.2;\n\n if (weight < crushThreshold) {\n weight *= weight * weight * (1.0 / (crushThreshold * crushThreshold));\n }\n\n // Avoid zero weight\n weight = max(0.000001, weight);\n\n weight *= barycentric[i];\n\n weight_sum += weight;\n\n visibility[i] = weight;\n }\n\n // normalize\n visibility /= weight_sum;\n\n return visibility;\n}\n\nvec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index) {\n\n uvec4 vertices = lpv_mesh_getVertices(tet_index);\n\n vec3[9] probe0 = lpv_probe_getData(vertices[0]);\n vec3[9] probe1 = lpv_probe_getData(vertices[1]);\n vec3[9] probe2 = lpv_probe_getData(vertices[2]);\n vec3[9] probe3 = lpv_probe_getData(vertices[3]);\n\n vec3[9] result;\n\n for (int i = 0; i < 9; i++) {\n\n result[i] = probe0[i] * weights[0]\n + probe1[i] * weights[1]\n + probe2[i] * weights[2]\n + probe3[i] * weights[3];\n\n }\n\n return result;\n}\n\nuint lpv_guess_initial_tet(vec3 position) {\n\n vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;\n vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;\n\n vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);\n\n return textureLod(lpv_t_mesh_lookup, lookup_coordinates, 0.0).r;\n\n}\n\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 lpv_get_irradiance_at(in vec3 normal, in vec3 shCoefficients[9]) {\n // normal is assumed to have unit length\n float x = normal.x, y = normal.y, z = normal.z;\n\n // band 0\n vec3 result = shCoefficients[0] * 0.8862269254527579;\n\n // band 1\n result -= shCoefficients[1] * 1.0233267079464885 * y;\n result += shCoefficients[2] * 1.0233267079464885 * z;\n result -= shCoefficients[3] * 1.0233267079464885 * x;\n\n // band 2\n result += shCoefficients[4] * 0.8580855308097834 * x * y;\n result -= shCoefficients[5] * 0.8580855308097834 * y * z;\n result += shCoefficients[6] * (0.7431238683011272 * z * z - 0.24770795610037571);\n result -= shCoefficients[7] * 0.8580855308097834 * x * z;\n result += shCoefficients[8] * 0.4290427654048917 * (x * x - y * y);\n\n return result;\n}\n\nvec4 lpv_renormalize_weights(in vec4 source) {\n\n float sum = source.x + source.y + source.z + source.w;\n\n if (sum <= 0.0001) {\n return vec4(0.0);\n }\n\n return source / sum;\n\n}\n\nvec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {\n\n // lookup nearby tet\n vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;\n vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;\n vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);\n\n\n uint nearest_tet = lpv_guess_initial_tet(position);\n\n uint tet;\n vec4 barycentric_coordinates;\n lpv_walk_to_tetrahedron(position, nearest_tet, tet, barycentric_coordinates);\n\n // apply visibility term\n vec4 weights = lvp_mask_weights_by_visibility(position, normal, view_direction, tet, barycentric_coordinates);\n\n if (tet == INVALID_TET) {\n // do nothing\n return vec3(0.0);\n\n } else {\n\n vec3[9] lpv_values = lpv_interpolate_probes(weights, tet);\n\n return lpv_get_irradiance_at(normal, lpv_values);\n\n }\n}\n\n#endif\n";
|
|
2
2
|
export default _default;
|
|
3
3
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -462,7 +462,7 @@ vec4 lvp_mask_weights_by_visibility(in vec3 position, in vec3 normal, in vec3 vi
|
|
|
462
462
|
// Moment visibility test (depth)
|
|
463
463
|
{
|
|
464
464
|
|
|
465
|
-
weight *= lpv_probe_getVisibilityMask(lookup_position, probe_index);
|
|
465
|
+
// weight *= lpv_probe_getVisibilityMask(lookup_position, probe_index);
|
|
466
466
|
|
|
467
467
|
}
|
|
468
468
|
|
|
@@ -26,8 +26,14 @@ export class LightProbeVolume {
|
|
|
26
26
|
* @param {number} x
|
|
27
27
|
* @param {number} y
|
|
28
28
|
* @param {number} z
|
|
29
|
+
* @returns {number}
|
|
29
30
|
*/
|
|
30
|
-
add_point(x: number, y: number, z: number):
|
|
31
|
+
add_point(x: number, y: number, z: number): number;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {number} index
|
|
35
|
+
*/
|
|
36
|
+
remove_point(index: number): void;
|
|
31
37
|
/**
|
|
32
38
|
*
|
|
33
39
|
* @param {AABB3} bounds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAMD;;;OAGG;IACH,sCAIC;IAZD,mCAEC;IAYD,sBAEC;IAMD,uBAGC;IAPD,oBAEC;IAsCD;;;;;;OAMG;IACH,aALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB;IAMD;;;OAGG;IACH,oBAFW,MAAM,QAYhB;IAED;;;;OAIG;IACH,sCAFW,UAAQ;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAC;QAAC,CAAC,EAAC,MAAM,CAAA;KAAC,QAOhD;IAED;;OAEG;IACH,mBAcC;IAGD,yBAEC;;CAEJ;gCA9N+B,wDAAwD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
import { array_shift_back } from "../../../../core/collection/array/array_shift_back.js";
|
|
2
3
|
import {
|
|
3
4
|
compute_delaunay_tetrahedral_mesh
|
|
4
5
|
} from "../../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
|
|
@@ -109,6 +110,38 @@ export class LightProbeVolume {
|
|
|
109
110
|
|
|
110
111
|
set count(v) {
|
|
111
112
|
this.#probe_count = v;
|
|
113
|
+
this.#ensure_capacity(v);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @param {number} capacity
|
|
119
|
+
*/
|
|
120
|
+
#ensure_capacity(capacity) {
|
|
121
|
+
const current_capacity = this.#probe_positions.length / 3;
|
|
122
|
+
|
|
123
|
+
if (current_capacity >= capacity) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const new_capacity = Math.max(
|
|
128
|
+
current_capacity + 16,
|
|
129
|
+
Math.ceil(current_capacity * 1.2),
|
|
130
|
+
capacity
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const new_positions = new Float32Array(new_capacity * 3);
|
|
134
|
+
new_positions.set(this.#probe_positions);
|
|
135
|
+
|
|
136
|
+
const new_depth = new Float32Array(new_capacity * this.#compute_depth_element_size());
|
|
137
|
+
new_depth.set(this.#probe_depth);
|
|
138
|
+
|
|
139
|
+
const new_color = new Float32Array(new_capacity * 27);
|
|
140
|
+
new_color.set(this.#sh3_rgb);
|
|
141
|
+
|
|
142
|
+
this.#probe_positions = new_positions;
|
|
143
|
+
this.#probe_depth = new_depth;
|
|
144
|
+
this.#sh3_rgb = new_color;
|
|
112
145
|
}
|
|
113
146
|
|
|
114
147
|
/**
|
|
@@ -116,10 +149,13 @@ export class LightProbeVolume {
|
|
|
116
149
|
* @param {number} x
|
|
117
150
|
* @param {number} y
|
|
118
151
|
* @param {number} z
|
|
152
|
+
* @returns {number}
|
|
119
153
|
*/
|
|
120
154
|
add_point(x, y, z) {
|
|
121
155
|
const i = this.#probe_count;
|
|
122
156
|
|
|
157
|
+
this.#ensure_capacity(i + 1);
|
|
158
|
+
|
|
123
159
|
const i3 = i * 3;
|
|
124
160
|
|
|
125
161
|
this.#probe_positions[i3] = x;
|
|
@@ -131,6 +167,29 @@ export class LightProbeVolume {
|
|
|
131
167
|
}
|
|
132
168
|
|
|
133
169
|
this.#probe_count++;
|
|
170
|
+
this.#version++;
|
|
171
|
+
|
|
172
|
+
return i;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#compute_depth_element_size() {
|
|
176
|
+
return this.#probe_depth_resolution * this.#probe_depth_resolution * 2;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
*
|
|
181
|
+
* @param {number} index
|
|
182
|
+
*/
|
|
183
|
+
remove_point(index) {
|
|
184
|
+
array_shift_back(this.#probe_positions, (index + 1) * 3, 3, (this.#probe_count - index - 1) * 3);
|
|
185
|
+
array_shift_back(this.#sh3_rgb, (index + 1) * 27, 27, (this.#probe_count - index - 1) * 27);
|
|
186
|
+
|
|
187
|
+
const depth_element_count = this.#compute_depth_element_size();
|
|
188
|
+
array_shift_back(this.#probe_depth, (index + 1) * depth_element_count, depth_element_count, (this.#probe_count - index - 1) * depth_element_count);
|
|
189
|
+
|
|
190
|
+
this.#probe_count--;
|
|
191
|
+
|
|
192
|
+
this.#version++;
|
|
134
193
|
}
|
|
135
194
|
|
|
136
195
|
/**
|
|
@@ -149,6 +208,7 @@ export class LightProbeVolume {
|
|
|
149
208
|
* Build tetrahedral mesh
|
|
150
209
|
*/
|
|
151
210
|
build_mesh() {
|
|
211
|
+
this.#mesh.clear();
|
|
152
212
|
|
|
153
213
|
const t0 = performance.now();
|
|
154
214
|
compute_delaunay_tetrahedral_mesh(this.#mesh, this.#probe_positions, this.#probe_count);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;
|
|
1
|
+
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;IAErB,qBAAoB;IAEpB,qBAAyB;IAEzB,uBAA6B;IAE7B;;;;;;;;OAQG;IACH,kCAPW,MAAM,aACN,MAAM,YACN,MAAM,EAAE,mBACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAchB;IAED,iFAuCC;IAKD,mBACC;IAED,4BAKC;CACJ;8BA/F6B,oBAAoB;2BAHvB,8BAA8B;gCADzB,mCAAmC"}
|
|
@@ -24,6 +24,7 @@ const sampled_irradiance = new Float32Array(3);
|
|
|
24
24
|
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
25
25
|
tracer = new PathTracer();
|
|
26
26
|
max_bounce_count = 5;
|
|
27
|
+
// sample_count = 256;
|
|
27
28
|
sample_count = 4096;
|
|
28
29
|
// sample_count = 40960;
|
|
29
30
|
random = seededRandom(0);
|