@woosh/meep-engine 2.109.6 → 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.
Files changed (180) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +203 -174
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +203 -174
  5. package/editor/tools/v2/TransformControls.js +39 -33
  6. package/package.json +1 -1
  7. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  8. package/src/core/bvh2/bvh3/BVH.js +8 -0
  9. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  10. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +11 -9
  11. package/src/core/geom/3d/Ray3.js +1 -1
  12. package/src/core/geom/3d/aabb/AABB3.js +1 -1
  13. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
  14. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  15. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
  16. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
  17. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
  18. package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
  19. package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
  20. package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
  21. package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
  22. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
  23. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
  24. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +3 -3
  25. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  26. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +10 -5
  27. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
  28. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
  29. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
  30. package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
  31. package/src/core/geom/vec3/v3_distance.js +5 -5
  32. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
  33. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
  34. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
  35. package/src/core/model/node-graph/DataType.d.ts.map +1 -1
  36. package/src/core/model/node-graph/DataType.js +16 -10
  37. package/src/core/model/node-graph/ParametricDataType.d.ts +34 -0
  38. package/src/core/model/node-graph/ParametricDataType.d.ts.map +1 -0
  39. package/src/core/model/node-graph/ParametricDataType.js +63 -0
  40. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
  41. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
  42. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
  43. package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
  44. package/src/engine/asset/loaders/AssetLoader.js +1 -1
  45. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  46. package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
  47. package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
  48. package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
  49. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
  50. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
  51. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
  52. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
  53. package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
  54. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  55. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
  56. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
  57. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
  58. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
  59. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
  60. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
  61. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
  62. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
  63. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
  64. package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
  65. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  66. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +59 -37
  67. package/src/engine/graphics/sh3/gi/material/common.glsl +484 -0
  68. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
  69. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
  70. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
  71. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
  72. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
  73. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
  74. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
  75. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +51 -0
  76. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
  77. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
  78. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
  79. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
  80. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
  81. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
  82. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
  83. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
  84. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
  85. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
  86. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
  87. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
  88. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
  89. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
  90. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
  91. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
  92. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
  93. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  94. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
  95. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
  96. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +26 -9
  97. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +11 -1
  98. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  99. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -61
  100. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  101. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +8 -6
  102. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
  103. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
  104. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
  105. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
  106. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
  107. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
  108. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
  109. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
  110. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
  111. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
  112. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
  113. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
  114. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
  115. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +149 -0
  116. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +161 -0
  117. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
  118. package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
  119. package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
  120. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts +8 -0
  121. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts.map +1 -0
  122. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +50 -0
  123. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
  124. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  125. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
  126. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
  127. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
  128. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
  129. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  130. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
  131. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
  132. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
  133. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
  134. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
  135. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  136. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
  137. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  138. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.js → sorting/build_bvh_nodes_distances_sqr_to_point.js} +2 -2
  139. package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  140. package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.js → sorting/sort_bvh_nodes_by_distance_to_point.js} +3 -3
  141. package/src/engine/graphics/sh3/prototypeSH3Probe.js +41 -8
  142. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
  143. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
  144. package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
  145. package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
  146. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
  147. package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
  148. package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
  149. package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
  150. package/src/view/View.d.ts.map +1 -1
  151. package/src/view/View.js +2 -0
  152. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
  153. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
  154. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
  155. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
  156. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
  157. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
  158. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
  159. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
  160. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
  161. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
  162. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
  163. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
  164. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
  165. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
  166. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
  167. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
  168. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
  169. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
  170. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
  171. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
  172. package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
  173. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
  174. /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
  175. /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
  176. /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
  177. /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.d.ts → sorting/build_bvh_nodes_distances_along_ray.d.ts} +0 -0
  178. /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.d.ts → sorting/build_bvh_nodes_distances_sqr_to_point.d.ts} +0 -0
  179. /package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.d.ts → sorting/sort_bvh_nodes_by_distance_to_point.d.ts} +0 -0
  180. /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
@@ -1,25 +1,38 @@
1
1
  //
2
2
 
3
- import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
3
+ import { assert } from "../../../../../core/assert.js";
4
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
5
+ import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
4
6
  import { convex_hull_jarvis_2d } from "../../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
5
7
  import { fixed_convex_hull_relaxation } from "../../../../../core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js";
6
- import { array_copy } from "../../../../../core/collection/array/array_copy.js";
7
- import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
8
8
  import { max2 } from "../../../../../core/math/max2.js";
9
- import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
9
+ import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
10
+ import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
10
11
  import {
11
12
  make_edge_condition_channel_threshold
12
13
  } from "../../../texture/sampler/search/make_edge_condition_channel_threshold.js";
13
- import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
14
+ import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
14
15
 
15
16
  /**
16
17
  * TODO For this specific use-case with octahedral impostors we can get away tracing a circular shape in general.
17
18
  * A circle is a lot easier to quantize (as long as we make sure we place edges outside of the circle)
18
19
  * @param {ImpostorDescription} impostor
19
20
  * @param {THREE.WebGLRenderer} renderer
20
- * @returns {number}
21
+ * @param {number} vertex_limit how many vertices to use for the billboard, more vertices will provide better fit and lower area reducing overdraw at the cost of extra triangles. Prefer values between 4 and 16
22
+ * @returns {number[]}
21
23
  */
22
- export function build_cutout_from_atlas_by_alpha(impostor, renderer) {
24
+ export function build_cutout_from_atlas_by_alpha({
25
+
26
+ impostor,
27
+ renderer,
28
+ vertex_limit = 8
29
+ }) {
30
+
31
+ assert.isNonNegativeInteger(vertex_limit, 'vertex_limit');
32
+ assert.greaterThanOrEqual(vertex_limit, 3);
33
+
34
+ assert.defined(renderer, 'renderer');
35
+
23
36
  // get impostor data first
24
37
 
25
38
  const ctrl = renderSamplerFromTexture({
@@ -98,23 +111,21 @@ export function build_cutout_from_atlas_by_alpha(impostor, renderer) {
98
111
  array_copy(filtered_edge_pixels, hpi * 2, hull_points, i * 2, 2);
99
112
  }
100
113
 
101
- const cutout_vertex_count = 8;
102
-
103
- const cutout_points = new Float32Array(cutout_vertex_count * 2);
114
+ const cutout_points = new Float32Array(vertex_limit * 2);
104
115
 
105
- fixed_convex_hull_relaxation(cutout_points, 0, cutout_vertex_count, hull_points, hull_point_indices.length);
116
+ fixed_convex_hull_relaxation(cutout_points, 0, vertex_limit, hull_points, hull_point_indices.length);
106
117
 
107
118
  // normalize points
108
- for (let i = 0; i < cutout_vertex_count; i++) {
119
+ for (let i = 0; i < vertex_limit; i++) {
109
120
  cutout_points[i * 2] /= frame_size;
110
121
  cutout_points[i * 2 + 1] /= frame_size;
111
122
  }
112
123
 
113
- const area = compute_polygon_area_2d(cutout_points, cutout_vertex_count);
124
+ const area = compute_polygon_area_2d(cutout_points, vertex_limit);
114
125
 
115
126
  console.log(`Cutout area: ${area}`);
116
127
 
117
- if (area >= 0.99 && cutout_vertex_count >= 4) {
128
+ if (area >= 0.99 && vertex_limit >= 4) {
118
129
  // default back to aligned quad, produced result is a degradation
119
130
  return new Float32Array([
120
131
  0, 0,
@@ -287,3 +287,4 @@ export function buildCanvasViewFromTexture({
287
287
  }
288
288
  }
289
289
  }
290
+
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialTransformer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/MaterialTransformer.js"],"names":[],"mappings":"AA0CA;IAoHI;;;OAGG;IACH,0CAMC;IAlBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAsBD,sBAIC;IAED,sBA2CC;IAED,eAuCC;IAED,4BA2BC;;CACJ;4CA5R2C,0DAA0D"}
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"}
@@ -1,4 +1,4 @@
1
- import { DataTexture3D, NearestFilter, RedIntegerFormat, UnsignedIntType, Vector3 } from "three";
1
+ import { Vector3 } from "three";
2
2
  import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
3
3
  import { AABB3 } from "../../../../../core/geom/3d/aabb/AABB3.js";
4
4
  import { aabb3_from_v3_array } from "../../../../../core/geom/3d/aabb/aabb3_from_v3_array.js";
@@ -7,38 +7,29 @@ import { composeCompile } from "../../../material/composeCompile.js";
7
7
  import { AbstractMaterialTransformer } from "../../../material/manager/AbstractMaterialTransformer.js";
8
8
  import { isLitMaterial } from "../../../render/forward_plus/plugin/isLitMaterial.js";
9
9
  import { AttributeDataTexture } from "../../../texture/AttributeDataTexture.js";
10
- import { vector_buffer_to_attribute_texture } from "../../lpv/probe_volume_to_textures.js";
10
+ import { octahedral_depth_to_atlas, vector_buffer_to_attribute_texture } from "../../lpv/probe_volume_to_textures.js";
11
11
  import { tetrahedral_mesh_to_texture } from "../tetrahedral_mesh_to_texture.js";
12
- import { build_fragment_shader } from "./build_fragment_shader.js";
13
- import { build_vertex_shader } from "./build_vertex_shader.js";
12
+ import { makeLookupTexture3D } from "./makeLookupTexture3D.js";
13
+ import { makeOctahedralDepthAtlas } from "./makeOctahedralDepthAtlas.js";
14
+ import { space_fragment_transform_shader } from "./space_fragment/space_fragment_transform_shader.js";
15
+ import { space_vertex_transform_shader } from "./space_vertex/space_vertex_transform_shader.js";
14
16
 
15
17
  const PROPERTY_TRANSFORMER_MARKER = '@light-probe-volume-material-transformer';
16
18
 
17
-
18
- function createLookupTexture(resolution) {
19
-
20
- const lookup = new DataTexture3D(
21
- new Uint32Array(resolution * resolution * resolution),
22
- resolution,
23
- resolution,
24
- resolution
25
- );
26
-
27
- lookup.name = "Tetrahedron Lookup";
28
-
29
- lookup.flipY = false;
30
- lookup.generateMipmaps = false;
31
- lookup.magFilter = NearestFilter;
32
- lookup.minFilter = NearestFilter;
33
-
34
- lookup.type = UnsignedIntType;
35
- lookup.format = RedIntegerFormat;
36
- lookup.internalFormat = "R32UI";
37
-
38
- lookup.needsUpdate = true;
39
-
40
- return lookup;
41
- }
19
+ /**
20
+ * Where should probes be resolved?
21
+ * @enum {number}
22
+ */
23
+ const ProbeResolutionSpace = {
24
+ /**
25
+ * Cheaper, but less precise
26
+ */
27
+ Vertex: 0,
28
+ /**
29
+ * More expensive, necessary for large geometries with few vertices
30
+ */
31
+ Fragment: 1
32
+ };
42
33
 
43
34
  export class MaterialTransformer extends AbstractMaterialTransformer {
44
35
 
@@ -48,9 +39,15 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
48
39
  */
49
40
  #volume = null;
50
41
 
51
- #mesh_lookup = createLookupTexture(32);
42
+ #mesh_lookup = makeLookupTexture3D(32);
52
43
  #mesh_bounds = new AABB3();
53
44
 
45
+ /**
46
+ *
47
+ * @type {ProbeResolutionSpace|number}
48
+ */
49
+ #space = ProbeResolutionSpace.Fragment
50
+
54
51
  #textures = {
55
52
  vertex: new AttributeDataTexture(
56
53
  AttributeSpec.fromJSON({
@@ -87,7 +84,8 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
87
84
  normalized: false
88
85
  }),
89
86
  256, 9
90
- )
87
+ ),
88
+ depth: makeOctahedralDepthAtlas()
91
89
  };
92
90
 
93
91
  #uniforms = {
@@ -107,6 +105,13 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
107
105
  type: "t",
108
106
  value: this.#textures.harmonics.texture
109
107
  },
108
+ lpv_t_probe_depth: {
109
+ type: "t",
110
+ value: this.#textures.depth
111
+ },
112
+ lpv_u_probe_depth_resolution: {
113
+ value: 1
114
+ },
110
115
  lpv_t_mesh_lookup: {
111
116
  type: "t",
112
117
  value: this.#mesh_lookup
@@ -134,8 +139,16 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
134
139
  #onBeforeCompile = (shader) => {
135
140
  Object.assign(shader.uniforms, this.#uniforms);
136
141
 
137
- shader.vertexShader = build_vertex_shader(shader.vertexShader);
138
- shader.fragmentShader = build_fragment_shader(shader.fragmentShader);
142
+ switch (this.#space) {
143
+ case ProbeResolutionSpace.Vertex:
144
+ space_vertex_transform_shader(shader);
145
+ break;
146
+ case ProbeResolutionSpace.Fragment:
147
+ space_fragment_transform_shader(shader);
148
+ break;
149
+ default:
150
+ throw new Error(`Unsupported resolution space ${this.#space}`);
151
+ }
139
152
  };
140
153
 
141
154
  #materials = [];
@@ -166,6 +179,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
166
179
  super();
167
180
 
168
181
  this.#volume = volume;
182
+
169
183
  }
170
184
 
171
185
  update_bounds() {
@@ -204,7 +218,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
204
218
  const w_y = n_y * bounds.getExtentsY() + bounds.y0;
205
219
  const w_z = n_z * bounds.getExtentsZ() + bounds.z0;
206
220
 
207
- const tet = volume.mesh.findTetraContainingPoint(w_x, w_y, w_z, volume.points, last_tet);
221
+ const tet = volume.mesh.walkToTetraContainingPoint(w_x, w_y, w_z, volume.points, last_tet);
208
222
 
209
223
  if (tet !== -1) {
210
224
  last_tet = tet;
@@ -232,15 +246,19 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
232
246
 
233
247
  this.update_lookup();
234
248
 
235
- this.#uniforms.lpv_u_mesh_tet_count.value = lpv.mesh.count;
249
+ const uniforms = this.#uniforms;
236
250
 
237
- this.#uniforms.lpv_v3_bounds_min.value.set(
251
+ uniforms.lpv_u_mesh_tet_count.value = lpv.mesh.count;
252
+
253
+ uniforms.lpv_v3_bounds_min.value.set(
238
254
  this.#mesh_bounds.x0, this.#mesh_bounds.y0, this.#mesh_bounds.z0
239
255
  );
240
- this.#uniforms.lpv_v3_bounds_max.value.set(
256
+ uniforms.lpv_v3_bounds_max.value.set(
241
257
  this.#mesh_bounds.x1, this.#mesh_bounds.y1, this.#mesh_bounds.z1
242
258
  );
243
259
 
260
+ uniforms.lpv_u_probe_depth_resolution.value = lpv.depth_map_resolution;
261
+
244
262
  this.#uniform_version = lpv.version;
245
263
 
246
264
  console.time('prepareTextures');
@@ -250,9 +268,13 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
250
268
  tetrahedral_mesh_to_texture(
251
269
  this.#textures.vertex, this.#textures.neighbour, lpv.mesh
252
270
  );
271
+ octahedral_depth_to_atlas(lpv, this.#textures.depth.image.data, this.#textures.depth.image.width);
272
+ this.#textures.depth.needsUpdate = true;
253
273
 
254
274
  console.timeEnd('prepareTextures');
255
275
 
276
+ console.log(this.#textures);
277
+
256
278
  for (let i = 0; i < this.#materials.length; i++) {
257
279
  const material = this.#materials[i];
258
280