@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
@@ -0,0 +1,50 @@
1
+ import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
2
+ import {
3
+ tetrahedral_mesh_find_tets_attached_to_vertex
4
+ } from "../../../../core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js";
5
+ import { max2 } from "../../../../core/math/max2.js";
6
+
7
+ /**
8
+ *
9
+ * @type {number[]}
10
+ */
11
+ const tets = [];
12
+
13
+ /**
14
+ *
15
+ * @param {number} vertex_index
16
+ * @param {TetrahedralMesh} mesh
17
+ * @param {number[]} points
18
+ */
19
+ export function find_max_depth_radius_for_point(vertex_index, mesh, points) {
20
+
21
+ const count = tetrahedral_mesh_find_tets_attached_to_vertex(
22
+ tets, 0,
23
+ mesh,
24
+ vertex_index
25
+ );
26
+
27
+ const ref_x = points[vertex_index * 3];
28
+ const ref_y = points[vertex_index * 3 + 1];
29
+ const ref_z = points[vertex_index * 3 + 2];
30
+
31
+ let radius_sqr = 0;
32
+
33
+ for (let i = 0; i < count; i++) {
34
+ const tet = tets[i];
35
+
36
+ for (let j = 0; j < 4; j++) {
37
+ const v = mesh.getVertexIndex(tet, j);
38
+
39
+ const x = points[v * 3];
40
+ const y = points[v * 3 + 1];
41
+ const z = points[v * 3 + 2];
42
+
43
+ const r2 = v3_distance_sqr(ref_x, ref_y, ref_z, x, y, z);
44
+
45
+ radius_sqr = max2(r2, radius_sqr);
46
+ }
47
+ }
48
+
49
+ return Math.sqrt(radius_sqr);
50
+ }
@@ -1,13 +1,10 @@
1
1
  /**
2
2
  *
3
3
  * @param {LightProbeVolume} lpv
4
+ * @param {number[]} atlas_data
5
+ * @param {number} atlas_width
4
6
  */
5
- export function probe_volume_to_textures(lpv: LightProbeVolume): {
6
- mesh_vertices: AttributeDataTexture;
7
- mesh_neighbours: AttributeDataTexture;
8
- probe_positions: AttributeDataTexture;
9
- probe_values: AttributeDataTexture;
10
- };
7
+ export function octahedral_depth_to_atlas(lpv: LightProbeVolume, atlas_data: number[], atlas_width: number): void;
11
8
  /**
12
9
  *
13
10
  * @param {AttributeDataTexture} target
@@ -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;AAED;;;;;;GAMG;AACH,2DALW,oBAAoB,UACpB,MAAM,EAAE,eACR,MAAM,eACN,MAAM,QAiBhB;qCAtFoC,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":"AAGA;;;;;GAKG;AACH,6EAHW,MAAM,EAAE,eACR,MAAM,QAiChB;AAGD;;;;;;GAMG;AACH,2DALW,oBAAoB,UACpB,MAAM,EAAE,eACR,MAAM,eACN,MAAM,QAiBhB;qCAhEoC,uCAAuC"}
@@ -1,70 +1,46 @@
1
- import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
2
1
  import { array_copy } from "../../../../core/collection/array/array_copy.js";
3
- import { AttributeSpec } from "../../geometry/AttributeSpec.js";
4
2
  import { AttributeDataTexture } from "../../texture/AttributeDataTexture.js";
5
- import { tetrahedral_mesh_to_texture } from "../gi/tetrahedral_mesh_to_texture.js";
6
3
 
7
4
  /**
8
5
  *
9
6
  * @param {LightProbeVolume} lpv
7
+ * @param {number[]} atlas_data
8
+ * @param {number} atlas_width
10
9
  */
11
- export function probe_volume_to_textures(lpv) {
12
-
13
- const tex_vertices = new AttributeDataTexture(
14
- AttributeSpec.fromJSON({
15
- name: "vertex",
16
- type: BinaryDataType.Uint16,
17
- itemSize: 4,
18
- normalized: false
19
- }),
20
- 256, 1
21
- );
22
-
23
- const tex_neighbours = new AttributeDataTexture(
24
- AttributeSpec.fromJSON({
25
- name: "neighbour",
26
- type: BinaryDataType.Uint32,
27
- itemSize: 4,
28
- normalized: false
29
- }),
30
- 256, 1
31
- );
32
-
33
- const tex_positions = new AttributeDataTexture(
34
- AttributeSpec.fromJSON({
35
- name: "positions",
36
- type: BinaryDataType.Float32,
37
- itemSize: 3,
38
- normalized: false
39
- }),
40
- 256, 1
41
- );
42
-
43
- const tex_harmonics = new AttributeDataTexture(
44
- AttributeSpec.fromJSON({
45
- name: "harmonics",
46
- type: BinaryDataType.Float32,
47
- itemSize: 3,
48
- normalized: false
49
- }),
50
- 256, 9
51
- );
52
-
53
- vector_buffer_to_attribute_texture(tex_positions, lpv.points, lpv.count, 3);
54
- vector_buffer_to_attribute_texture(tex_harmonics, lpv.harmonics, lpv.count * 9, 3);
55
- tetrahedral_mesh_to_texture(
56
- tex_vertices, tex_neighbours, lpv.mesh
57
- );
58
-
59
- return {
60
- mesh_vertices: tex_vertices,
61
- mesh_neighbours: tex_neighbours,
62
-
63
- probe_positions: tex_positions,
64
- probe_values: tex_harmonics
65
- };
10
+ export function octahedral_depth_to_atlas(lpv, atlas_data, atlas_width) {
11
+ const tile_resolution = lpv.depth_map_resolution;
12
+ const probe_count = lpv.count;
13
+ const probe_depth = lpv.depth;
14
+
15
+ const tiles_per_row = Math.floor(atlas_width / tile_resolution);
16
+
17
+ // populate atlas
18
+ for (let i = 0; i < probe_count; i++) {
19
+
20
+ const tile_x = i % tiles_per_row;
21
+ const tile_y = (i / tiles_per_row) >>> 0;
22
+
23
+ for (let pixel_y = 0; pixel_y < tile_resolution; pixel_y++) {
24
+ for (let pixel_x = 0; pixel_x < tile_resolution; pixel_x++) {
25
+
26
+ const source_offset = i * tile_resolution * tile_resolution;
27
+
28
+ const tile_pixel_index = pixel_y * tile_resolution + pixel_x;
29
+
30
+ const source_value = probe_depth[source_offset + tile_pixel_index];
31
+
32
+ const target_pixel_x = tile_x * tile_resolution + pixel_x;
33
+ const target_pixel_y = tile_y * tile_resolution + pixel_y;
34
+
35
+ const target_pixel_index = target_pixel_y * atlas_width + target_pixel_x;
36
+
37
+ atlas_data[target_pixel_index] = source_value;
38
+ }
39
+ }
40
+ }
66
41
  }
67
42
 
43
+
68
44
  /**
69
45
  *
70
46
  * @param {AttributeDataTexture} target
@@ -1 +1 @@
1
- {"version":3,"file":"LightProbeVolumeSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,+BAAwB;IAGxB;;;;OAIG;IACH,8BAFW,gBAAgB,QAY1B;IAED;;;;OAIG;IACH,gCAFW,gBAAgB,QAc1B;CACJ;gDA3C+C,mEAAmE;iCAClF,wBAAwB"}
1
+ {"version":3,"file":"LightProbeVolumeSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,+BAAwB;IAGxB;;;;OAIG;IACH,8BAFW,gBAAgB,QAiB1B;IAED;;;;OAIG;IACH,gCAFW,gBAAgB,QAiB1B;CACJ;gDAnD+C,mEAAmE;iCAClF,wBAAwB"}
@@ -20,6 +20,11 @@ export class LightProbeVolumeSerializationAdapter extends BinaryClassSerializati
20
20
  // probe values
21
21
  buffer.writeFloat32Array(value.harmonics, 0, count * 27);
22
22
 
23
+ // depth
24
+ const depth_resolution = value.depth_map_resolution;
25
+ buffer.writeUint32(depth_resolution);
26
+ buffer.writeFloat32Array(value.depth, 0, depth_resolution * depth_resolution * count);
27
+
23
28
  value.mesh.serialize(buffer);
24
29
  }
25
30
 
@@ -38,6 +43,9 @@ export class LightProbeVolumeSerializationAdapter extends BinaryClassSerializati
38
43
  buffer.readFloat32Array(value.points, 0, count * 3);
39
44
  buffer.readFloat32Array(value.harmonics, 0, count * 27);
40
45
 
46
+ // depth
47
+ const depth_resolution = buffer.readUint32();
48
+ buffer.readFloat32Array(value.depth, 0, depth_resolution * depth_resolution * count);
41
49
 
42
50
  value.mesh.deserialize(buffer);
43
51
  }
@@ -30,9 +30,9 @@ export class BufferedGeometryBVH {
30
30
  private __triangle_count;
31
31
  /**
32
32
  *
33
- * @param {THREE.BufferGeometry} geometry
33
+ * @param {THREE.BufferGeometry} geo
34
34
  */
35
- build(geometry: THREE.BufferGeometry): void;
35
+ build(geo: THREE.BufferGeometry): void;
36
36
  /**
37
37
  * Tests ray for occlusion
38
38
  * Returns true if ray hits anything at all
@@ -1 +1 @@
1
- {"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"AAwBA;IAkBI;;;OAGG;IACH,eAFW,KAAK,GAAC,MAAM,EAAE,QAIxB;IAIG;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,gBAFW,MAAM,cAAc,QAsC9B;IAED;;;;;OAKG;IACH,qBAFa,OAAO,CAkDnB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,EAAE,OACR,MAAM,EAAE,OAAK,GACX,MAAM,CA2ElB;;CACJ;sBAhQqB,wCAAwC"}
1
+ {"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"AAyBA;IAkBI;;;OAGG;IACH,eAFW,KAAK,GAAC,MAAM,EAAE,QAIxB;IAIG;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,WAFW,MAAM,cAAc,QAwC9B;IAED;;;;;OAKG;IACH,qBAFa,OAAO,CAkDnB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,EAAE,OACR,MAAM,EAAE,OAAK,GACX,MAAM,CA2ElB;;CACJ;sBAnQqB,wCAAwC"}
@@ -8,6 +8,7 @@ import {
8
8
  computeTriangleRayIntersectionBarycentricGeometry
9
9
  } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js";
10
10
  import Vector4 from "../../../../core/geom/Vector4.js";
11
+ import { makeGeometryIndexed } from "../../geometry/buffered/makeGeometryIndexed.js";
11
12
  import { computeBoundingSphereFromVertexData } from "../../geometry/computeBoundingSphereFromVertexData.js";
12
13
  import { construct_ray_hit_from_geometry } from "./geometry/construct_ray_hit_from_geometry.js";
13
14
 
@@ -82,16 +83,18 @@ export class BufferedGeometryBVH {
82
83
 
83
84
  /**
84
85
  *
85
- * @param {THREE.BufferGeometry} geometry
86
+ * @param {THREE.BufferGeometry} geo
86
87
  */
87
- build(geometry) {
88
- this.__geometry = geometry;
88
+ build(geo) {
89
+ makeGeometryIndexed(geo);
89
90
 
90
- const index = geometry.getIndex();
91
+ this.__geometry = geo;
92
+
93
+ const index = geo.getIndex();
91
94
  const index_array = index.array;
92
95
 
93
96
 
94
- const attribute_position = geometry.getAttribute('position');
97
+ const attribute_position = geo.getAttribute('position');
95
98
  const array_positions = attribute_position.array;
96
99
 
97
100
  this.__geometry_positions = array_positions;
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {EntityComponentDataset} ecd
4
+ * @param {PathTracedScene} scene
5
+ */
6
+ export function populate_path_traced_scene_from_ecd(ecd: EntityComponentDataset, scene: PathTracedScene): void;
7
+ //# sourceMappingURL=populate_path_traced_scene_from_ecd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"populate_path_traced_scene_from_ecd.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,+GAqCC"}
@@ -0,0 +1,50 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { Transform } from "../../../ecs/transform/Transform.js";
3
+ import { Light } from "../../ecs/light/Light.js";
4
+ import { LightType } from "../../ecs/light/LightType.js";
5
+ import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
6
+ import { DirectionalLight } from "../../render/forward_plus/model/DirectionalLight.js";
7
+
8
+ /**
9
+ *
10
+ * @param {EntityComponentDataset} ecd
11
+ * @param {PathTracedScene} scene
12
+ */
13
+ export function populate_path_traced_scene_from_ecd(ecd, scene) {
14
+ assert.defined(ecd, 'ecd');
15
+ assert.defined(scene, 'scene');
16
+
17
+ ecd.traverseEntities([ShadedGeometry, Transform],
18
+ /**
19
+ *
20
+ * @param {ShadedGeometry} sg
21
+ * @param {Transform} transform
22
+ */
23
+ (sg, transform) => {
24
+
25
+ scene.createMesh(sg.geometry, sg.material, transform.matrix)
26
+
27
+ });
28
+
29
+
30
+ ecd.traverseEntities([Light, Transform],
31
+ /**
32
+ *
33
+ * @param {Light} light
34
+ * @param {Transform} transform
35
+ */
36
+ (light, transform) => {
37
+
38
+ if (light.type.getValue() === LightType.DIRECTION) {
39
+
40
+ const l = new DirectionalLight();
41
+
42
+ l.color.copy(light.color);
43
+ l.direction.copy(transform.forward);
44
+ l.intensity.copy(light.intensity);
45
+
46
+ scene.addLight(l);
47
+ }
48
+
49
+ });
50
+ }
@@ -67,8 +67,8 @@ vCanvas.css({
67
67
  * How many rays to use per-pixel
68
68
  * @type {number}
69
69
  */
70
- const PIXEL_SAMPLE_COUNT = 256;
71
- const PIXEL_RENDER_RATIO = 1;
70
+ const PIXEL_SAMPLE_COUNT = 1;
71
+ const PIXEL_RENDER_RATIO = 0.5;
72
72
 
73
73
  const scene = new PathTracedScene();
74
74
  const pt = new PathTracer();
@@ -201,6 +201,42 @@ async function prepare_gi_box_scene(scene, camera) {
201
201
 
202
202
  }
203
203
 
204
+ /**
205
+ *
206
+ * @param {PathTracedScene} scene
207
+ * @param {THREE.Camera} camera
208
+ * @returns {Promise<void>}
209
+ */
210
+ async function prepare_attic_scene(scene, camera) {
211
+ const path = 'data/models/samples/the_attic_environment/scene1.gltf';
212
+ await prepare_scene_gltf({
213
+ scene: scene,
214
+ camera: camera,
215
+ url: path,
216
+ sun: {
217
+ direction: new Vector3(1.2, -1, 0.2)
218
+ }
219
+ });
220
+
221
+ const transform = Transform.fromJSON({
222
+ "position": {
223
+ "x": -11.027168212431539,
224
+ "y": 1.0396201881596159,
225
+ "z": -2.9677969519799223
226
+ },
227
+ "rotation": {
228
+ "x": 0.024907147178871554,
229
+ "y": -0.08487115365830479,
230
+ "z": 0.0021222209892540838,
231
+ "w": 0.9960783189459508
232
+ },
233
+ "scale": { "x": 1, "y": 1, "z": 1 }
234
+ });
235
+
236
+ set_camera_from_transform(camera, transform);
237
+
238
+ }
239
+
204
240
  /**
205
241
  *
206
242
  * @param {PathTracedScene} scene
@@ -505,8 +541,9 @@ async function start_renderer(camera) {
505
541
  // await prepare_scene_lucy(scene, camera);
506
542
  // await prepare_scene_rtiow(pt, camera);
507
543
  // await prepare_scene_sphere_01(pt, camera);
508
- await prepare_gi_box_scene(scene, camera);
544
+ // await prepare_gi_box_scene(scene, camera);
509
545
  // await prepare_sponza(scene, camera);
546
+ await prepare_attic_scene(scene, camera);
510
547
  // await prepare_scene_gltf({scene, camera, path, url: path});
511
548
 
512
549
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build_bvh_nodes_distances_along_ray.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,4DAXW,MAAM,EAAE,iBACR,MAAM,uBAEN,MAAM,EAAE,oBACR,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,gBACN,MAAM,QA4BhB"}
@@ -1,7 +1,7 @@
1
- import { ELEMENT_WORD_COUNT } from "../../../../core/bvh2/bvh3/BVH.js";
1
+ import { ELEMENT_WORD_COUNT } from "../../../../../core/bvh2/bvh3/BVH.js";
2
2
  import {
3
3
  aabb3_compute_distance_above_plane_min
4
- } from "../../../../core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js";
4
+ } from "../../../../../core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js";
5
5
 
6
6
  /**
7
7
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build_bvh_nodes_distances_sqr_to_point.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,+DAVW,MAAM,EAAE,iBACR,MAAM,uBAEN,MAAM,EAAE,oBACR,MAAM,kBACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA2BhB"}
@@ -1,7 +1,7 @@
1
- import { ELEMENT_WORD_COUNT } from "../../../../core/bvh2/bvh3/BVH.js";
1
+ import { ELEMENT_WORD_COUNT } from "../../../../../core/bvh2/bvh3/BVH.js";
2
2
  import {
3
3
  aabb3_unsigned_distance_sqr_to_point
4
- } from "../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
4
+ } from "../../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
5
5
 
6
6
  /**
7
7
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort_bvh_nodes_by_distance_to_point.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.js"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,yEAPW,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,kBACN,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,QA+BhB"}
@@ -1,8 +1,8 @@
1
- import { ELEMENT_WORD_COUNT } from "../../../../core/bvh2/bvh3/BVH.js";
2
- import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
1
+ import { ELEMENT_WORD_COUNT } from "../../../../../core/bvh2/bvh3/BVH.js";
2
+ import { arrayQuickSort } from "../../../../../core/collection/array/arrayQuickSort.js";
3
3
  import {
4
4
  aabb3_unsigned_distance_sqr_to_point
5
- } from "../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
5
+ } from "../../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
6
6
 
7
7
  /**
8
8
  *
@@ -52,6 +52,8 @@ import { three_object_to_entity_composition } from "../ecs/mesh-v2/three_object_
52
52
  import { GizmoRenderingPlugin } from "../render/gizmo/GizmoRenderingPlugin.js";
53
53
  import { MaterialTransformer } from "./gi/material/MaterialTransformer.js";
54
54
  import { build_probes_for_scene } from "./lpv/build_probes_for_scene.js";
55
+ import { OctahedralDepthDebuggerWidget } from "./lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js";
56
+ import { VLPDepthMapVisualisation } from "./lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js";
55
57
  import { LightProbeVolume } from "./lpv/LightProbeVolume.js";
56
58
  import { LightProbeVolumeSerializationAdapter } from "./lpv/serialization/LightProbeVolumeSerializationAdapter.js";
57
59
 
@@ -218,7 +220,7 @@ async function getVolume({
218
220
  const adapter = new LightProbeVolumeSerializationAdapter();
219
221
 
220
222
  if (await engine.storage.promiseContains(key)
221
- && false // TODO re-enable
223
+ // && false // TODO re-enable
222
224
  ) {
223
225
  const data = await engine.storage.promiseLoadBinary(key);
224
226
 
@@ -360,26 +362,26 @@ async function main(engine) {
360
362
 
361
363
 
362
364
  // const path = 'data/models/samples/sd_macross_city_standoff_diorama/scene.gltf';
363
- // const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
364
365
  // const path = 'data/models/sibenik/2/model.gltf';
365
366
  // const path = 'data/models/vokselia_spawn/model.gltf';
366
- // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
367
367
  // const path = 'data/models/samples/just_a_girl/scene.gltf';
368
368
  // const path = 'data/models/samples/slum_house/scene.gltf';
369
369
  // const path = 'data/models/samples/jack_trigger/scene.gltf';
370
370
  // const path = 'data/models/samples/cornell_box/scene.gltf';
371
371
  // const path = 'data/models/Slaughter Mech/Slaugter Mech.gltf';
372
372
  // const path = 'data/models/samples/gi_box_01/model-thick-1.glb';
373
- // const path = 'data/models/sibenik/3-window-less/model.gltf';
374
373
  // const path = 'data/models/samples/ancient_bath_house_-_modular_set/scene.gltf';
375
374
  // const path = 'data/models/samples/environment_-_library/scene.gltf';
375
+ // const path = 'data/models/Scans/green_car_wreck/scene.gltf';
376
+ // const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
376
377
  // const path = 'data/models/samples/the_attic_environment/scene1.gltf';
378
+ // const path = 'data/models/LowPolyTownshipSet/Small_house/Small_house.gltf';
377
379
  // const path = 'data/models/samples/cyberpunk_bike/scene.gltf';
378
- const path = 'data/models/sponza-pbr/gltf/sponza.glb';
380
+ // const path = 'data/models/LowPolyTownshipSet/Town_Hall/model.gltf';
381
+ // const path = 'data/models/sibenik/3-window-less/model.gltf';
379
382
  // const path = 'data/models/samples/gi_box_01/model.glb';
380
- // const path = 'data/models/Scans/green_car_wreck/scene.gltf';
381
- // const path = 'data/models/pica_pica/pica_pica.gltf';
382
- // const path = 'data/models/samples/low_poly_classroom/no-glass/model.gltf';
383
+ // const path = 'data/models/sponza-pbr/gltf/sponza.glb';
384
+ const path = 'data/models/pica_pica/pica_pica.gltf';
383
385
 
384
386
  const mesh_asset = await engine.assetManager.promise(path, 'model/gltf+json');
385
387
  const gltf = mesh_asset.gltf;
@@ -498,6 +500,8 @@ async function main(engine) {
498
500
  opacity: 0.5
499
501
  });
500
502
 
503
+ const depth_viz = VLPDepthMapVisualisation.from(volume).build();
504
+
501
505
  // volume.visualize_mesh({ ecd, opacity: 0.5 });
502
506
 
503
507
  const gui = new GUI();
@@ -536,12 +540,41 @@ async function main(engine) {
536
540
  }
537
541
  }, "mesh_vis").name("Visualise Mesh");
538
542
 
543
+ gui.add({
544
+ get depth_vis() {
545
+ return depth_viz.isBuilt
546
+ },
547
+ set depth_vis(v) {
548
+ if (v) {
549
+ depth_viz.build(ecd);
550
+ } else {
551
+ depth_viz.destroy();
552
+ }
553
+ }
554
+ }, "depth_vis").name("Visualise Depth");
555
+
556
+ // makeDebugGizmo(engine, mesh_bounds.getCenter());
557
+
539
558
 
540
559
  // mesh_entity.addEventListener(SGMeshEvents.AssetLoaded, build);
541
560
  //
542
561
  // mesh_entity.build(ecd);
543
562
  }
544
563
 
564
+ /**
565
+ *
566
+ * @param {Engine} engine
567
+ * @param {Vector3} position
568
+ */
569
+ function makeDebugGizmo(engine, position) {
570
+
571
+ const widget = new OctahedralDepthDebuggerWidget();
572
+
573
+ widget.entity.getComponentSafe(Transform).position.copy(position);
574
+
575
+ widget.build(engine.entityManager.dataset, engine);
576
+ }
577
+
545
578
  new EngineHarness().initialize({
546
579
  configuration(config, engine) {
547
580
  config.addSystem(new ShadedGeometrySystem(engine));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SH3VisualisationMaterial.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js"],"names":[],"mappings":"AAIA;IAEI,cAoBC;CAEJ;+BA5BuC,OAAO"}
@@ -0,0 +1,29 @@
1
+ import { ShaderMaterial, Vector3 } from "three";
2
+ import shader_fg from './visualize.frag.glsl';
3
+ import shader_vx from './visualize.vert.glsl';
4
+
5
+ export class SH3VisualisationMaterial extends ShaderMaterial {
6
+
7
+ constructor() {
8
+ const sh = [];
9
+
10
+ for (let i = 0; i < 9; i++) {
11
+ sh.push(new Vector3());
12
+ }
13
+
14
+ super({
15
+ fragmentShader: shader_fg,
16
+ vertexShader: shader_vx,
17
+ lights: false,
18
+ uniforms: {
19
+ intensity: {
20
+ value: 1,
21
+ },
22
+ sh: {
23
+ value: sh
24
+ }
25
+ }
26
+ })
27
+ }
28
+
29
+ }
@@ -0,0 +1,41 @@
1
+ #define RECIPROCAL_PI 0.318309886
2
+
3
+ vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
4
+ // matrix is assumed to be orthogonal
5
+ return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
6
+ }
7
+
8
+ // source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
9
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
10
+ // normal is assumed to have unit length
11
+ float x = normal.x, y = normal.y, z = normal.z;
12
+
13
+ // band 0
14
+ vec3 result = shCoefficients[ 0 ] * 0.8862269254527579;
15
+
16
+ // band 1
17
+ result -= shCoefficients[ 1 ] * 1.0233267079464885 * y;
18
+ result += shCoefficients[ 2 ] * 1.0233267079464885 * z;
19
+ result -= shCoefficients[ 3 ] * 1.0233267079464885 * x;
20
+
21
+ // band 2
22
+ result += shCoefficients[ 4 ] * 0.8580855308097834 * x * y;
23
+ result -= shCoefficients[ 5 ] * 0.8580855308097834 * y * z;
24
+ result += shCoefficients[ 6 ] * ( 0.7431238683011272 * z * z - 0.24770795610037571 );
25
+ result -= shCoefficients[ 7 ] * 0.8580855308097834 * x * z;
26
+ result += shCoefficients[ 8 ] * 0.4290427654048917 * ( x * x - y * y );
27
+
28
+ return result;
29
+ }
30
+
31
+ uniform vec3 sh[ 9 ]; // sh coefficients
32
+ uniform float intensity; // light probe intensity
33
+ varying vec3 vNormal;
34
+
35
+ void main() {
36
+ vec3 normal = normalize( vNormal );
37
+ vec3 worldNormal = normalize(inverseTransformDirection( normal, viewMatrix ));
38
+ vec3 irradiance = shGetIrradianceAt( worldNormal, sh );
39
+ vec3 outgoingLight = 1.0 * irradiance * intensity;
40
+ gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );
41
+ }
@@ -0,0 +1,9 @@
1
+ varying vec3 vNormal;
2
+
3
+ void main() {
4
+
5
+ vNormal = normalize( normalMatrix * normal );
6
+
7
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
8
+
9
+ }
@@ -3,7 +3,7 @@ import Entity from "../../ecs/Entity.js";
3
3
  import { Transform } from "../../ecs/transform/Transform.js";
4
4
  import { ShadedGeometry } from "../ecs/mesh-v2/ShadedGeometry.js";
5
5
  import { ShadedGeometryFlags } from "../ecs/mesh-v2/ShadedGeometryFlags.js";
6
- import { SH3VisualisationMaterial } from "./SH3VisualisationMaterial.js";
6
+ import { SH3VisualisationMaterial } from "./shader/SH3VisualisationMaterial.js";
7
7
 
8
8
  const geometry = new OctahedronBufferGeometry(1, 5);
9
9
 
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Useful tool for previewing textures
3
+ * @param {THREE.Texture} texture
4
+ * @param {number} resolution
5
+ * @param {boolean} flipY
6
+ */
7
+ export function debug_preview_texture({ texture, resolution, flipY }: THREE.Texture): void;
8
+ //# sourceMappingURL=debug_preview_texture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug_preview_texture.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/debug_preview_texture.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,sEAJW,MAAM,OAAO,QA+BvB"}