@woosh/meep-engine 2.109.7 → 2.109.8
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/package.json +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +3 -3
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +10 -5
- package/src/core/model/node-graph/DataType.d.ts.map +1 -1
- package/src/core/model/node-graph/DataType.js +16 -10
- package/src/core/model/node-graph/ParametricDataType.d.ts +34 -0
- package/src/core/model/node-graph/ParametricDataType.d.ts.map +1 -0
- package/src/core/model/node-graph/ParametricDataType.js +63 -0
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +11 -4
- package/src/engine/graphics/sh3/gi/material/common.glsl +117 -67
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +2 -4
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +5 -47
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +4 -24
- 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 +8 -6
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +4 -4
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +3 -0
- package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +4 -2
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts +8 -0
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +50 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +4 -4
package/package.json
CHANGED
|
@@ -208,15 +208,15 @@ export class TetrahedralMesh {
|
|
|
208
208
|
*/
|
|
209
209
|
removeTetrasConnectedToPoints(range_start: number, range_end: number): void;
|
|
210
210
|
/**
|
|
211
|
-
*
|
|
211
|
+
* Note that this method does not guarantee to find the containing tet in case of concave mesh, that is - if there is a gap between the starting tet and the countaining tet
|
|
212
212
|
* @param {number} x
|
|
213
213
|
* @param {number} y
|
|
214
214
|
* @param {number} z
|
|
215
215
|
* @param {number[]} points Positions of vertices of tetrahedrons
|
|
216
|
-
* @param {number} [
|
|
216
|
+
* @param {number} [start_tetrahedron]
|
|
217
217
|
* @returns {number} index of tetra or -1 if no containing tetra found
|
|
218
218
|
*/
|
|
219
|
-
|
|
219
|
+
walkToTetraContainingPoint(x: number, y: number, z: number, points: number[], start_tetrahedron?: number): number;
|
|
220
220
|
/**
|
|
221
221
|
* Relocate tetrahedron in memory, patches neighbourhood links as well
|
|
222
222
|
* NOTE: The destination slot will be overwritten. This is a dangerous method that can break the topology, make sure you fully understand what you are doing when using it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qCAFU,MAAM,CAEkD;AAElE;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,4BAFU,MAAM,CAEwB;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACI;;;OAGG;IACH,2BAFW,MAAM,EAqDhB;IAhDG;;;;OAIG;IACH,iBAAsE;IAEtE;;;;OAIG;IACH,sBAAmD;IAEnD;;;;OAIG;IACH,eAAyC;IAEzC;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,mBAAmB;IAEnB;;;;OAIG;IACH,eAAgB;IAEhB;;;;OAIG;IACH,uBAAuB;IAG3B;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,2BAEC;IAED;;;;OAIG;IACH,2CAQC;IAED;;OAEG;IACH,cAWC;IAED;;;OAGG;IACH,sBAFW,MAAM,QA8BhB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,uBAFW,MAAM,QAchB;IAED;;;OAGG;IACH,yBAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,YAHW,MAAM,GACL,OAAO,CAiBlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,mBACN,MAAM,aACN,MAAM,QAchB;IAGD;;;;;OAKG;IACH,0BAJW,MAAM,eACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,eACN,MAAM,UACN,MAAM,QAiBhB;IAED;;;;;OAKG;IACH,uBAJW,MAAM,UACN,MAAM,GACL,OAAO,CAUlB;IAGD;;;;OAIG;IACH,YAFY,MAAM,CA4BjB;IAED;;;;;;;;OAQG;IACH,eAPW,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB;IAED;;;;OAIG;IACH,wBAFW,MAAM,QAmBhB;IAED;;;;OAIG;IACH,oBAFW,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,2CAHW,MAAM,aACN,MAAM,QAwBhB;IAED;;;;;;;;OAQG;IACH,
|
|
1
|
+
{"version":3,"file":"TetrahedralMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/TetrahedralMesh.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qCAFU,MAAM,CAEkD;AAElE;;;GAGG;AACH,gCAFU,MAAM,CAE4B;AAE5C;;;GAGG;AACH,4BAFU,MAAM,CAEwB;AAoBxC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACI;;;OAGG;IACH,2BAFW,MAAM,EAqDhB;IAhDG;;;;OAIG;IACH,iBAAsE;IAEtE;;;;OAIG;IACH,sBAAmD;IAEnD;;;;OAIG;IACH,eAAyC;IAEzC;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,mBAAmB;IAEnB;;;;OAIG;IACH,eAAgB;IAEhB;;;;OAIG;IACH,uBAAuB;IAG3B;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,2BAEC;IAED;;;;OAIG;IACH,2CAQC;IAED;;OAEG;IACH,cAWC;IAED;;;OAGG;IACH,sBAFW,MAAM,QA8BhB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,uBAFW,MAAM,QAchB;IAED;;;OAGG;IACH,yBAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,YAHW,MAAM,GACL,OAAO,CAiBlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,mBACN,MAAM,aACN,MAAM,QAchB;IAGD;;;;;OAKG;IACH,0BAJW,MAAM,eACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;OAKG;IACH,0BAJW,MAAM,eACN,MAAM,UACN,MAAM,QAiBhB;IAED;;;;;OAKG;IACH,uBAJW,MAAM,UACN,MAAM,GACL,OAAO,CAUlB;IAGD;;;;OAIG;IACH,YAFY,MAAM,CA4BjB;IAED;;;;;;;;OAQG;IACH,eAPW,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB;IAED;;;;OAIG;IACH,wBAFW,MAAM,QAmBhB;IAED;;;;OAIG;IACH,oBAFW,MAAM,QAmBhB;IAED;;;;;OAKG;IACH,2CAHW,MAAM,aACN,MAAM,QAwBhB;IAED;;;;;;;;OAQG;IACH,8BAPW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,sBACR,MAAM,GACJ,MAAM,CA8DlB;IAGD;;;;;OAKG;IACH,uBAHW,MAAM,qBACN,MAAM,QA6BhB;IAED;;;;OAIG;IACH,WAFa,MAAM,CA2ClB;IAED;;;OAGG;IACH,kBAFW,YAAY,QAUtB;IAED;;;OAGG;IACH,oBAFW,YAAY,QAiBtB;IAED;;;OAGG;IACH,oBAFY,MAAM,CAUjB;IAED;;;OAGG;IACH,wBAFW,MAAM,QAQhB;IAGL;;;OAGG;IACH,4BAFU,OAAO,CAE0B;CAN1C;6BA/tB4B,iCAAiC"}
|
|
@@ -522,19 +522,19 @@ export class TetrahedralMesh {
|
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
/**
|
|
525
|
-
*
|
|
525
|
+
* Note that this method does not guarantee to find the containing tet in case of concave mesh, that is - if there is a gap between the starting tet and the countaining tet
|
|
526
526
|
* @param {number} x
|
|
527
527
|
* @param {number} y
|
|
528
528
|
* @param {number} z
|
|
529
529
|
* @param {number[]} points Positions of vertices of tetrahedrons
|
|
530
|
-
* @param {number} [
|
|
530
|
+
* @param {number} [start_tetrahedron]
|
|
531
531
|
* @returns {number} index of tetra or -1 if no containing tetra found
|
|
532
532
|
*/
|
|
533
|
-
|
|
533
|
+
walkToTetraContainingPoint(x, y, z, points, start_tetrahedron = 0) {
|
|
534
534
|
|
|
535
535
|
let entering_face = 4;
|
|
536
536
|
|
|
537
|
-
let cur_tet =
|
|
537
|
+
let cur_tet = start_tetrahedron;
|
|
538
538
|
|
|
539
539
|
let i;
|
|
540
540
|
while (true) {
|
|
@@ -570,7 +570,12 @@ export class TetrahedralMesh {
|
|
|
570
570
|
// point is outside the tet on the neighbour's side, move in that direction
|
|
571
571
|
const neighbour = this.getNeighbour(cur_tet, i);
|
|
572
572
|
|
|
573
|
-
|
|
573
|
+
if(neighbour === INVALID_NEIGHBOUR){
|
|
574
|
+
// walked outside the mesh, point is not contained within
|
|
575
|
+
return -1;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// assert.notEqual(neighbour, INVALID_NEIGHBOUR, 'walked outside of the mesh');
|
|
574
579
|
|
|
575
580
|
cur_tet = neighbour >>> 2;
|
|
576
581
|
entering_face = neighbour & 3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/DataType.js"],"names":[],"mappings":"AAEA;
|
|
1
|
+
{"version":3,"file":"DataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/DataType.js"],"names":[],"mappings":"AAEA;IAyDI;;;;OAIG;IACH,yBAFa,QAAQ,CAQpB;IAGD;;;;;OAKG;IACH,gBAJW,MAAM,QACN,MAAM,GACJ,QAAQ,CAQpB;IAjFD;;;OAGG;IACH,IAFU,MAAM,CAET;IAEP;;;OAGG;IACH,MAFU,MAAM,CAEN;IAEV,mBAEC;IAED;;;OAGG;IACH,QAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAKnB;IAED;;;;OAIG;IACH,QAHW,MAAM,QACN,MAAM,QAQhB;IAED,eAEC;IAED;;;aAEC;IAgCL;;;OAGG;IACH,qBAFU,OAAO,CAEY;CAP5B"}
|
|
@@ -36,11 +36,12 @@ export class DataType {
|
|
|
36
36
|
&& this.name === other.name;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {number} id
|
|
42
|
+
* @param {string} name
|
|
43
|
+
*/
|
|
44
|
+
set(id, name) {
|
|
44
45
|
assert.isNonNegativeInteger(id, 'id');
|
|
45
46
|
assert.isString(name, 'name');
|
|
46
47
|
|
|
@@ -48,6 +49,14 @@ export class DataType {
|
|
|
48
49
|
this.name = name;
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
toJSON() {
|
|
53
|
+
return { ...this };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fromJSON({ id, name }) {
|
|
57
|
+
this.set(id, name);
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
/**
|
|
52
61
|
*
|
|
53
62
|
* @param {*} j
|
|
@@ -61,6 +70,7 @@ export class DataType {
|
|
|
61
70
|
return r;
|
|
62
71
|
}
|
|
63
72
|
|
|
73
|
+
|
|
64
74
|
/**
|
|
65
75
|
*
|
|
66
76
|
* @param {number} id
|
|
@@ -68,13 +78,9 @@ export class DataType {
|
|
|
68
78
|
* @returns {DataType}
|
|
69
79
|
*/
|
|
70
80
|
static from(id, name) {
|
|
71
|
-
assert.isNonNegativeInteger(id, 'id');
|
|
72
|
-
assert.isString(name, 'name');
|
|
73
|
-
|
|
74
81
|
const r = new DataType();
|
|
75
82
|
|
|
76
|
-
r.id
|
|
77
|
-
r.name = name;
|
|
83
|
+
r.set(id, name);
|
|
78
84
|
|
|
79
85
|
return r;
|
|
80
86
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loosely can be thought as implementing generics, allows creation of types that reference other types
|
|
3
|
+
* Useful for collection types, like lists
|
|
4
|
+
*/
|
|
5
|
+
export class ParametricDataType extends DataType {
|
|
6
|
+
/**
|
|
7
|
+
* @param {number} id
|
|
8
|
+
* @param {string} name
|
|
9
|
+
* @param {DataType[]} [parameters]
|
|
10
|
+
*/
|
|
11
|
+
static from(id: number, name: string, parameters?: DataType[]): ParametricDataType;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {DataType[]}
|
|
15
|
+
*/
|
|
16
|
+
parameters: DataType[];
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {number} id
|
|
20
|
+
* @param {string} name
|
|
21
|
+
* @param {DataType[]} [parameters]
|
|
22
|
+
*/
|
|
23
|
+
set(id: number, name: string, parameters?: DataType[]): void;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {ParametricDataType} other
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
equals(other: ParametricDataType): boolean;
|
|
30
|
+
toJSON(): void;
|
|
31
|
+
fromJSON(j: any): void;
|
|
32
|
+
}
|
|
33
|
+
import { DataType } from "./DataType.js";
|
|
34
|
+
//# sourceMappingURL=ParametricDataType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParametricDataType.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/node-graph/ParametricDataType.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IAyCI;;;;OAIG;IACH,gBAJW,MAAM,QACN,MAAM,eACN,QAAQ,EAAE,sBAUpB;IArDD;;;OAGG;IACH,YAFU,QAAQ,EAAE,CAEJ;IAGhB;;;;;OAKG;IACH,QAJW,MAAM,QACN,MAAM,eACN,QAAQ,EAAE,QAMpB;IAED;;;;OAIG;IACH,cAHW,kBAAkB,GAChB,OAAO,CAQnB;IAED,eAEC;IAED,uBAEC;CAgBJ;yBA7DwB,eAAe"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isArrayEqual } from "../../collection/array/isArrayEqual.js";
|
|
2
|
+
import { DataType } from "./DataType.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Loosely can be thought as implementing generics, allows creation of types that reference other types
|
|
6
|
+
* Useful for collection types, like lists
|
|
7
|
+
*/
|
|
8
|
+
export class ParametricDataType extends DataType {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @type {DataType[]}
|
|
12
|
+
*/
|
|
13
|
+
parameters = [];
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {number} id
|
|
19
|
+
* @param {string} name
|
|
20
|
+
* @param {DataType[]} [parameters]
|
|
21
|
+
*/
|
|
22
|
+
set(id, name, parameters = []) {
|
|
23
|
+
super.set(id, name);
|
|
24
|
+
|
|
25
|
+
this.parameters = parameters;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {ParametricDataType} other
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
33
|
+
equals(other) {
|
|
34
|
+
if (!(other instanceof ParametricDataType)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return super.equals(other) && isArrayEqual(this.parameters, other.parameters);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
toJSON() {
|
|
42
|
+
throw new Error('Unsupported Operation');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fromJSON(j) {
|
|
46
|
+
throw new Error('Unsupported Operation');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {number} id
|
|
51
|
+
* @param {string} name
|
|
52
|
+
* @param {DataType[]} [parameters]
|
|
53
|
+
*/
|
|
54
|
+
static from(id, name, parameters = []) {
|
|
55
|
+
|
|
56
|
+
const r = new ParametricDataType();
|
|
57
|
+
|
|
58
|
+
r.set(id, name, parameters);
|
|
59
|
+
|
|
60
|
+
return r;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AAiCA;
|
|
1
|
+
{"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AAiCA;IA0II;;;OAGG;IACH,0CAOC;IAnBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAuBD,sBAIC;IAED,sBA2CC;IAED,eA+CC;IAED,4BA2BC;;CACJ;4CAlT2C,0DAA0D"}
|
|
@@ -109,6 +109,9 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
109
109
|
type: "t",
|
|
110
110
|
value: this.#textures.depth
|
|
111
111
|
},
|
|
112
|
+
lpv_u_probe_depth_resolution: {
|
|
113
|
+
value: 1
|
|
114
|
+
},
|
|
112
115
|
lpv_t_mesh_lookup: {
|
|
113
116
|
type: "t",
|
|
114
117
|
value: this.#mesh_lookup
|
|
@@ -215,7 +218,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
215
218
|
const w_y = n_y * bounds.getExtentsY() + bounds.y0;
|
|
216
219
|
const w_z = n_z * bounds.getExtentsZ() + bounds.z0;
|
|
217
220
|
|
|
218
|
-
const tet = volume.mesh.
|
|
221
|
+
const tet = volume.mesh.walkToTetraContainingPoint(w_x, w_y, w_z, volume.points, last_tet);
|
|
219
222
|
|
|
220
223
|
if (tet !== -1) {
|
|
221
224
|
last_tet = tet;
|
|
@@ -243,15 +246,19 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
|
|
|
243
246
|
|
|
244
247
|
this.update_lookup();
|
|
245
248
|
|
|
246
|
-
|
|
249
|
+
const uniforms = this.#uniforms;
|
|
247
250
|
|
|
248
|
-
|
|
251
|
+
uniforms.lpv_u_mesh_tet_count.value = lpv.mesh.count;
|
|
252
|
+
|
|
253
|
+
uniforms.lpv_v3_bounds_min.value.set(
|
|
249
254
|
this.#mesh_bounds.x0, this.#mesh_bounds.y0, this.#mesh_bounds.z0
|
|
250
255
|
);
|
|
251
|
-
|
|
256
|
+
uniforms.lpv_v3_bounds_max.value.set(
|
|
252
257
|
this.#mesh_bounds.x1, this.#mesh_bounds.y1, this.#mesh_bounds.z1
|
|
253
258
|
);
|
|
254
259
|
|
|
260
|
+
uniforms.lpv_u_probe_depth_resolution.value = lpv.depth_map_resolution;
|
|
261
|
+
|
|
255
262
|
this.#uniform_version = lpv.version;
|
|
256
263
|
|
|
257
264
|
console.time('prepareTextures');
|
|
@@ -8,14 +8,20 @@ uniform usampler3D lpv_t_mesh_lookup;
|
|
|
8
8
|
|
|
9
9
|
uniform sampler2D lpv_t_probe_positions;
|
|
10
10
|
uniform sampler2D lpv_t_probe_data;
|
|
11
|
+
|
|
11
12
|
uniform sampler2D lpv_t_probe_depth;
|
|
13
|
+
uniform uint lpv_u_probe_depth_resolution;
|
|
12
14
|
|
|
13
15
|
uniform uint lpv_u_mesh_tet_count;
|
|
14
16
|
uniform vec3 lpv_v3_bounds_min;
|
|
15
17
|
uniform vec3 lpv_v3_bounds_max;
|
|
16
18
|
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
const float lpv_min_thickness = 0.03; // in Meters
|
|
21
|
+
const float lpv_max_thickness = 0.50; // in Meters
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#define SEARCH_STEP_LIMIT 32u
|
|
19
25
|
#define INVALID_TET 1073741823u
|
|
20
26
|
|
|
21
27
|
ivec2 lpv_index_to_256_coordinate(uint index) {
|
|
@@ -132,9 +138,9 @@ float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
|
132
138
|
return samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
133
139
|
}
|
|
134
140
|
|
|
135
|
-
|
|
141
|
+
vec2 lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
136
142
|
// get offset
|
|
137
|
-
uint depth_tile_resolution =
|
|
143
|
+
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
138
144
|
uvec2 atlas_size = uvec2(4096u);
|
|
139
145
|
|
|
140
146
|
uint tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
@@ -166,18 +172,14 @@ float lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
|
166
172
|
frame1 += tile_offset;
|
|
167
173
|
frame2 += tile_offset;
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return textureLod(lpv_t_probe_depth,uv0,0.0).r;
|
|
175
|
+
float samp0 = texelFetch(lpv_t_probe_depth, ivec2(frame0), 0).r;
|
|
176
|
+
float samp1 = texelFetch(lpv_t_probe_depth, ivec2(frame1), 0).r;
|
|
177
|
+
float samp2 = texelFetch(lpv_t_probe_depth, ivec2(frame2), 0).r;
|
|
174
178
|
|
|
179
|
+
float mean = samp0 * weights.x + samp1 * weights.y + samp2 * weights.z;
|
|
180
|
+
float mean2 = samp0 * samp0 * weights.x + samp1 * samp1 * weights.y + samp2 * samp2 * weights.z;
|
|
175
181
|
|
|
176
|
-
return
|
|
177
|
-
lpv_t_probe_depth,
|
|
178
|
-
uv0, uv1, uv2,
|
|
179
|
-
weights
|
|
180
|
-
);
|
|
182
|
+
return vec2(mean, mean2);
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
vec3 lpv_probe_getPosition(uint probe_index) {
|
|
@@ -211,7 +213,7 @@ vec4 lpv_mesh_getBarycentricCoordinates(uint tet_index, vec3 position) {
|
|
|
211
213
|
return vec4(mult, 1.0 - mult.x - mult.y - mult.z);
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
void
|
|
216
|
+
void lpv_walk_to_tetrahedron(
|
|
215
217
|
in vec3 position,
|
|
216
218
|
in uint tet_guess,
|
|
217
219
|
out uint tet_index,
|
|
@@ -262,14 +264,28 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
|
262
264
|
|
|
263
265
|
vec3 local_probe_offset = probe_position - position;
|
|
264
266
|
|
|
267
|
+
float distToProbe = length(local_probe_offset);
|
|
268
|
+
|
|
265
269
|
vec3 direction = normalize(local_probe_offset);
|
|
266
270
|
|
|
267
|
-
|
|
271
|
+
vec2 temp = lpv_probe_getDepth(probe_index, direction);
|
|
272
|
+
|
|
273
|
+
float mean = temp.x;
|
|
274
|
+
float variance = abs(mean * mean - temp.y);
|
|
268
275
|
|
|
269
|
-
|
|
276
|
+
// http://www.punkuser.net/vsm/vsm_paper.pdf; equation 5
|
|
277
|
+
// Need the max in the denominator because biasing can cause a negative displacement
|
|
278
|
+
float distance_delta = max(distToProbe - mean, 0.0);
|
|
279
|
+
|
|
280
|
+
float chebyshevWeight = variance / (variance + distance_delta * distance_delta);
|
|
281
|
+
|
|
282
|
+
// Increase contrast in the weight
|
|
283
|
+
// chebyshevWeight = max(chebyshevWeight*chebyshevWeight*chebyshevWeight, 0.0);
|
|
284
|
+
|
|
285
|
+
return (distToProbe <= mean) ? 1.0 : chebyshevWeight;
|
|
270
286
|
}
|
|
271
287
|
|
|
272
|
-
vec4
|
|
288
|
+
vec4 lvp_mask_weights_by_visibility_by_depth(vec3 position, uint tet_index, vec4 weights) {
|
|
273
289
|
|
|
274
290
|
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
275
291
|
|
|
@@ -283,6 +299,36 @@ vec4 lvp_mask_weights_by_visibility(vec3 position, uint tet_index, vec4 weights)
|
|
|
283
299
|
return visibility * weights;
|
|
284
300
|
}
|
|
285
301
|
|
|
302
|
+
float lpv_probe_visibility_weight(uint probe_index, vec3 position, vec3 normal) {
|
|
303
|
+
float weight = 1.0;
|
|
304
|
+
|
|
305
|
+
vec3 probe_position = lpv_probe_getPosition(probe_index);
|
|
306
|
+
|
|
307
|
+
vec3 direction_to_probe = normalize(probe_position - position);
|
|
308
|
+
|
|
309
|
+
// Smooth backface test
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
// The naive soft backface weight would ignore a probe when
|
|
313
|
+
// it is behind the surface. That's good for walls. But for small details inside of a
|
|
314
|
+
// room, the normals on the details might rule out all of the probes that have mutual
|
|
315
|
+
// visibility to the point. So, we instead use a "wrap shading" test below inspired by
|
|
316
|
+
// NPR work.
|
|
317
|
+
// weight *= max(0.0001, dot(direction_to_probe, normal));
|
|
318
|
+
|
|
319
|
+
// The small offset at the end reduces the "going to zero" impact
|
|
320
|
+
// where this is really close to exactly opposite
|
|
321
|
+
float backface_term = max(0.0001, (dot(direction_to_probe, normal) + 1.0) * 0.5);
|
|
322
|
+
weight *= backface_term * backface_term + 0.2;
|
|
323
|
+
|
|
324
|
+
weight *= lpv_probe_getVisibilityMask(position, probe_index);
|
|
325
|
+
|
|
326
|
+
// Avoid zero weight
|
|
327
|
+
weight = max(0.000001, weight);
|
|
328
|
+
|
|
329
|
+
return weight;
|
|
330
|
+
}
|
|
331
|
+
|
|
286
332
|
vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint tet_index, vec4 weights) {
|
|
287
333
|
|
|
288
334
|
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
@@ -294,12 +340,25 @@ vec4 lvp_mask_weights_by_visibility_by_normal(vec3 position, vec3 normal, uint t
|
|
|
294
340
|
|
|
295
341
|
vec3 direction_to_probe = position - probe_position;
|
|
296
342
|
|
|
297
|
-
|
|
343
|
+
visibility[i] = step(dot(direction_to_probe, normal), 0.0);
|
|
298
344
|
}
|
|
299
345
|
|
|
300
346
|
return visibility * weights;
|
|
301
347
|
}
|
|
302
348
|
|
|
349
|
+
vec4 lvp_mask_weights_by_visibility(vec3 position, vec3 normal, uint tet_index) {
|
|
350
|
+
|
|
351
|
+
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
352
|
+
|
|
353
|
+
vec4 visibility;
|
|
354
|
+
|
|
355
|
+
for (int i = 0; i < 4; i++) {
|
|
356
|
+
visibility[i] = lpv_probe_visibility_weight(vertices[i], position, normal);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return visibility;
|
|
360
|
+
}
|
|
361
|
+
|
|
303
362
|
vec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index) {
|
|
304
363
|
|
|
305
364
|
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
@@ -323,29 +382,6 @@ vec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index) {
|
|
|
323
382
|
return result;
|
|
324
383
|
}
|
|
325
384
|
|
|
326
|
-
vec4 lpv_bias_weight_by_normal(const in vec3 position, const in vec3 normal, const in uint tet_index, const in vec4 weights) {
|
|
327
|
-
|
|
328
|
-
uvec4 vertices = lpv_mesh_getVertices(tet_index);
|
|
329
|
-
|
|
330
|
-
vec4 result = weights;
|
|
331
|
-
|
|
332
|
-
for (int i = 0; i < 4; i++) {
|
|
333
|
-
vec3 p = lpv_probe_getPosition(vertices[i]) - position;
|
|
334
|
-
|
|
335
|
-
if (dot(normal, p) <= 0.0) {
|
|
336
|
-
// behind the surface, bias to 0
|
|
337
|
-
result[i] = 0.0;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
float total_weight = result.x + result.y + result.z + result.w;
|
|
342
|
-
|
|
343
|
-
// needs to add up to 1
|
|
344
|
-
result = result / total_weight;
|
|
345
|
-
|
|
346
|
-
return result;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
385
|
uint lpv_guess_initial_tet(vec3 position) {
|
|
350
386
|
|
|
351
387
|
vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
|
|
@@ -358,75 +394,89 @@ uint lpv_guess_initial_tet(vec3 position) {
|
|
|
358
394
|
}
|
|
359
395
|
|
|
360
396
|
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
|
|
361
|
-
vec3 lpv_get_irradiance_at(
|
|
397
|
+
vec3 lpv_get_irradiance_at(in vec3 normal, in vec3 shCoefficients[9]) {
|
|
362
398
|
// normal is assumed to have unit length
|
|
363
399
|
float x = normal.x, y = normal.y, z = normal.z;
|
|
364
400
|
|
|
365
401
|
// band 0
|
|
366
|
-
vec3 result = shCoefficients[
|
|
402
|
+
vec3 result = shCoefficients[0] * 0.8862269254527579;
|
|
367
403
|
|
|
368
404
|
// band 1
|
|
369
|
-
result -= shCoefficients[
|
|
370
|
-
result += shCoefficients[
|
|
371
|
-
result -= shCoefficients[
|
|
405
|
+
result -= shCoefficients[1] * 1.0233267079464885 * y;
|
|
406
|
+
result += shCoefficients[2] * 1.0233267079464885 * z;
|
|
407
|
+
result -= shCoefficients[3] * 1.0233267079464885 * x;
|
|
372
408
|
|
|
373
409
|
// band 2
|
|
374
|
-
result += shCoefficients[
|
|
375
|
-
result -= shCoefficients[
|
|
376
|
-
result += shCoefficients[
|
|
377
|
-
result -= shCoefficients[
|
|
378
|
-
result += shCoefficients[
|
|
410
|
+
result += shCoefficients[4] * 0.8580855308097834 * x * y;
|
|
411
|
+
result -= shCoefficients[5] * 0.8580855308097834 * y * z;
|
|
412
|
+
result += shCoefficients[6] * (0.7431238683011272 * z * z - 0.24770795610037571);
|
|
413
|
+
result -= shCoefficients[7] * 0.8580855308097834 * x * z;
|
|
414
|
+
result += shCoefficients[8] * 0.4290427654048917 * (x * x - y * y);
|
|
379
415
|
|
|
380
416
|
return result;
|
|
381
417
|
}
|
|
382
418
|
|
|
383
|
-
vec4 lpv_renormalize_weights(in vec4 source){
|
|
419
|
+
vec4 lpv_renormalize_weights(in vec4 source) {
|
|
384
420
|
|
|
385
421
|
float sum = source.x + source.y + source.z + source.w;
|
|
386
422
|
|
|
423
|
+
if (sum <= 0.0) {
|
|
424
|
+
return vec4(1.0);
|
|
425
|
+
}
|
|
426
|
+
|
|
387
427
|
return source / sum;
|
|
388
428
|
|
|
389
429
|
}
|
|
390
430
|
|
|
391
431
|
|
|
392
432
|
|
|
393
|
-
|
|
433
|
+
/** Slightly bump the location of the shadow test point away from the shadow casting surface.
|
|
434
|
+
The shadow casting surface is the boundary for shadow, so the nearer an imprecise value is
|
|
435
|
+
to it the more the light leaks.
|
|
436
|
+
*/
|
|
437
|
+
#define LPV_NORMAL_BIAS 0.01f
|
|
394
438
|
|
|
395
|
-
vec3 lpv_sample_irradiance(vec3 position, vec3 normal){
|
|
439
|
+
vec3 lpv_sample_irradiance(vec3 position, vec3 normal, vec3 view_direction) {
|
|
396
440
|
|
|
397
|
-
|
|
441
|
+
// Bias the position at which visibility is computed; this
|
|
442
|
+
// avoids performing a shadow test *at* a surface, which is a
|
|
443
|
+
// dangerous location because that is exactly the line between
|
|
444
|
+
// shadowed and unshadowed. If the normal bias is too small,
|
|
445
|
+
// there will be light and dark leaks. If it is too large,
|
|
446
|
+
// then samples can pass through thin occluders to the other
|
|
447
|
+
// side (this can only happen if there are MULTIPLE occluders
|
|
448
|
+
// near each other, a wall surface won't pass through itself.)
|
|
449
|
+
vec3 lookup_position = position + (normal + view_direction * 3.0) * LPV_NORMAL_BIAS;
|
|
398
450
|
|
|
399
451
|
// lookup nearby tet
|
|
400
452
|
vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
|
|
401
453
|
vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
|
|
402
|
-
vec3 lookup_coordinates = (lookup_position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min)
|
|
454
|
+
vec3 lookup_coordinates = (lookup_position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min);
|
|
403
455
|
|
|
404
456
|
|
|
405
|
-
uint nearest_tet = lpv_guess_initial_tet(
|
|
457
|
+
uint nearest_tet = lpv_guess_initial_tet(lookup_position);
|
|
406
458
|
|
|
407
459
|
uint tet;
|
|
408
460
|
vec4 weights;
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
weights = lvp_mask_weights_by_visibility(lookup_position, tet, weights);
|
|
412
|
-
// weights = lvp_mask_weights_by_visibility_by_normal(lookup_position, normal, tet, weights);
|
|
461
|
+
lpv_walk_to_tetrahedron(lookup_position, nearest_tet, tet, weights);
|
|
413
462
|
|
|
414
|
-
//
|
|
415
|
-
//
|
|
463
|
+
// apply visibility term
|
|
464
|
+
// weights = lvp_mask_weights_by_visibility_by_depth(lookup_position, tet, weights);
|
|
465
|
+
// weights = lvp_mask_weights_by_visibility_by_normal(lookup_position,normal, tet, weights);
|
|
466
|
+
weights *= lvp_mask_weights_by_visibility(lookup_position, normal, tet);
|
|
416
467
|
|
|
417
468
|
// re-normalize weights
|
|
418
|
-
// weights = normalize(weights);
|
|
419
469
|
weights = lpv_renormalize_weights(weights);
|
|
420
470
|
|
|
421
|
-
if(tet == INVALID_TET){
|
|
471
|
+
if (tet == INVALID_TET) {
|
|
422
472
|
// do nothing
|
|
423
473
|
return vec3(0.0);
|
|
424
474
|
|
|
425
|
-
}else{
|
|
475
|
+
} else {
|
|
426
476
|
|
|
427
477
|
vec3[9] lpv_values = lpv_interpolate_probes(weights, tet);
|
|
428
478
|
|
|
429
|
-
return lpv_get_irradiance_at(
|
|
479
|
+
return lpv_get_irradiance_at(normal, lpv_values);
|
|
430
480
|
|
|
431
481
|
}
|
|
432
482
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_fragment_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_fragment_shader.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js"],"names":[],"mappings":"AAkCA;;;GAGG;AACH,8CAFW,MAAM,UAchB"}
|
|
@@ -22,12 +22,10 @@ const ACCUMULATION = `
|
|
|
22
22
|
|
|
23
23
|
vec3 world_normal = normalize(inverseTransformDirection( geometry.normal, viewMatrix ));
|
|
24
24
|
|
|
25
|
-
vec3 probe_irradiance = lpv_sample_irradiance( vWorldPosition, world_normal );
|
|
25
|
+
vec3 probe_irradiance = lpv_sample_irradiance( vWorldPosition, world_normal, geometry.viewDir );
|
|
26
26
|
|
|
27
27
|
irradiance += probe_irradiance * lpv_f_intensity;
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
// material.diffuseColor.rgb = vec3(1.0) ;
|
|
28
|
+
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolumeBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LightProbeVolumeBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js"],"names":[],"mappings":"AAOA;IAEI,8BAAqC;IAGrC;;;;;OAKG;IACH,0DAJa,SAAS,CAgErB;CACJ;wCA1EuC,8BAA8B;sBALhD,4CAA4C"}
|
|
@@ -1,57 +1,12 @@
|
|
|
1
|
-
import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
2
|
-
import {
|
|
3
|
-
tetrahedral_mesh_find_tets_attached_to_vertex
|
|
4
|
-
} from "../../../../core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js";
|
|
5
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
6
1
|
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
7
2
|
import { actionTask } from "../../../../core/process/task/util/actionTask.js";
|
|
8
3
|
import { countTask } from "../../../../core/process/task/util/countTask.js";
|
|
9
4
|
import { promiseTask } from "../../../../core/process/task/util/promiseTask.js";
|
|
5
|
+
import { find_max_depth_radius_for_point } from "./find_max_depth_radius_for_point.js";
|
|
10
6
|
import { PathTracerProbeRenderer } from "./PathTracerProbeRenderer.js";
|
|
11
7
|
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {number} vertex_index
|
|
15
|
-
* @param {TetrahedralMesh} mesh
|
|
16
|
-
* @param {number[]} points
|
|
17
|
-
*/
|
|
18
|
-
function find_max_depth_radius_for_point(vertex_index, mesh, points) {
|
|
19
|
-
const tets = [];
|
|
20
|
-
|
|
21
|
-
const count = tetrahedral_mesh_find_tets_attached_to_vertex(
|
|
22
|
-
tets, 0,
|
|
23
|
-
mesh,
|
|
24
|
-
vertex_index
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const ref_x = points[vertex_index * 3];
|
|
28
|
-
const ref_y = points[vertex_index * 3 + 1];
|
|
29
|
-
const ref_z = points[vertex_index * 3 + 2];
|
|
30
|
-
|
|
31
|
-
let radius_sqr = 0;
|
|
32
|
-
|
|
33
|
-
for (let i = 0; i < count; i++) {
|
|
34
|
-
const tet = tets[i];
|
|
35
|
-
|
|
36
|
-
for (let j = 0; j < 4; j++) {
|
|
37
|
-
const v = mesh.getVertexIndex(tet, j);
|
|
38
|
-
|
|
39
|
-
const x = points[v * 3];
|
|
40
|
-
const y = points[v * 3 + 1];
|
|
41
|
-
const z = points[v * 3 + 2];
|
|
42
|
-
|
|
43
|
-
const r2 = v3_distance_sqr(ref_x, ref_y, ref_z, x, y, z);
|
|
44
|
-
|
|
45
|
-
radius_sqr = max2(r2, radius_sqr);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return Math.sqrt(radius_sqr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
8
|
export class LightProbeVolumeBaker {
|
|
53
9
|
|
|
54
|
-
// this._ren = new WebGLCubeProbeRenderer();
|
|
55
10
|
_ren = new PathTracerProbeRenderer();
|
|
56
11
|
|
|
57
12
|
|
|
@@ -86,11 +41,14 @@ export class LightProbeVolumeBaker {
|
|
|
86
41
|
// Bake depth
|
|
87
42
|
const max_distance = find_max_depth_radius_for_point(i, lpv.mesh, lpv.points);
|
|
88
43
|
|
|
44
|
+
// bias a little to ensure we capture everything
|
|
45
|
+
const max_depth = max_distance * 1.01 + 0.00001;
|
|
46
|
+
|
|
89
47
|
const depth_resolution = lpv.depth_map_resolution;
|
|
90
48
|
|
|
91
49
|
renderer.bake_depth_octahedral(
|
|
92
50
|
depth_resolution,
|
|
93
|
-
|
|
51
|
+
max_depth,
|
|
94
52
|
lpv.points, i * 3,
|
|
95
53
|
lpv.depth, i * depth_resolution * depth_resolution
|
|
96
54
|
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
2
2
|
tracer: PathTracer;
|
|
3
|
+
max_bounce_count: number;
|
|
3
4
|
sample_count: number;
|
|
4
5
|
random: () => number;
|
|
5
6
|
scene: PathTracedScene;
|
|
6
|
-
bake_depth(position: any, position_offset: any, output: any, output_offset: any): void;
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
* @param {number} resolution
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;IACrB,qBAAmB;IACnB,qBAAyB;IAEzB,uBAA6B;IAE7B;;;;;;;;OAQG;IACH,kCAPW,MAAM,aACN,MAAM,YACN,MAAM,EAAE,mBACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAahB;IAED,iFAuCC;IAKD,mBACC;IAED,4BAKC;CACJ;8BA5F6B,oBAAoB;2BAHvB,8BAA8B;gCADzB,mCAAmC"}
|
|
@@ -12,7 +12,6 @@ import { PathTracedScene } from "../path_tracer/PathTracedScene.js";
|
|
|
12
12
|
import { PathTracer } from "../path_tracer/PathTracer.js";
|
|
13
13
|
import { populate_path_traced_scene_from_ecd } from "../path_tracer/populate_path_traced_scene_from_ecd.js";
|
|
14
14
|
import { bake_octahedral_depth_map } from "./depth/octahedral/bake_octahedral_depth_map.js";
|
|
15
|
-
import { sh3_bake_depth } from "./depth/sh3_bake_depth.js";
|
|
16
15
|
import { ProbeRenderer } from "./ProbeRenderer.js";
|
|
17
16
|
|
|
18
17
|
const __shared_buffer = new ArrayBuffer((27 + 9) * 8);
|
|
@@ -24,33 +23,12 @@ const sampled_irradiance = new Float32Array(3);
|
|
|
24
23
|
|
|
25
24
|
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
26
25
|
tracer = new PathTracer();
|
|
26
|
+
max_bounce_count = 7;
|
|
27
27
|
sample_count = 192;
|
|
28
28
|
random = seededRandom(0);
|
|
29
29
|
|
|
30
30
|
scene = new PathTracedScene()
|
|
31
31
|
|
|
32
|
-
bake_depth(position, position_offset, output, output_offset) {
|
|
33
|
-
|
|
34
|
-
sh3_bake_depth(
|
|
35
|
-
coefficients, 0, this.scene,
|
|
36
|
-
position[position_offset],
|
|
37
|
-
position[position_offset + 1],
|
|
38
|
-
position[position_offset + 2],
|
|
39
|
-
1.5
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
sh3_dering_optimize_positive(coefficients, 0, coefficients, 0, 1);
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < 9; i++) {
|
|
45
|
-
const coefficient = coefficients[i];
|
|
46
|
-
|
|
47
|
-
for (let j = 0; j < 3; j++) {
|
|
48
|
-
output[output_offset + i * 3 + j] = coefficient;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
32
|
/**
|
|
55
33
|
*
|
|
56
34
|
* @param {number} resolution
|
|
@@ -84,13 +62,15 @@ export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
|
84
62
|
|
|
85
63
|
coefficients.fill(0);
|
|
86
64
|
|
|
65
|
+
const max_bounce = this.max_bounce_count;
|
|
66
|
+
|
|
87
67
|
for (let i = 0; i < this.sample_count; i++) {
|
|
88
68
|
|
|
89
69
|
randomPointOnSphere(this.random, ray, 3);
|
|
90
70
|
ray.tMax = Infinity;
|
|
91
71
|
ray.tMin = 0;
|
|
92
72
|
|
|
93
|
-
tracer.path_trace(sampled_irradiance, ray, 1,
|
|
73
|
+
tracer.path_trace(sampled_irradiance, ray, 1, max_bounce, this.random, this.scene);
|
|
94
74
|
|
|
95
75
|
sh3_basis_at(ray[3], ray[4], ray[5], sh_basis);
|
|
96
76
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_probes_for_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/build_probes_for_scene.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_probes_for_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/build_probes_for_scene.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH,iFAPW,gBAAgB,GAKd,QAAQ,gBAAgB,CAAC,CAoFrC;iCA9FgC,uBAAuB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
2
2
|
import { make_justified_point_grid } from "../../../../core/geom/3d/util/make_justified_point_grid.js";
|
|
3
3
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
4
|
+
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
4
5
|
import { delay } from "../../../../core/process/delay.js";
|
|
5
6
|
import Entity from "../../../ecs/Entity.js";
|
|
6
7
|
import GUIElement from "../../../ecs/gui/GUIElement.js";
|
|
@@ -49,12 +50,13 @@ export async function build_probes_for_scene(
|
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
// sg_hierarchy_compute_bounding_box_via_parent_entity(light_volume_bounds, composition.entity.entity, ecd);
|
|
53
|
+
const random = seededRandom(1);
|
|
52
54
|
|
|
53
|
-
// for (let i = 0; i <
|
|
54
|
-
//
|
|
55
|
-
// randomFloatBetween(random,
|
|
56
|
-
// randomFloatBetween(random,
|
|
57
|
-
// randomFloatBetween(random,
|
|
55
|
+
// for (let i = 0; i < 1000; i++) {
|
|
56
|
+
// volume.add_point(
|
|
57
|
+
// randomFloatBetween(random, model_bounds.x0, model_bounds.x1),
|
|
58
|
+
// randomFloatBetween(random, model_bounds.y0, model_bounds.y1),
|
|
59
|
+
// randomFloatBetween(random, model_bounds.z0, model_bounds.z1),
|
|
58
60
|
// );
|
|
59
61
|
// }
|
|
60
62
|
|
|
@@ -64,7 +66,7 @@ export async function build_probes_for_scene(
|
|
|
64
66
|
|
|
65
67
|
// lpv.add_point(10, 1, -10);
|
|
66
68
|
|
|
67
|
-
await delay(
|
|
69
|
+
await delay(1);
|
|
68
70
|
|
|
69
71
|
//
|
|
70
72
|
// console.profile('lpv build');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QAuChB"}
|
|
@@ -6,6 +6,8 @@ import { Ray3 } from "../../../../../../core/geom/3d/Ray3.js";
|
|
|
6
6
|
|
|
7
7
|
const scratch_ray = new Ray3();
|
|
8
8
|
|
|
9
|
+
const ray_hit = [];
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
*
|
|
11
13
|
* @param {number[]} result
|
|
@@ -29,13 +31,11 @@ export function bake_octahedral_depth_map(
|
|
|
29
31
|
|
|
30
32
|
const ray_direction = scratch_ray.direction;
|
|
31
33
|
|
|
32
|
-
const ray_hit = [];
|
|
33
|
-
|
|
34
34
|
for (let oct_x = 0; oct_x < resolution; oct_x++) {
|
|
35
35
|
for (let oct_y = 0; oct_y < resolution; oct_y++) {
|
|
36
36
|
|
|
37
|
-
const u = oct_x / (resolution - 1);
|
|
38
|
-
const v = oct_y / (resolution - 1);
|
|
37
|
+
const u = (oct_x) / (resolution - 1);
|
|
38
|
+
const v = (oct_y) / (resolution - 1);
|
|
39
39
|
|
|
40
40
|
decode_octahedron_to_unit(
|
|
41
41
|
ray_direction, 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VLPDepthMapVisualisation.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VLPDepthMapVisualisation.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js"],"names":[],"mappings":"AA6EA;IAYI;;;;OAIG;IACH,oCAFa,wBAAwB,CAQpC;IAfD,qBAEC;IAeD,gBA4CC;;CAEJ;mBAzIkB,iCAAiC"}
|
|
@@ -12,6 +12,8 @@ precision highp usampler3D;
|
|
|
12
12
|
uniform sampler2D lpv_t_probe_positions;
|
|
13
13
|
uniform sampler2D lpv_t_probe_depth;
|
|
14
14
|
|
|
15
|
+
uniform uint lpv_u_probe_depth_resolution;
|
|
16
|
+
|
|
15
17
|
#define SEARCH_STEP_LIMIT 64u
|
|
16
18
|
#define INVALID_TET 1073741823u
|
|
17
19
|
|
|
@@ -84,7 +86,7 @@ float SampleBlended(sampler2D tex, vec2 uv0, vec2 uv1, vec2 uv2, vec4 weights) {
|
|
|
84
86
|
|
|
85
87
|
float lpv_probe_getDepth(uint probe_index, vec3 direction) {
|
|
86
88
|
// get offset
|
|
87
|
-
uint depth_tile_resolution =
|
|
89
|
+
uint depth_tile_resolution = lpv_u_probe_depth_resolution;
|
|
88
90
|
uvec2 atlas_size = uvec2(4096u);
|
|
89
91
|
|
|
90
92
|
uint tiles_per_row = atlas_size.x / depth_tile_resolution;
|
|
@@ -152,7 +154,7 @@ void main() {
|
|
|
152
154
|
vec3 normal = normalize(vNormal);
|
|
153
155
|
vec3 worldNormal = normalize(inverseTransformDirection(normal, viewMatrix));
|
|
154
156
|
|
|
155
|
-
float depth = lpv_probe_getDepth(instance_index , worldNormal) /
|
|
157
|
+
float depth = lpv_probe_getDepth(instance_index , worldNormal) / 7.0;
|
|
156
158
|
|
|
157
159
|
gl_FragColor = vec4(vec3(depth), 1.0);
|
|
158
160
|
// gl_FragColor = vec4( 1.0);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} vertex_index
|
|
4
|
+
* @param {TetrahedralMesh} mesh
|
|
5
|
+
* @param {number[]} points
|
|
6
|
+
*/
|
|
7
|
+
export function find_max_depth_radius_for_point(vertex_index: number, mesh: TetrahedralMesh, points: number[]): number;
|
|
8
|
+
//# sourceMappingURL=find_max_depth_radius_for_point.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_max_depth_radius_for_point.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,8DAJW,MAAM,iCAEN,MAAM,EAAE,UAiClB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
|
|
2
|
+
import {
|
|
3
|
+
tetrahedral_mesh_find_tets_attached_to_vertex
|
|
4
|
+
} from "../../../../core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js";
|
|
5
|
+
import { max2 } from "../../../../core/math/max2.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @type {number[]}
|
|
10
|
+
*/
|
|
11
|
+
const tets = [];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {number} vertex_index
|
|
16
|
+
* @param {TetrahedralMesh} mesh
|
|
17
|
+
* @param {number[]} points
|
|
18
|
+
*/
|
|
19
|
+
export function find_max_depth_radius_for_point(vertex_index, mesh, points) {
|
|
20
|
+
|
|
21
|
+
const count = tetrahedral_mesh_find_tets_attached_to_vertex(
|
|
22
|
+
tets, 0,
|
|
23
|
+
mesh,
|
|
24
|
+
vertex_index
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const ref_x = points[vertex_index * 3];
|
|
28
|
+
const ref_y = points[vertex_index * 3 + 1];
|
|
29
|
+
const ref_z = points[vertex_index * 3 + 2];
|
|
30
|
+
|
|
31
|
+
let radius_sqr = 0;
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < count; i++) {
|
|
34
|
+
const tet = tets[i];
|
|
35
|
+
|
|
36
|
+
for (let j = 0; j < 4; j++) {
|
|
37
|
+
const v = mesh.getVertexIndex(tet, j);
|
|
38
|
+
|
|
39
|
+
const x = points[v * 3];
|
|
40
|
+
const y = points[v * 3 + 1];
|
|
41
|
+
const z = points[v * 3 + 2];
|
|
42
|
+
|
|
43
|
+
const r2 = v3_distance_sqr(ref_x, ref_y, ref_z, x, y, z);
|
|
44
|
+
|
|
45
|
+
radius_sqr = max2(r2, radius_sqr);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return Math.sqrt(radius_sqr);
|
|
50
|
+
}
|
|
@@ -364,7 +364,6 @@ async function main(engine) {
|
|
|
364
364
|
// const path = 'data/models/samples/sd_macross_city_standoff_diorama/scene.gltf';
|
|
365
365
|
// const path = 'data/models/sibenik/2/model.gltf';
|
|
366
366
|
// const path = 'data/models/vokselia_spawn/model.gltf';
|
|
367
|
-
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
368
367
|
// const path = 'data/models/samples/just_a_girl/scene.gltf';
|
|
369
368
|
// const path = 'data/models/samples/slum_house/scene.gltf';
|
|
370
369
|
// const path = 'data/models/samples/jack_trigger/scene.gltf';
|
|
@@ -374,14 +373,15 @@ async function main(engine) {
|
|
|
374
373
|
// const path = 'data/models/samples/ancient_bath_house_-_modular_set/scene.gltf';
|
|
375
374
|
// const path = 'data/models/samples/environment_-_library/scene.gltf';
|
|
376
375
|
// const path = 'data/models/Scans/green_car_wreck/scene.gltf';
|
|
377
|
-
// const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
378
|
-
// const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
379
376
|
// const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
|
|
380
377
|
// const path = 'data/models/samples/the_attic_environment/scene1.gltf';
|
|
381
378
|
// const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
|
|
382
379
|
// const path = 'data/models/samples/cyberpunk_bike/scene.gltf';
|
|
380
|
+
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
381
|
+
// const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
382
|
+
// const path = 'data/models/samples/gi_box_01/model.glb';
|
|
383
383
|
// const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
384
|
-
const path = 'data/models/
|
|
384
|
+
const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
385
385
|
|
|
386
386
|
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
387
387
|
const gltf = mesh_asset.gltf;
|