@woosh/meep-engine 2.109.12 → 2.109.14
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/collection/array/array_range_equal_strict.d.ts +3 -3
- package/src/core/collection/array/array_range_equal_strict.d.ts.map +1 -1
- package/src/core/collection/array/array_range_equal_strict.js +2 -2
- package/src/core/geom/3d/Ray3.d.ts +43 -2
- package/src/core/geom/3d/Ray3.d.ts.map +1 -1
- package/src/core/geom/3d/Ray3.js +97 -0
- package/src/core/geom/vec3/v3_normalize_array.d.ts +3 -3
- package/src/core/geom/vec3/v3_normalize_array.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_normalize_array.js +2 -2
- package/src/core/math/random/generate_halton_jitter.js +2 -2
- package/src/engine/graphics/ecs/camera/focal_length_to_fov.d.ts +8 -0
- package/src/engine/graphics/ecs/camera/focal_length_to_fov.d.ts.map +1 -0
- package/src/engine/graphics/ecs/camera/focal_length_to_fov.js +11 -0
- package/src/engine/graphics/render/gizmo/Gizmo.d.ts.map +1 -1
- package/src/engine/graphics/render/gizmo/Gizmo.js +4 -0
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.d.ts.map +1 -1
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +8 -8
- package/src/engine/graphics/sh3/gi/material/common.glsl +0 -2
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +3 -3
- package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +4 -2
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +1 -1
- 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 +78 -41
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +6 -2
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +6 -13
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +11 -4
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks that elements in supplied arrays are exactly equal within a certain range defined by a pair of offsets and element count (length)
|
|
3
3
|
* @template T
|
|
4
|
-
* @param {T[]} a
|
|
4
|
+
* @param {T[]|Float32Array} a
|
|
5
5
|
* @param {number} offset_a
|
|
6
|
-
* @param {T[]} b
|
|
6
|
+
* @param {T[]|Float32Array} b
|
|
7
7
|
* @param {number} offset_b
|
|
8
8
|
* @param {number} length
|
|
9
9
|
* @returns {boolean}
|
|
10
10
|
*/
|
|
11
|
-
export function array_range_equal_strict<T>(a: T[], offset_a: number, b: T[], offset_b: number, length: number): boolean;
|
|
11
|
+
export function array_range_equal_strict<T>(a: Float32Array | T[], offset_a: number, b: Float32Array | T[], offset_b: number, length: number): boolean;
|
|
12
12
|
//# sourceMappingURL=array_range_equal_strict.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_range_equal_strict.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_range_equal_strict.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,
|
|
1
|
+
{"version":3,"file":"array_range_equal_strict.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_range_equal_strict.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,6EANW,MAAM,mCAEN,MAAM,UACN,MAAM,GACJ,OAAO,CAanB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks that elements in supplied arrays are exactly equal within a certain range defined by a pair of offsets and element count (length)
|
|
3
3
|
* @template T
|
|
4
|
-
* @param {T[]} a
|
|
4
|
+
* @param {T[]|Float32Array} a
|
|
5
5
|
* @param {number} offset_a
|
|
6
|
-
* @param {T[]} b
|
|
6
|
+
* @param {T[]|Float32Array} b
|
|
7
7
|
* @param {number} offset_b
|
|
8
8
|
* @param {number} length
|
|
9
9
|
* @returns {boolean}
|
|
@@ -6,8 +6,48 @@ export class Ray3 extends Float32Array {
|
|
|
6
6
|
set tMax(arg: any);
|
|
7
7
|
get tMax(): any;
|
|
8
8
|
6: any;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {number[]|Float32Array} v
|
|
12
|
+
*/
|
|
13
|
+
set direction(arg: number[] | Float32Array);
|
|
14
|
+
get direction(): number[] | Float32Array;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {number[]|Float32Array} v
|
|
18
|
+
*/
|
|
19
|
+
set origin(arg: number[] | Float32Array);
|
|
20
|
+
get origin(): number[] | Float32Array;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {number} x
|
|
24
|
+
* @param {number} y
|
|
25
|
+
* @param {number} z
|
|
26
|
+
*/
|
|
27
|
+
setOrigin(x: number, y: number, z: number): void;
|
|
28
|
+
0: number;
|
|
29
|
+
1: number;
|
|
30
|
+
2: number;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {number} x
|
|
34
|
+
* @param {number} y
|
|
35
|
+
* @param {number} z
|
|
36
|
+
*/
|
|
37
|
+
setDirection(x: number, y: number, z: number): void;
|
|
38
|
+
3: number;
|
|
39
|
+
4: number;
|
|
40
|
+
5: number;
|
|
41
|
+
normalizeDirection(): void;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param {number} x normalized coordinates in -1,1 range
|
|
45
|
+
* @param {number} y normalized coordinates in -1,1 range
|
|
46
|
+
* @param {number} z normalized coordinates in -1,1 range, typically 0.5
|
|
47
|
+
* @param {number[]|Float32Array|mat4} transform
|
|
48
|
+
* @param {number[]|Float32Array|mat4} projection_inverse
|
|
49
|
+
*/
|
|
50
|
+
projectFromCamera(x: number, y: number, z: number, transform: number[] | Float32Array | mat4, projection_inverse: number[] | Float32Array | mat4): void;
|
|
11
51
|
/**
|
|
12
52
|
*
|
|
13
53
|
* @param {number} distance
|
|
@@ -28,6 +68,7 @@ export class Ray3 extends Float32Array {
|
|
|
28
68
|
* @param {Ray3} other
|
|
29
69
|
*/
|
|
30
70
|
copy(other: Ray3): void;
|
|
71
|
+
hash(): number;
|
|
31
72
|
/**
|
|
32
73
|
*
|
|
33
74
|
* @param {Ray3} other
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ray3.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/Ray3.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Ray3.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/Ray3.js"],"names":[],"mappings":"AASA;;GAEG;AACH;IACI,cAKC;IAMD,mBAEC;IAND,gBAEC;IAGG,OAAW;IAOf;;;OAGG;IACH,4CAEC;IAVD,yCAEC;IAcD;;;OAGG;IACH,yCAEC;IAVD,sCAEC;IAUD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAUhB;IAHG,UAAW;IACX,UAAW;IACX,UAAW;IAGf;;;;;OAKG;IACH,gBAJW,MAAM,KACN,MAAM,KACN,MAAM,QAUhB;IAHG,UAAW;IACX,UAAW;IACX,UAAW;IAGf,2BAEC;IAED;;;;;;;OAOG;IACH,qBANW,MAAM,KACN,MAAM,KACN,MAAM,aACN,MAAM,EAAE,GAAC,YAAY,OAAK,sBAC1B,MAAM,EAAE,GAAC,YAAY,OAAK,QA6BpC;IAED;;;OAGG;IACH,uBAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,iBAFW,MAAM,EAAE,UAAM,YAAY,QAepC;IAED;;;OAGG;IACH,SAFa,IAAI,CAQhB;IAED;;;OAGG;IACH,YAFW,IAAI,QAId;IAED,eAEC;IAED;;;;OAIG;IACH,cAHW,IAAI,GACF,OAAO,CAInB;CACJ"}
|
package/src/core/geom/3d/Ray3.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { array_copy } from "../../collection/array/array_copy.js";
|
|
1
3
|
import { array_range_equal_strict } from "../../collection/array/array_range_equal_strict.js";
|
|
4
|
+
import { computeHashFloatArray } from "../../math/hash/computeHashFloatArray.js";
|
|
2
5
|
import { v3_matrix4_multiply } from "../vec3/v3_matrix4_multiply.js";
|
|
3
6
|
import { v3_matrix4_rotate } from "../vec3/v3_matrix4_rotate.js";
|
|
7
|
+
import { v3_normalize_array } from "../vec3/v3_normalize_array.js";
|
|
4
8
|
import { ray3_interval_array_apply_matrix4 } from "./ray/ray3_interval_array_apply_matrix4.js";
|
|
5
9
|
|
|
6
10
|
/**
|
|
@@ -26,10 +30,99 @@ export class Ray3 extends Float32Array {
|
|
|
26
30
|
return new Float32Array(this.buffer, this.byteOffset + 3 * 4, 3);
|
|
27
31
|
}
|
|
28
32
|
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {number[]|Float32Array} v
|
|
36
|
+
*/
|
|
37
|
+
set direction(v) {
|
|
38
|
+
array_copy(v, 0, this, 3, 3);
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
get origin() {
|
|
30
42
|
return new Float32Array(this.buffer, this.byteOffset, 3);
|
|
31
43
|
}
|
|
32
44
|
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {number[]|Float32Array} v
|
|
48
|
+
*/
|
|
49
|
+
set origin(v) {
|
|
50
|
+
array_copy(v, 0, this, 0, 3);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {number} x
|
|
56
|
+
* @param {number} y
|
|
57
|
+
* @param {number} z
|
|
58
|
+
*/
|
|
59
|
+
setOrigin(x, y, z) {
|
|
60
|
+
assert.isNumber(x, 'x');
|
|
61
|
+
assert.isNumber(y, 'y');
|
|
62
|
+
assert.isNumber(z, 'z');
|
|
63
|
+
|
|
64
|
+
this[0] = x;
|
|
65
|
+
this[1] = y;
|
|
66
|
+
this[2] = z;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param {number} x
|
|
72
|
+
* @param {number} y
|
|
73
|
+
* @param {number} z
|
|
74
|
+
*/
|
|
75
|
+
setDirection(x, y, z) {
|
|
76
|
+
assert.isNumber(x, 'x');
|
|
77
|
+
assert.isNumber(y, 'y');
|
|
78
|
+
assert.isNumber(z, 'z');
|
|
79
|
+
|
|
80
|
+
this[3] = x;
|
|
81
|
+
this[4] = y;
|
|
82
|
+
this[5] = z;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
normalizeDirection() {
|
|
86
|
+
v3_normalize_array(this, 3, this, 3);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param {number} x normalized coordinates in -1,1 range
|
|
92
|
+
* @param {number} y normalized coordinates in -1,1 range
|
|
93
|
+
* @param {number} z normalized coordinates in -1,1 range, typically 0.5
|
|
94
|
+
* @param {number[]|Float32Array|mat4} transform
|
|
95
|
+
* @param {number[]|Float32Array|mat4} projection_inverse
|
|
96
|
+
*/
|
|
97
|
+
projectFromCamera(
|
|
98
|
+
x, y, z,
|
|
99
|
+
transform,
|
|
100
|
+
projection_inverse
|
|
101
|
+
) {
|
|
102
|
+
assert.isNumber(x, 'x');
|
|
103
|
+
assert.isNumber(y, 'y');
|
|
104
|
+
assert.isNumber(z, 'z');
|
|
105
|
+
|
|
106
|
+
// extract position from transform matrix
|
|
107
|
+
const origin_x = transform[12];
|
|
108
|
+
const origin_y = transform[13];
|
|
109
|
+
const origin_z = transform[14];
|
|
110
|
+
|
|
111
|
+
this.setOrigin(origin_x, origin_y, origin_z);
|
|
112
|
+
|
|
113
|
+
this.setDirection(x, y, z);
|
|
114
|
+
v3_matrix4_multiply(this, 3, this, 3, projection_inverse);
|
|
115
|
+
v3_matrix4_multiply(this, 3, this, 3, transform);
|
|
116
|
+
|
|
117
|
+
// subtract origin
|
|
118
|
+
this[3] -= origin_x;
|
|
119
|
+
this[4] -= origin_y;
|
|
120
|
+
this[5] -= origin_z;
|
|
121
|
+
|
|
122
|
+
// normalize
|
|
123
|
+
this.normalizeDirection();
|
|
124
|
+
}
|
|
125
|
+
|
|
33
126
|
/**
|
|
34
127
|
*
|
|
35
128
|
* @param {number} distance
|
|
@@ -79,6 +172,10 @@ export class Ray3 extends Float32Array {
|
|
|
79
172
|
this.set(other);
|
|
80
173
|
}
|
|
81
174
|
|
|
175
|
+
hash() {
|
|
176
|
+
return computeHashFloatArray(this);
|
|
177
|
+
}
|
|
178
|
+
|
|
82
179
|
/**
|
|
83
180
|
*
|
|
84
181
|
* @param {Ray3} other
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
|
-
* @param {number[]} input
|
|
3
|
+
* @param {number[]|Float32Array} input
|
|
4
4
|
* @param {number} input_offset
|
|
5
|
-
* @param {number[]} output
|
|
5
|
+
* @param {number[]|Float32Array} output
|
|
6
6
|
* @param {number} output_offset
|
|
7
7
|
*/
|
|
8
|
-
export function v3_normalize_array(input: number[], input_offset: number, output: number[], output_offset: number): void;
|
|
8
|
+
export function v3_normalize_array(input: number[] | Float32Array, input_offset: number, output: number[] | Float32Array, output_offset: number): void;
|
|
9
9
|
//# sourceMappingURL=v3_normalize_array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v3_normalize_array.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_normalize_array.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,0CALW,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"v3_normalize_array.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec3/v3_normalize_array.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,0CALW,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,UACN,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,QAqBhB"}
|
|
@@ -13,8 +13,8 @@ export function generate_halton_jitter(point_count) {
|
|
|
13
13
|
|
|
14
14
|
for (let i = 0; i < point_count; i++) {
|
|
15
15
|
const i2 = i * 2;
|
|
16
|
-
result[i2] = halton_sequence(2, i) * 2
|
|
17
|
-
result[i2 + 1] = halton_sequence(3, i) * 2
|
|
16
|
+
result[i2] = 1 - halton_sequence(2, i) * 2;
|
|
17
|
+
result[i2 + 1] = 1 - halton_sequence(3, i) * 2;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return result;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://en.wikipedia.org/wiki/Focal_length
|
|
3
|
+
* @param {number} focal_length (in mm)
|
|
4
|
+
* @param {number} [sensor_width] Width of camera sensor (in mm)
|
|
5
|
+
* @returns {number} in Radians
|
|
6
|
+
*/
|
|
7
|
+
export function focal_length_to_fov(focal_length: number, sensor_width?: number): number;
|
|
8
|
+
//# sourceMappingURL=focal_length_to_fov.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focal_length_to_fov.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/ecs/camera/focal_length_to_fov.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,kDAJW,MAAM,iBACN,MAAM,GACJ,MAAM,CAMlB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see https://en.wikipedia.org/wiki/Focal_length
|
|
3
|
+
* @param {number} focal_length (in mm)
|
|
4
|
+
* @param {number} [sensor_width] Width of camera sensor (in mm)
|
|
5
|
+
* @returns {number} in Radians
|
|
6
|
+
*/
|
|
7
|
+
export function focal_length_to_fov(focal_length, sensor_width = 35) {
|
|
8
|
+
|
|
9
|
+
return 2 * Math.atan(sensor_width / (2 * focal_length));
|
|
10
|
+
|
|
11
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gizmo.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/gizmo/Gizmo.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"Gizmo.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/gizmo/Gizmo.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oBAFU,4BAA4B,CAEqB;6CANd,mCAAmC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GizmoShapeRenderingInterface.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js"],"names":[],"mappings":"AAyCA;;GAEG;AACH;IAGQ;;;;OAIG;IACH,
|
|
1
|
+
{"version":3,"file":"GizmoShapeRenderingInterface.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js"],"names":[],"mappings":"AAyCA;;GAEG;AACH;IAGQ;;;;OAIG;IACH,gBAA6C;IAE7C,kCAA8F;IAC9F,iCAA6F;IAI7F,mCAA2G;IAC3G,kCAAiG;IAKjG,eAA0B;IAG9B,+CAQC;IAED;;;;;OAKG;IACH,qBAJW,MAAM,QAAQ,EAAE,sBAChB,MAAM,WACN,MAAM,EAAE,UAYlB;IAED,cAOC;IAED;;;;OAIG;IACH,yBAMC;IAED;;;OAGG;IACH,sBAEC;IAED;;;;OAIG;IACH,wBAHW,MAAM,EAAE,QACR,MAAM,EAAE,QAKlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,EAAE,QACR,MAAM,EAAE,QAKlB;IAED;;;;OAIG;IACH,gBAHW,MAAM,EAAE,MACR,MAAM,EAAE,QAIlB;IAGD;;;;OAIG;IACH,0BAHW,MAAM,EAAE,UACR,MAAM,QAKhB;IAED;;;;OAIG;IACH,yBAHW,MAAM,EAAE,UACR,MAAM,QAKhB;CACJ;;;;mCAtKkC,iDAAiD;sBAC9D,aAAa"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
2
|
-
import { assert } from "../../../../core/assert.js";
|
|
3
|
-
import { InstancedMeshGroup } from "../../geometry/instancing/InstancedMeshGroup.js";
|
|
4
1
|
import { BoxBufferGeometry, LineBasicMaterial, MeshBasicMaterial, OctahedronBufferGeometry } from "three";
|
|
2
|
+
import { makeHelperBoxGeometry } from "../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
|
|
3
|
+
import { makeHelperSphereGeometry } from "../../../../../editor/process/symbolic/makeHelperSphereGeometry.js";
|
|
4
|
+
import { assert } from "../../../../core/assert.js";
|
|
5
|
+
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
5
6
|
import { compose_matrix4_array } from "../../../../core/geom/3d/compose_matrix4_array.js";
|
|
6
|
-
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
7
7
|
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
8
|
-
import
|
|
8
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
9
9
|
import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
|
|
10
|
-
import {
|
|
10
|
+
import { InstancedMeshGroup } from "../../geometry/instancing/InstancedMeshGroup.js";
|
|
11
11
|
import { Lines } from "../Lines.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -47,10 +47,10 @@ export class GizmoShapeRenderingInterface {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
*
|
|
50
|
-
* @type {number[]}
|
|
50
|
+
* @type {number[]|Float32Array}
|
|
51
51
|
* @private
|
|
52
52
|
*/
|
|
53
|
-
this.__color = [1, 1, 1, 1];
|
|
53
|
+
this.__color = new Float32Array([1, 1, 1, 1]);
|
|
54
54
|
|
|
55
55
|
this.__boxes_solid = InstancedMeshGroup.from(new BoxBufferGeometry(), new MeshBasicMaterial());
|
|
56
56
|
this.__boxes_wire = InstancedMeshGroup.from(makeHelperBoxGeometry(), new LineBasicMaterial());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeOctahedralDepthAtlas.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,sDAHW,MAAM,GACJ,WAAW,CAsBvB;
|
|
1
|
+
{"version":3,"file":"makeOctahedralDepthAtlas.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,sDAHW,MAAM,GACJ,WAAW,CAsBvB;4BA3BoF,OAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClampToEdgeWrapping, DataTexture, FloatType, NearestFilter,
|
|
1
|
+
import { ClampToEdgeWrapping, DataTexture, FloatType, NearestFilter, RGFormat } from "three";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -7,10 +7,10 @@ import { ClampToEdgeWrapping, DataTexture, FloatType, NearestFilter, RedFormat }
|
|
|
7
7
|
*/
|
|
8
8
|
export function makeOctahedralDepthAtlas(resolution = 4096) {
|
|
9
9
|
const texture = new DataTexture(
|
|
10
|
-
new Float32Array(resolution * resolution),
|
|
10
|
+
new Float32Array(resolution * resolution * 2),
|
|
11
11
|
resolution,
|
|
12
12
|
resolution,
|
|
13
|
-
|
|
13
|
+
RGFormat, // 2 channels
|
|
14
14
|
FloatType
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAkErB;CACJ;wCA5EuC,8BAA8B;sBALhD,4CAA4C"}
|
|
@@ -42,15 +42,17 @@ export class LightProbeVolumeBaker {
|
|
|
42
42
|
const max_distance = find_max_depth_radius_for_point(i, lpv.mesh, lpv.points);
|
|
43
43
|
|
|
44
44
|
// bias a little to ensure we capture everything
|
|
45
|
-
const max_depth = max_distance * 1.01 +
|
|
45
|
+
const max_depth = max_distance * 1.01 + 1e-6;
|
|
46
46
|
|
|
47
47
|
const depth_resolution = lpv.depth_map_resolution;
|
|
48
48
|
|
|
49
|
+
const probe_element_count = depth_resolution * depth_resolution * 2;
|
|
50
|
+
|
|
49
51
|
renderer.bake_depth_octahedral(
|
|
50
52
|
depth_resolution,
|
|
51
53
|
max_depth,
|
|
52
54
|
lpv.points, i * 3,
|
|
53
|
-
lpv.depth, i *
|
|
55
|
+
lpv.depth, i * probe_element_count
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
});
|
|
@@ -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;IACrB,
|
|
1
|
+
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,yBAAqB;IACrB,qBAAoB;IACpB,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"}
|
|
@@ -24,7 +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 = 7;
|
|
27
|
-
sample_count =
|
|
27
|
+
sample_count = 4096;
|
|
28
28
|
random = seededRandom(0);
|
|
29
29
|
|
|
30
30
|
scene = new PathTracedScene()
|
|
@@ -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":"AA2BA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QA+GhB"}
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
import { Ray3 } from "../../../../../../core/geom/3d/Ray3.js";
|
|
6
6
|
import { v3_distance } from "../../../../../../core/geom/vec3/v3_distance.js";
|
|
7
7
|
import { v3_dot } from "../../../../../../core/geom/vec3/v3_dot.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { v3_dot_array_array } from "../../../../../../core/geom/vec3/v3_dot_array_array.js";
|
|
9
|
+
import { max2 } from "../../../../../../core/math/max2.js";
|
|
10
|
+
import { generate_halton_jitter } from "../../../../../../core/math/random/generate_halton_jitter.js";
|
|
10
11
|
|
|
11
12
|
const scratch_ray = new Ray3();
|
|
12
13
|
|
|
@@ -16,6 +17,14 @@ const scratch_ray = new Ray3();
|
|
|
16
17
|
*/
|
|
17
18
|
const ray_hit = [];
|
|
18
19
|
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {number}
|
|
23
|
+
*/
|
|
24
|
+
const SUB_SAMPLE_COUNT = 7;
|
|
25
|
+
|
|
26
|
+
const DEPTH_SHARPNESS = 1;
|
|
27
|
+
|
|
19
28
|
/**
|
|
20
29
|
*
|
|
21
30
|
* @param {number[]} result
|
|
@@ -37,73 +46,101 @@ export function bake_octahedral_depth_map(
|
|
|
37
46
|
scratch_ray.tMax = max_depth;
|
|
38
47
|
array_copy(position, position_offset, scratch_ray, 0, 3);
|
|
39
48
|
|
|
49
|
+
const CONSTANT_NORMAL_BIAS = max_depth * 0.01 + 1e-6;
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
* Resolution bias is to compensate for discontinuities between samples
|
|
43
|
-
* The lower the resolution - the higher the discontinuities
|
|
44
|
-
* This is heights of an arch on a unit sphere, where arch spans 1/resolution angle
|
|
45
|
-
* Half-PI is to get the height at midpoint of the arch
|
|
46
|
-
* x2 is to get error over the entire circle, as the previous term only gets us to semicircle
|
|
47
|
-
* xMath.SQRT2 is to allow for diagonals between pixels
|
|
48
|
-
* @type {number}
|
|
49
|
-
*/
|
|
50
|
-
const RESOLUTION_BIAS = Math.sin(PI_HALF / resolution) * 2 * Math.SQRT2;
|
|
51
|
+
const ray_direction = scratch_ray.direction;
|
|
51
52
|
|
|
52
|
-
const
|
|
53
|
+
const probe_direction = new Float32Array(3);
|
|
54
|
+
|
|
55
|
+
const texel_uv_scale = 0.5 / (resolution - 1);
|
|
56
|
+
|
|
57
|
+
const jittered_sub_samples = generate_halton_jitter(SUB_SAMPLE_COUNT);
|
|
53
58
|
|
|
54
|
-
const ray_direction = scratch_ray.direction;
|
|
55
59
|
|
|
56
60
|
for (let oct_x = 0; oct_x < resolution; oct_x++) {
|
|
57
61
|
for (let oct_y = 0; oct_y < resolution; oct_y++) {
|
|
58
62
|
|
|
63
|
+
let distance_sum = 0;
|
|
64
|
+
let distance2_sum = 0;
|
|
65
|
+
let weight_sum = 0;
|
|
66
|
+
|
|
59
67
|
const u = (oct_x) / (resolution - 1);
|
|
60
68
|
const v = (oct_y) / (resolution - 1);
|
|
61
69
|
|
|
62
70
|
decode_octahedron_to_unit(
|
|
63
|
-
|
|
71
|
+
probe_direction, 0,
|
|
64
72
|
u * 2 - 1, v * 2 - 1
|
|
65
73
|
);
|
|
66
74
|
|
|
67
|
-
let
|
|
75
|
+
for (let sub_sample_index = 0; sub_sample_index < SUB_SAMPLE_COUNT; sub_sample_index++) {
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
// no hit
|
|
71
|
-
distance = max_depth;
|
|
72
|
-
} else {
|
|
73
|
-
const surface_normal_x = ray_hit[3];
|
|
74
|
-
const surface_normal_y = ray_hit[4];
|
|
75
|
-
const surface_normal_z = ray_hit[5];
|
|
77
|
+
const sample_index2 = sub_sample_index * 2;
|
|
76
78
|
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const surface_position_z = ray_hit[2];
|
|
79
|
+
const ray_u = u + jittered_sub_samples[sample_index2] * texel_uv_scale;
|
|
80
|
+
const ray_v = v + jittered_sub_samples[sample_index2 + 1] * texel_uv_scale;
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
ray_direction[0], ray_direction[1], ray_direction[2]
|
|
82
|
+
decode_octahedron_to_unit(
|
|
83
|
+
ray_direction, 0,
|
|
84
|
+
ray_u * 2 - 1, ray_v * 2 - 1
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
let distance = scene.trace(ray_hit, scratch_ray);
|
|
88
|
+
|
|
89
|
+
if (distance < 0) {
|
|
90
|
+
// no hit
|
|
91
|
+
distance = max_depth;
|
|
92
|
+
} else {
|
|
93
|
+
const surface_normal_x = ray_hit[3];
|
|
94
|
+
const surface_normal_y = ray_hit[4];
|
|
95
|
+
const surface_normal_z = ray_hit[5];
|
|
96
|
+
|
|
97
|
+
const surface_position_x = ray_hit[0];
|
|
98
|
+
const surface_position_y = ray_hit[1];
|
|
99
|
+
const surface_position_z = ray_hit[2];
|
|
100
|
+
|
|
101
|
+
// check for possible miss
|
|
102
|
+
const hit_angle_cos = -v3_dot(
|
|
103
|
+
surface_normal_x, surface_normal_y, surface_normal_z,
|
|
104
|
+
ray_direction[0], ray_direction[1], ray_direction[2]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const resolution_bias_offset = max_depth * texel_uv_scale;
|
|
88
108
|
|
|
89
|
-
|
|
109
|
+
const hit_normal_bias = CONSTANT_NORMAL_BIAS;
|
|
90
110
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
// sink the contact into the surface along the hit normal
|
|
112
|
+
const biased_hit_x = surface_position_x + surface_normal_x * hit_normal_bias;
|
|
113
|
+
const biased_hit_y = surface_position_y + surface_normal_y * hit_normal_bias;
|
|
114
|
+
const biased_hit_z = surface_position_z + surface_normal_z * hit_normal_bias;
|
|
95
115
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
116
|
+
distance = v3_distance(
|
|
117
|
+
scratch_ray[0], scratch_ray[1], scratch_ray[2],
|
|
118
|
+
biased_hit_x, biased_hit_y, biased_hit_z
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
// distance += resolution_bias_offset;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const direction_dot_product = v3_dot_array_array(ray_direction, 0, probe_direction, 0);
|
|
125
|
+
|
|
126
|
+
const weight = Math.pow(
|
|
127
|
+
max2(0,
|
|
128
|
+
direction_dot_product
|
|
129
|
+
),
|
|
130
|
+
DEPTH_SHARPNESS
|
|
99
131
|
);
|
|
100
132
|
|
|
101
|
-
|
|
133
|
+
distance_sum += distance * weight;
|
|
134
|
+
distance2_sum += distance * distance * weight;
|
|
135
|
+
weight_sum += weight;
|
|
102
136
|
}
|
|
103
137
|
|
|
104
138
|
const pixel_index = oct_y * resolution + oct_x;
|
|
105
139
|
|
|
106
|
-
|
|
140
|
+
const address = result_offset + pixel_index * 2;
|
|
141
|
+
|
|
142
|
+
result[address] = distance_sum / weight_sum;
|
|
143
|
+
result[address + 1] = distance2_sum / weight_sum;
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
146
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe_volume_to_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/probe_volume_to_textures.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,6EAHW,MAAM,EAAE,eACR,MAAM,
|
|
1
|
+
{"version":3,"file":"probe_volume_to_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/probe_volume_to_textures.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,6EAHW,MAAM,EAAE,eACR,MAAM,QAqChB;AAGD;;;;;;GAMG;AACH,2DALW,oBAAoB,UACpB,MAAM,EAAE,eACR,MAAM,eACN,MAAM,QAiBhB;qCApEoC,uCAAuC"}
|
|
@@ -27,14 +27,18 @@ export function octahedral_depth_to_atlas(lpv, atlas_data, atlas_width) {
|
|
|
27
27
|
|
|
28
28
|
const tile_pixel_index = pixel_y * tile_resolution + pixel_x;
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const source_pixel_index = source_offset + tile_pixel_index;
|
|
31
|
+
const source_pixel_address = source_pixel_index * 2;
|
|
31
32
|
|
|
32
33
|
const target_pixel_x = tile_x * tile_resolution + pixel_x;
|
|
33
34
|
const target_pixel_y = tile_y * tile_resolution + pixel_y;
|
|
34
35
|
|
|
35
36
|
const target_pixel_index = target_pixel_y * atlas_width + target_pixel_x;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
const target_pixel_address = target_pixel_index * 2;
|
|
39
|
+
|
|
40
|
+
atlas_data[target_pixel_address] = probe_depth[source_pixel_address];
|
|
41
|
+
atlas_data[target_pixel_address + 1] = probe_depth[source_pixel_address + 1];
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
}
|
|
@@ -411,9 +411,6 @@ function* render(target, pt, camera, scene, progress = { current: 0, total: 0 })
|
|
|
411
411
|
const pixel_accummulation = [];
|
|
412
412
|
const ray = new Ray3();
|
|
413
413
|
|
|
414
|
-
const ray_origin = new Vector3();
|
|
415
|
-
const ray_direction = new Vector3();
|
|
416
|
-
|
|
417
414
|
const width = target.width;
|
|
418
415
|
const height = target.height;
|
|
419
416
|
|
|
@@ -467,16 +464,12 @@ function* render(target, pt, camera, scene, progress = { current: 0, total: 0 })
|
|
|
467
464
|
|
|
468
465
|
for (let i = 0; i < pixel_sample_count; i++) {
|
|
469
466
|
|
|
470
|
-
|
|
467
|
+
ray.projectFromCamera(
|
|
471
468
|
_x + random() * pixel_scale_x * 2,
|
|
472
469
|
_y + random() * pixel_scale_y * 2,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
ray3_array_compose(
|
|
477
|
-
ray,
|
|
478
|
-
ray_origin.x, ray_origin.y, ray_origin.z,
|
|
479
|
-
ray_direction.x, ray_direction.y, ray_direction.z
|
|
470
|
+
0.5,
|
|
471
|
+
camera.matrixWorld.elements,
|
|
472
|
+
camera.projectionMatrixInverse.elements
|
|
480
473
|
);
|
|
481
474
|
|
|
482
475
|
ray.tMax = Infinity;
|
|
@@ -542,8 +535,8 @@ async function start_renderer(camera) {
|
|
|
542
535
|
// await prepare_scene_rtiow(pt, camera);
|
|
543
536
|
// await prepare_scene_sphere_01(pt, camera);
|
|
544
537
|
// await prepare_gi_box_scene(scene, camera);
|
|
545
|
-
|
|
546
|
-
await prepare_attic_scene(scene, camera);
|
|
538
|
+
await prepare_sponza(scene, camera);
|
|
539
|
+
// await prepare_attic_scene(scene, camera);
|
|
547
540
|
// await prepare_scene_gltf({scene, camera, path, url: path});
|
|
548
541
|
|
|
549
542
|
|
|
@@ -25,6 +25,7 @@ import Quaternion from "../../../core/geom/Quaternion.js";
|
|
|
25
25
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
26
26
|
import { max2 } from "../../../core/math/max2.js";
|
|
27
27
|
import { min2 } from "../../../core/math/min2.js";
|
|
28
|
+
import { RAD_TO_DEG } from "../../../core/math/RAD_TO_DEG.js";
|
|
28
29
|
import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
|
|
29
30
|
import { seededRandom } from "../../../core/math/random/seededRandom.js";
|
|
30
31
|
import { number_pretty_print } from "../../../core/primitives/numbers/number_pretty_print.js";
|
|
@@ -39,6 +40,7 @@ import { TransformAttachmentSystem } from "../../ecs/transform-attachment/Transf
|
|
|
39
40
|
import { Transform } from "../../ecs/transform/Transform.js";
|
|
40
41
|
import { EngineHarness } from "../../EngineHarness.js";
|
|
41
42
|
import { Camera } from "../ecs/camera/Camera.js";
|
|
43
|
+
import { focal_length_to_fov } from "../ecs/camera/focal_length_to_fov.js";
|
|
42
44
|
import TopDownCameraController from "../ecs/camera/topdown/TopDownCameraController.js";
|
|
43
45
|
import { Light } from "../ecs/light/Light.js";
|
|
44
46
|
import LightSystem from "../ecs/light/LightSystem.js";
|
|
@@ -337,6 +339,7 @@ async function main(engine) {
|
|
|
337
339
|
pitch: 1,
|
|
338
340
|
yaw: -1.54,
|
|
339
341
|
distance: 54,
|
|
342
|
+
cameraFieldOfView: focal_length_to_fov(50, 25) * RAD_TO_DEG,
|
|
340
343
|
// shadowmapResolution: 4096
|
|
341
344
|
});
|
|
342
345
|
|
|
@@ -381,8 +384,12 @@ async function main(engine) {
|
|
|
381
384
|
// const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
|
|
382
385
|
// const path = 'data/models/sibenik/3-window-less/model.gltf';
|
|
383
386
|
// const path = 'data/models/samples/gi_box_01/model.glb';
|
|
384
|
-
const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
385
|
-
|
|
387
|
+
// const path = 'data/models/sponza-pbr/gltf/sponza.glb';
|
|
388
|
+
const path = 'data/models/pica_pica/pica_pica.gltf';
|
|
389
|
+
// const path = 'data/models/samples/susanne.glb';
|
|
390
|
+
// const path = 'data/models/samples/teapot.gltf';
|
|
391
|
+
// const path = 'data/models/samples/salle_de_bain/model.glb';
|
|
392
|
+
// const path = 'data/models/samples/conference/model-no-curtains.glb';
|
|
386
393
|
|
|
387
394
|
const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
|
|
388
395
|
const gltf = mesh_asset.gltf;
|
|
@@ -442,9 +449,9 @@ async function main(engine) {
|
|
|
442
449
|
|
|
443
450
|
|
|
444
451
|
const camera = ecd.getAnyComponent(Camera);
|
|
445
|
-
camera.component.clip_far = max2(100, model_footprint);
|
|
452
|
+
camera.component.clip_far = max2(100, model_footprint * 3);
|
|
446
453
|
const camera_controller = ecd.getComponent(camera.entity, TopDownCameraController);
|
|
447
|
-
camera_controller.distanceMax = model_footprint *
|
|
454
|
+
camera_controller.distanceMax = model_footprint * 2;
|
|
448
455
|
camera_controller.distanceMin = min2(camera_controller.distanceMin, model_footprint * 0.01);
|
|
449
456
|
mesh_bounds.getCenter(camera_controller.target)
|
|
450
457
|
|