@woosh/meep-engine 3.78.2 → 3.78.4

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 (278) hide show
  1. package/CHANGELOG.md +46 -13
  2. package/editor/view/node-graph/NodeGraphView.d.ts +1 -1
  3. package/editor/view/node-graph/NodeGraphView.js +1 -1
  4. package/package.json +1 -1
  5. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +2 -1
  6. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -1
  7. package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +2 -1
  8. package/src/core/math/snap_to_integer.d.ts +13 -0
  9. package/src/core/math/snap_to_integer.d.ts.map +1 -0
  10. package/src/core/math/snap_to_integer.js +20 -0
  11. package/src/core/model/node-graph/NodeGraph.d.ts +0 -1
  12. package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
  13. package/src/core/model/node-graph/NodeGraph.js +0 -1
  14. package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
  15. package/src/engine/asset/loaders/GroomAssetLoader.js +2 -1
  16. package/src/engine/graphics/hair/Groom.d.ts +30 -0
  17. package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
  18. package/src/engine/graphics/hair/Groom.js +35 -0
  19. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +18 -2
  20. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
  21. package/src/engine/graphics/hair/GroomSerializationAdapter.js +36 -6
  22. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.d.ts +8 -0
  23. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.d.ts.map +1 -0
  24. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.js +44 -0
  25. package/src/engine/graphics/hair/groom_bake_shelter.d.ts +33 -0
  26. package/src/engine/graphics/hair/groom_bake_shelter.d.ts.map +1 -0
  27. package/src/engine/graphics/hair/groom_bake_shelter.js +288 -0
  28. package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +1 -1
  29. package/src/engine/graphics/hair/groom_bind_to_mesh.js +1 -1
  30. package/src/engine/graphics/hair/groom_build_group.d.ts +10 -2
  31. package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
  32. package/src/engine/graphics/hair/groom_build_group.js +8 -2
  33. package/src/engine/graphics/hair/groom_build_guides.d.ts +1 -1
  34. package/src/engine/graphics/hair/groom_build_guides.js +1 -1
  35. package/src/engine/graphics/impostors/voxel/README.md +11 -11
  36. package/src/engine/physics/cloth/collider/ClothColliderKind.js +1 -1
  37. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts +1 -1
  38. package/src/engine/physics/cloth/ecs/cloth_geodesic.js +1 -1
  39. package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.d.ts +2 -3
  40. package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.d.ts.map +1 -1
  41. package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.js +2 -3
  42. package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts +0 -2
  43. package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts.map +1 -1
  44. package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +0 -5
  45. package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.d.ts.map +1 -1
  46. package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.js +5 -3
  47. package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.d.ts.map +1 -1
  48. package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +5 -3
  49. package/src/generation/grid/coords/grid_to_texel.d.ts +7 -1
  50. package/src/generation/grid/coords/grid_to_texel.d.ts.map +1 -1
  51. package/src/generation/grid/coords/grid_to_texel.js +11 -1
  52. package/src/generation/grid/coords/grid_to_texel_span.d.ts +15 -0
  53. package/src/generation/grid/coords/grid_to_texel_span.d.ts.map +1 -0
  54. package/src/generation/grid/coords/grid_to_texel_span.js +38 -0
  55. package/src/generation/grid/coords/texel_to_grid.d.ts +2 -1
  56. package/src/generation/grid/coords/texel_to_grid.d.ts.map +1 -1
  57. package/src/generation/grid/coords/texel_to_grid.js +6 -1
  58. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts +32 -1
  59. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts.map +1 -1
  60. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js +114 -9
  61. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts +8 -0
  62. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
  63. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +91 -29
  64. package/src/generation/grid/layers/GridDataLayer.d.ts +21 -2
  65. package/src/generation/grid/layers/GridDataLayer.d.ts.map +1 -1
  66. package/src/generation/grid/layers/GridDataLayer.js +43 -4
  67. package/src/generation/placement/action/GridCellActionPlaceTags.d.ts +7 -1
  68. package/src/generation/placement/action/GridCellActionPlaceTags.d.ts.map +1 -1
  69. package/src/generation/placement/action/GridCellActionPlaceTags.js +42 -16
  70. package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts +5 -0
  71. package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts.map +1 -1
  72. package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +32 -9
  73. package/src/generation/rules/CellMatcherLayerBitMaskTest.d.ts.map +1 -1
  74. package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -2
  75. package/src/generation/wfc/GridWFCCompiledTileSet.d.ts +4 -2
  76. package/src/generation/wfc/GridWFCCompiledTileSet.d.ts.map +1 -1
  77. package/src/generation/wfc/GridWFCCompiledTileSet.js +2 -2
  78. package/src/generation/wfc/GridWFCTileSet.d.ts +16 -7
  79. package/src/generation/wfc/GridWFCTileSet.d.ts.map +1 -1
  80. package/src/generation/wfc/GridWFCTileSet.js +32 -8
  81. package/src/shade/playground/contact_shadows/shader_contact_lab_composite.js +2 -2
  82. package/src/shade/playground/particle_editor/README.md +2 -2
  83. package/src/shade/playground/probe_clipmap/index.html +1 -1
  84. package/src/shade/playground/screen_probes/README.md +5 -5
  85. package/src/shade/playground/screen_probes/main.js +1 -1
  86. package/src/shade/playground/tonemap_sdr/README.md +3 -2
  87. package/src/shade/playground/vgeo_scene/README.md +1 -3
  88. package/src/shade/playground/vgeo_scene/main.js +3 -3
  89. package/src/shade/renderer/Renderer.d.ts +3 -3
  90. package/src/shade/renderer/Renderer.js +4 -4
  91. package/src/shade/renderer/ShadeIndirectLightingMode.js +1 -1
  92. package/src/shade/renderer/camera/PerspectiveCamera.js +1 -1
  93. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +11 -13
  94. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
  95. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +11 -13
  96. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -1
  97. package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +6 -7
  98. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +1 -1
  99. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +1 -1
  100. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +6 -8
  101. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -1
  102. package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +7 -10
  103. package/src/shade/renderer/geometry/sdf/MESH_SDF.d.ts +1 -1
  104. package/src/shade/renderer/geometry/sdf/MESH_SDF.js +1 -1
  105. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.d.ts +1 -1
  106. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.js +1 -1
  107. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.d.ts +1 -1
  108. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.js +1 -1
  109. package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts +1 -2
  110. package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts.map +1 -1
  111. package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.js +1 -2
  112. package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.d.ts.map +1 -1
  113. package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.js +2 -1
  114. package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.d.ts +1 -1
  115. package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.js +1 -1
  116. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster_graph.js +1 -1
  117. package/src/shade/renderer/geometry/virtual/format/page/VGEO_DEFAULT_PAGE_SIZE.d.ts +2 -2
  118. package/src/shade/renderer/geometry/virtual/format/page/VGEO_DEFAULT_PAGE_SIZE.js +2 -2
  119. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_access.d.ts +2 -2
  120. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_access.js +4 -4
  121. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.d.ts +1 -1
  122. package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.js +1 -1
  123. package/src/shade/renderer/geometry/virtual/runtime/cut/shader_vgeo_cut_collect.js +1 -1
  124. package/src/shade/renderer/geometry/virtual/runtime/layout/VGEO_INSTANCE_OFFSET.d.ts +3 -3
  125. package/src/shade/renderer/geometry/virtual/runtime/layout/VGEO_INSTANCE_OFFSET.js +3 -3
  126. package/src/shade/renderer/global_illumination/brick4/README.md +2 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +4 -6
  128. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  129. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +4 -6
  130. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_MOVERS.d.ts +1 -1
  131. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_MOVERS.js +1 -1
  132. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +1 -1
  133. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +2 -2
  134. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts +1 -1
  135. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.js +1 -1
  136. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +1 -1
  137. package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +1 -1
  138. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +28 -35
  139. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
  140. package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +28 -35
  141. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +21 -24
  142. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
  143. package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +21 -24
  144. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts +8 -8
  145. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +8 -8
  146. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts +4 -4
  147. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.js +4 -4
  148. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts +3 -5
  149. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts.map +1 -1
  150. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.js +3 -5
  151. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts +4 -4
  152. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.js +4 -4
  153. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +2 -3
  154. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -1
  155. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +2 -3
  156. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts +4 -4
  157. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.js +4 -4
  158. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts +2 -4
  159. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts.map +1 -1
  160. package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.js +2 -4
  161. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts +2 -4
  162. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts.map +1 -1
  163. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.js +2 -4
  164. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +13 -17
  165. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
  166. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +13 -17
  167. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts +11 -14
  168. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts.map +1 -1
  169. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.js +11 -14
  170. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts +2 -2
  171. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.js +2 -2
  172. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts +9 -9
  173. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.js +9 -9
  174. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +15 -18
  175. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
  176. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +16 -19
  177. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts +10 -11
  178. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts.map +1 -1
  179. package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.js +11 -12
  180. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  181. package/src/shade/renderer/hair/GPUHairSystem.js +27 -2
  182. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
  183. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +4 -0
  184. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +27 -6
  185. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -1
  186. package/src/shade/renderer/hair/HAIR_SIMULATION.js +33 -6
  187. package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +9 -8
  188. package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -1
  189. package/src/shade/renderer/hair/chunk_hair_bsdf.js +10 -9
  190. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +5 -6
  191. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
  192. package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +5 -6
  193. package/src/shade/renderer/hair/chunk_hair_guide.d.ts +9 -2
  194. package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -1
  195. package/src/shade/renderer/hair/chunk_hair_guide.js +30 -2
  196. package/src/shade/renderer/hair/hair_lighting.d.ts +3 -3
  197. package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
  198. package/src/shade/renderer/hair/hair_lighting.js +4 -5
  199. package/src/shade/renderer/hair/hair_scattering_lut.d.ts +5 -5
  200. package/src/shade/renderer/hair/hair_scattering_lut.js +5 -5
  201. package/src/shade/renderer/hair/shader_hair_roots.d.ts +2 -2
  202. package/src/shade/renderer/hair/shader_hair_roots.js +2 -2
  203. package/src/shade/renderer/hair/shader_hair_simulate.d.ts +5 -2
  204. package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -1
  205. package/src/shade/renderer/hair/shader_hair_simulate.js +23 -5
  206. package/src/shade/renderer/light/environment/DEFINES.d.ts +1 -1
  207. package/src/shade/renderer/light/environment/DEFINES.js +1 -1
  208. package/src/shade/renderer/light/environment/shader_convolve_reflection_map_from_blurred.js +2 -2
  209. package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts +1 -2
  210. package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts.map +1 -1
  211. package/src/shade/renderer/material/dispatch/MaterialDispatch.js +1 -2
  212. package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
  213. package/src/shade/renderer/material/standard/fragment_gbuffer.js +2 -1
  214. package/src/shade/renderer/material/util/dielectric_specular_color.d.ts +1 -1
  215. package/src/shade/renderer/material/util/dielectric_specular_color.js +1 -1
  216. package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.d.ts +1 -1
  217. package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.js +1 -1
  218. package/src/shade/renderer/postprocess/dof/gather/DOF2_PRESETS.js +1 -1
  219. package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.d.ts +1 -1
  220. package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.js +1 -1
  221. package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.d.ts +1 -1
  222. package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.js +1 -1
  223. package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.d.ts +3 -4
  224. package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.d.ts.map +1 -1
  225. package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.js +3 -4
  226. package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.d.ts +1 -1
  227. package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.js +1 -1
  228. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +1 -1
  229. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +1 -1
  230. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts.map +1 -1
  231. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.js +2 -3
  232. package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.d.ts +1 -2
  233. package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.d.ts.map +1 -1
  234. package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.js +1 -2
  235. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts +2 -3
  236. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts.map +1 -1
  237. package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js +2 -3
  238. package/src/shade/renderer/postprocess/taa/filter_blackman_harris.d.ts +1 -1
  239. package/src/shade/renderer/postprocess/taa/filter_blackman_harris.js +1 -1
  240. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +1 -1
  241. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +1 -1
  242. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +1 -1
  243. package/src/shade/renderer/restir/di/ReSTIRDI.d.ts +3 -3
  244. package/src/shade/renderer/restir/di/ReSTIRDI.js +3 -3
  245. package/src/shade/renderer/restir/di/chunk_restir_trace_visibility.d.ts +1 -1
  246. package/src/shade/renderer/restir/di/chunk_restir_trace_visibility.js +1 -1
  247. package/src/shade/renderer/shader/chunk/brdf/chunk_MIN_DIELECTRICS_F0.d.ts +1 -1
  248. package/src/shade/renderer/shader/chunk/brdf/chunk_MIN_DIELECTRICS_F0.js +1 -1
  249. package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +1 -2
  250. package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
  251. package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +1 -2
  252. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +4 -5
  253. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -1
  254. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +4 -5
  255. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +2 -2
  256. package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_aces_ue_matrices.d.ts +2 -2
  257. package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_aces_ue_matrices.js +2 -2
  258. package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.d.ts +14 -17
  259. package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.d.ts.map +1 -1
  260. package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.js +18 -21
  261. package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris.d.ts +1 -1
  262. package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris.js +1 -1
  263. package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris229.d.ts +1 -1
  264. package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris229.js +1 -1
  265. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +3 -4
  266. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -1
  267. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +3 -4
  268. package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.d.ts +1 -1
  269. package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +1 -1
  270. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +3 -3
  271. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +6 -8
  272. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -1
  273. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +8 -10
  274. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +5 -7
  275. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -1
  276. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +5 -7
  277. package/src/shade/renderer/texture/virtual/README.md +257 -257
  278. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +2 -2
@@ -1,10 +1,20 @@
1
1
  /**
2
2
  * Canonical grid → layer-texel mapping (see generation/COORDINATES.md).
3
3
  * Integer grid coordinates are cell centers, integer texel coordinates are texel centers.
4
+ *
5
+ * Unstretched, texel `t` is centred on grid `t / resolution`, so texel 0 sits on cell 0. Stretched, the layer is laid
6
+ * over the grid from its first corner and texel `t` covers cells `t / resolution` up to `(t + 1) / resolution`. At
7
+ * resolution 1 both are the identity.
8
+ *
4
9
  * @param {number} v grid coordinate
5
10
  * @param {number} resolution texels per grid cell ({@link GridDataLayer#resolution})
11
+ * @param {boolean} stretch {@link GridDataLayer#stretch}
6
12
  * @returns {number} texel coordinate
7
13
  */
8
- export function grid_to_texel(v, resolution) {
14
+ export function grid_to_texel(v, resolution, stretch) {
15
+ if (stretch) {
16
+ return (v + 0.5) * resolution - 0.5;
17
+ }
18
+
9
19
  return v * resolution;
10
20
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The texels along one axis that a write at grid coordinate `v` sets, as `[first, last]` in `result`.
3
+ *
4
+ * Unstretched, the texel nearest `v`. Stretched, every texel whose centre lies in the cell holding `v`: on a layer
5
+ * finer than the grid, all of that cell's texels, so the cell reads back what was written wherever a reader samples
6
+ * it; on a coarser one, where a cell holds no texel centre, the texel holding the cell. At resolution 1 both are the
7
+ * texel of the cell. The span may reach outside the layer; bounding it is the caller's.
8
+ *
9
+ * @param {number[]|Int32Array} result
10
+ * @param {number} v grid coordinate
11
+ * @param {number} resolution texels per grid cell ({@link GridDataLayer#resolution})
12
+ * @param {boolean} stretch {@link GridDataLayer#stretch}
13
+ */
14
+ export function grid_to_texel_span(result: number[] | Int32Array, v: number, resolution: number, stretch: boolean): void;
15
+ //# sourceMappingURL=grid_to_texel_span.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid_to_texel_span.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/coords/grid_to_texel_span.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,2CALW,MAAM,EAAE,GAAC,UAAU,KACnB,MAAM,cACN,MAAM,WACN,OAAO,QAwBjB"}
@@ -0,0 +1,38 @@
1
+ import { grid_to_texel } from "./grid_to_texel.js";
2
+
3
+ /**
4
+ * The texels along one axis that a write at grid coordinate `v` sets, as `[first, last]` in `result`.
5
+ *
6
+ * Unstretched, the texel nearest `v`. Stretched, every texel whose centre lies in the cell holding `v`: on a layer
7
+ * finer than the grid, all of that cell's texels, so the cell reads back what was written wherever a reader samples
8
+ * it; on a coarser one, where a cell holds no texel centre, the texel holding the cell. At resolution 1 both are the
9
+ * texel of the cell. The span may reach outside the layer; bounding it is the caller's.
10
+ *
11
+ * @param {number[]|Int32Array} result
12
+ * @param {number} v grid coordinate
13
+ * @param {number} resolution texels per grid cell ({@link GridDataLayer#resolution})
14
+ * @param {boolean} stretch {@link GridDataLayer#stretch}
15
+ */
16
+ export function grid_to_texel_span(result, v, resolution, stretch) {
17
+ if (stretch) {
18
+ const cell = Math.round(v);
19
+
20
+ // texel t is centred at grid (t + 1/2) / resolution - 1/2, inside the cell from cell - 1/2 to cell + 1/2
21
+ const first = Math.ceil(cell * resolution - 0.5);
22
+ const last = Math.ceil((cell + 1) * resolution - 0.5) - 1;
23
+
24
+ if (first <= last) {
25
+ result[0] = first;
26
+ result[1] = last;
27
+
28
+ return;
29
+ }
30
+
31
+ v = cell;
32
+ }
33
+
34
+ const nearest = Math.round(grid_to_texel(v, resolution, stretch));
35
+
36
+ result[0] = nearest;
37
+ result[1] = nearest;
38
+ }
@@ -3,7 +3,8 @@
3
3
  * Inverse of {@link grid_to_texel}.
4
4
  * @param {number} v texel coordinate
5
5
  * @param {number} resolution texels per grid cell ({@link GridDataLayer#resolution})
6
+ * @param {boolean} stretch {@link GridDataLayer#stretch}
6
7
  * @returns {number} grid coordinate
7
8
  */
8
- export function texel_to_grid(v: number, resolution: number): number;
9
+ export function texel_to_grid(v: number, resolution: number, stretch: boolean): number;
9
10
  //# sourceMappingURL=texel_to_grid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"texel_to_grid.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/coords/texel_to_grid.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,iCAJW,MAAM,cACN,MAAM,GACJ,MAAM,CAIlB"}
1
+ {"version":3,"file":"texel_to_grid.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/coords/texel_to_grid.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iCALW,MAAM,cACN,MAAM,WACN,OAAO,GACL,MAAM,CAQlB"}
@@ -3,8 +3,13 @@
3
3
  * Inverse of {@link grid_to_texel}.
4
4
  * @param {number} v texel coordinate
5
5
  * @param {number} resolution texels per grid cell ({@link GridDataLayer#resolution})
6
+ * @param {boolean} stretch {@link GridDataLayer#stretch}
6
7
  * @returns {number} grid coordinate
7
8
  */
8
- export function texel_to_grid(v, resolution) {
9
+ export function texel_to_grid(v, resolution, stretch) {
10
+ if (stretch) {
11
+ return (v + 0.5) / resolution - 0.5;
12
+ }
13
+
9
14
  return v / resolution;
10
15
  }
@@ -3,6 +3,11 @@
3
3
  * {@link GridWFCTileSet}, and every pair of neighbours shows the same socket on the edge they
4
4
  * share. Each tile's {@link GridCellAction} is then run on its cell, turned the way the tile is.
5
5
  *
6
+ * The solve is laid on a {@link GridDataLayer}, named by {@link layer}: its texels are the cells of
7
+ * the solve, and each ends up holding the value of the tile laid there, for the stages after this
8
+ * one to read. A layer at resolution 1/2 makes every tile a block of two cells by two, for art that
9
+ * size (a paving slab two cells across).
10
+ *
6
11
  * What adjacency alone cannot say is said around the solve:
7
12
  * - {@link restrictions} narrow what a cell may hold before it starts — keep these cells open,
8
13
  * let paving stand only where that field is high;
@@ -20,6 +25,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
20
25
  * @param {Object} options
21
26
  * @param {string} [options.name]
22
27
  * @param {GridWFCTileSet} options.tiles
28
+ * @param {string} options.layer id of the {@link GridDataLayer} the solve is laid on and written into
23
29
  * @param {{matcher: CellMatcher, tag: string}[]} [options.restrictions]
24
30
  * @param {string|null} [options.boundary]
25
31
  * @param {string|null} [options.connected]
@@ -28,9 +34,10 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
28
34
  * @param {string|null} [options.fallback]
29
35
  * @returns {GridTaskWaveFunctionCollapse}
30
36
  */
31
- static from({ name, tiles, restrictions, boundary, connected, cell_choice, attempts, fallback }: {
37
+ static from({ name, tiles, layer, restrictions, boundary, connected, cell_choice, attempts, fallback }: {
32
38
  name?: string;
33
39
  tiles: GridWFCTileSet;
40
+ layer: string;
34
41
  restrictions?: {
35
42
  matcher: CellMatcher;
36
43
  tag: string;
@@ -45,6 +52,30 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
45
52
  * @type {GridWFCTileSet}
46
53
  */
47
54
  tiles: GridWFCTileSet;
55
+ /**
56
+ * Id of the {@link GridDataLayer} the solve is laid on. Its texels are the cells of the solve,
57
+ * and once the solve is done each holds the value its tile has in the {@link GridWFCTileSet} —
58
+ * the prototype's index, unless the set gives one — so that every stage after this one can read
59
+ * what was laid. The whole result is written before any tile's action runs.
60
+ *
61
+ * At resolution 1 a tile is a cell. At `1/n` a tile stands for a block of `n` by `n` cells, and
62
+ * the layer has to be {@link GridDataLayer#stretch stretched}, so that its texels are such blocks
63
+ * laid from the grid's first cell; unstretched, its texel 0 is centred on cell 0 and stands for
64
+ * part of a block. Any other resolution is refused: a tile is a whole number of cells. A last row
65
+ * or column of texels that the grid cuts short holds no tile, since its art would reach past the
66
+ * grid, and keeps what the layer held there.
67
+ *
68
+ * Everything else is then about blocks. A restriction holds on a block when its matcher matches
69
+ * every one of the block's cells — so a restriction and its negation never both hold on one
70
+ * block, and a block half on a building is not the building's. The boundary is the outer ring of
71
+ * whole blocks. A tile's action runs once for its block, written as if the block's first cell
72
+ * (lowest x, lowest y) were its own cell and turned with the tile about the block's centre: an
73
+ * action marking cells (0,0) to (n-1,n-1) from where it runs marks exactly its block, whichever
74
+ * way the tile is turned.
75
+ *
76
+ * @type {string}
77
+ */
78
+ layer: string;
48
79
  /**
49
80
  * A cell that `matcher` matches may only hold tiles carrying `tag`. A cell matched by several
50
81
  * may only hold tiles carrying all their tags.
@@ -1 +1 @@
1
- {"version":3,"file":"GridTaskWaveFunctionCollapse.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;;GAgBG;AACH;IAuEI;;;;;;;;;;;OAWG;IACH;QAV4B,IAAI,GAArB,MAAM;QACkB,KAAK;QACmB,YAAY,GAA5D;YAAC,OAAO,cAAc;YAAC,GAAG,EAAE,MAAM,CAAA;SAAC,EAAE;QACf,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACW,SAAS,GAA/B,MAAM,GAAC,IAAI;QACa,WAAW,GAAnC,aAAa;QACI,QAAQ,GAAzB,MAAM;QACgB,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACT,4BAA4B,CAiCxC;IAhHD;;OAEG;IACH,sBAAa;IAEb;;;;;OAKG;IACH,cAFU;QAAC,OAAO,cAAc;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAE7B;IAElB;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;;;;;;;;OAYG;IACH,WAFU,MAAM,GAAC,IAAI,CAEJ;IAEjB;;OAEG;IACH,aAFU,aAAa,CAEc;IAErC;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;OAKG;IACH,YAFU;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAEb;IAmDzF,iDA0YC;CACJ;kCA/hBiC,4BAA4B;8BAThC,uCAAuC;sBAJ/C,4CAA4C"}
1
+ {"version":3,"file":"GridTaskWaveFunctionCollapse.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAgGI;;;;;;;;;;;;OAYG;IACH;QAX4B,IAAI,GAArB,MAAM;QACkB,KAAK;QACb,KAAK,EAArB,MAAM;QAC0C,YAAY,GAA5D;YAAC,OAAO,cAAc;YAAC,GAAG,EAAE,MAAM,CAAA;SAAC,EAAE;QACf,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACW,SAAS,GAA/B,MAAM,GAAC,IAAI;QACa,WAAW,GAAnC,aAAa;QACI,QAAQ,GAAzB,MAAM;QACgB,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACT,4BAA4B,CAoCxC;IA7ID;;OAEG;IACH,sBAAa;IAEb;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAFU,MAAM,CAEH;IAEb;;;;;OAKG;IACH,cAFU;QAAC,OAAO,cAAc;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAE7B;IAElB;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;;;;;;;;OAYG;IACH,WAFU,MAAM,GAAC,IAAI,CAEJ;IAEjB;;OAEG;IACH,aAFU,aAAa,CAEc;IAErC;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;OAKG;IACH,YAFU;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAEb;IAyDzF,iDA8cC;CACJ;kCAvoBiC,4BAA4B;8BAThC,uCAAuC;sBAJ/C,4CAA4C"}
@@ -1,6 +1,7 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
  import { array_shuffle } from "../../../../core/collection/array/array_shuffle.js";
3
3
  import { uf_find, uf_init, uf_union } from "../../../../core/collection/union-find/union_find.js";
4
+ import { v2_rotate } from "../../../../core/geom/vec2/v2_rotate.js";
4
5
  import { PI_HALF } from "../../../../core/math/PI_HALF.js";
5
6
  import { seededRandom } from "../../../../core/math/random/seededRandom.js";
6
7
  import Task from "../../../../core/process/task/Task.js";
@@ -33,6 +34,11 @@ const OPERATIONS_PER_CYCLE = 4096;
33
34
  * {@link GridWFCTileSet}, and every pair of neighbours shows the same socket on the edge they
34
35
  * share. Each tile's {@link GridCellAction} is then run on its cell, turned the way the tile is.
35
36
  *
37
+ * The solve is laid on a {@link GridDataLayer}, named by {@link layer}: its texels are the cells of
38
+ * the solve, and each ends up holding the value of the tile laid there, for the stages after this
39
+ * one to read. A layer at resolution 1/2 makes every tile a block of two cells by two, for art that
40
+ * size (a paving slab two cells across).
41
+ *
36
42
  * What adjacency alone cannot say is said around the solve:
37
43
  * - {@link restrictions} narrow what a cell may hold before it starts — keep these cells open,
38
44
  * let paving stand only where that field is high;
@@ -52,6 +58,31 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
52
58
  */
53
59
  tiles = null;
54
60
 
61
+ /**
62
+ * Id of the {@link GridDataLayer} the solve is laid on. Its texels are the cells of the solve,
63
+ * and once the solve is done each holds the value its tile has in the {@link GridWFCTileSet} —
64
+ * the prototype's index, unless the set gives one — so that every stage after this one can read
65
+ * what was laid. The whole result is written before any tile's action runs.
66
+ *
67
+ * At resolution 1 a tile is a cell. At `1/n` a tile stands for a block of `n` by `n` cells, and
68
+ * the layer has to be {@link GridDataLayer#stretch stretched}, so that its texels are such blocks
69
+ * laid from the grid's first cell; unstretched, its texel 0 is centred on cell 0 and stands for
70
+ * part of a block. Any other resolution is refused: a tile is a whole number of cells. A last row
71
+ * or column of texels that the grid cuts short holds no tile, since its art would reach past the
72
+ * grid, and keeps what the layer held there.
73
+ *
74
+ * Everything else is then about blocks. A restriction holds on a block when its matcher matches
75
+ * every one of the block's cells — so a restriction and its negation never both hold on one
76
+ * block, and a block half on a building is not the building's. The boundary is the outer ring of
77
+ * whole blocks. A tile's action runs once for its block, written as if the block's first cell
78
+ * (lowest x, lowest y) were its own cell and turned with the tile about the block's centre: an
79
+ * action marking cells (0,0) to (n-1,n-1) from where it runs marks exactly its block, whichever
80
+ * way the tile is turned.
81
+ *
82
+ * @type {string}
83
+ */
84
+ layer = null;
85
+
55
86
  /**
56
87
  * A cell that `matcher` matches may only hold tiles carrying `tag`. A cell matched by several
57
88
  * may only hold tiles carrying all their tags.
@@ -120,6 +151,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
120
151
  * @param {Object} options
121
152
  * @param {string} [options.name]
122
153
  * @param {GridWFCTileSet} options.tiles
154
+ * @param {string} options.layer id of the {@link GridDataLayer} the solve is laid on and written into
123
155
  * @param {{matcher: CellMatcher, tag: string}[]} [options.restrictions]
124
156
  * @param {string|null} [options.boundary]
125
157
  * @param {string|null} [options.connected]
@@ -131,6 +163,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
131
163
  static from({
132
164
  name = 'wave function collapse',
133
165
  tiles,
166
+ layer,
134
167
  restrictions = [],
135
168
  boundary = null,
136
169
  connected = null,
@@ -139,6 +172,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
139
172
  fallback = null
140
173
  }) {
141
174
  assert.defined(tiles, 'tiles');
175
+ assert.isString(layer, 'layer');
142
176
  assert.isArray(restrictions, 'restrictions');
143
177
  assert.isPositiveInteger(attempts, 'attempts');
144
178
 
@@ -151,6 +185,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
151
185
 
152
186
  r.name = name;
153
187
  r.tiles = tiles;
188
+ r.layer = layer;
154
189
  r.restrictions = restrictions;
155
190
  r.boundary = boundary;
156
191
  r.connected = connected;
@@ -162,20 +197,65 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
162
197
  }
163
198
 
164
199
  computeWrites() {
165
- return compute_writes_union(this.tiles.prototypes.map(p => p.action).filter(a => a !== null));
200
+ const writes = compute_writes_union(this.tiles.prototypes.map(p => p.action).filter(a => a !== null));
201
+
202
+ return writes.includes(this.layer) ? writes : writes.concat(this.layer);
166
203
  }
167
204
 
168
205
  build(grid, ecd, seed) {
169
206
  const compiled = this.tiles.compile();
170
207
  const prototypes = compiled.prototypes;
171
208
 
172
- const width = grid.width;
173
- const height = grid.height;
209
+ // real throws, like the fallback's below: what the layer is depends on the grid built on
210
+ const layer = grid.getLayerById(this.layer);
211
+
212
+ if (layer === undefined) {
213
+ throw new Error(`Layer '${this.layer}' not found`);
214
+ }
215
+
216
+ // cells along a side of the block a texel stands for
217
+ const pitch = Math.round(1 / layer.resolution);
218
+
219
+ if (!Number.isSafeInteger(pitch) || pitch < 1 || 1 / pitch !== layer.resolution) {
220
+ throw new Error(`layer '${this.layer}' has resolution ${layer.resolution}: a tile stands for a whole number of cells, so it must be 1/n for a whole number n`);
221
+ }
222
+
223
+ if (pitch > 1 && !layer.stretch) {
224
+ throw new Error(`layer '${this.layer}' at resolution 1/${pitch} is not stretched: its texel 0 is centred on cell 0, so its texels are not blocks laid from the grid's first cell`);
225
+ }
226
+
227
+ const sampler = layer.sampler;
228
+
229
+ // The solve's cells, the layer's texels: blocks of `pitch` by `pitch` grid cells (one, at
230
+ // resolution 1), and whole ones only. Everything below indexes these; only matching, acting
231
+ // and writing go back to the grid and the layer.
232
+ const width = Math.floor(grid.width / pitch);
233
+ const height = Math.floor(grid.height / pitch);
174
234
  const cell_count = width * height;
175
235
 
176
- // y on axis 0, so a cell's index in the lattice is the grid's own `y * width + x`
236
+ // y on axis 0, so a cell's index in the lattice is `y * width + x`, the grid's own at resolution 1
177
237
  const lattice = cell_count > 0 ? WFCLattice.from_shape([height, width]) : null;
178
238
 
239
+ /**
240
+ * Does `matcher` match every grid cell of the block at lattice cell (x, y)?
241
+ *
242
+ * @param {CellMatcher} matcher
243
+ * @param {number} x
244
+ * @param {number} y
245
+ * @returns {boolean}
246
+ */
247
+ const matches_block = (matcher, x, y) => {
248
+ for (let dy = 0; dy < pitch; dy++) {
249
+ for (let dx = 0; dx < pitch; dx++) {
250
+ if (!matcher.match(grid, x * pitch + dx, y * pitch + dy, 0)) {
251
+ return false;
252
+ }
253
+ }
254
+ }
255
+
256
+ return true;
257
+ };
258
+
179
259
  const restrictions = this.restrictions;
180
260
  const boundary = this.boundary;
181
261
  const connected = this.connected;
@@ -259,7 +339,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
259
339
  let key = '';
260
340
 
261
341
  for (let i = 0; i < restrictions.length; i++) {
262
- if (restrictions[i].matcher.match(grid, x, y, 0)) {
342
+ if (matches_block(restrictions[i].matcher, x, y)) {
263
343
  key += i + ',';
264
344
  }
265
345
  }
@@ -547,17 +627,42 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
547
627
 
548
628
  tSolve.addDependency(tInitialize);
549
629
 
630
+ // the whole result into the layer before any action runs, so an action may read it too
631
+ const tWrite = countTask(0, cell_count, cell => {
632
+ const value = prototypes[compiled.tile_prototype[result[cell]]].value;
633
+
634
+ sampler.writeChannel(cell % width, (cell / width) | 0, 0, value);
635
+ });
636
+
637
+ tWrite.addDependency(tSolve);
638
+
639
+ // half the block's side less a cell: from its first cell to its centre, along each axis
640
+ const centre = (pitch - 1) / 2;
641
+ const turned = new Float64Array(2);
642
+
550
643
  const tApply = countTask(0, cell_count, cell => {
551
644
  const tile = result[cell];
552
645
  const action = prototypes[compiled.tile_prototype[tile]].action;
553
646
 
554
- if (action !== null) {
555
- action.execute(grid, cell % width, (cell / width) | 0, compiled.tile_turns[tile] * PI_HALF);
647
+ if (action === null) {
648
+ return;
556
649
  }
650
+
651
+ const rotation = compiled.tile_turns[tile] * PI_HALF;
652
+
653
+ // Turned about the block's centre, the block's first cell lands at the centre less the
654
+ // turned offset to it — always on a cell, so the action runs there and its own turn
655
+ // carries the rest of the block round. At resolution 1 it is the cell itself.
656
+ v2_rotate(turned, 0, centre, centre, rotation);
657
+
658
+ const x = (cell % width) * pitch + Math.round(centre - turned[0]);
659
+ const y = ((cell / width) | 0) * pitch + Math.round(centre - turned[1]);
660
+
661
+ action.execute(grid, x, y, rotation);
557
662
  });
558
663
 
559
- tApply.addDependency(tSolve);
664
+ tApply.addDependency(tWrite);
560
665
 
561
- return new TaskGroup([tInitialize, tSolve, tApply], this.name);
666
+ return new TaskGroup([tInitialize, tSolve, tWrite, tApply], this.name);
562
667
  }
563
668
  }
@@ -1,5 +1,13 @@
1
1
  /**
2
2
  * Build a map of distances across the grid, using 2 concepts: source cells and passable cells. Source cells are where the distance is 0, and passable cells are those that can be travelled through
3
+ *
4
+ * The map is the layer's: the search steps from texel to edge-sharing texel. On a layer as fine as the grid or finer,
5
+ * a texel is a source, or passable, as the matchers find the grid at its centre ({@link texel_to_grid}). On a coarser
6
+ * one a texel holds a block of cells — those whose nearest texel it is, which is where a matcher at the cell reads —
7
+ * and is a source if any of them is, passable if all of them are, so that a wall one cell thick still stops the
8
+ * search. Distances are in cells whatever the resolution, a step between neighbouring texels being `1 / resolution`
9
+ * cells, and are written into the layer when the search is done, converted to its type there; a texel no source
10
+ * reaches holds {@link initial}.
3
11
  */
4
12
  export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
5
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"GridTaskBuildSourceDistanceMap.d.ts","sourceRoot":"","sources":["../../../../../../../src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js"],"names":[],"mappings":"AAUA;;GAEG;AACH;IA0BI;;;;;;;OAOG;IACH;;;;;;uCAgBC;IAhDD;;;OAGG;IACH,2BAAqB;IAErB;;;OAGG;IACH,yBAAmB;IAEnB;;;OAGG;IACH,cAAa;IAEb;;;OAGG;IACH,SAFU,MAAM,CAEA;IAgChB,iDAuJC;CACJ;kCArNiC,+BAA+B;sBAJ3C,+CAA+C"}
1
+ {"version":3,"file":"GridTaskBuildSourceDistanceMap.d.ts","sourceRoot":"","sources":["../../../../../../../src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH;IA0BI;;;;;;;OAOG;IACH;;;;;;uCAgBC;IAhDD;;;OAGG;IACH,2BAAqB;IAErB;;;OAGG;IACH,yBAAmB;IAEnB;;;OAGG;IACH,cAAa;IAEb;;;OAGG;IACH,SAFU,MAAM,CAEA;IAgChB,iDA0MC;CACJ;kCAhRiC,+BAA+B;sBAN3C,+CAA+C"}
@@ -1,15 +1,26 @@
1
1
  import { assert } from "../../../../../core/assert.js";
2
2
  import { BitSet } from "../../../../../core/binary/BitSet.js";
3
3
  import BinaryHeap from "../../../../../core/collection/heap/BinaryHeap.js";
4
+ import { snap_to_integer } from "../../../../../core/math/snap_to_integer.js";
4
5
  import Task from "../../../../../core/process/task/Task.js";
5
6
  import TaskGroup from "../../../../../core/process/task/TaskGroup.js";
6
7
  import { TaskSignal } from "../../../../../core/process/task/TaskSignal.js";
7
8
  import { actionTask } from "../../../../../core/process/task/util/actionTask.js";
8
9
  import { countTask } from "../../../../../core/process/task/util/countTask.js";
10
+ import { grid_to_texel } from "../../../coords/grid_to_texel.js";
11
+ import { texel_to_grid } from "../../../coords/texel_to_grid.js";
9
12
  import { GridTaskGenerator } from "../../../GridTaskGenerator.js";
10
13
 
11
14
  /**
12
15
  * Build a map of distances across the grid, using 2 concepts: source cells and passable cells. Source cells are where the distance is 0, and passable cells are those that can be travelled through
16
+ *
17
+ * The map is the layer's: the search steps from texel to edge-sharing texel. On a layer as fine as the grid or finer,
18
+ * a texel is a source, or passable, as the matchers find the grid at its centre ({@link texel_to_grid}). On a coarser
19
+ * one a texel holds a block of cells — those whose nearest texel it is, which is where a matcher at the cell reads —
20
+ * and is a source if any of them is, passable if all of them are, so that a wall one cell thick still stops the
21
+ * search. Distances are in cells whatever the resolution, a step between neighbouring texels being `1 / resolution`
22
+ * cells, and are written into the layer when the search is done, converted to its type there; a texel no source
23
+ * reaches holds {@link initial}.
13
24
  */
14
25
  export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
15
26
 
@@ -92,10 +103,28 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
92
103
  throw new Error(`Layer '${this.layer}' doesn't exist`);
93
104
  }
94
105
 
95
- const target = layer.sampler.data;
106
+ const resolution = layer.resolution;
107
+ const stretch = layer.stretch;
108
+
109
+ // the layer's texels are the nodes of the search
110
+ const width = layer.sampler.width;
111
+ const height = layer.sampler.height;
112
+ const texel_count = width * height;
113
+
114
+ /**
115
+ * Steps from the nearest source to each texel, Infinity where none reaches. Whole steps, so that a distance
116
+ * is one conversion to cells and not a sum of fractions of a cell.
117
+ * @type {Float64Array}
118
+ */
119
+ const steps = new Float64Array(texel_count);
120
+
121
+ /** @type {Uint8Array} */
122
+ const is_source = new Uint8Array(texel_count);
123
+ /** @type {Uint8Array} */
124
+ const is_passable = new Uint8Array(texel_count);
96
125
 
97
126
  const open = new BinaryHeap(function (i) {
98
- return target[i];
127
+ return steps[i];
99
128
  });
100
129
 
101
130
  /**
@@ -110,12 +139,12 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
110
139
  */
111
140
  const inOpen = new BitSet();
112
141
 
113
- const width = grid.width;
114
- const height = grid.height;
115
-
116
142
  const tInitialize = actionTask(() => {
117
- //initialize target
118
- target.fill(initial);
143
+ steps.fill(Infinity);
144
+
145
+ is_source.fill(0);
146
+ // a texel of cells is passable until one of them is not
147
+ is_passable.fill(resolution > 1 ? 0 : 1);
119
148
 
120
149
  //initialize matchers
121
150
  sourceMatcher.initialize(grid, seed);
@@ -123,23 +152,54 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
123
152
 
124
153
  });
125
154
 
126
- //collect start cells
127
- const tCollectSources = countTask(0, width * height, index => {
128
- const y = (index / width) | 0;
129
- const x = index % width;
155
+ const grid_width = grid.width;
156
+
157
+ const tClassify = resolution > 1
158
+ ? countTask(0, texel_count, index => {
159
+ // a texel inside a cell: what the grid is at its centre
160
+ const x = texel_to_grid(index % width, resolution, stretch);
161
+ const y = texel_to_grid((index / width) | 0, resolution, stretch);
162
+
163
+ is_source[index] = sourceMatcher.match(grid, x, y, 0) ? 1 : 0;
164
+ is_passable[index] = passMatcher.match(grid, x, y, 0) ? 1 : 0;
165
+ })
166
+ : countTask(0, grid_width * grid.height, cell => {
167
+ // a cell into the texel holding it
168
+ const x = cell % grid_width;
169
+ const y = (cell / grid_width) | 0;
170
+
171
+ const texel_x = Math.round(grid_to_texel(x, resolution, stretch));
172
+ const texel_y = Math.round(grid_to_texel(y, resolution, stretch));
173
+
174
+ if (texel_x < 0 || texel_x >= width || texel_y < 0 || texel_y >= height) {
175
+ // a cell past the last texel of an unstretched layer
176
+ return;
177
+ }
178
+
179
+ const index = texel_y * width + texel_x;
180
+
181
+ if (sourceMatcher.match(grid, x, y, 0)) {
182
+ is_source[index] = 1;
183
+ }
184
+
185
+ if (!passMatcher.match(grid, x, y, 0)) {
186
+ is_passable[index] = 0;
187
+ }
188
+ });
130
189
 
131
- const match = sourceMatcher.match(grid, x, y, 0);
190
+ tClassify.addDependency(tInitialize);
132
191
 
133
- if (match) {
192
+ //collect start texels
193
+ const tCollectSources = countTask(0, texel_count, index => {
194
+ if (is_source[index] === 1) {
134
195
  open.push(index);
135
196
  inOpen.set(index, true);
136
197
 
137
- //initialize target value
138
- target[index] = 0;
198
+ steps[index] = 0;
139
199
  }
140
200
  });
141
201
 
142
- tCollectSources.addDependency(tInitialize);
202
+ tCollectSources.addDependency(tClassify);
143
203
 
144
204
  /**
145
205
  *
@@ -148,14 +208,8 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
148
208
  */
149
209
  function processNeighbor(iNeighbor, iCurrent) {
150
210
 
151
- //check if cell is passable
152
- const y = (iNeighbor / width) | 0;
153
- const x = iNeighbor % width;
154
-
155
- const isPassable = passMatcher.match(grid, x, y, 0);
156
-
157
- if (!isPassable) {
158
- //cell is an obstacle
211
+ if (is_passable[iNeighbor] === 0) {
212
+ //texel is an obstacle
159
213
  return;
160
214
  }
161
215
 
@@ -164,16 +218,16 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
164
218
  return;
165
219
  }
166
220
 
167
- const distance = target[iCurrent] + 1;
221
+ const d = steps[iCurrent] + 1;
168
222
 
169
223
  const notInOpen = !inOpen.get(iNeighbor);
170
224
 
171
225
  if (notInOpen) {
172
- target[iNeighbor] = distance;
226
+ steps[iNeighbor] = d;
173
227
  open.push(iNeighbor);
174
228
  inOpen.set(iNeighbor, true);
175
- } else if (distance < target[iNeighbor]) {
176
- target[iNeighbor] = distance;
229
+ } else if (d < steps[iNeighbor]) {
230
+ steps[iNeighbor] = d;
177
231
  open.updateElementScore(iNeighbor);
178
232
  }
179
233
  }
@@ -182,6 +236,14 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
182
236
  name: 'Build Distance Map',
183
237
  cycleFunction() {
184
238
  if (open.size() === 0) {
239
+ const target = layer.sampler.data;
240
+
241
+ for (let i = 0; i < texel_count; i++) {
242
+ const s = steps[i];
243
+
244
+ target[i] = s === Infinity ? initial : snap_to_integer(s / resolution);
245
+ }
246
+
185
247
  return TaskSignal.EndSuccess;
186
248
  }
187
249
 
@@ -217,6 +279,6 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
217
279
 
218
280
  tMain.addDependency(tCollectSources);
219
281
 
220
- return new TaskGroup([tInitialize, tCollectSources, tMain]);
282
+ return new TaskGroup([tInitialize, tClassify, tCollectSources, tMain]);
221
283
  }
222
284
  }
@@ -4,9 +4,10 @@ export class GridDataLayer {
4
4
  * @param {string} id
5
5
  * @param {BinaryDataType} type
6
6
  * @param {number} [resolution=1]
7
+ * @param {boolean} [stretch=false] see {@link GridDataLayer#stretch}
7
8
  * @returns {GridDataLayer}
8
9
  */
9
- static from(id: string, type: BinaryDataType, resolution?: number): GridDataLayer;
10
+ static from(id: string, type: BinaryDataType, resolution?: number, stretch?: boolean): GridDataLayer;
10
11
  /**
11
12
  * Unique ID to reference the layer
12
13
  * @type {string}
@@ -17,13 +18,31 @@ export class GridDataLayer {
17
18
  * @type {number}
18
19
  */
19
20
  resolution: number;
21
+ /**
22
+ * Whether a texel is stretched over the cells it stands for, laid from the grid's first corner, rather than
23
+ * centred on a point.
24
+ *
25
+ * Unstretched, texel `t` is centred on grid position `t / resolution` (`texel = grid · resolution`, see
26
+ * `generation/COORDINATES.md`), and the grid must be a whole number of texels across. At resolution 0.5 that puts
27
+ * texel 0 on cell 0, texel 1 on cell 2, and a cell between them half way.
28
+ *
29
+ * Stretched, texel `t` covers the cells from `t / resolution` up to `(t + 1) / resolution`, counted from the grid's
30
+ * first corner: at resolution 0.5, cells `2t` and `2t + 1`; at 2, a cell is two texels across. The layer has as
31
+ * many texels as covering the grid takes, so any grid size will do; on one that is not a whole number of texels
32
+ * across, the last row and column reach past the grid's far edge.
33
+ *
34
+ * At resolution 1 the two are the same. Set it before the layer is added to a grid.
35
+ *
36
+ * @type {boolean}
37
+ */
38
+ stretch: boolean;
20
39
  /**
21
40
  *
22
41
  * @type {Sampler2D}
23
42
  */
24
43
  sampler: Sampler2D;
25
44
  /**
26
- *
45
+ * Size of the grid the sampler was last sized for, in cells; the empty sampler a layer starts with is for none
27
46
  * @type {Vector2}
28
47
  */
29
48
  size: Vector2;