@woosh/meep-engine 2.109.6 → 2.109.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +203 -174
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +203 -174
  5. package/editor/tools/v2/TransformControls.js +39 -33
  6. package/package.json +1 -1
  7. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  8. package/src/core/bvh2/bvh3/BVH.js +8 -0
  9. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  10. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +11 -9
  11. package/src/core/geom/3d/Ray3.js +1 -1
  12. package/src/core/geom/3d/aabb/AABB3.js +1 -1
  13. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +4 -4
  14. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  15. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +15 -11
  16. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.d.ts.map +1 -1
  17. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +13 -7
  18. package/src/core/geom/3d/normal/octahedron/encoding.spec.js +26 -1
  19. package/src/core/geom/3d/normal/octahedron/prototype.d.ts +2 -0
  20. package/src/core/geom/3d/normal/octahedron/prototype.d.ts.map +1 -0
  21. package/src/core/geom/3d/normal/octahedron/prototype.js +226 -0
  22. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.d.ts +1 -1
  23. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_bl.js +4 -4
  24. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +3 -3
  25. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  26. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +10 -5
  27. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +7 -1
  28. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -1
  29. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +6 -0
  30. package/src/core/geom/vec3/v3_distance.d.ts.map +1 -1
  31. package/src/core/geom/vec3/v3_distance.js +5 -5
  32. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts +10 -0
  33. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.d.ts.map +1 -0
  34. package/src/core/geometry/3d/tetrahedra/tetrahedral_mesh_find_tets_attached_to_vertex.js +34 -0
  35. package/src/core/model/node-graph/DataType.d.ts.map +1 -1
  36. package/src/core/model/node-graph/DataType.js +16 -10
  37. package/src/core/model/node-graph/ParametricDataType.d.ts +34 -0
  38. package/src/core/model/node-graph/ParametricDataType.d.ts.map +1 -0
  39. package/src/core/model/node-graph/ParametricDataType.js +63 -0
  40. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts +5 -1
  41. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.d.ts.map +1 -1
  42. package/src/core/model/node-graph/json/serializeNodeGraphToJSON.js +11 -6
  43. package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
  44. package/src/engine/asset/loaders/AssetLoader.js +1 -1
  45. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  46. package/src/engine/asset/loaders/material/computeTextureEquality.js +6 -1
  47. package/src/engine/asset/loaders/material/computeTextureHash.d.ts.map +1 -1
  48. package/src/engine/asset/loaders/material/computeTextureHash.js +8 -3
  49. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.d.ts.map +1 -1
  50. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +9 -15
  51. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts +7 -0
  52. package/src/engine/graphics/geometry/instancing/geometry_copy.d.ts.map +1 -0
  53. package/src/engine/graphics/geometry/instancing/geometry_copy.js +15 -0
  54. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
  55. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -20
  56. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts +1 -0
  57. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.d.ts.map +1 -1
  58. package/src/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +4 -0
  59. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +6 -6
  60. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +16 -7
  61. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +3 -2
  62. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
  63. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +25 -14
  64. package/src/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +1 -0
  65. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  66. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +59 -37
  67. package/src/engine/graphics/sh3/gi/material/common.glsl +484 -0
  68. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts +8 -0
  69. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.d.ts.map +1 -0
  70. package/src/engine/graphics/sh3/gi/material/makeLookupTexture3D.js +35 -0
  71. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts +8 -0
  72. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -0
  73. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +28 -0
  74. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.d.ts.map +1 -0
  75. package/src/engine/graphics/sh3/gi/material/space_fragment/build_fragment_shader.js +51 -0
  76. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.d.ts.map +1 -0
  77. package/src/engine/graphics/sh3/gi/material/space_fragment/build_vertex_shader.js +29 -0
  78. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts +9 -0
  79. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.d.ts.map +1 -0
  80. package/src/engine/graphics/sh3/gi/material/space_fragment/space_fragment_transform_shader.js +12 -0
  81. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts +6 -0
  82. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.d.ts.map +1 -0
  83. package/src/engine/graphics/sh3/gi/material/space_vertex/build_fragment_shader.js +26 -0
  84. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts +6 -0
  85. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.d.ts.map +1 -0
  86. package/src/engine/graphics/sh3/gi/material/space_vertex/build_vertex_shader.js +62 -0
  87. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.frag.glsl +43 -0
  88. package/src/engine/graphics/sh3/gi/material/space_vertex/preable.vert.glsl +9 -0
  89. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts +9 -0
  90. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.d.ts.map +1 -0
  91. package/src/engine/graphics/sh3/gi/material/space_vertex/space_vertex_transform_shader.js +12 -0
  92. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +2 -0
  93. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  94. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +35 -3
  95. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
  96. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +26 -9
  97. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +11 -1
  98. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  99. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +27 -61
  100. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  101. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +8 -6
  102. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts +17 -0
  103. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.d.ts.map +1 -0
  104. package/src/engine/graphics/sh3/lpv/depth/octahedral/OctahedralDepthDebuggerWidget.js +100 -0
  105. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts +12 -0
  106. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -0
  107. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +58 -0
  108. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts +11 -0
  109. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.d.ts.map +1 -0
  110. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/OctahedralDepthVisualizationMaterial.js +45 -0
  111. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.frag.glsl +126 -0
  112. package/src/engine/graphics/sh3/lpv/depth/octahedral/shader/visualize.vert.glsl +10 -0
  113. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts +13 -0
  114. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.d.ts.map +1 -0
  115. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/VLPDepthMapVisualisation.js +149 -0
  116. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +161 -0
  117. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.vert.glsl +13 -0
  118. package/src/engine/graphics/sh3/lpv/depth/sh3_bake_depth.d.ts.map +1 -0
  119. package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.js → depth/sh3_bake_depth.js} +7 -7
  120. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts +8 -0
  121. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.d.ts.map +1 -0
  122. package/src/engine/graphics/sh3/lpv/find_max_depth_radius_for_point.js +50 -0
  123. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +3 -6
  124. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  125. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +34 -58
  126. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -1
  127. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +8 -0
  128. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +2 -2
  129. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  130. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +8 -5
  131. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts +7 -0
  132. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.d.ts.map +1 -0
  133. package/src/engine/graphics/sh3/path_tracer/populate_path_traced_scene_from_ecd.js +50 -0
  134. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +40 -3
  135. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  136. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.js → sorting/build_bvh_nodes_distances_along_ray.js} +2 -2
  137. package/src/engine/graphics/sh3/path_tracer/sorting/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  138. package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.js → sorting/build_bvh_nodes_distances_sqr_to_point.js} +2 -2
  139. package/src/engine/graphics/sh3/path_tracer/sorting/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  140. package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.js → sorting/sort_bvh_nodes_by_distance_to_point.js} +3 -3
  141. package/src/engine/graphics/sh3/prototypeSH3Probe.js +41 -8
  142. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.d.ts.map +1 -0
  143. package/src/engine/graphics/sh3/shader/SH3VisualisationMaterial.js +29 -0
  144. package/src/engine/graphics/sh3/shader/visualize.frag.glsl +41 -0
  145. package/src/engine/graphics/sh3/shader/visualize.vert.glsl +9 -0
  146. package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +1 -1
  147. package/src/engine/graphics/texture/debug_preview_texture.d.ts +8 -0
  148. package/src/engine/graphics/texture/debug_preview_texture.d.ts.map +1 -0
  149. package/src/engine/graphics/texture/debug_preview_texture.js +38 -0
  150. package/src/view/View.d.ts.map +1 -1
  151. package/src/view/View.js +2 -0
  152. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts +0 -8
  153. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.d.ts.map +0 -1
  154. package/src/core/geom/3d/sphere/harmonics/sh3_rotate_filament.js +0 -32
  155. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +0 -8
  156. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +0 -1
  157. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +0 -44
  158. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +0 -8
  159. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +0 -1
  160. package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +0 -86
  161. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +0 -1
  162. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +0 -83
  163. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +0 -1
  164. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +0 -71
  165. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +0 -1
  166. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +0 -256
  167. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +0 -1
  168. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +0 -1
  169. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +0 -1
  170. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts +0 -2
  171. package/src/engine/graphics/sh3/path_tracer/ray_reflect.d.ts.map +0 -1
  172. package/src/engine/graphics/sh3/path_tracer/ray_reflect.js +0 -27
  173. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +0 -1
  174. /package/src/engine/graphics/sh3/gi/material/{build_fragment_shader.d.ts → space_fragment/build_fragment_shader.d.ts} +0 -0
  175. /package/src/engine/graphics/sh3/gi/material/{build_vertex_shader.d.ts → space_fragment/build_vertex_shader.d.ts} +0 -0
  176. /package/src/engine/graphics/sh3/lpv/{sh3_bake_depth.d.ts → depth/sh3_bake_depth.d.ts} +0 -0
  177. /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_along_ray.d.ts → sorting/build_bvh_nodes_distances_along_ray.d.ts} +0 -0
  178. /package/src/engine/graphics/sh3/path_tracer/{build_bvh_nodes_distances_sqr_to_point.d.ts → sorting/build_bvh_nodes_distances_sqr_to_point.d.ts} +0 -0
  179. /package/src/engine/graphics/sh3/path_tracer/{sort_bvh_nodes_by_distance_to_point.d.ts → sorting/sort_bvh_nodes_by_distance_to_point.d.ts} +0 -0
  180. /package/src/engine/graphics/sh3/{SH3VisualisationMaterial.d.ts → shader/SH3VisualisationMaterial.d.ts} +0 -0
@@ -1,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"}