@woosh/meep-engine 2.108.2 → 2.108.3

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.
Files changed (120) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +472 -181
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +472 -181
  5. package/package.json +1 -1
  6. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +6 -0
  7. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  8. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +15 -3
  9. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +3 -3
  10. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  11. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +25 -14
  12. package/src/core/collection/array/arrayQuickSort.d.ts +0 -9
  13. package/src/core/collection/array/arrayQuickSort.d.ts.map +1 -1
  14. package/src/core/collection/array/arrayQuickSort.js +0 -73
  15. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts +10 -0
  16. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts.map +1 -0
  17. package/src/core/collection/array/array_quick_sort_by_comparator.js +75 -0
  18. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +8 -0
  19. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +1 -0
  20. package/src/core/collection/array/array_quick_sort_by_lookup.js +78 -0
  21. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +15 -0
  22. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -0
  23. package/src/core/geom/2d/triangle2d_get_barycentric.js +48 -0
  24. package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
  25. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +2 -7
  26. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts +11 -0
  27. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts.map +1 -0
  28. package/src/core/geom/3d/aabb3_compute_from_triangle.js +43 -0
  29. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +5 -5
  30. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts +9 -0
  31. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts.map +1 -0
  32. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +17 -0
  33. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +6 -3
  34. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  35. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +56 -18
  36. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts +1 -1
  37. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts.map +1 -1
  38. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.js +11 -4
  39. package/src/core/geom/3d/tetrahedra/{GetDepthForTetrahedronProbe.glsl → triangle/GetDepthForTetrahedronProbe.glsl} +17 -10
  40. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts +2 -0
  41. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts.map +1 -0
  42. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +128 -0
  43. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts +13 -0
  44. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -0
  45. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +120 -0
  46. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +3 -0
  47. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -0
  48. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +106 -0
  49. package/src/core/math/factorial.d.ts +7 -0
  50. package/src/core/math/factorial.d.ts.map +1 -0
  51. package/src/core/math/factorial.js +15 -0
  52. package/src/core/math/factorial.spec.d.ts +2 -0
  53. package/src/core/math/factorial.spec.d.ts.map +1 -0
  54. package/src/core/math/factorial.spec.js +9 -0
  55. package/src/core/model/DebouncedObservedBoolean.d.ts +1 -1
  56. package/src/core/model/DebouncedObservedBoolean.d.ts.map +1 -1
  57. package/src/core/model/node-graph/node/NodeDescription.d.ts +6 -4
  58. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  59. package/src/engine/asset/loaders/material/computeTextureEquality.js +8 -1
  60. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts.map +1 -1
  61. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +3 -1
  62. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts +8 -0
  63. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts.map +1 -0
  64. package/src/engine/graphics/filter/{FlipArrayInPlace.js → sampler2d_flipY_in_place.js} +1 -1
  65. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.d.ts.map +1 -1
  66. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +5 -27
  67. package/src/engine/graphics/render/Lines.d.ts.map +1 -1
  68. package/src/engine/graphics/render/Lines.js +10 -2
  69. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +24 -0
  70. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -0
  71. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +293 -0
  72. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts +6 -0
  73. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +1 -0
  74. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +71 -0
  75. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts +6 -0
  76. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +1 -0
  77. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +256 -0
  78. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +4 -4
  79. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +3 -1
  80. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  81. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +12 -1
  82. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +2 -1
  83. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  84. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +6 -6
  85. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +8 -0
  86. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  87. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +3 -2
  88. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  89. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +9 -4
  90. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +3 -3
  91. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  92. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
  93. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts +2 -2
  94. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +1 -1
  95. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +18 -8
  96. package/src/engine/graphics/sh3/prototypeSH3Probe.js +51 -22
  97. package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
  98. package/src/engine/graphics/texture/AttributeDataTexture.js +8 -2
  99. package/src/engine/graphics/texture/computeThreeTextureFormat.js +2 -1
  100. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts +7 -0
  101. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts.map +1 -0
  102. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.js +13 -0
  103. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts +9 -0
  104. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts.map +1 -0
  105. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.js +31 -0
  106. package/src/engine/graphics/texture/sampler/Sampler2D.js +2 -2
  107. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
  108. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +47 -19
  109. package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.js +5 -33
  110. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts +11 -0
  111. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts.map +1 -0
  112. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.js +41 -0
  113. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts +0 -4
  114. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts.map +1 -1
  115. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.js +19 -30
  116. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts +0 -8
  117. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts.map +0 -1
  118. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +0 -3
  119. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +0 -1
  120. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +0 -3
@@ -0,0 +1,256 @@
1
+ import { insert_after } from "../../../../../core/primitives/strings/insert_after.js";
2
+
3
+ const PREAMBLE = `
4
+ #ifndef LPV_SHADER_CHUNK_PREAMBLE
5
+ #define LPV_SHADER_CHUNK_PREAMBLE
6
+
7
+ precision highp usampler2D;
8
+ precision highp usampler3D;
9
+
10
+ uniform usampler2D lpv_t_mesh_vertices;
11
+ uniform usampler2D lpv_t_mesh_neighbours;
12
+ uniform usampler3D lpv_t_mesh_lookup;
13
+
14
+ uniform sampler2D lpv_t_probe_positions;
15
+ uniform sampler2D lpv_t_probe_data;
16
+
17
+ uniform uint lpv_u_mesh_tet_count;
18
+ uniform vec3 lpv_v3_bounds_min;
19
+ uniform vec3 lpv_v3_bounds_max;
20
+
21
+ varying vec3[9] lpv_values;
22
+
23
+ #define SEARCH_STEP_LIMIT 64u
24
+ #define INVALID_TET 1073741823u
25
+
26
+ ivec2 lpv_index_to_256_coordinate(uint index){
27
+
28
+ uint pixel_x = index % 256u;
29
+ uint pixel_y = index / 256u;
30
+
31
+ return ivec2(int(pixel_x), int(pixel_y));
32
+ }
33
+
34
+ uvec4 lpv_mesh_getVertices(uint tet_index){
35
+ ivec2 p = lpv_index_to_256_coordinate(tet_index);
36
+
37
+ return texelFetch(lpv_t_mesh_vertices, p, 0);
38
+
39
+ }
40
+
41
+ uvec4 lpv_mesh_getNeighbours(uint tet_index){
42
+ ivec2 p = lpv_index_to_256_coordinate(tet_index);
43
+
44
+ return texelFetch(lpv_t_mesh_neighbours, p, 0);
45
+ }
46
+
47
+ vec3[9] lpv_probe_getData(uint probe_index){
48
+
49
+
50
+ int slot = int( probe_index % 256u );
51
+ int column = int(probe_index / 256u);
52
+
53
+ int offset_x = int(slot * 9);
54
+
55
+ vec3[9] result;
56
+
57
+ for(int i=0; i<9; i++){
58
+ result[i] = texelFetch(lpv_t_probe_data, ivec2(offset_x + i, column),0).rgb;
59
+ }
60
+
61
+ return result;
62
+ }
63
+
64
+ vec3 lpv_probe_getPosition(uint probe_index){
65
+ return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;
66
+ }
67
+
68
+ mat3 lpv_mesh_makeMatrix(vec3 p0, vec3 p1, vec3 p2, vec3 p3){
69
+
70
+ return inverse(
71
+ mat3(
72
+ p0 - p3,
73
+ p1 - p3,
74
+ p2 - p3
75
+ )
76
+ );
77
+
78
+ }
79
+
80
+ vec4 lpv_mesh_getBarycentricCoordinates(uint tet_index, vec3 position){
81
+ uvec4 vertices = lpv_mesh_getVertices(tet_index);
82
+
83
+ vec3 p0 = lpv_probe_getPosition(vertices[0]);
84
+ vec3 p1 = lpv_probe_getPosition(vertices[1]);
85
+ vec3 p2 = lpv_probe_getPosition(vertices[2]);
86
+ vec3 p3 = lpv_probe_getPosition(vertices[3]);
87
+
88
+ mat3 matrix = lpv_mesh_makeMatrix(p0, p1, p2, p3);
89
+
90
+ vec3 mult = matrix * (position - p3);
91
+
92
+ return vec4(mult, 1.0 - mult.x - mult.y - mult.z);
93
+ }
94
+
95
+ void lpv_getTetrahedron(
96
+ in vec3 position ,
97
+ in uint tet_guess,
98
+ out uint tet_index,
99
+ out vec4 weights
100
+ ){
101
+ uint came_from = 0u;
102
+
103
+ tet_index = tet_guess;
104
+
105
+ for(uint i=0u; i < SEARCH_STEP_LIMIT; i++){
106
+
107
+ weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);
108
+
109
+ if(weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0){
110
+ return;
111
+ }
112
+
113
+ uvec4 neighbors = lpv_mesh_getNeighbours(tet_index);
114
+
115
+ uint next_tet;
116
+
117
+ // Otherwise find the smallest barycentric coord and move in that direction
118
+ if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) {
119
+ next_tet = neighbors[0];
120
+ } else if (weights.y < weights.z && weights.y < weights.w) {
121
+ next_tet = neighbors[1];
122
+ } else if (weights.z < weights.w) {
123
+ next_tet = neighbors[2];
124
+ } else {
125
+ next_tet = neighbors[3];
126
+ }
127
+
128
+ if(next_tet == came_from){
129
+ // numerical instability caused us to oscillate on the boundary
130
+ return;
131
+ }
132
+
133
+ came_from = tet_index;
134
+ tet_index = next_tet;
135
+ }
136
+
137
+ tet_index = INVALID_TET;
138
+ }
139
+
140
+ vec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index){
141
+
142
+ uvec4 vertices = lpv_mesh_getVertices(tet_index);
143
+
144
+ vec3[9] probe0 = lpv_probe_getData(vertices[0]);
145
+ vec3[9] probe1 = lpv_probe_getData(vertices[1]);
146
+ vec3[9] probe2 = lpv_probe_getData(vertices[2]);
147
+ vec3[9] probe3 = lpv_probe_getData(vertices[3]);
148
+
149
+ vec3[9] result;
150
+
151
+ for(int i=0; i< 9; i++){
152
+
153
+ result[i] = probe0[i]* weights[0]
154
+ + probe1[i]* weights[1]
155
+ + probe2[i]* weights[2]
156
+ + probe3[i]* weights[3];
157
+
158
+ }
159
+
160
+ return result;
161
+ }
162
+
163
+ vec4 lpv_bias_weight_by_normal(const in vec3 position, const in vec3 normal, const in uint tet_index, const in vec4 weights){
164
+
165
+ uvec4 vertices = lpv_mesh_getVertices(tet_index);
166
+
167
+ vec4 result = weights;
168
+
169
+ for(int i = 0; i< 4; i++){
170
+ vec3 p = lpv_probe_getPosition(vertices[i]) - position;
171
+
172
+ if(dot(normal, p) <= 0.0){
173
+ // behind the surface, bias to 0
174
+ result[i] = 0.0;
175
+ }
176
+ }
177
+
178
+ float total_weight = result.x + result.y + result.z + result.w;
179
+
180
+ // needs to add up to 1
181
+ result = result / total_weight;
182
+
183
+ return result;
184
+ }
185
+
186
+ uint lpv_guess_initial_tet(vec3 position){
187
+
188
+ vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
189
+ vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
190
+
191
+ vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min) ;
192
+
193
+ return textureLod( lpv_t_mesh_lookup, lookup_coordinates, 0.0 ).r;
194
+
195
+ }
196
+
197
+ #endif
198
+ `;
199
+
200
+
201
+ const SHADER_CHUNK_ACCUMULATION = `
202
+ {
203
+ // lookup nearby tet
204
+ vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
205
+ vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
206
+ vec3 lookup_coordinates = (worldPosition.xyz - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min) ;
207
+
208
+ uint nearest_tet = lpv_guess_initial_tet( worldPosition.xyz );
209
+
210
+ uint tet;
211
+ vec4 weights;
212
+ lpv_getTetrahedron(worldPosition.xyz, nearest_tet, tet, weights);
213
+
214
+
215
+ if(tet == INVALID_TET){
216
+ lpv_values = vec3[](
217
+ vec3(0.0, 0.0, 0.0),
218
+ vec3(0.0, 0.0, 0.0),
219
+ vec3(0.0, 0.0, 0.0),
220
+
221
+ vec3(0.0, 0.0, 0.0),
222
+ vec3(0.0, 0.0, 0.0),
223
+ vec3(0.0, 0.0, 0.0),
224
+
225
+ vec3(0.0, 0.0, 0.0),
226
+ vec3(0.0, 0.0, 0.0),
227
+ vec3(0.0, 0.0, 0.0)
228
+ );
229
+ }else{
230
+
231
+ vec3 worldNormal = normalize(inverseTransformDirection( normalize(normal), viewMatrix ));
232
+
233
+ //weights = lpv_bias_weight_by_normal(worldPosition.xyz, normal, tet, weights);
234
+
235
+ lpv_values = lpv_interpolate_probes(weights, tet);
236
+ }
237
+ }
238
+ `
239
+
240
+ /**
241
+ *
242
+ * @param {string} source
243
+ */
244
+ export function build_vertex_shader(source) {
245
+ let result = PREAMBLE + source;
246
+
247
+ result = insert_after(
248
+ result,
249
+ '#include <fog_vertex>',
250
+ SHADER_CHUNK_ACCUMULATION
251
+ );
252
+
253
+ // console.log(result)
254
+
255
+ return result;
256
+ }
@@ -31,9 +31,6 @@ export function tetrahedral_mesh_to_texture(
31
31
  vertices.resize(tetrahedron_count);
32
32
  neighbours.resize(tetrahedron_count);
33
33
 
34
- vertices.build()
35
- neighbours.build();
36
-
37
34
  const vertices_data = vertices.data;
38
35
  const neighbours_data = neighbours.data;
39
36
 
@@ -44,8 +41,11 @@ export function tetrahedral_mesh_to_texture(
44
41
  for (let j = 0; j < 4; j++) {
45
42
  vertices_data[i4 + j] = mesh.getVertexIndex(i, j);
46
43
 
47
- neighbours_data[i4 + j] = mesh.getNeighbour(i, j);
44
+ neighbours_data[i4 + j] = mesh.getNeighbour(i, j) >>> 2;
48
45
  }
49
46
 
50
47
  }
48
+
49
+ vertices.texture.needsUpdate = true;
50
+ neighbours.texture.needsUpdate = true;
51
51
  }
@@ -1,4 +1,5 @@
1
1
  export class LightProbeVolume {
2
+ get version(): number;
2
3
  __positions: any[];
3
4
  __mesh: TetrahedralMesh;
4
5
  __probe_data: any[];
@@ -53,10 +54,11 @@ export class LightProbeVolume {
53
54
  visualize_mesh({ ecd, color, opacity }: EntityComponentDataset): void;
54
55
  /**
55
56
  *
56
- * @returns {TaskGroup}
57
57
  * @param {EntityComponentDataset} ecd
58
+ * @returns {TaskGroup}
58
59
  */
59
60
  build(ecd: EntityComponentDataset): TaskGroup;
61
+ #private;
60
62
  }
61
63
  import { TetrahedralMesh } from "../../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
62
64
  import TaskGroup from "../../../../core/process/task/TaskGroup.js";
@@ -1 +1 @@
1
- {"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAiJA;IAEQ,mBAAqB;IAErB,wBAAmC;IAEnC,oBAAsB;IAEtB,iBAAiB;IAGrB,cAMC;IAED;;;OAGG;IACH,4BAEC;IAED,oBAEC;IAED,uBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAIhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;OAIG;IACH,mCAHa,SAAS,CA4CrB;IAED;;;;;OAKG;IACH,sEAWC;IAED;;;;;OAKG;IACH,sEAkBC;IAED;;;;OAIG;IACH,oCAHa,SAAS,CAMrB;CACJ;gCA1U+B,wDAAwD;sBAClE,4CAA4C"}
1
+ {"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAkJA;IAGI,sBAEC;IAGG,mBAAqB;IAErB,wBAAmC;IAEnC,oBAAsB;IAEtB,iBAAiB;IAGrB,cAQC;IAED;;;OAGG;IACH,4BAEC;IAED,oBAEC;IAED,uBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAIhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;OAIG;IACH,mCAHa,SAAS,CA8CrB;IAED;;;;;OAKG;IACH,sEAWC;IAED;;;;;OAKG;IACH,sEAkBC;IAED;;;;OAIG;IACH,oCAFa,SAAS,CAKrB;;CACJ;gCArV+B,wDAAwD;sBAClE,4CAA4C"}
@@ -42,6 +42,7 @@ class Baker {
42
42
  this.__min_bounce_count = 3;
43
43
  this.__max_bounce_count = 100;
44
44
 
45
+ // this._ren = new WebGLCubeProbeRenderer();
45
46
  this._ren = new PathTracerProbeRenderer();
46
47
  }
47
48
 
@@ -144,6 +145,12 @@ class Baker {
144
145
  }
145
146
 
146
147
  export class LightProbeVolume {
148
+ #version = 0;
149
+
150
+ get version() {
151
+ return this.#version;
152
+ }
153
+
147
154
  constructor() {
148
155
  this.__positions = [];
149
156
 
@@ -160,6 +167,8 @@ export class LightProbeVolume {
160
167
  this.__mesh.clear();
161
168
 
162
169
  this.__length = 0;
170
+
171
+ this.#version++;
163
172
  }
164
173
 
165
174
  /**
@@ -273,6 +282,8 @@ export class LightProbeVolume {
273
282
 
274
283
  const tFinish = actionTask(() => {
275
284
  baker.finish();
285
+
286
+ this.#version++;
276
287
  });
277
288
 
278
289
  tFinish.addDependency(tBake);
@@ -330,8 +341,8 @@ export class LightProbeVolume {
330
341
 
331
342
  /**
332
343
  *
333
- * @returns {TaskGroup}
334
344
  * @param {EntityComponentDataset} ecd
345
+ * @returns {TaskGroup}
335
346
  */
336
347
  build(ecd) {
337
348
  this.build_mesh();
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  *
3
+ * @param {LightProbeVolume} volume
3
4
  * @param {Engine} engine
4
5
  * @param {EntityComponentDataset} ecd
5
6
  * @param {AABB3} bounds
6
7
  * @param {number} [density]
7
8
  * @returns {Promise<LightProbeVolume>}
8
9
  */
9
- export function build_probes_for_scene({ engine, ecd, bounds, density }: Engine): Promise<LightProbeVolume>;
10
+ export function build_probes_for_scene({ volume, engine, ecd, bounds, density }: LightProbeVolume): Promise<LightProbeVolume>;
10
11
  import { LightProbeVolume } from "./LightProbeVolume.js";
11
12
  //# sourceMappingURL=build_probes_for_scene.d.ts.map
@@ -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":"AAUA;;;;;;;GAOG;AACH,kFAFa,QAAQ,gBAAgB,CAAC,CA8GrC;iCAtHgC,uBAAuB"}
1
+ {"version":3,"file":"build_probes_for_scene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/build_probes_for_scene.js"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,iFAPW,gBAAgB,GAKd,QAAQ,gBAAgB,CAAC,CA6GrC;iCAtHgC,uBAAuB"}
@@ -10,6 +10,7 @@ import { LightProbeVolume } from "./LightProbeVolume.js";
10
10
 
11
11
  /**
12
12
  *
13
+ * @param {LightProbeVolume} volume
13
14
  * @param {Engine} engine
14
15
  * @param {EntityComponentDataset} ecd
15
16
  * @param {AABB3} bounds
@@ -18,6 +19,7 @@ import { LightProbeVolume } from "./LightProbeVolume.js";
18
19
  */
19
20
  export async function build_probes_for_scene(
20
21
  {
22
+ volume = new LightProbeVolume(),
21
23
  engine,
22
24
  ecd,
23
25
  bounds,
@@ -25,8 +27,6 @@ export async function build_probes_for_scene(
25
27
  }
26
28
  ) {
27
29
 
28
- const lpv = new LightProbeVolume();
29
-
30
30
  // lpv.add_point(10, 5, 10);
31
31
 
32
32
  // const desired_density = 8000;
@@ -58,7 +58,7 @@ export async function build_probes_for_scene(
58
58
  // }
59
59
 
60
60
  make_justified_point_grid(model_bounds, probe_grid_spacing, (x, y, z) => {
61
- lpv.add_point(x, y, z);
61
+ volume.add_point(x, y, z);
62
62
  });
63
63
 
64
64
  // lpv.add_point(10, 1, -10);
@@ -68,7 +68,7 @@ export async function build_probes_for_scene(
68
68
  //
69
69
  // console.profile('lpv build');
70
70
  //
71
- const task = lpv.build(ecd);
71
+ const task = volume.build(ecd);
72
72
  // console.profileEnd('lpv build');
73
73
 
74
74
  const progress = makeSimpleTaskProgressView({
@@ -119,9 +119,9 @@ export async function build_probes_for_scene(
119
119
  // 0.2137442, -0.0547578, -0.3061700], 0);
120
120
 
121
121
 
122
- console.log(lpv);
122
+ console.log(volume);
123
123
 
124
124
  await task.promise();
125
125
 
126
- return lpv;
126
+ return volume;
127
127
  }
@@ -8,5 +8,13 @@ export function probe_volume_to_textures(lpv: LightProbeVolume): {
8
8
  probe_positions: AttributeDataTexture;
9
9
  probe_values: AttributeDataTexture;
10
10
  };
11
+ /**
12
+ *
13
+ * @param {AttributeDataTexture} target
14
+ * @param {number[]} points
15
+ * @param {number} point_count
16
+ * @param {number} dimensions
17
+ */
18
+ export function vector_buffer_to_attribute_texture(target: AttributeDataTexture, points: number[], point_count: number, dimensions?: number): void;
11
19
  import { AttributeDataTexture } from "../../texture/AttributeDataTexture.js";
12
20
  //# sourceMappingURL=probe_volume_to_textures.d.ts.map
@@ -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":"AAMA;;;GAGG;AACH;;;;;EAuDC;qCA9DoC,uCAAuC"}
1
+ {"version":3,"file":"probe_volume_to_textures.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/probe_volume_to_textures.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;;;;;EAuDC;AAED;;;;;;GAMG;AACH,2DALW,oBAAoB,UACpB,MAAM,EAAE,eACR,MAAM,eACN,MAAM,QAiBhB;qCAtFoC,uCAAuC"}
@@ -72,7 +72,7 @@ export function probe_volume_to_textures(lpv) {
72
72
  * @param {number} point_count
73
73
  * @param {number} dimensions
74
74
  */
75
- function vector_buffer_to_attribute_texture(
75
+ export function vector_buffer_to_attribute_texture(
76
76
  target,
77
77
  points,
78
78
  point_count,
@@ -83,7 +83,8 @@ function vector_buffer_to_attribute_texture(
83
83
  }
84
84
 
85
85
  target.resize(point_count);
86
- target.build();
87
86
 
88
87
  array_copy(points, 0, target.data, 0, point_count * dimensions);
88
+
89
+ target.texture.needsUpdate = true;
89
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAsBA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAE1B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAElB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEX;IAEd;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,kBAAkB,CAAC,CAEjC;IAEtB;;;OAGG;IACH,UAFU,IAAI,MAAM,YAAY,CAEX;IAGrB;;;;OAIG;IACH,6BAA6C;IAE7C,iBAGC;IAED,uBAoCC;IAED;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,kBAAkB,CAgB7B;IAED;;;OAGG;IACH,gBAFW,aAAa,QAMvB;IAED;;;;;OAKG;IACH,aAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,OAAK,MAAM,EAAE,QA6CvB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,OACR,MAAM,EAAE,QAyBlB;IAED;;;;;;;OAOG;IACH,WANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACL,MAAM,CAwCjB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,EAAE,cACR,MAAM,aACN,MAAM,EAAE,oBACR,MAAM,QAIhB;IAED;;;;;;;OAOG;IACH,mBANW,MAAM,EAAE,cACR,MAAM,OACN,MAAM,EAAE,eACR,MAAM,GACJ,OAAO,CAmEnB;CACJ;oBA9VmB,mCAAmC;+BAaxB,qBAAqB;8BALtB,kDAAkD;mCAG7C,yBAAyB"}
1
+ {"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAuBA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAE1B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAElB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEX;IAEd;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,kBAAkB,CAAC,CAEjC;IAEtB;;;OAGG;IACH,UAFU,IAAI,MAAM,YAAY,CAEX;IAGrB;;;;OAIG;IACH,6BAA6C;IAE7C,iBAGC;IAED,uBAqCC;IAED;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,kBAAkB,CAmB7B;IAED;;;OAGG;IACH,gBAFW,aAAa,QAMvB;IAED;;;;;OAKG;IACH,aAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,OAAK,MAAM,EAAE,QA6CvB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,OACR,MAAM,EAAE,QAyBlB;IAED;;;;;;;OAOG;IACH,WANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACL,MAAM,CAwCjB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,EAAE,cACR,MAAM,aACN,MAAM,EAAE,oBACR,MAAM,QAIhB;IAED;;;;;;;OAOG;IACH,mBANW,MAAM,EAAE,cACR,MAAM,OACN,MAAM,EAAE,eACR,MAAM,GACJ,OAAO,CAmEnB;CACJ;oBAnWmB,mCAAmC;+BAcxB,qBAAqB;8BALtB,kDAAkD;mCAG7C,yBAAyB"}
@@ -7,6 +7,7 @@ import { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matri
7
7
  import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
8
8
  import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
9
9
  import { TextureAttachmentsByMaterialType } from "../../../asset/loaders/material/TextureAttachmensByMaterialType.js";
10
+ import { compute_geometry_polycount } from "../../geometry/compute_geometry_polycount.js";
10
11
  import { AbstractLight } from "../../render/forward_plus/model/AbstractLight.js";
11
12
  import { convertTexture2Sampler2D } from "../../texture/sampler/convertTexture2Sampler2D.js";
12
13
  import { ensureGeometryBoundingBox } from "../../util/ensureGeometryBoundingBox.js";
@@ -67,6 +68,7 @@ export class PathTracedScene {
67
68
  }
68
69
 
69
70
  async build() {
71
+
70
72
  for (const [id, mesh] of this.meshes) {
71
73
  const material = mesh.material;
72
74
 
@@ -116,13 +118,16 @@ export class PathTracedScene {
116
118
  return cached;
117
119
  }
118
120
 
119
- const bvh8 = new GeometryBVHBatched();
121
+ const bvh = new GeometryBVHBatched();
120
122
 
121
- bvh8.build(geo);
123
+ const label = `bvh build ${compute_geometry_polycount(geo)}`;
124
+ console.time(label);
125
+ bvh.build(geo);
126
+ console.timeEnd(label);
122
127
 
123
- this.geo_cache.set(geo, bvh8);
128
+ this.geo_cache.set(geo, bvh);
124
129
 
125
- return bvh8;
130
+ return bvh;
126
131
  }
127
132
 
128
133
  /**
@@ -1,14 +1,14 @@
1
1
  export class PathTracer {
2
2
  /**
3
3
  *
4
- * @param {number[]} out
5
- * @param {number[]} ray
4
+ * @param {number[]|Float32Array} out
5
+ * @param {number[]|Float32Array} ray
6
6
  * @param {number} max_distance
7
7
  * @param {number} min_bounce
8
8
  * @param {number} max_bounce
9
9
  * @param {function} random
10
10
  * @param {PathTracedScene} scene
11
11
  */
12
- path_trace(out: number[], ray: number[], max_distance: number, min_bounce: number, max_bounce: number, random: Function, scene: PathTracedScene): void;
12
+ path_trace(out: number[] | Float32Array, ray: number[] | Float32Array, max_distance: number, min_bounce: number, max_bounce: number, random: Function, scene: PathTracedScene): void;
13
13
  }
14
14
  //# sourceMappingURL=PathTracer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PathTracer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracer.js"],"names":[],"mappings":"AA2BA;IAGI;;;;;;;;;OASG;IACH,gBARW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,cACN,MAAM,cACN,MAAM,kDAgFhB;CACJ"}
1
+ {"version":3,"file":"PathTracer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracer.js"],"names":[],"mappings":"AA2BA;IAGI;;;;;;;;;OASG;IACH,gBARW,MAAM,EAAE,GAAC,YAAY,OACrB,MAAM,EAAE,GAAC,YAAY,gBACrB,MAAM,cACN,MAAM,cACN,MAAM,kDAgFhB;CACJ"}
@@ -30,8 +30,8 @@ export class PathTracer {
30
30
 
31
31
  /**
32
32
  *
33
- * @param {number[]} out
34
- * @param {number[]} ray
33
+ * @param {number[]|Float32Array} out
34
+ * @param {number[]|Float32Array} ray
35
35
  * @param {number} max_distance
36
36
  * @param {number} min_bounce
37
37
  * @param {number} max_bounce
@@ -6,7 +6,7 @@
6
6
  * @param {number[]|ArrayLike<number>} positions
7
7
  * @param {number} index_offset
8
8
  * @param {number} index_count
9
- * @param {number} d
9
+ * @param {number} dimension_count
10
10
  */
11
- export function compute_triangle_group_aabb3(output: number[] | Float32Array, output_offset: number, indices: number[] | ArrayLike<number>, positions: number[] | ArrayLike<number>, index_offset: number, index_count: number, d: number): void;
11
+ export function compute_triangle_group_aabb3(output: number[] | Float32Array, output_offset: number, indices: number[] | ArrayLike<number>, positions: number[] | ArrayLike<number>, index_offset: number, index_count: number, dimension_count: number): void;
12
12
  //# sourceMappingURL=compute_triangle_group_aabb3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compute_triangle_group_aabb3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,qDARW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,WACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,aAC1B,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,eACN,MAAM,KACN,MAAM,QAwBhB"}
1
+ {"version":3,"file":"compute_triangle_group_aabb3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,qDARW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,WACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,aAC1B,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,eACN,MAAM,mBACN,MAAM,QAkChB"}
@@ -1,5 +1,5 @@
1
- import { min2 } from "../../../../core/math/min2.js";
2
1
  import { max2 } from "../../../../core/math/max2.js";
2
+ import { min2 } from "../../../../core/math/min2.js";
3
3
 
4
4
  /**
5
5
  * Compute AABB for a group of triangles based on index-buffer
@@ -9,27 +9,37 @@ import { max2 } from "../../../../core/math/max2.js";
9
9
  * @param {number[]|ArrayLike<number>} positions
10
10
  * @param {number} index_offset
11
11
  * @param {number} index_count
12
- * @param {number} d
12
+ * @param {number} dimension_count
13
13
  */
14
- export function compute_triangle_group_aabb3(output, output_offset, indices, positions, index_offset, index_count, d) {
14
+ export function compute_triangle_group_aabb3(
15
+ output,
16
+ output_offset,
17
+ indices,
18
+ positions,
19
+ index_offset,
20
+ index_count,
21
+ dimension_count
22
+ ) {
15
23
 
16
24
  let i = 0;
17
- for (; i < d; i++) {
25
+ for (; i < dimension_count; i++) {
26
+ // min bound
18
27
  output[output_offset + i] = Infinity;
19
- output[output_offset + i + d] = -Infinity;
28
+ // max bound
29
+ output[output_offset + i + dimension_count] = -Infinity;
20
30
  }
21
31
 
22
32
  for (i = 0; i < index_count; i++) {
23
33
  for (let j = 0; j < 3; j++) {
24
34
  const index = indices[index_offset + i * 3 + j];
25
35
 
26
- const i3 = index * d;
36
+ const i3 = index * dimension_count;
27
37
 
28
- for (let k = 0; k < d; k++) {
38
+ for (let k = 0; k < dimension_count; k++) {
29
39
  const v = positions[i3 + k];
30
40
 
31
41
  output[output_offset + k] = min2(output[output_offset + k], v);
32
- output[output_offset + k + d] = max2(output[output_offset + k + d], v);
42
+ output[output_offset + k + dimension_count] = max2(output[output_offset + k + dimension_count], v);
33
43
  }
34
44
  }
35
45
  }