@woosh/meep-engine 2.109.6 → 2.109.7

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 (167) 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/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
  25. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
  26. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
  27. package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
  28. package/src/core/geom/vec3/v3_distance.js +5 -5
  29. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
  30. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
  31. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
  32. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
  33. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
  34. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
  35. package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
  36. package/src/engine/asset/loaders/AssetLoader.js +1 -1
  37. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  38. package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
  39. package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
  40. package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
  41. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
  42. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
  43. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
  44. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
  45. package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
  46. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  47. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
  48. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
  49. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
  50. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
  51. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
  52. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
  53. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
  54. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
  55. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
  56. package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
  57. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  58. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +48 -33
  59. package/src/engine/graphics/sh3/gi/material/common.glsl +434 -0
  60. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
  61. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
  62. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
  63. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
  64. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
  65. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
  66. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
  67. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +53 -0
  68. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
  69. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
  70. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
  71. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
  72. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
  73. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
  74. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
  75. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
  76. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
  77. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
  78. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
  79. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
  80. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
  81. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
  82. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
  83. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
  84. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
  85. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  86. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
  87. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
  88. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +67 -8
  89. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +10 -0
  90. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  91. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -41
  92. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
  93. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
  94. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
  95. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
  96. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
  97. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
  98. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
  99. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
  100. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
  101. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
  102. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
  103. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
  104. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
  105. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +146 -0
  106. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +159 -0
  107. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
  108. package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
  109. package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
  110. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
  111. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  112. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
  113. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
  114. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
  115. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
  116. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  117. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
  118. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
  119. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
  120. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
  121. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
  122. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  123. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
  124. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  125. 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
  126. package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  127. 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
  128. package/src/engine/graphics/sh3/prototypeSH3Probe.js +40 -7
  129. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
  130. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
  131. package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
  132. package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
  133. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
  134. package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
  135. package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
  136. package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
  137. package/src/view/View.d.ts.map +1 -1
  138. package/src/view/View.js +2 -0
  139. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
  140. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
  141. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
  142. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
  143. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
  144. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
  145. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
  146. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
  147. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
  148. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
  149. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
  150. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
  151. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
  152. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
  153. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
  154. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
  155. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
  156. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
  157. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
  158. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
  159. package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
  160. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
  161. /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
  162. /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
  163. /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
  164. /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
  165. /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
  166. /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
  167. /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CA8DnB"}
1
+ {"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CAmEnB"}
@@ -93,7 +93,12 @@ export function textureImagesEqual(a, b) {
93
93
  return false;
94
94
  }
95
95
 
96
- if (a instanceof ImageBitmap && b instanceof ImageBitmap) {
96
+ if (
97
+ // check that browser/environment has the class at all to avoid potential exceptions
98
+ // Required for Safari below version 15.6
99
+ ImageBitmap !== undefined
100
+ && (a instanceof ImageBitmap && b instanceof ImageBitmap)
101
+ ) {
97
102
  return computeImageBitmapEquality(a, b);
98
103
  }
99
104
 
@@ -1 +1 @@
1
- {"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH;;WAHoD,MAAM;YAAQ,MAAM;IAC5D,MAAM,CAkCjB;AA4CD;;;;GAIG;AACH,sCAHW,UAAQ,MAAM,OAAO,GACnB,MAAM,CAiClB"}
1
+ {"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH;;WAHoD,MAAM;YAAQ,MAAM;IAC5D,MAAM,CAuCjB;AA4CD;;;;GAIG;AACH,sCAHW,UAAQ,MAAM,OAAO,GACnB,MAAM,CAiClB"}
@@ -1,8 +1,8 @@
1
- import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
2
1
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
3
- import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
4
2
  import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
3
+ import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
5
4
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
5
+ import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
6
6
 
7
7
  /**
8
8
  *
@@ -35,7 +35,12 @@ export function computeImageDataHash(image) {
35
35
 
36
36
  let result = 0;
37
37
 
38
- if (image instanceof ImageBitmap) {
38
+ if (
39
+ // check that browser/environment has the class at all to avoid potential exceptions
40
+ // Required for Safari below version 15.6
41
+ ImageBitmap !== undefined
42
+ && (image instanceof ImageBitmap)
43
+ ) {
39
44
  result = computeImageBitmapHash(image);
40
45
  } else if (image instanceof HTMLImageElement) {
41
46
  result = computeStringHash(image.src);
@@ -1 +1 @@
1
- {"version":3,"file":"InstancedMeshGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/InstancedMeshGroup.js"],"names":[],"mappings":"AAsCA;IA4iBI;;;;;OAKG;IACH,sBAJW,oBAAoB,uBAElB,kBAAkB,CAS9B;IAnjBG;;;;OAIG;IACH,wBAA2B;IAE3B;;;;OAIG;IACH,gCAAmC;IAEnC;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,YAFU,MAAM,CAEK;IACrB;;;OAGG;IACH,cAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,cAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,gBAFU,MAAM,CAEQ;IAExB;;;;OAIG;IACH,6BAAgC;IAEhC;;;;OAIG;IACH,kCAAqC;IAGrC;;;;;OAKG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,8BAAiC;IAEjC;;;;OAIG;IACH,wBAAuC;IAEvC;;;;OAIG;IACH,mBAAsB;IAEtB,eAAiB;IACjB,kBAAoB;IAEpB;;;;OAIG;IACH,oBAAqC;IAErC,kFAAqC;IAErC,mBAAqB;IAGzB,qBA8BC;IAED;;;OAGG;IACH,6BAUC;IAED;;;OAGG;IACH,+BAcC;IAED;;;OAGG;IACH,4BAEC;IAED,gBAIC;IAED;;;OAGG;IACH,sBAFW,oBAAoB,QAU9B;IA4CD;;;OAGG;IACH,4BAFW,MAAM,QAAQ,GAAC,MAAM,cAAc,QAS7C;IAED;;;OAGG;IACH,kBAFW,MAAM,QAWhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QA6BhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,aACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;OAIG;IACH,kBAHW,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAWhB;IAED,+BAMC;IAED;;;;OAIG;IACH,qCAEC;IAED;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,YAFY,MAAM,MAAI,CAIrB;IAED;;;;OAIG;IACH,yBAUC;IAED;;;;OAIG;IACH,sDAcC;IAED;;;OAGG;IACH,6BAoDC;IAED,cAwEC;;CAgBJ;;;;;+BAtlBM,OAAO;qBAAP,OAAO;yBAQW,+BAA+B"}
1
+ {"version":3,"file":"InstancedMeshGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/InstancedMeshGroup.js"],"names":[],"mappings":"AAuCA;IAqiBI;;;;;OAKG;IACH,sBAJW,oBAAoB,uBAElB,kBAAkB,CAS9B;IA5iBG;;;;OAIG;IACH,wBAA2B;IAE3B;;;;OAIG;IACH,gCAAmC;IAEnC;;;OAGG;IACH,cAAc;IAEd;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,YAFU,MAAM,CAEK;IACrB;;;OAGG;IACH,cAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,cAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,gBAFU,MAAM,CAEQ;IAExB;;;;OAIG;IACH,6BAAgC;IAEhC;;;;OAIG;IACH,kCAAqC;IAGrC;;;;;OAKG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,8BAAiC;IAEjC;;;;OAIG;IACH,wBAAuC;IAEvC;;;;OAIG;IACH,mBAAsB;IAEtB,eAAiB;IACjB,kBAAoB;IAEpB;;;;OAIG;IACH,oBAAqC;IAErC,kFAAqC;IAErC,mBAAqB;IAGzB,qBA8BC;IAED;;;OAGG;IACH,6BAUC;IAED;;;OAGG;IACH,+BAcC;IAED;;;OAGG;IACH,4BAEC;IAED,gBAIC;IAED;;;OAGG;IACH,sBAFW,oBAAoB,QAU9B;IA4CD;;;OAGG;IACH,4BAFW,MAAM,QAAQ,GAAC,MAAM,cAAc,QAS7C;IAED;;;OAGG;IACH,kBAFW,MAAM,QAWhB;IAED;;;OAGG;IACH,qBAFW,MAAM,QA6BhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,aACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;OAIG;IACH,kBAHW,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,QAIjD;IAED;;;;;;;OAOG;IACH,6BANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAWhB;IAED,+BAMC;IAED;;;;OAIG;IACH,qCAEC;IAED;;;OAGG;IACH,0BAKC;IAED;;;OAGG;IACH,YAFY,MAAM,MAAI,CAIrB;IAED;;;;OAIG;IACH,yBAUC;IAED;;;;OAIG;IACH,sDAcC;IAED;;;OAGG;IACH,6BAoDC;IAED,cAiEC;;CAgBJ;;;;;+BAhlBM,OAAO;qBAAP,OAAO;yBAQW,+BAA+B"}
@@ -9,17 +9,18 @@ import {
9
9
  MeshDepthMaterial,
10
10
  RGBADepthPacking
11
11
  } from 'three';
12
- import ThreeFactory from "../../three/ThreeFactory.js";
13
- import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
14
- import { composeCompile } from "../../material/composeCompile.js";
12
+ import { Cache } from "../../../../core/cache/Cache.js";
13
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
15
14
  import { typed_array_copy } from "../../../../core/collection/array/typed/typed_array_copy.js";
16
- import { rewriteMaterial } from "./rewriteMaterial.js";
17
15
  import { max3 } from "../../../../core/math/max3.js";
18
16
  import { min2 } from "../../../../core/math/min2.js";
19
- import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
20
- import { array_copy } from "../../../../core/collection/array/array_copy.js";
21
- import { Cache } from "../../../../core/cache/Cache.js";
22
17
  import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
18
+ import { StaticMaterialCache } from "../../../asset/loaders/material/StaticMaterialCache.js";
19
+ import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
20
+ import { composeCompile } from "../../material/composeCompile.js";
21
+ import ThreeFactory from "../../three/ThreeFactory.js";
22
+ import { geometry_copy } from "./geometry_copy.js";
23
+ import { rewriteMaterial } from "./rewriteMaterial.js";
23
24
 
24
25
  /**
25
26
  * @typedef {Object} CacheKey
@@ -533,14 +534,7 @@ export class InstancedMeshGroup {
533
534
  geometry.dynamic = true;
534
535
 
535
536
  //copy instance attributes
536
- geometry.index = instance.index;
537
- for (let attributeName in instance.attributes) {
538
- if (!instance.attributes.hasOwnProperty(attributeName)) {
539
- continue;
540
- }
541
-
542
- geometry.attributes[attributeName] = instance.attributes[attributeName];
543
- }
537
+ geometry_copy(geometry, instance);
544
538
 
545
539
  //build instanced attributes
546
540
  const newTransformArray = new Float32Array(this.capacity * 16);
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {BufferGeometry} target
4
+ * @param {BufferGeometry} source
5
+ */
6
+ export function geometry_copy(target: BufferGeometry, source: BufferGeometry): void;
7
+ //# sourceMappingURL=geometry_copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry_copy.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/instancing/geometry_copy.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oFASC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param {BufferGeometry} target
4
+ * @param {BufferGeometry} source
5
+ */
6
+ export function geometry_copy(target, source) {
7
+ target.index = source.index;
8
+ for (let attributeName in source.attributes) {
9
+ if (!source.attributes.hasOwnProperty(attributeName)) {
10
+ continue;
11
+ }
12
+
13
+ target.attributes[attributeName] = source.attributes[attributeName];
14
+ }
15
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ImpostorBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorBaker.js"],"names":[],"mappings":";AAoBA;IAEI;;;;OAIG;IACH,kBAAiB;IAEjB;;;OAGG;IACH,iDAEC;IAGD;;;;;;;OAOG;IACH,yEANW,MAAM,EAAE,OAAK,uBAsOvB;IAED;;;;;;;OAOG;IACH,4CANW;QAAC,IAAI,iBAAgB;QAAC,WAAU,IAAI,CAAA;KAAC,EAAE,GAIrC,mBAAmB,CAqE/B;CACJ;oCAxVmC,0BAA0B;qBACnC,WAAW"}
1
+ {"version":3,"file":"ImpostorBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorBaker.js"],"names":[],"mappings":";AAoBA;IAEI;;;;OAIG;IACH,kBAAiB;IAEjB;;;OAGG;IACH,iDAEC;IAGD;;;;;;;OAOG;IACH,yEANW,MAAM,EAAE,OAAK,uBAgPvB;IAED;;;;;;;OAOG;IACH,4CANW;QAAC,IAAI,iBAAgB;QAAC,WAAU,IAAI,CAAA;KAAC,EAAE,GAIrC,mBAAmB,CAmE/B;CACJ;oCApVmC,0BAA0B;qBAhBnC,WAAW"}
@@ -1,21 +1,21 @@
1
- import { ImpostorCaptureType } from "./ImpostorCaptureType.js";
2
- import { assert } from "../../../../core/assert.js";
3
- import { isPowerOfTwo } from "../../../../core/math/isPowerOrTwo.js";
4
- import { Mesh, OrthographicCamera, Scene, Vector4, WebGLMultipleRenderTargets } from "three";
5
- import { ImpostorDescription } from "./ImpostorDescription.js";
6
1
  import { mat4, vec3 } from "gl-matrix";
7
- import { BakeShaderStandard } from "./shader/BakeShaderStandard.js";
8
- import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
9
- import Signal from "../../../../core/events/signal/Signal.js";
2
+ import { Mesh, OrthographicCamera, Scene, Vector4, WebGLMultipleRenderTargets } from "three";
3
+ import { assert } from "../../../../core/assert.js";
4
+ import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
10
5
  import { HashMap } from "../../../../core/collection/map/HashMap.js";
11
- import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
6
+ import Signal from "../../../../core/events/signal/Signal.js";
7
+ import { isPowerOfTwo } from "../../../../core/math/isPowerOrTwo.js";
12
8
  import { computeMaterialEquality } from "../../../asset/loaders/material/computeMaterialEquality.js";
13
- import { UvEncoder } from "./grid/UvEncoder.js";
14
- import { OctahedralUvEncoder } from "./grid/OctahedralUvEncoder.js";
15
- import { HemiOctahedralUvEncoder } from "./grid/HemiOctahedralUvEncoder.js";
16
- import { prepare_bake_material } from "./bake/prepare_bake_material.js";
17
- import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
9
+ import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
10
+ import { Sampler2D } from "../../texture/sampler/Sampler2D.js";
18
11
  import { compute_bounding_sphere } from "./bake/compute_bounding_sphere.js";
12
+ import { prepare_bake_material } from "./bake/prepare_bake_material.js";
13
+ import { HemiOctahedralUvEncoder } from "./grid/HemiOctahedralUvEncoder.js";
14
+ import { OctahedralUvEncoder } from "./grid/OctahedralUvEncoder.js";
15
+ import { UvEncoder } from "./grid/UvEncoder.js";
16
+ import { ImpostorCaptureType } from "./ImpostorCaptureType.js";
17
+ import { ImpostorDescription } from "./ImpostorDescription.js";
18
+ import { BakeShaderStandard } from "./shader/BakeShaderStandard.js";
19
19
  import { build_cutout_from_atlas_by_alpha } from "./util/build_cutout_from_atlas_by_alpha.js";
20
20
 
21
21
  export class ImpostorBaker {
@@ -62,6 +62,7 @@ export class ImpostorBaker {
62
62
 
63
63
  const cam = new OrthographicCamera();
64
64
  const rt = new WebGLMultipleRenderTargets(resolution, resolution, 3);
65
+
65
66
  rt.scissorTest = false;
66
67
  rt.stencilBuffer = false;
67
68
 
@@ -185,14 +186,14 @@ export class ImpostorBaker {
185
186
  const max_frame_index = frames - 1;
186
187
 
187
188
  for (let i = 0; i < frames; i++) {
188
- const octahedron_u = max_frame_index > 0 ? (i / max_frame_index) : 0;
189
+ const frame_u = max_frame_index > 0 ? (i / max_frame_index) : 0;
189
190
 
190
191
  for (let j = 0; j < frames; j++) {
191
192
 
192
- const octahedron_v = max_frame_index > 0 ? (j / max_frame_index) : 0;
193
+ const frame_v = max_frame_index > 0 ? (j / max_frame_index) : 0;
193
194
 
194
195
  // compute vector direction where to place camera
195
- encoder.uv_to_unit(unit_sphere_direction, [octahedron_u, octahedron_v]);
196
+ encoder.uv_to_unit(unit_sphere_direction, [frame_u, frame_v]);
196
197
 
197
198
  // offset by the radius of the sphere
198
199
  const camera_px = distance * unit_sphere_direction[0] + bounding_sphere[0];
@@ -206,6 +207,7 @@ export class ImpostorBaker {
206
207
  cam.right = distance;
207
208
  cam.top = distance;
208
209
  cam.bottom = -distance;
210
+
209
211
  cam.near = 0;
210
212
  cam.far = distance * 2;
211
213
 
@@ -265,7 +267,15 @@ export class ImpostorBaker {
265
267
  id.rt = rt;
266
268
 
267
269
  // build cutout
268
- id.cutout = build_cutout_from_atlas_by_alpha(id, renderer);
270
+ id.cutout = build_cutout_from_atlas_by_alpha({
271
+ impostor: id,
272
+ renderer,
273
+ vertex_limit: 5
274
+ });
275
+
276
+
277
+ id.sphere_radius = bounding_sphere[3];
278
+ vec3.copy(id.offset, bounding_sphere);
269
279
 
270
280
  return id;
271
281
  }
@@ -339,8 +349,6 @@ export class ImpostorBaker {
339
349
  });
340
350
 
341
351
  r.capture_type = type;
342
- r.sphere_radius = bounding_sphere[3];
343
- vec3.copy(r.offset, bounding_sphere);
344
352
 
345
353
  console.timeEnd('bake');
346
354
 
@@ -1,3 +1,4 @@
1
+ export type ImpostorCaptureType = number;
1
2
  export namespace ImpostorCaptureType {
2
3
  let FullSphere: number;
3
4
  let Hemisphere: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ImpostorCaptureType.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"ImpostorCaptureType.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js"],"names":[],"mappings":"kCAEU,MAAM"}
@@ -1,3 +1,7 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
1
5
  export const ImpostorCaptureType = {
2
6
  /**
3
7
  * Capture from all sides
@@ -1,6 +1,6 @@
1
1
  import { vec3 } from "gl-matrix";
2
2
  import { v3_dot } from "../../../../../core/geom/vec3/v3_dot.js";
3
- import { sign } from "../../../../../core/math/sign.js";
3
+ import { sign_not_zero } from "../../../../../core/math/sign_not_zero.js";
4
4
  import { UvEncoder } from "./UvEncoder.js";
5
5
 
6
6
  export class OctahedralUvEncoder extends UvEncoder {
@@ -13,8 +13,8 @@ export class OctahedralUvEncoder extends UvEncoder {
13
13
  const py = 1 - abs_x - abs_z;
14
14
 
15
15
  if (py < 0) {
16
- px = sign(px) * (1 - abs_z);
17
- pz = sign(pz) * (1 - abs_x);
16
+ px = sign_not_zero(px) * (1 - abs_z);
17
+ pz = sign_not_zero(pz) * (1 - abs_x);
18
18
  }
19
19
 
20
20
  output[0] = px;
@@ -30,9 +30,9 @@ export class OctahedralUvEncoder extends UvEncoder {
30
30
  const input_y = input[1];
31
31
  const input_z = input[2];
32
32
 
33
- const octant_x = sign(input_x);
34
- const octant_y = sign(input_y);
35
- const octant_z = sign(input_z);
33
+ const octant_x = sign_not_zero(input_x);
34
+ const octant_y = sign_not_zero(input_y);
35
+ const octant_z = sign_not_zero(input_z);
36
36
 
37
37
  // |x| + |y| + |z| = 1
38
38
  const sum = v3_dot(input_x, input_y, input_z, octant_x, octant_y, octant_z);
@@ -38,7 +38,14 @@ async function main(engine) {
38
38
  engine,
39
39
  enableWater: false,
40
40
  cameraFieldOfView: 45,
41
- showFps: false
41
+ showFps: false,
42
+ enableLights: false
43
+ });
44
+
45
+ await EngineHarness.buildLights({
46
+ engine,
47
+ sunIntensity: 0,
48
+ ambientIntensity: 1
42
49
  });
43
50
 
44
51
  const ecd = engine.entityManager.dataset;
@@ -47,13 +54,15 @@ async function main(engine) {
47
54
  const renderer = engine.graphics.renderer;
48
55
  baker.renderer = renderer;
49
56
 
50
-
51
57
  // const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
58
+ // const path = 'data/models/samples/textured_unit_cube.gltf';
59
+ // const path = 'data/models/samples/teapot.gltf';
60
+ const path = 'data/models/samples/just_a_girl/scene.gltf';
52
61
  // const path = 'data/models/road_bike/road_bike.gltf'; //large CAD-type model
53
62
  // const path = 'data/models/LowPolyTownshipSet/Barrel/model.gltf';
54
63
  // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
55
64
  // const path = 'data/models/RTS_Buildings_Humans/18/Building_R_18_out/Building_R_18.gltf';
56
- const path = 'data/models/MOBA and Tower Defense/Tree_01.gltf';
65
+ // const path = 'data/models/MOBA and Tower Defense/Tree_01.gltf';
57
66
  // const path = 'data/models/samples/transform-hierarchy.glb';
58
67
  // const path = 'data/models/sponza-pbr/gltf/sponza.glb';
59
68
  // const path = 'data/models/snaps/cube_blue.gltf';
@@ -66,9 +75,9 @@ async function main(engine) {
66
75
  // console.profile('bake');
67
76
  const id = baker.bake({
68
77
  objects,
69
- frames: 12,
78
+ frames: 8,
70
79
  resolution: 1024,
71
- type: ImpostorCaptureType.Hemisphere
80
+ type: ImpostorCaptureType.FullSphere
72
81
  });
73
82
  // console.profileEnd('bake');
74
83
 
@@ -80,14 +89,14 @@ async function main(engine) {
80
89
  mode: 'diffuse'
81
90
  });
82
91
 
83
- ctrl.scale.setScalar(0.5);
92
+ ctrl.scale.setScalar(1);
84
93
 
85
94
  new Entity()
86
95
  .add(ViewportPosition.fromJSON({
87
96
  offset: new Vector2(0, 0)
88
97
  }))
89
98
  .add(GUIElement.fromView(ctrl))
90
- .build(ecd);
99
+ .build(ecd);
91
100
 
92
101
  // build out preview scene with impostor and the original
93
102
  const t0 = Transform.fromJSON({
@@ -3,7 +3,8 @@
3
3
  * A circle is a lot easier to quantize (as long as we make sure we place edges outside of the circle)
4
4
  * @param {ImpostorDescription} impostor
5
5
  * @param {THREE.WebGLRenderer} renderer
6
- * @returns {number}
6
+ * @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
7
+ * @returns {number[]}
7
8
  */
8
- export function build_cutout_from_atlas_by_alpha(impostor: ImpostorDescription, renderer: THREE.WebGLRenderer): number;
9
+ export function build_cutout_from_atlas_by_alpha({ impostor, renderer, vertex_limit }: ImpostorDescription): number[];
9
10
  //# sourceMappingURL=build_cutout_from_atlas_by_alpha.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build_cutout_from_atlas_by_alpha.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,0FAHW,MAAM,aAAa,GACjB,MAAM,CA4GlB"}
1
+ {"version":3,"file":"build_cutout_from_atlas_by_alpha.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,6GAFa,MAAM,EAAE,CAqHpB"}
@@ -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;IAuII;;;OAGG;IACH,0CAOC;IAnBD;;;OAGG;IACH,2BAEC;IAdD;;;OAGG;IACH,wBAEC;IAuBD,sBAIC;IAED,sBA2CC;IAED,eA2CC;IAED,4BA2BC;;CACJ;4CA3S2C,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,10 @@ 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
+ },
110
112
  lpv_t_mesh_lookup: {
111
113
  type: "t",
112
114
  value: this.#mesh_lookup
@@ -134,8 +136,16 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
134
136
  #onBeforeCompile = (shader) => {
135
137
  Object.assign(shader.uniforms, this.#uniforms);
136
138
 
137
- shader.vertexShader = build_vertex_shader(shader.vertexShader);
138
- shader.fragmentShader = build_fragment_shader(shader.fragmentShader);
139
+ switch (this.#space) {
140
+ case ProbeResolutionSpace.Vertex:
141
+ space_vertex_transform_shader(shader);
142
+ break;
143
+ case ProbeResolutionSpace.Fragment:
144
+ space_fragment_transform_shader(shader);
145
+ break;
146
+ default:
147
+ throw new Error(`Unsupported resolution space ${this.#space}`);
148
+ }
139
149
  };
140
150
 
141
151
  #materials = [];
@@ -166,6 +176,7 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
166
176
  super();
167
177
 
168
178
  this.#volume = volume;
179
+
169
180
  }
170
181
 
171
182
  update_bounds() {
@@ -250,9 +261,13 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
250
261
  tetrahedral_mesh_to_texture(
251
262
  this.#textures.vertex, this.#textures.neighbour, lpv.mesh
252
263
  );
264
+ octahedral_depth_to_atlas(lpv, this.#textures.depth.image.data, this.#textures.depth.image.width);
265
+ this.#textures.depth.needsUpdate = true;
253
266
 
254
267
  console.timeEnd('prepareTextures');
255
268
 
269
+ console.log(this.#textures);
270
+
256
271
  for (let i = 0; i < this.#materials.length; i++) {
257
272
  const material = this.#materials[i];
258
273