@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,86 +0,0 @@
1
- /**
2
- * Math.sqrt(3)
3
- * @type {number}
4
- */
5
- const SQRT_3 = 1.7320508075688772;
6
-
7
- /**
8
- *
9
- * @param {number[]|Float32Array} M 5x5 matrix
10
- * @param {number[]} x vec5
11
- * @return {number[]} vec5
12
- */
13
- function multiply_5d(M, x) {
14
- return [
15
- M[0] * x[0] + M[5] * x[1] + M[10] * x[2] + M[15] * x[3] + M[20] * x[4],
16
- M[1] * x[0] + M[6] * x[1] + M[11] * x[2] + M[16] * x[3] + M[21] * x[4],
17
- M[2] * x[0] + M[7] * x[1] + M[12] * x[2] + M[17] * x[3] + M[22] * x[4],
18
- M[3] * x[0] + M[8] * x[1] + M[13] * x[2] + M[18] * x[3] + M[23] * x[4],
19
- M[4] * x[0] + M[9] * x[1] + M[14] * x[2] + M[19] * x[3] + M[24] * x[4]
20
- ];
21
- }
22
-
23
- /**
24
- * This projects a vec3 to SH2/k space (i.e. we premultiply by 1/k)
25
- * these are second band SH factors, multiplied by 1/K ( K = Math.sqrt(15) / (2*Math.sqrt(Math.PI)) )
26
- * @param {number[]|Float32Array} output
27
- * @param {number} output_offset
28
- * @param {number} x
29
- * @param {number} y
30
- * @param {number} z
31
- */
32
- function project_v3_to_sh2k(output, output_offset, x, y, z) {
33
- output[output_offset] = (y * x)
34
- output[output_offset + 1] = -(y * z)
35
- output[output_offset + 2] = 0.28867513459481287 * (3 * z * z - 1)
36
- output[output_offset + 3] = -(z * x)
37
- output[output_offset + 4] = 0.5 * (x * x - y * y)
38
- }
39
-
40
- /**
41
- *
42
- * @param {number[]} band2 vec5
43
- * @param {number[]} M mat3
44
- * @return {number[]} vec5
45
- */
46
- export function sh_rotate_band2(band2, M) {
47
- const n = Math.SQRT1_2;
48
-
49
- // Below we precompute (with help of Mathematica):
50
- // constexpr float3 N0{ 1, 0, 0 };
51
- // constexpr float3 N1{ 0, 0, 1 };
52
- // constexpr float3 N2{ n, n, 0 };
53
- // constexpr float3 N3{ n, 0, n };
54
- // constexpr float3 N4{ 0, n, n };
55
- // constexpr float M_SQRT_PI = 1.7724538509f;
56
- // constexpr float M_SQRT_15 = 3.8729833462f;
57
- // constexpr float k = M_SQRT_15 / (2.0f * M_SQRT_PI);
58
- // --> k * inverse(mat5{project(N0), project(N1), project(N2), project(N3), project(N4)})
59
- const invATimesK = [
60
- 0, 1, 2, 0, 0,
61
- -1, 0, 0, 0, -2,
62
- 0, SQRT_3, 0, 0, 0,
63
- 1, 1, 0, -2, 0,
64
- 2, 1, 0, 0, 0
65
- ];
66
-
67
- // this is: invA * k * band2
68
- // 5x5 matrix by vec5 (this a lot of zeroes and constants, which the compiler should eliminate)
69
- const invATimesKTimesBand2 = multiply_5d(invATimesK, band2);
70
-
71
- // this is: mat5{project(N0), project(N1), project(N2), project(N3), project(N4)} / k
72
- // (the 1/k comes from project(), see above)
73
- const ROverK = new Float32Array(25);
74
-
75
- project_v3_to_sh2k(ROverK, 0, M[0], M[1], M[2]) // M * N0
76
- project_v3_to_sh2k(ROverK, 5, M[6], M[7], M[8]) // M * N1
77
- project_v3_to_sh2k(ROverK, 10, n * (M[0] + M[3]), n * (M[1] + M[4]), n * (M[2] + M[5])) // M * N2
78
- project_v3_to_sh2k(ROverK, 15, n * (M[0] + M[6]), n * (M[1] + M[7]), n * (M[2] + M[8])) // M * N3
79
- project_v3_to_sh2k(ROverK, 20, n * (M[3] + M[6]), n * (M[4] + M[7]), n * (M[5] + M[8])) // M * N4;
80
-
81
- // notice how "k" disappears
82
- // this is: (R / k) * (invA * k) * band2 == R * invA * band2
83
- const result = multiply_5d(ROverK, invATimesKTimesBand2);
84
-
85
- return result;
86
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"SH3VisualisationMaterial.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/sh3/SH3VisualisationMaterial.js"],"names":[],"mappings":"AA0DA;IAEI,cAoBC;CAEJ;+BAlFuC,OAAO"}
@@ -1,83 +0,0 @@
1
- import { ShaderMaterial, Vector3 } from "three";
2
-
3
- const shader_vx = `
4
- varying vec3 vNormal;
5
-
6
- void main() {
7
-
8
- vNormal = normalize( normalMatrix * normal );
9
-
10
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
11
-
12
- }
13
- `;
14
-
15
- const shader_fg = `
16
- #define RECIPROCAL_PI 0.318309886
17
-
18
- vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
19
- // matrix is assumed to be orthogonal
20
- return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
21
- }
22
-
23
- // source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
24
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
25
- // normal is assumed to have unit length
26
- float x = normal.x, y = normal.y, z = normal.z;
27
-
28
- // band 0
29
- vec3 result = shCoefficients[ 0 ] * 0.8862269254527579;
30
-
31
- // band 1
32
- result -= shCoefficients[ 1 ] * 1.0233267079464885 * y;
33
- result += shCoefficients[ 2 ] * 1.0233267079464885 * z;
34
- result -= shCoefficients[ 3 ] * 1.0233267079464885 * x;
35
-
36
- // band 2
37
- result += shCoefficients[ 4 ] * 0.8580855308097834 * x * y;
38
- result -= shCoefficients[ 5 ] * 0.8580855308097834 * y * z;
39
- result += shCoefficients[ 6 ] * ( 0.7431238683011272 * z * z - 0.24770795610037571 );
40
- result -= shCoefficients[ 7 ] * 0.8580855308097834 * x * z;
41
- result += shCoefficients[ 8 ] * 0.4290427654048917 * ( x * x - y * y );
42
-
43
- return result;
44
- }
45
-
46
- uniform vec3 sh[ 9 ]; // sh coefficients
47
- uniform float intensity; // light probe intensity
48
- varying vec3 vNormal;
49
-
50
- void main() {
51
- vec3 normal = normalize( vNormal );
52
- vec3 worldNormal = normalize(inverseTransformDirection( normal, viewMatrix ));
53
- vec3 irradiance = shGetIrradianceAt( worldNormal, sh );
54
- vec3 outgoingLight = 1.0 * irradiance * intensity;
55
- gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );
56
- }
57
- `;
58
-
59
- export class SH3VisualisationMaterial extends ShaderMaterial {
60
-
61
- constructor() {
62
- const sh = [];
63
-
64
- for (let i = 0; i < 9; i++) {
65
- sh.push(new Vector3());
66
- }
67
-
68
- super({
69
- fragmentShader: shader_fg,
70
- vertexShader: shader_vx,
71
- lights: false,
72
- uniforms: {
73
- intensity: {
74
- value: 1,
75
- },
76
- sh: {
77
- value: sh
78
- }
79
- }
80
- })
81
- }
82
-
83
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_fragment_shader.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/build_fragment_shader.js"],"names":[],"mappings":"AAsDA;;;GAGG;AACH,8CAFW,MAAM,UAchB"}
@@ -1,71 +0,0 @@
1
- import { insert_after } from "../../../../../core/primitives/strings/insert_after.js";
2
-
3
- const PREAMBLE = `
4
-
5
- uniform float lpv_f_intensity;
6
-
7
- varying vec3[9] lpv_values;
8
-
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.886227;
15
- //
16
- // // band 1
17
- // result -= shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
18
- // result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
19
- // result -= shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
20
- //
21
- // // band 2
22
- // result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
23
- // result -= shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
24
- // result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
25
- // result -= shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
26
- // result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
27
- //
28
- // return result;
29
- // }
30
- //
31
- // vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
32
- //
33
- // // matrix is assumed to be orthogonal
34
- //
35
- // return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
36
- //
37
- // }
38
- //
39
- // vec3 lpv_getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
40
- //
41
- // vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
42
- //
43
- // vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
44
- //
45
- // return irradiance;
46
- //
47
- // }
48
- `;
49
-
50
- const ACCUMULATION = `
51
- irradiance += getLightProbeIrradiance(lpv_values, geometryNormal )* lpv_f_intensity;
52
- `;
53
-
54
-
55
- /**
56
- *
57
- * @param {string} source
58
- */
59
- export function build_fragment_shader(source) {
60
-
61
- let result = PREAMBLE + source;
62
-
63
-
64
- result = insert_after(
65
- result,
66
- '#include <lights_fragment_begin>',
67
- ACCUMULATION
68
- );
69
-
70
- return result;
71
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_vertex_shader.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/gi/material/build_vertex_shader.js"],"names":[],"mappings":"AA+OA;;;GAGG;AACH,4CAFW,MAAM,UAchB"}
@@ -1,256 +0,0 @@
1
- import { insert_after } from "../../../../../core/primitives/strings/insert_after.js";
2
-
3
- const PREAMBLE = `
4
- #ifndef LPV_SHADER_CHUNK_PREAMBLE
5
- #define LPV_SHADER_CHUNK_PREAMBLE
6
-
7
- precision highp usampler2D;
8
- precision highp usampler3D;
9
-
10
- uniform usampler2D lpv_t_mesh_vertices;
11
- uniform usampler2D lpv_t_mesh_neighbours;
12
- uniform usampler3D lpv_t_mesh_lookup;
13
-
14
- uniform sampler2D lpv_t_probe_positions;
15
- uniform sampler2D lpv_t_probe_data;
16
-
17
- uniform uint lpv_u_mesh_tet_count;
18
- uniform vec3 lpv_v3_bounds_min;
19
- uniform vec3 lpv_v3_bounds_max;
20
-
21
- varying vec3[9] lpv_values;
22
-
23
- #define SEARCH_STEP_LIMIT 64u
24
- #define INVALID_TET 1073741823u
25
-
26
- ivec2 lpv_index_to_256_coordinate(uint index){
27
-
28
- uint pixel_x = index % 256u;
29
- uint pixel_y = index / 256u;
30
-
31
- return ivec2(int(pixel_x), int(pixel_y));
32
- }
33
-
34
- uvec4 lpv_mesh_getVertices(uint tet_index){
35
- ivec2 p = lpv_index_to_256_coordinate(tet_index);
36
-
37
- return texelFetch(lpv_t_mesh_vertices, p, 0);
38
-
39
- }
40
-
41
- uvec4 lpv_mesh_getNeighbours(uint tet_index){
42
- ivec2 p = lpv_index_to_256_coordinate(tet_index);
43
-
44
- return texelFetch(lpv_t_mesh_neighbours, p, 0);
45
- }
46
-
47
- vec3[9] lpv_probe_getData(uint probe_index){
48
-
49
-
50
- int slot = int( probe_index % 256u );
51
- int column = int(probe_index / 256u);
52
-
53
- int offset_x = int(slot * 9);
54
-
55
- vec3[9] result;
56
-
57
- for(int i=0; i<9; i++){
58
- result[i] = texelFetch(lpv_t_probe_data, ivec2(offset_x + i, column),0).rgb;
59
- }
60
-
61
- return result;
62
- }
63
-
64
- vec3 lpv_probe_getPosition(uint probe_index){
65
- return texelFetch(lpv_t_probe_positions, lpv_index_to_256_coordinate(probe_index), 0).rgb;
66
- }
67
-
68
- mat3 lpv_mesh_makeMatrix(vec3 p0, vec3 p1, vec3 p2, vec3 p3){
69
-
70
- return inverse(
71
- mat3(
72
- p0 - p3,
73
- p1 - p3,
74
- p2 - p3
75
- )
76
- );
77
-
78
- }
79
-
80
- vec4 lpv_mesh_getBarycentricCoordinates(uint tet_index, vec3 position){
81
- uvec4 vertices = lpv_mesh_getVertices(tet_index);
82
-
83
- vec3 p0 = lpv_probe_getPosition(vertices[0]);
84
- vec3 p1 = lpv_probe_getPosition(vertices[1]);
85
- vec3 p2 = lpv_probe_getPosition(vertices[2]);
86
- vec3 p3 = lpv_probe_getPosition(vertices[3]);
87
-
88
- mat3 matrix = lpv_mesh_makeMatrix(p0, p1, p2, p3);
89
-
90
- vec3 mult = matrix * (position - p3);
91
-
92
- return vec4(mult, 1.0 - mult.x - mult.y - mult.z);
93
- }
94
-
95
- void lpv_getTetrahedron(
96
- in vec3 position ,
97
- in uint tet_guess,
98
- out uint tet_index,
99
- out vec4 weights
100
- ){
101
- uint came_from = 0u;
102
-
103
- tet_index = tet_guess;
104
-
105
- for(uint i=0u; i < SEARCH_STEP_LIMIT; i++){
106
-
107
- weights = lpv_mesh_getBarycentricCoordinates(tet_index, position);
108
-
109
- if(weights.x >= 0.0 && weights.y >= 0.0 && weights.z >= 0.0 && weights.w >= 0.0){
110
- return;
111
- }
112
-
113
- uvec4 neighbors = lpv_mesh_getNeighbours(tet_index);
114
-
115
- uint next_tet;
116
-
117
- // Otherwise find the smallest barycentric coord and move in that direction
118
- if (weights.x < weights.y && weights.x < weights.z && weights.x < weights.w) {
119
- next_tet = neighbors[0];
120
- } else if (weights.y < weights.z && weights.y < weights.w) {
121
- next_tet = neighbors[1];
122
- } else if (weights.z < weights.w) {
123
- next_tet = neighbors[2];
124
- } else {
125
- next_tet = neighbors[3];
126
- }
127
-
128
- if(next_tet == came_from){
129
- // numerical instability caused us to oscillate on the boundary
130
- return;
131
- }
132
-
133
- came_from = tet_index;
134
- tet_index = next_tet;
135
- }
136
-
137
- tet_index = INVALID_TET;
138
- }
139
-
140
- vec3[9] lpv_interpolate_probes(vec4 weights, uint tet_index){
141
-
142
- uvec4 vertices = lpv_mesh_getVertices(tet_index);
143
-
144
- vec3[9] probe0 = lpv_probe_getData(vertices[0]);
145
- vec3[9] probe1 = lpv_probe_getData(vertices[1]);
146
- vec3[9] probe2 = lpv_probe_getData(vertices[2]);
147
- vec3[9] probe3 = lpv_probe_getData(vertices[3]);
148
-
149
- vec3[9] result;
150
-
151
- for(int i=0; i< 9; i++){
152
-
153
- result[i] = probe0[i]* weights[0]
154
- + probe1[i]* weights[1]
155
- + probe2[i]* weights[2]
156
- + probe3[i]* weights[3];
157
-
158
- }
159
-
160
- return result;
161
- }
162
-
163
- vec4 lpv_bias_weight_by_normal(const in vec3 position, const in vec3 normal, const in uint tet_index, const in vec4 weights){
164
-
165
- uvec4 vertices = lpv_mesh_getVertices(tet_index);
166
-
167
- vec4 result = weights;
168
-
169
- for(int i = 0; i< 4; i++){
170
- vec3 p = lpv_probe_getPosition(vertices[i]) - position;
171
-
172
- if(dot(normal, p) <= 0.0){
173
- // behind the surface, bias to 0
174
- result[i] = 0.0;
175
- }
176
- }
177
-
178
- float total_weight = result.x + result.y + result.z + result.w;
179
-
180
- // needs to add up to 1
181
- result = result / total_weight;
182
-
183
- return result;
184
- }
185
-
186
- uint lpv_guess_initial_tet(vec3 position){
187
-
188
- vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
189
- vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
190
-
191
- vec3 lookup_coordinates = (position - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min) ;
192
-
193
- return textureLod( lpv_t_mesh_lookup, lookup_coordinates, 0.0 ).r;
194
-
195
- }
196
-
197
- #endif
198
- `;
199
-
200
-
201
- const SHADER_CHUNK_ACCUMULATION = `
202
- {
203
- // lookup nearby tet
204
- vec3 lpv_mesh_bounds_min = lpv_v3_bounds_min;
205
- vec3 lpv_mesh_bounds_max = lpv_v3_bounds_max;
206
- vec3 lookup_coordinates = (worldPosition.xyz - lpv_mesh_bounds_min) / (lpv_mesh_bounds_max - lpv_mesh_bounds_min) ;
207
-
208
- uint nearest_tet = lpv_guess_initial_tet( worldPosition.xyz );
209
-
210
- uint tet;
211
- vec4 weights;
212
- lpv_getTetrahedron(worldPosition.xyz, nearest_tet, tet, weights);
213
-
214
-
215
- if(tet == INVALID_TET){
216
- lpv_values = vec3[](
217
- vec3(0.0, 0.0, 0.0),
218
- vec3(0.0, 0.0, 0.0),
219
- vec3(0.0, 0.0, 0.0),
220
-
221
- vec3(0.0, 0.0, 0.0),
222
- vec3(0.0, 0.0, 0.0),
223
- vec3(0.0, 0.0, 0.0),
224
-
225
- vec3(0.0, 0.0, 0.0),
226
- vec3(0.0, 0.0, 0.0),
227
- vec3(0.0, 0.0, 0.0)
228
- );
229
- }else{
230
-
231
- vec3 worldNormal = normalize(inverseTransformDirection( normalize(normal), viewMatrix ));
232
-
233
- //weights = lpv_bias_weight_by_normal(worldPosition.xyz, normal, tet, weights);
234
-
235
- lpv_values = lpv_interpolate_probes(weights, tet);
236
- }
237
- }
238
- `
239
-
240
- /**
241
- *
242
- * @param {string} source
243
- */
244
- export function build_vertex_shader(source) {
245
- let result = PREAMBLE + source;
246
-
247
- result = insert_after(
248
- result,
249
- '#include <fog_vertex>',
250
- SHADER_CHUNK_ACCUMULATION
251
- );
252
-
253
- // console.log(result)
254
-
255
- return result;
256
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"sh3_bake_depth.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/sh3_bake_depth.js"],"names":[],"mappings":"AAQA;;;;;;;;;;GAUG;AACH,uCATW,MAAM,EAAE,iBACR,MAAM,sCAEN,MAAM,cACN,MAAM,cACN,MAAM,cACN,MAAM,eACN,MAAM,QAsDhB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_bvh_nodes_distances_along_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/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 +0,0 @@
1
- {"version":3,"file":"build_bvh_nodes_distances_sqr_to_point.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ray_reflect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ray_reflect.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/ray_reflect.js"],"names":[],"mappings":""}
@@ -1,27 +0,0 @@
1
- import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
2
-
3
- /**
4
- *
5
- * @param {number[]} out
6
- * @param {number} output_offset
7
- * @param {number[]} v
8
- * @param {number} input_offset
9
- * @param {number[]} n
10
- * @param {number} normal_offset
11
- */
12
- function ray_reflect(out, output_offset, v, input_offset, n, normal_offset) {
13
- const input_x = v[0 + input_offset];
14
- const input_y = v[1 + input_offset];
15
- const input_z = v[2 + input_offset];
16
-
17
- const nx = n[normal_offset + 0];
18
- const ny = n[normal_offset + 1];
19
- const nz = n[normal_offset + 2];
20
-
21
- const dot = v3_dot(input_x, input_y, input_z, nx, ny, nz);
22
-
23
- out[output_offset + 0] = input_x - 2 * dot * nx;
24
- out[output_offset + 1] = input_y - 2 * dot * ny;
25
- out[output_offset + 2] = input_z - 2 * dot * nz;
26
-
27
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"sort_bvh_nodes_by_distance_to_point.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/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"}