@woosh/meep-engine 3.16.0 → 3.17.0

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 (410) hide show
  1. package/editor/particles/effect/ParticleEffectDocument.d.ts +21 -6
  2. package/editor/particles/effect/ParticleEffectDocument.d.ts.map +1 -1
  3. package/editor/particles/effect/ParticleEffectDocument.js +38 -17
  4. package/editor/view/node-graph/NodeGraphClipboard.d.ts +186 -0
  5. package/editor/view/node-graph/NodeGraphClipboard.d.ts.map +1 -0
  6. package/editor/view/node-graph/NodeGraphClipboard.js +231 -0
  7. package/editor/view/node-graph/NodeGraphEditorView.d.ts +59 -1
  8. package/editor/view/node-graph/NodeGraphEditorView.d.ts.map +1 -1
  9. package/editor/view/node-graph/NodeGraphEditorView.js +248 -5
  10. package/editor/view/node-graph/NodeGraphView.d.ts.map +1 -1
  11. package/editor/view/node-graph/NodeGraphView.js +84 -8
  12. package/editor/view/node-graph/actions/connection_bind_actions.d.ts +23 -0
  13. package/editor/view/node-graph/actions/connection_bind_actions.d.ts.map +1 -0
  14. package/editor/view/node-graph/actions/connection_bind_actions.js +39 -0
  15. package/editor/view/particles/effect/ParticleCodeEditorView.d.ts.map +1 -1
  16. package/editor/view/particles/effect/ParticleCodeEditorView.js +4 -3
  17. package/editor/view/particles/effect/ParticleCurveEditorView.d.ts +20 -0
  18. package/editor/view/particles/effect/ParticleCurveEditorView.d.ts.map +1 -0
  19. package/editor/view/particles/effect/ParticleCurveEditorView.js +574 -0
  20. package/editor/view/particles/effect/ParticleEmitterInspectorView.d.ts.map +1 -1
  21. package/editor/view/particles/effect/ParticleEmitterInspectorView.js +27 -1
  22. package/editor/view/particles/effect/ParticleGradientEditorView.d.ts +24 -0
  23. package/editor/view/particles/effect/ParticleGradientEditorView.d.ts.map +1 -0
  24. package/editor/view/particles/effect/ParticleGradientEditorView.js +472 -0
  25. package/editor/view/particles/effect/ParticleGraphEditorView.d.ts +5 -0
  26. package/editor/view/particles/effect/ParticleGraphEditorView.d.ts.map +1 -1
  27. package/editor/view/particles/effect/ParticleGraphEditorView.js +61 -31
  28. package/editor/view/particles/effect/ParticleNodeParametersView.d.ts.map +1 -1
  29. package/editor/view/particles/effect/ParticleNodeParametersView.js +33 -0
  30. package/editor/view/particles/effect/particle-editor.css +123 -35
  31. package/package.json +1 -1
  32. package/src/core/binary/allocator/OffsetAllocator.d.ts +25 -16
  33. package/src/core/binary/allocator/OffsetAllocator.d.ts.map +1 -1
  34. package/src/core/binary/allocator/OffsetAllocator.js +10 -1
  35. package/src/core/collection/array/typed/float32_array_hash.d.ts +21 -0
  36. package/src/core/collection/array/typed/float32_array_hash.d.ts.map +1 -0
  37. package/src/core/collection/array/typed/float32_array_hash.js +38 -0
  38. package/src/core/graph/csr/CSRGraph.d.ts +8 -1
  39. package/src/core/graph/csr/CSRGraph.d.ts.map +1 -1
  40. package/src/core/graph/csr/CSRGraph.js +14 -6
  41. package/src/core/model/node-graph/visual/layout/LayoutProblem.d.ts +24 -0
  42. package/src/core/model/node-graph/visual/layout/LayoutProblem.d.ts.map +1 -1
  43. package/src/core/model/node-graph/visual/layout/LayoutProblem.js +27 -0
  44. package/src/core/model/node-graph/visual/layout/NodeGraphLayoutOptions.d.ts +26 -0
  45. package/src/core/model/node-graph/visual/layout/NodeGraphLayoutOptions.d.ts.map +1 -1
  46. package/src/core/model/node-graph/visual/layout/NodeGraphLayoutOptions.js +28 -0
  47. package/src/core/model/node-graph/visual/layout/RouteGrid.d.ts +92 -3
  48. package/src/core/model/node-graph/visual/layout/RouteGrid.d.ts.map +1 -1
  49. package/src/core/model/node-graph/visual/layout/RouteGrid.js +405 -242
  50. package/src/core/model/node-graph/visual/layout/RouteSearch.d.ts +50 -5
  51. package/src/core/model/node-graph/visual/layout/RouteSearch.d.ts.map +1 -1
  52. package/src/core/model/node-graph/visual/layout/RouteSearch.js +160 -24
  53. package/src/core/model/node-graph/visual/layout/RouteSet.d.ts +7 -0
  54. package/src/core/model/node-graph/visual/layout/RouteSet.d.ts.map +1 -1
  55. package/src/core/model/node-graph/visual/layout/RouteSet.js +8 -0
  56. package/src/core/model/node-graph/visual/layout/layout_assign_coordinates.js +9 -3
  57. package/src/core/model/node-graph/visual/layout/layout_build_problem.d.ts.map +1 -1
  58. package/src/core/model/node-graph/visual/layout/layout_build_problem.js +7 -0
  59. package/src/core/model/node-graph/visual/layout/layout_insert_lanes.d.ts +9 -3
  60. package/src/core/model/node-graph/visual/layout/layout_insert_lanes.d.ts.map +1 -1
  61. package/src/core/model/node-graph/visual/layout/layout_insert_lanes.js +17 -3
  62. package/src/core/model/node-graph/visual/layout/layout_node_graph.d.ts +9 -6
  63. package/src/core/model/node-graph/visual/layout/layout_node_graph.d.ts.map +1 -1
  64. package/src/core/model/node-graph/visual/layout/layout_node_graph.js +49 -7
  65. package/src/core/model/node-graph/visual/layout/layout_order_layers.d.ts +11 -1
  66. package/src/core/model/node-graph/visual/layout/layout_order_layers.d.ts.map +1 -1
  67. package/src/core/model/node-graph/visual/layout/layout_order_layers.js +135 -16
  68. package/src/core/model/node-graph/visual/layout/route_connections.d.ts +29 -0
  69. package/src/core/model/node-graph/visual/layout/route_connections.d.ts.map +1 -1
  70. package/src/core/model/node-graph/visual/layout/route_connections.js +716 -309
  71. package/src/core/model/node-graph/visual/layout/route_grid_build.d.ts +3 -2
  72. package/src/core/model/node-graph/visual/layout/route_grid_build.d.ts.map +1 -1
  73. package/src/core/model/node-graph/visual/layout/route_grid_build.js +7 -15
  74. package/src/core/model/node-graph/visual/layout/route_nudge.d.ts +6 -0
  75. package/src/core/model/node-graph/visual/layout/route_nudge.d.ts.map +1 -1
  76. package/src/core/model/node-graph/visual/layout/route_nudge.js +42 -13
  77. package/src/engine/animation/AnimationUtils.js +246 -246
  78. package/src/engine/animation/Animations.js +74 -74
  79. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +2078 -2078
  80. package/src/engine/ecs/EventType.d.ts +0 -1
  81. package/src/engine/ecs/EventType.js +1 -26
  82. package/src/engine/ecs/ik/ik_write_local_rotation.d.ts +1 -1
  83. package/src/engine/ecs/ik/ik_write_local_rotation.d.ts.map +1 -1
  84. package/src/engine/ecs/ik/ik_write_local_rotation.js +3 -7
  85. package/src/engine/ecs/parent/EntityNode.d.ts.map +1 -1
  86. package/src/engine/ecs/parent/EntityNode.js +4 -9
  87. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  88. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +360 -364
  89. package/src/engine/ecs/transform/TRANSFORM64_EVENT_CHANGE.d.ts +41 -0
  90. package/src/engine/ecs/transform/TRANSFORM64_EVENT_CHANGE.d.ts.map +1 -0
  91. package/src/engine/ecs/transform/TRANSFORM64_EVENT_CHANGE.js +40 -0
  92. package/src/engine/ecs/transform/TRANSFORM64_MIGRATION_PLAN_2026_09_04.md +8 -0
  93. package/src/engine/ecs/transform/t64_announce_change.d.ts +10 -7
  94. package/src/engine/ecs/transform/t64_announce_change.d.ts.map +1 -1
  95. package/src/engine/ecs/transform/t64_announce_change.js +12 -12
  96. package/src/engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.d.ts +30 -0
  97. package/src/engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.d.ts.map +1 -0
  98. package/src/engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.js +29 -0
  99. package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.d.ts.map +1 -1
  100. package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.js +13 -21
  101. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  102. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +4 -8
  103. package/src/engine/graphics3/LightSystem.d.ts.map +1 -1
  104. package/src/engine/graphics3/LightSystem.js +4 -8
  105. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
  106. package/src/engine/graphics3/MeshSystem.js +9 -19
  107. package/src/engine/graphics3/ParticleEmitterSystem.d.ts.map +1 -1
  108. package/src/engine/graphics3/ParticleEmitterSystem.js +4 -8
  109. package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -1
  110. package/src/engine/graphics3/ShadedGeometrySystem.js +4 -10
  111. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.d.ts +1 -1
  112. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.d.ts.map +1 -1
  113. package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +4 -8
  114. package/src/engine/intelligence/behavior/ecs/OrbitingBehavior.js +218 -218
  115. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  116. package/src/engine/physics/ecs/PhysicsSystem.js +2 -5
  117. package/src/engine/sound/ecs/SoundListenerSystem.d.ts.map +1 -1
  118. package/src/engine/sound/ecs/SoundListenerSystem.js +6 -8
  119. package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.d.ts +0 -4
  120. package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.d.ts.map +1 -1
  121. package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.js +5 -11
  122. package/src/shade/playground/particle_editor/README.md +43 -2
  123. package/src/shade/playground/particle_system/particle_prototype.d.ts.map +1 -1
  124. package/src/shade/playground/particle_system/particle_prototype.js +4 -5
  125. package/src/shade/playground/particle_system/particle_scene.js +4 -4
  126. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  127. package/src/shade/renderer/Renderer.js +13 -1
  128. package/src/shade/renderer/particles/DESIGN.md +104 -19
  129. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +64 -50
  130. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  131. package/src/shade/renderer/particles/GPUParticleSystem.js +176 -78
  132. package/src/shade/renderer/particles/ParticleConstants.d.ts +59 -23
  133. package/src/shade/renderer/particles/ParticleConstants.d.ts.map +1 -1
  134. package/src/shade/renderer/particles/ParticleConstants.js +66 -23
  135. package/src/shade/renderer/particles/ParticleRenderMode.d.ts +19 -0
  136. package/src/shade/renderer/particles/ParticleRenderMode.d.ts.map +1 -0
  137. package/src/shade/renderer/particles/ParticleRenderMode.js +33 -0
  138. package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.d.ts.map +1 -1
  139. package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.js +167 -166
  140. package/src/shade/renderer/particles/data/particle_emitter_record.d.ts +37 -0
  141. package/src/shade/renderer/particles/data/particle_emitter_record.d.ts.map +1 -0
  142. package/src/shade/renderer/particles/data/particle_emitter_record.js +109 -0
  143. package/src/shade/renderer/particles/graph/ParticleGroupBuilder.d.ts +3 -3
  144. package/src/shade/renderer/particles/graph/ParticleGroupBuilder.js +303 -303
  145. package/src/shade/renderer/particles/graph/ParticleNodeDescription.d.ts +18 -0
  146. package/src/shade/renderer/particles/graph/ParticleNodeDescription.d.ts.map +1 -1
  147. package/src/shade/renderer/particles/graph/ParticleNodeDescription.js +152 -133
  148. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts +0 -11
  149. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts.map +1 -1
  150. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.js +720 -621
  151. package/src/shade/renderer/particles/graph/compile_particle_graph.d.ts.map +1 -1
  152. package/src/shade/renderer/particles/graph/compile_particle_graph.js +8 -3
  153. package/src/shade/renderer/particles/graph/flatten_particle_graph.d.ts.map +1 -1
  154. package/src/shade/renderer/particles/graph/flatten_particle_graph.js +244 -213
  155. package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.d.ts.map +1 -1
  156. package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.js +6 -0
  157. package/src/shade/renderer/particles/graph/groups/particle_groups_geometry.d.ts.map +1 -1
  158. package/src/shade/renderer/particles/graph/groups/particle_groups_geometry.js +294 -319
  159. package/src/shade/renderer/particles/graph/groups/particle_groups_noise.d.ts.map +1 -1
  160. package/src/shade/renderer/particles/graph/groups/particle_groups_noise.js +524 -517
  161. package/src/shade/renderer/particles/graph/groups/particle_groups_psrdnoise.d.ts +22 -0
  162. package/src/shade/renderer/particles/graph/groups/particle_groups_psrdnoise.d.ts.map +1 -0
  163. package/src/shade/renderer/particles/graph/groups/particle_groups_psrdnoise.js +517 -0
  164. package/src/shade/renderer/particles/graph/groups/simplex_reference.d.ts.map +1 -1
  165. package/src/shade/renderer/particles/graph/groups/simplex_reference.js +185 -159
  166. package/src/shade/renderer/particles/graph/make_particle_group.d.ts.map +1 -1
  167. package/src/shade/renderer/particles/graph/make_particle_group.js +2 -20
  168. package/src/shade/renderer/particles/graph/particle_compare_ops.d.ts +17 -0
  169. package/src/shade/renderer/particles/graph/particle_compare_ops.d.ts.map +1 -0
  170. package/src/shade/renderer/particles/graph/particle_compare_ops.js +22 -0
  171. package/src/shade/renderer/particles/graph/particle_graph_diagnostic.d.ts +28 -8
  172. package/src/shade/renderer/particles/graph/particle_graph_diagnostic.d.ts.map +1 -1
  173. package/src/shade/renderer/particles/graph/particle_graph_diagnostic.js +49 -25
  174. package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts +40 -0
  175. package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts.map +1 -1
  176. package/src/shade/renderer/particles/graph/particle_node_parameters.js +312 -234
  177. package/src/shade/renderer/particles/graph/particle_node_presentation.d.ts.map +1 -1
  178. package/src/shade/renderer/particles/graph/particle_node_presentation.js +59 -3
  179. package/src/shade/renderer/particles/graph/particle_ramp.d.ts +230 -0
  180. package/src/shade/renderer/particles/graph/particle_ramp.d.ts.map +1 -0
  181. package/src/shade/renderer/particles/graph/particle_ramp.js +403 -0
  182. package/src/shade/renderer/particles/graph/validate_particle_graph.d.ts +7 -1
  183. package/src/shade/renderer/particles/graph/validate_particle_graph.d.ts.map +1 -1
  184. package/src/shade/renderer/particles/graph/validate_particle_graph.js +66 -10
  185. package/src/shade/renderer/particles/graph_particles.d.ts +23 -69
  186. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  187. package/src/shade/renderer/particles/graph_particles.js +105 -262
  188. package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
  189. package/src/shade/renderer/particles/graph_particles_avboit.js +3 -2
  190. package/src/shade/renderer/particles/graph_particles_billboard.d.ts +37 -0
  191. package/src/shade/renderer/particles/graph_particles_billboard.d.ts.map +1 -0
  192. package/src/shade/renderer/particles/graph_particles_billboard.js +93 -0
  193. package/src/shade/renderer/particles/isa/InstructionStream.d.ts +51 -22
  194. package/src/shade/renderer/particles/isa/InstructionStream.d.ts.map +1 -1
  195. package/src/shade/renderer/particles/isa/InstructionStream.js +98 -38
  196. package/src/shade/renderer/particles/isa/ParticleProgram.d.ts +49 -8
  197. package/src/shade/renderer/particles/isa/ParticleProgram.d.ts.map +1 -1
  198. package/src/shade/renderer/particles/isa/ParticleProgram.js +95 -150
  199. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +306 -64
  200. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
  201. package/src/shade/renderer/particles/isa/ParticleVMISA.js +505 -136
  202. package/src/shade/renderer/particles/isa/particle_assembly.d.ts +36 -12
  203. package/src/shade/renderer/particles/isa/particle_assembly.d.ts.map +1 -1
  204. package/src/shade/renderer/particles/isa/particle_assembly.js +354 -139
  205. package/src/shade/renderer/particles/isa/validate_particle_program.d.ts +9 -0
  206. package/src/shade/renderer/particles/isa/validate_particle_program.d.ts.map +1 -0
  207. package/src/shade/renderer/particles/isa/validate_particle_program.js +128 -0
  208. package/src/shade/renderer/particles/layout/ParticleLayout.d.ts +23 -0
  209. package/src/shade/renderer/particles/layout/ParticleLayout.d.ts.map +1 -1
  210. package/src/shade/renderer/particles/layout/ParticleLayout.js +68 -0
  211. package/src/shade/renderer/particles/optimizer/dag/optimize_particle_program_vector.d.ts +77 -0
  212. package/src/shade/renderer/particles/optimizer/dag/optimize_particle_program_vector.d.ts.map +1 -0
  213. package/src/shade/renderer/particles/optimizer/dag/optimize_particle_program_vector.js +219 -0
  214. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.d.ts +83 -0
  215. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.d.ts.map +1 -0
  216. package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.js +283 -0
  217. package/src/shade/renderer/particles/optimizer/dag/particle_vector_graph.d.ts +133 -0
  218. package/src/shade/renderer/particles/optimizer/dag/particle_vector_graph.d.ts.map +1 -0
  219. package/src/shade/renderer/particles/optimizer/dag/particle_vector_graph.js +334 -0
  220. package/src/shade/renderer/particles/optimizer/dag/particle_vector_groups.d.ts +117 -0
  221. package/src/shade/renderer/particles/optimizer/dag/particle_vector_groups.d.ts.map +1 -0
  222. package/src/shade/renderer/particles/optimizer/dag/particle_vector_groups.js +70 -0
  223. package/src/shade/renderer/particles/optimizer/dag/particle_vector_lift.d.ts +97 -0
  224. package/src/shade/renderer/particles/optimizer/dag/particle_vector_lift.d.ts.map +1 -0
  225. package/src/shade/renderer/particles/optimizer/dag/particle_vector_lift.js +462 -0
  226. package/src/shade/renderer/particles/optimizer/dag/particle_vector_lower.d.ts +116 -0
  227. package/src/shade/renderer/particles/optimizer/dag/particle_vector_lower.d.ts.map +1 -0
  228. package/src/shade/renderer/particles/optimizer/dag/particle_vector_lower.js +687 -0
  229. package/src/shade/renderer/particles/optimizer/dag/particle_vector_pack.d.ts +57 -0
  230. package/src/shade/renderer/particles/optimizer/dag/particle_vector_pack.d.ts.map +1 -0
  231. package/src/shade/renderer/particles/optimizer/dag/particle_vector_pack.js +860 -0
  232. package/src/shade/renderer/particles/optimizer/dag/particle_vector_rules.d.ts +115 -0
  233. package/src/shade/renderer/particles/optimizer/dag/particle_vector_rules.d.ts.map +1 -0
  234. package/src/shade/renderer/particles/optimizer/dag/particle_vector_rules.js +264 -0
  235. package/src/shade/renderer/particles/optimizer/optimize_particle_program.d.ts +81 -42
  236. package/src/shade/renderer/particles/optimizer/optimize_particle_program.d.ts.map +1 -1
  237. package/src/shade/renderer/particles/optimizer/optimize_particle_program.js +477 -478
  238. package/src/shade/renderer/particles/optimizer/particle_integer_bounds.d.ts +100 -0
  239. package/src/shade/renderer/particles/optimizer/particle_integer_bounds.d.ts.map +1 -0
  240. package/src/shade/renderer/particles/optimizer/particle_integer_bounds.js +236 -0
  241. package/src/shade/renderer/particles/optimizer/particle_program_analysis.d.ts +139 -59
  242. package/src/shade/renderer/particles/optimizer/particle_program_analysis.d.ts.map +1 -1
  243. package/src/shade/renderer/particles/optimizer/particle_program_analysis.js +764 -647
  244. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts +40 -7
  245. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts.map +1 -1
  246. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.js +376 -213
  247. package/src/shade/renderer/particles/optimizer/particle_program_fuzz.d.ts +30 -3
  248. package/src/shade/renderer/particles/optimizer/particle_program_fuzz.d.ts.map +1 -1
  249. package/src/shade/renderer/particles/optimizer/particle_program_fuzz.js +337 -223
  250. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts +24 -38
  251. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
  252. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +166 -206
  253. package/src/shade/renderer/particles/optimizer/pass_allocate_registers.d.ts +99 -0
  254. package/src/shade/renderer/particles/optimizer/pass_allocate_registers.d.ts.map +1 -0
  255. package/src/shade/renderer/particles/optimizer/pass_allocate_registers.js +313 -0
  256. package/src/shade/renderer/particles/optimizer/pass_dedup_constants.d.ts +3 -2
  257. package/src/shade/renderer/particles/optimizer/pass_dedup_constants.d.ts.map +1 -1
  258. package/src/shade/renderer/particles/optimizer/pass_dedup_constants.js +198 -197
  259. package/src/shade/renderer/particles/optimizer/pass_eliminate_dead_code.d.ts.map +1 -1
  260. package/src/shade/renderer/particles/optimizer/pass_fold_constants.d.ts +19 -0
  261. package/src/shade/renderer/particles/optimizer/pass_fold_constants.d.ts.map +1 -1
  262. package/src/shade/renderer/particles/optimizer/pass_fold_constants.js +678 -561
  263. package/src/shade/renderer/particles/optimizer/pass_inline_constants.d.ts +22 -0
  264. package/src/shade/renderer/particles/optimizer/pass_inline_constants.d.ts.map +1 -0
  265. package/src/shade/renderer/particles/optimizer/pass_inline_constants.js +221 -0
  266. package/src/shade/renderer/particles/optimizer/pass_narrow_widths.d.ts.map +1 -1
  267. package/src/shade/renderer/particles/optimizer/pass_narrow_widths.js +63 -72
  268. package/src/shade/renderer/particles/optimizer/pass_pack_registers.d.ts.map +1 -1
  269. package/src/shade/renderer/particles/optimizer/pass_pack_registers.js +87 -86
  270. package/src/shade/renderer/particles/optimizer/pass_peephole.d.ts.map +1 -1
  271. package/src/shade/renderer/particles/optimizer/pass_peephole.js +392 -271
  272. package/src/shade/renderer/particles/optimizer/pass_propagate_copies.d.ts.map +1 -1
  273. package/src/shade/renderer/particles/optimizer/pass_propagate_copies.js +361 -268
  274. package/src/shade/renderer/particles/optimizer/pass_schedule.d.ts +4 -0
  275. package/src/shade/renderer/particles/optimizer/pass_schedule.d.ts.map +1 -0
  276. package/src/shade/renderer/particles/optimizer/pass_schedule.js +244 -0
  277. package/src/shade/renderer/particles/optimizer/pass_share_subexpressions.d.ts.map +1 -1
  278. package/src/shade/renderer/particles/optimizer/pass_share_subexpressions.js +154 -151
  279. package/src/shade/renderer/particles/particle_test_fixtures.d.ts +20 -0
  280. package/src/shade/renderer/particles/particle_test_fixtures.d.ts.map +1 -1
  281. package/src/shade/renderer/particles/particle_test_fixtures.js +229 -203
  282. package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +99 -25
  283. package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
  284. package/src/shade/renderer/particles/runtime/EmitterRegistry.js +438 -286
  285. package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.d.ts +109 -0
  286. package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.d.ts.map +1 -0
  287. package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.js +127 -0
  288. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +87 -102
  289. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
  290. package/src/shade/renderer/particles/runtime/ParticleEmitter.js +184 -163
  291. package/src/shade/renderer/particles/runtime/ProgramArena.d.ts +26 -0
  292. package/src/shade/renderer/particles/runtime/ProgramArena.d.ts.map +1 -1
  293. package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts +130 -0
  294. package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts.map +1 -0
  295. package/src/shade/renderer/particles/runtime/ProgramHeap.js +595 -0
  296. package/src/shade/renderer/particles/runtime/ProgramPlacement.d.ts +91 -0
  297. package/src/shade/renderer/particles/runtime/ProgramPlacement.d.ts.map +1 -0
  298. package/src/shade/renderer/particles/runtime/ProgramPlacement.js +106 -0
  299. package/src/shade/renderer/particles/runtime/create_particle_effect.d.ts +5 -2
  300. package/src/shade/renderer/particles/runtime/create_particle_effect.d.ts.map +1 -1
  301. package/src/shade/renderer/particles/runtime/create_particle_effect.js +22 -19
  302. package/src/shade/renderer/particles/shaders/chunk_particle_emit_step.d.ts +28 -0
  303. package/src/shade/renderer/particles/shaders/chunk_particle_emit_step.d.ts.map +1 -0
  304. package/src/shade/renderer/particles/shaders/chunk_particle_emit_step.js +136 -0
  305. package/src/shade/renderer/particles/shaders/chunk_particle_simulate_step.d.ts +35 -0
  306. package/src/shade/renderer/particles/shaders/chunk_particle_simulate_step.d.ts.map +1 -0
  307. package/src/shade/renderer/particles/shaders/chunk_particle_simulate_step.js +133 -0
  308. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts +18 -9
  309. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
  310. package/src/shade/renderer/particles/shaders/shader_particle_emit.js +20 -80
  311. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts +33 -0
  312. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts.map +1 -0
  313. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.js +114 -0
  314. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts +8 -0
  315. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
  316. package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +33 -101
  317. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts +45 -0
  318. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts.map +1 -0
  319. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.js +123 -0
  320. package/src/shade/renderer/particles/sort/graph_particle_sort.d.ts +51 -0
  321. package/src/shade/renderer/particles/sort/graph_particle_sort.d.ts.map +1 -0
  322. package/src/shade/renderer/particles/sort/graph_particle_sort.js +120 -0
  323. package/src/shade/renderer/particles/vm/PARTICLE_VM_CONTEXT_STRUCT.d.ts +6 -0
  324. package/src/shade/renderer/particles/vm/PARTICLE_VM_CONTEXT_STRUCT.d.ts.map +1 -0
  325. package/src/shade/renderer/particles/vm/PARTICLE_VM_CONTEXT_STRUCT.js +16 -0
  326. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +4 -1
  327. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
  328. package/src/shade/renderer/particles/vm/ParticleVMReference.js +261 -140
  329. package/src/shade/renderer/particles/vm/chunk_particle_vm.d.ts.map +1 -1
  330. package/src/shade/renderer/particles/vm/chunk_particle_vm.js +217 -255
  331. package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_fast.d.ts +43 -0
  332. package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_fast.d.ts.map +1 -0
  333. package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_fast.js +55 -0
  334. package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.d.ts +62 -0
  335. package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.d.ts.map +1 -0
  336. package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.js +86 -0
  337. package/src/shade/renderer/shader/chunk/math/chunk_mod_v3f.d.ts +22 -0
  338. package/src/shade/renderer/shader/chunk/math/chunk_mod_v3f.d.ts.map +1 -0
  339. package/src/shade/renderer/shader/chunk/math/chunk_mod_v3f.js +32 -0
  340. package/src/shade/renderer/shader/chunk/math/chunk_mod_v4f.d.ts +9 -0
  341. package/src/shade/renderer/shader/chunk/math/chunk_mod_v4f.d.ts.map +1 -0
  342. package/src/shade/renderer/shader/chunk/math/chunk_mod_v4f.js +19 -0
  343. package/src/shade/renderer/shader/chunk/noise/psrdnoise/README.md +65 -0
  344. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.d.ts +24 -0
  345. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.d.ts.map +1 -0
  346. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.js +83 -0
  347. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.d.ts +25 -0
  348. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.d.ts.map +1 -0
  349. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.js +42 -0
  350. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.d.ts +31 -0
  351. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.d.ts.map +1 -0
  352. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.js +80 -0
  353. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.d.ts +26 -0
  354. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.d.ts.map +1 -0
  355. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.js +109 -0
  356. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.d.ts +38 -0
  357. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.d.ts.map +1 -0
  358. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.js +129 -0
  359. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.d.ts +21 -0
  360. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.d.ts.map +1 -0
  361. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.js +35 -0
  362. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.d.ts +19 -0
  363. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.d.ts.map +1 -0
  364. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.js +28 -0
  365. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.d.ts +13 -0
  366. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.d.ts.map +1 -0
  367. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.js +22 -0
  368. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.d.ts +22 -0
  369. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.d.ts.map +1 -0
  370. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.js +59 -0
  371. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise3.d.ts +23 -0
  372. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise3.d.ts.map +1 -0
  373. package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise3.js +74 -0
  374. package/src/shade/wgsl/emulator/ComputeShaderEmulator.d.ts +34 -1
  375. package/src/shade/wgsl/emulator/ComputeShaderEmulator.d.ts.map +1 -1
  376. package/src/shade/wgsl/emulator/ComputeShaderEmulator.js +41 -1
  377. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts +3 -2
  378. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts.map +1 -1
  379. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +49 -10
  380. package/src/view/minimap/dom/MinimapCameraView.d.ts.map +1 -1
  381. package/src/view/minimap/dom/MinimapCameraView.js +4 -9
  382. package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.d.ts +0 -15
  383. package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.d.ts.map +0 -1
  384. package/src/core/model/node-graph/visual/layout/ConnectedBoxLayouter.d.ts +0 -45
  385. package/src/core/model/node-graph/visual/layout/ConnectedBoxLayouter.d.ts.map +0 -1
  386. package/src/core/model/node-graph/visual/layout/ConnectionEndpointLayoutSpec.d.ts +0 -24
  387. package/src/core/model/node-graph/visual/layout/ConnectionEndpointLayoutSpec.d.ts.map +0 -1
  388. package/src/core/model/node-graph/visual/layout/ConnectionLayoutSpec.d.ts +0 -19
  389. package/src/core/model/node-graph/visual/layout/ConnectionLayoutSpec.d.ts.map +0 -1
  390. package/src/engine/ecs/transform/__probe.d.ts +0 -4
  391. package/src/engine/ecs/transform/__probe.d.ts.map +0 -1
  392. package/src/engine/ecs/util/hideEntityGracefully.d.ts +0 -9
  393. package/src/engine/ecs/util/hideEntityGracefully.d.ts.map +0 -1
  394. package/src/shade/renderer/buffer/table/gpu_database_emulator_image.d.ts +0 -27
  395. package/src/shade/renderer/buffer/table/gpu_database_emulator_image.d.ts.map +0 -1
  396. package/src/shade/renderer/particles/cull/chunk_particle_cull.d.ts +0 -14
  397. package/src/shade/renderer/particles/cull/chunk_particle_cull.d.ts.map +0 -1
  398. package/src/shade/renderer/particles/data/PARTICLE_EMITTER_LAYOUT.d.ts +0 -156
  399. package/src/shade/renderer/particles/data/PARTICLE_EMITTER_LAYOUT.d.ts.map +0 -1
  400. package/src/shade/renderer/particles/runtime/Emitter.d.ts +0 -219
  401. package/src/shade/renderer/particles/runtime/Emitter.d.ts.map +0 -1
  402. package/src/shade/renderer/particles/runtime/ParticleSpawnScheduler.d.ts +0 -77
  403. package/src/shade/renderer/particles/runtime/ParticleSpawnScheduler.d.ts.map +0 -1
  404. package/src/shade/renderer/particles/runtime/ProgramArena.js +0 -155
  405. package/src/shade/renderer/particles/runtime/emitter_database_image.d.ts +0 -15
  406. package/src/shade/renderer/particles/runtime/emitter_database_image.d.ts.map +0 -1
  407. package/src/shade/renderer/particles/runtime/spawn_request_encoding.d.ts +0 -34
  408. package/src/shade/renderer/particles/runtime/spawn_request_encoding.d.ts.map +0 -1
  409. package/src/shade/renderer/particles/shaders/chunk_particle_context.d.ts +0 -32
  410. package/src/shade/renderer/particles/shaders/chunk_particle_context.d.ts.map +0 -1
@@ -0,0 +1,80 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_psrdnoise2_hash } from "./chunk_psrdnoise2_hash.js";
3
+
4
+ /**
5
+ * Everything a 2-D psrdnoise sample does once its simplex is known: hash the three corners, turn
6
+ * each hash into a rotating unit gradient, and sum the radially-weighted ramps into a noise value
7
+ * and its exact first derivative.
8
+ *
9
+ * This is the whole cost of the function. It is factored out because it is identical for the
10
+ * periodic {@link chunk_psrdnoise2} and the non-periodic {@link chunk_srdnoise2} — the two differ
11
+ * only in how they arrive at `iu`/`iv`, and sharing this keeps that difference down to the wrap
12
+ * itself.
13
+ *
14
+ * **Rotating gradients.** Each corner's gradient is a *unit vector at an angle*, not a table entry:
15
+ * `psi` is the hashed angle and `alpha` turns every gradient in the field by the same amount. The
16
+ * result is a swirl rather than a crossfade, which is what "flow noise" is — animate `alpha` and the
17
+ * pattern rotates in place instead of dissolving. The rotation is a single add, so unlike the 3-D
18
+ * version there is nothing to gain from `alpha == 0`.
19
+ *
20
+ * **Why the derivative is free.** `w⁴·(g·x)` is a product of two things whose derivatives are
21
+ * already computed, so the product rule costs a handful of multiply-adds and no transcendentals.
22
+ * Curl noise, normal mapping and erosion all need the gradient, and a finite difference would cost
23
+ * three more evaluations and be wrong at the cell boundaries.
24
+ *
25
+ * Returns `vec3(noise, gradient.x, gradient.y)` — the noise value in `.x`, so a caller that wants
26
+ * only the value writes `.x` and lets the compiler drop the derivative tail.
27
+ *
28
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
29
+ * @see https://github.com/stegu/psrdnoise/
30
+ * @type {CodeChunk}
31
+ */
32
+ export const chunk_psrdnoise2_kernel = CodeChunk.from(
33
+ //language=WGSL
34
+ `
35
+ fn psrdnoise2_kernel(
36
+ iu: vec3<f32>,
37
+ iv: vec3<f32>,
38
+ x0: vec2<f32>,
39
+ x1: vec2<f32>,
40
+ x2: vec2<f32>,
41
+ alpha: f32
42
+ ) -> vec3<f32> {
43
+ // a pseudo-random angle per corner, every one of them turned by alpha. 0.07482 rad per hash
44
+ // step is deliberately not 2*pi/289: the 289 hash values wind about three and a half times
45
+ // around the circle rather than once, so two corners whose hashes landed near each other do
46
+ // not get gradients pointing the same way. Upstream states the constant without deriving it
47
+ let psi = psrdnoise2_hash(iu, iv) * 0.07482 + alpha;
48
+
49
+ let gx = cos(psi);
50
+ let gy = sin(psi);
51
+
52
+ let g0 = vec2<f32>(gx.x, gy.x);
53
+ let g1 = vec2<f32>(gx.y, gy.y);
54
+ let g2 = vec2<f32>(gx.z, gy.z);
55
+
56
+ // radial decay with distance from each corner. 0.8 is the squared radius of each corner's
57
+ // support: far enough that the three of them cover the cell between them, near enough that no
58
+ // corner outside the simplex ever reaches into it and would have had to be summed as well
59
+ let w = max(0.8 - vec3<f32>(dot(x0, x0), dot(x1, x1), dot(x2, x2)), vec3<f32>(0.0));
60
+ let w2 = w * w;
61
+ let w4 = w2 * w2;
62
+
63
+ // the linear ramp from each corner
64
+ let gdotx = vec3<f32>(dot(g0, x0), dot(g1, x1), dot(g2, x2));
65
+
66
+ let n = dot(w4, gdotx);
67
+
68
+ // d/dx of w^4 * (g . x), by the product rule. d(w^4) = 4*w^3 * d(w), and d(w) = -2*x
69
+ let dw = -8.0 * (w2 * w) * gdotx;
70
+ let dn0 = w4.x * g0 + dw.x * x0;
71
+ let dn1 = w4.y * g1 + dw.y * x1;
72
+ let dn2 = w4.z * g2 + dw.z * x2;
73
+
74
+ // 10.9 scales the sum to fill [-1, 1]; the same factor applies to the derivative
75
+ return vec3<f32>(n, dn0 + dn1 + dn2) * 10.9;
76
+ }
77
+ `, [
78
+ chunk_psrdnoise2_hash,
79
+ ]
80
+ );
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Periodic (tiling) 3-D simplex noise with rotating gradients and an analytic derivative.
3
+ *
4
+ * Returns `vec4(noise, gradient.xyz)`: the noise value is in `.x`, in `[-1, 1]`, and `.yzw` is its
5
+ * exact gradient. Ask for only `.x` and the compiler drops the derivative.
6
+ *
7
+ * **What tiles.** The lattice is axis-aligned in texture space, which ordinary 3-D simplex noise's
8
+ * skewed grid is not, and that is what lets a rectangular period be imposed on it at all. Any
9
+ * integer period up to 289 works on each axis independently; zero or negative skips the wrap for
10
+ * that axis, and `vec3(0.0)` on all three takes a shortcut worth 10-15% by upstream's measurement of
11
+ * the GLSL. A caller that always passes zero should call {@link chunk_srdnoise3} instead and not pay
12
+ * for the branch. 289 is the hash's modulus, so it is a hard ceiling — a longer period does not
13
+ * tile, it repeats inside itself.
14
+ *
15
+ * **What `alpha` does.** It turns every gradient by that many radians about a per-corner
16
+ * pseudo-random axis. Animating it swirls the field in place rather than crossfading it, and with
17
+ * the gradient it gives curl noise; `alpha == 0` takes a cheaper path when the whole warp agrees on
18
+ * it. See {@link chunk_psrdnoise3_kernel}.
19
+ *
20
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
21
+ * @see https://github.com/stegu/psrdnoise/
22
+ * @type {CodeChunk}
23
+ */
24
+ export const chunk_psrdnoise3: CodeChunk;
25
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
26
+ //# sourceMappingURL=chunk_psrdnoise3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_psrdnoise3.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+BAFU,SAAS,CAiFjB;0BA5GwB,gCAAgC"}
@@ -0,0 +1,109 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_mod_v4f } from "../../math/chunk_mod_v4f.js";
3
+ import { chunk_psrdnoise3_kernel } from "./chunk_psrdnoise3_kernel.js";
4
+ import { chunk_psrdnoise3_skew } from "./chunk_psrdnoise3_skew.js";
5
+ import { chunk_psrdnoise3_unskew } from "./chunk_psrdnoise3_unskew.js";
6
+
7
+ /**
8
+ * Periodic (tiling) 3-D simplex noise with rotating gradients and an analytic derivative.
9
+ *
10
+ * Returns `vec4(noise, gradient.xyz)`: the noise value is in `.x`, in `[-1, 1]`, and `.yzw` is its
11
+ * exact gradient. Ask for only `.x` and the compiler drops the derivative.
12
+ *
13
+ * **What tiles.** The lattice is axis-aligned in texture space, which ordinary 3-D simplex noise's
14
+ * skewed grid is not, and that is what lets a rectangular period be imposed on it at all. Any
15
+ * integer period up to 289 works on each axis independently; zero or negative skips the wrap for
16
+ * that axis, and `vec3(0.0)` on all three takes a shortcut worth 10-15% by upstream's measurement of
17
+ * the GLSL. A caller that always passes zero should call {@link chunk_srdnoise3} instead and not pay
18
+ * for the branch. 289 is the hash's modulus, so it is a hard ceiling — a longer period does not
19
+ * tile, it repeats inside itself.
20
+ *
21
+ * **What `alpha` does.** It turns every gradient by that many radians about a per-corner
22
+ * pseudo-random axis. Animating it swirls the field in place rather than crossfading it, and with
23
+ * the gradient it gives curl noise; `alpha == 0` takes a cheaper path when the whole warp agrees on
24
+ * it. See {@link chunk_psrdnoise3_kernel}.
25
+ *
26
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
27
+ * @see https://github.com/stegu/psrdnoise/
28
+ * @type {CodeChunk}
29
+ */
30
+ export const chunk_psrdnoise3 = CodeChunk.from(
31
+ //language=WGSL
32
+ `
33
+ fn psrdnoise3(
34
+ x: vec3<f32>,
35
+ period: vec3<f32>,
36
+ alpha: f32
37
+ ) -> vec4<f32> {
38
+ let uvw = psrdnoise3_skew(x);
39
+
40
+ // which simplex we are in. i0 is the base corner of the skewed cube; o1 and o2 step to the
41
+ // second and third corners, found by rank-ordering u, v, w — the descending order of the
42
+ // fractional coordinates is exactly the order the tetrahedron's corners are traversed in
43
+ let i0 = floor(uvw);
44
+ let f0 = uvw - i0;
45
+
46
+ let gt_ = step(f0.xyx, f0.yzz);
47
+ let lt_ = 1.0 - gt_;
48
+ let gt = vec3<f32>(lt_.z, gt_.xy);
49
+ let lt = vec3<f32>(lt_.xy, gt_.z);
50
+ let o1 = min(gt, lt);
51
+ let o2 = max(gt, lt);
52
+
53
+ let i1 = i0 + o1;
54
+ let i2 = i0 + o2;
55
+ let i3 = i0 + vec3<f32>(1.0);
56
+
57
+ // the four corners back in texture space
58
+ let v0 = psrdnoise3_unskew(i0);
59
+ let v1 = psrdnoise3_unskew(i1);
60
+ let v2 = psrdnoise3_unskew(i2);
61
+ let v3 = psrdnoise3_unskew(i3);
62
+
63
+ var ix = vec4<f32>(i0.x, i1.x, i2.x, i3.x);
64
+ var iy = vec4<f32>(i0.y, i1.y, i2.y, i3.y);
65
+ var iz = vec4<f32>(i0.z, i1.z, i2.z, i3.z);
66
+
67
+ if (any(period > vec3<f32>(0.0))) {
68
+ // the wrap has to happen in texture space, where the period is rectangular, and the corners
69
+ // then go back to simplex space to be hashed. Only the hash inputs move; the offsets below
70
+ // stay measured from the unwrapped corners, which is what keeps the field continuous
71
+ // across the seam
72
+ var vx = vec4<f32>(v0.x, v1.x, v2.x, v3.x);
73
+ var vy = vec4<f32>(v0.y, v1.y, v2.y, v3.y);
74
+ var vz = vec4<f32>(v0.z, v1.z, v2.z, v3.z);
75
+
76
+ if (period.x > 0.0) {
77
+ vx = mod_v4f(vx, period.x);
78
+ }
79
+
80
+ if (period.y > 0.0) {
81
+ vy = mod_v4f(vy, period.y);
82
+ }
83
+
84
+ if (period.z > 0.0) {
85
+ vz = mod_v4f(vz, period.z);
86
+ }
87
+
88
+ // the skew takes each wrapped corner back to simplex space, where it is an integer lattice
89
+ // point — but the wrap leaves it a hair off one, so the +0.5 under the floor rounds to
90
+ // nearest rather than truncating into the neighbouring cell
91
+ let j0 = floor(psrdnoise3_skew(vec3<f32>(vx.x, vy.x, vz.x)) + 0.5);
92
+ let j1 = floor(psrdnoise3_skew(vec3<f32>(vx.y, vy.y, vz.y)) + 0.5);
93
+ let j2 = floor(psrdnoise3_skew(vec3<f32>(vx.z, vy.z, vz.z)) + 0.5);
94
+ let j3 = floor(psrdnoise3_skew(vec3<f32>(vx.w, vy.w, vz.w)) + 0.5);
95
+
96
+ ix = vec4<f32>(j0.x, j1.x, j2.x, j3.x);
97
+ iy = vec4<f32>(j0.y, j1.y, j2.y, j3.y);
98
+ iz = vec4<f32>(j0.z, j1.z, j2.z, j3.z);
99
+ }
100
+
101
+ return psrdnoise3_kernel(ix, iy, iz, x - v0, x - v1, x - v2, x - v3, alpha);
102
+ }
103
+ `, [
104
+ chunk_mod_v4f,
105
+ chunk_psrdnoise3_kernel,
106
+ chunk_psrdnoise3_skew,
107
+ chunk_psrdnoise3_unskew,
108
+ ]
109
+ );
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Everything a 3-D psrdnoise sample does once its simplex is known: hash the four corners, turn each
3
+ * hash into a rotating unit gradient, and sum the radially-weighted ramps into a noise value and its
4
+ * exact first derivative.
5
+ *
6
+ * This is the whole cost of the function. It is factored out because it is identical for the
7
+ * periodic {@link chunk_psrdnoise3} and the non-periodic {@link chunk_srdnoise3}, which differ only
8
+ * in how they arrive at the lattice coordinates.
9
+ *
10
+ * **Gradients from a spiral, not a table.** Classic 3-D simplex noise picks each corner's gradient
11
+ * from a small fixed table, and the table's directions show up in the field as faint preferred axes.
12
+ * Here `hash` is read as a position on a Fibonacci spiral over the unit sphere — `theta` around,
13
+ * `sz` up — which spreads 289 directions near-uniformly with no axis to favour.
14
+ *
15
+ * **Rotating gradients.** `alpha` turns every gradient by that many radians about a per-corner
16
+ * pseudo-random axis. Animating it swirls the field in place instead of crossfading it, which is
17
+ * what "flow noise" is, and with the analytic derivative below it is what curl noise needs. The
18
+ * rotation is a genuine 3-D rotation and costs two more transcendental pairs, so `alpha == 0` takes
19
+ * the shortcut branch and uses the spiral point directly — worth 15-20% by upstream's measurement of
20
+ * the GLSL when the whole warp agrees on `alpha == 0`, and nothing when it does not.
21
+ *
22
+ * **Why the derivative is free.** `w³·(g·x)` is a product of two things already computed, so the
23
+ * product rule costs a handful of multiply-adds and no transcendentals. A finite difference would
24
+ * cost three more evaluations and be wrong at the cell boundaries.
25
+ *
26
+ * The lattice coordinates arrive transposed — `ix` holds the x coordinate of all four corners, and
27
+ * so on — which is the layout the hash wants and the one the caller already has.
28
+ *
29
+ * Returns `vec4(noise, gradient.xyz)`: the noise value in `.x`, so a caller that wants only the
30
+ * value writes `.x` and lets the compiler drop the derivative tail.
31
+ *
32
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
33
+ * @see https://github.com/stegu/psrdnoise/
34
+ * @type {CodeChunk}
35
+ */
36
+ export const chunk_psrdnoise3_kernel: CodeChunk;
37
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
38
+ //# sourceMappingURL=chunk_psrdnoise3_kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_psrdnoise3_kernel.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,sCAFU,SAAS,CA4FjB;0BAhIwB,gCAAgC"}
@@ -0,0 +1,129 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_psrdnoise3_permute } from "./chunk_psrdnoise3_permute.js";
3
+
4
+ /**
5
+ * Everything a 3-D psrdnoise sample does once its simplex is known: hash the four corners, turn each
6
+ * hash into a rotating unit gradient, and sum the radially-weighted ramps into a noise value and its
7
+ * exact first derivative.
8
+ *
9
+ * This is the whole cost of the function. It is factored out because it is identical for the
10
+ * periodic {@link chunk_psrdnoise3} and the non-periodic {@link chunk_srdnoise3}, which differ only
11
+ * in how they arrive at the lattice coordinates.
12
+ *
13
+ * **Gradients from a spiral, not a table.** Classic 3-D simplex noise picks each corner's gradient
14
+ * from a small fixed table, and the table's directions show up in the field as faint preferred axes.
15
+ * Here `hash` is read as a position on a Fibonacci spiral over the unit sphere — `theta` around,
16
+ * `sz` up — which spreads 289 directions near-uniformly with no axis to favour.
17
+ *
18
+ * **Rotating gradients.** `alpha` turns every gradient by that many radians about a per-corner
19
+ * pseudo-random axis. Animating it swirls the field in place instead of crossfading it, which is
20
+ * what "flow noise" is, and with the analytic derivative below it is what curl noise needs. The
21
+ * rotation is a genuine 3-D rotation and costs two more transcendental pairs, so `alpha == 0` takes
22
+ * the shortcut branch and uses the spiral point directly — worth 15-20% by upstream's measurement of
23
+ * the GLSL when the whole warp agrees on `alpha == 0`, and nothing when it does not.
24
+ *
25
+ * **Why the derivative is free.** `w³·(g·x)` is a product of two things already computed, so the
26
+ * product rule costs a handful of multiply-adds and no transcendentals. A finite difference would
27
+ * cost three more evaluations and be wrong at the cell boundaries.
28
+ *
29
+ * The lattice coordinates arrive transposed — `ix` holds the x coordinate of all four corners, and
30
+ * so on — which is the layout the hash wants and the one the caller already has.
31
+ *
32
+ * Returns `vec4(noise, gradient.xyz)`: the noise value in `.x`, so a caller that wants only the
33
+ * value writes `.x` and lets the compiler drop the derivative tail.
34
+ *
35
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
36
+ * @see https://github.com/stegu/psrdnoise/
37
+ * @type {CodeChunk}
38
+ */
39
+ export const chunk_psrdnoise3_kernel = CodeChunk.from(
40
+ //language=WGSL
41
+ `
42
+ fn psrdnoise3_kernel(
43
+ ix: vec4<f32>,
44
+ iy: vec4<f32>,
45
+ iz: vec4<f32>,
46
+ x0: vec3<f32>,
47
+ x1: vec3<f32>,
48
+ x2: vec3<f32>,
49
+ x3: vec3<f32>,
50
+ alpha: f32
51
+ ) -> vec4<f32> {
52
+ // one pseudo-random value per corner. Folding one axis in between each permutation is what
53
+ // makes the three coordinates a single hash rather than three independent ones
54
+ let hash = psrdnoise3_permute(psrdnoise3_permute(psrdnoise3_permute(iz) + iy) + ix);
55
+
56
+ // read the hash as a point on a Fibonacci spiral over the unit sphere
57
+ let theta = hash * 3.883222077; // 2*pi / golden ratio, the spiral's turn per step
58
+ let sz = hash * -0.006920415 + 0.996539792; // height, 1 - (hash + 0.5) * 2/289
59
+ let psi = hash * 0.108705628; // 10*pi/289, a rotation phase chosen not to
60
+ // correlate with theta
61
+
62
+ let ct = cos(theta);
63
+ let st = sin(theta);
64
+ let sz_prime = sqrt(1.0 - sz * sz); // the spiral point's radius off the axis
65
+
66
+ var gx: vec4<f32>;
67
+ var gy: vec4<f32>;
68
+ var gz: vec4<f32>;
69
+
70
+ if (alpha != 0.0) {
71
+ // rotate the spiral point s by alpha about a pseudo-random axis orthogonal to it. p is s
72
+ // itself and q is the orthogonal direction that psi picks out, so (p, q) spans the plane
73
+ // of rotation and the gradient is just cos(alpha)*p + sin(alpha)*q
74
+ let sp = sin(psi);
75
+ let cp = cos(psi);
76
+
77
+ let px = ct * sz_prime;
78
+ let py = st * sz_prime;
79
+ let pz = sz;
80
+
81
+ let ctp = st * sp - ct * cp;
82
+ let qx = mix(ctp * st, sp, sz);
83
+ let qy = mix(-ctp * ct, cp, sz);
84
+ let qz = -(py * cp + px * sp);
85
+
86
+ let sa = sin(alpha);
87
+ let ca = cos(alpha);
88
+
89
+ gx = ca * px + sa * qx;
90
+ gy = ca * py + sa * qy;
91
+ gz = ca * pz + sa * qz;
92
+ } else {
93
+ // no rotation asked for, so the spiral point is the gradient
94
+ gx = ct * sz_prime;
95
+ gy = st * sz_prime;
96
+ gz = sz;
97
+ }
98
+
99
+ let g0 = vec3<f32>(gx.x, gy.x, gz.x);
100
+ let g1 = vec3<f32>(gx.y, gy.y, gz.y);
101
+ let g2 = vec3<f32>(gx.z, gy.z, gz.z);
102
+ let g3 = vec3<f32>(gx.w, gy.w, gz.w);
103
+
104
+ // radial decay with distance from each corner. 0.5 is the squared radius of each corner's
105
+ // support: far enough that the four of them cover the cell between them, near enough that no
106
+ // corner outside the simplex ever reaches into it
107
+ let w = max(0.5 - vec4<f32>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), vec4<f32>(0.0));
108
+ let w2 = w * w;
109
+ let w3 = w2 * w;
110
+
111
+ // the linear ramp from each corner
112
+ let gdotx = vec4<f32>(dot(g0, x0), dot(g1, x1), dot(g2, x2), dot(g3, x3));
113
+
114
+ let n = dot(w3, gdotx);
115
+
116
+ // d/dx of w^3 * (g . x), by the product rule. d(w^3) = 3*w^2 * d(w), and d(w) = -2*x
117
+ let dw = -6.0 * w2 * gdotx;
118
+ let dn0 = w3.x * g0 + dw.x * x0;
119
+ let dn1 = w3.y * g1 + dw.y * x1;
120
+ let dn2 = w3.z * g2 + dw.z * x2;
121
+ let dn3 = w3.w * g3 + dw.w * x3;
122
+
123
+ // 39.5 scales the sum to fill [-1, 1]; the same factor applies to the derivative
124
+ return vec4<f32>(n, dn0 + dn1 + dn2 + dn3) * 39.5;
125
+ }
126
+ `, [
127
+ chunk_psrdnoise3_permute,
128
+ ]
129
+ );
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The permutation polynomial behind the 3-D psrdnoise hash, applied to four lattice coordinates at
3
+ * once.
4
+ *
5
+ * `x ↦ (34x + 10)x mod 289` is a bijection on `[0, 289)`, which is what makes it a *permutation*
6
+ * and not merely a hash: no two lattice coordinates collide, so no two corners of a cell can be
7
+ * handed the same gradient. Nesting it three times, folding in one axis between each, extends that
8
+ * to three dimensions — see {@link chunk_psrdnoise3_kernel} for the nesting.
9
+ *
10
+ * 289 is 17², and the modulus is what bounds the period of the noise field: coordinates congruent
11
+ * modulo 289 hash the same, so the field repeats every 289 cells whether or not a period was asked
12
+ * for. The coefficients are sized to keep `(34x + 10)x` inside the range an `f32` represents
13
+ * exactly, which is why the modulus cannot simply be made larger.
14
+ *
15
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
16
+ * @see https://github.com/stegu/psrdnoise/
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_psrdnoise3_permute: CodeChunk;
20
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
21
+ //# sourceMappingURL=chunk_psrdnoise3_permute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_psrdnoise3_permute.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,uCAFU,SAAS,CAejB;0BAlCwB,gCAAgC"}
@@ -0,0 +1,35 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_mod_v4f } from "../../math/chunk_mod_v4f.js";
3
+
4
+ /**
5
+ * The permutation polynomial behind the 3-D psrdnoise hash, applied to four lattice coordinates at
6
+ * once.
7
+ *
8
+ * `x ↦ (34x + 10)x mod 289` is a bijection on `[0, 289)`, which is what makes it a *permutation*
9
+ * and not merely a hash: no two lattice coordinates collide, so no two corners of a cell can be
10
+ * handed the same gradient. Nesting it three times, folding in one axis between each, extends that
11
+ * to three dimensions — see {@link chunk_psrdnoise3_kernel} for the nesting.
12
+ *
13
+ * 289 is 17², and the modulus is what bounds the period of the noise field: coordinates congruent
14
+ * modulo 289 hash the same, so the field repeats every 289 cells whether or not a period was asked
15
+ * for. The coefficients are sized to keep `(34x + 10)x` inside the range an `f32` represents
16
+ * exactly, which is why the modulus cannot simply be made larger.
17
+ *
18
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
19
+ * @see https://github.com/stegu/psrdnoise/
20
+ * @type {CodeChunk}
21
+ */
22
+ export const chunk_psrdnoise3_permute = CodeChunk.from(
23
+ //language=WGSL
24
+ `
25
+ fn psrdnoise3_permute(
26
+ x: vec4<f32>
27
+ ) -> vec4<f32> {
28
+ let xm = mod_v4f(x, 289.0);
29
+
30
+ return mod_v4f((xm * 34.0 + 10.0) * xm, 289.0);
31
+ }
32
+ `, [
33
+ chunk_mod_v4f,
34
+ ]
35
+ );
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Texture space to 3-D psrdnoise simplex space.
3
+ *
4
+ * The transform `M = [[0,1,1],[1,0,1],[1,1,0]]`, written out. `det(M) = 2`, so the lattice it
5
+ * generates carries two points per unit cube of texture space — the body-centred cubic lattice that
6
+ * every tetrahedral simplex noise uses, but here *axis-aligned* with the space being sampled rather
7
+ * than skewed away from it. That alignment is the whole reason this noise can be given a rectangular
8
+ * period at all: a wrap applied to the texture-space corners maps back onto the lattice cleanly,
9
+ * which it does not when the lattice sits at an angle to the axes the period is expressed in.
10
+ *
11
+ * {@link chunk_psrdnoise3_unskew} is the inverse.
12
+ *
13
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
14
+ * @see https://github.com/stegu/psrdnoise/
15
+ * @type {CodeChunk}
16
+ */
17
+ export const chunk_psrdnoise3_skew: CodeChunk;
18
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
19
+ //# sourceMappingURL=chunk_psrdnoise3_skew.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_psrdnoise3_skew.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,oCAFU,SAAS,CAWjB;0BA3BwB,gCAAgC"}
@@ -0,0 +1,28 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * Texture space to 3-D psrdnoise simplex space.
5
+ *
6
+ * The transform `M = [[0,1,1],[1,0,1],[1,1,0]]`, written out. `det(M) = 2`, so the lattice it
7
+ * generates carries two points per unit cube of texture space — the body-centred cubic lattice that
8
+ * every tetrahedral simplex noise uses, but here *axis-aligned* with the space being sampled rather
9
+ * than skewed away from it. That alignment is the whole reason this noise can be given a rectangular
10
+ * period at all: a wrap applied to the texture-space corners maps back onto the lattice cleanly,
11
+ * which it does not when the lattice sits at an angle to the axes the period is expressed in.
12
+ *
13
+ * {@link chunk_psrdnoise3_unskew} is the inverse.
14
+ *
15
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
16
+ * @see https://github.com/stegu/psrdnoise/
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_psrdnoise3_skew = CodeChunk.from(
20
+ //language=WGSL
21
+ `
22
+ fn psrdnoise3_skew(
23
+ x: vec3<f32>
24
+ ) -> vec3<f32> {
25
+ return vec3<f32>(x.y + x.z, x.z + x.x, x.x + x.y);
26
+ }
27
+ `
28
+ );
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 3-D psrdnoise simplex space back to texture space — the inverse of {@link chunk_psrdnoise3_skew}.
3
+ *
4
+ * `M⁻¹ = [[-0.5,0.5,0.5],[0.5,-0.5,0.5],[0.5,0.5,-0.5]]`, written out. Its inputs are always
5
+ * integer lattice coordinates and the factor is a power of two, so every operation here is exact.
6
+ *
7
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
8
+ * @see https://github.com/stegu/psrdnoise/
9
+ * @type {CodeChunk}
10
+ */
11
+ export const chunk_psrdnoise3_unskew: CodeChunk;
12
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
13
+ //# sourceMappingURL=chunk_psrdnoise3_unskew.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_psrdnoise3_unskew.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,sCAFU,SAAS,CAWjB;0BArBwB,gCAAgC"}
@@ -0,0 +1,22 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * 3-D psrdnoise simplex space back to texture space — the inverse of {@link chunk_psrdnoise3_skew}.
5
+ *
6
+ * `M⁻¹ = [[-0.5,0.5,0.5],[0.5,-0.5,0.5],[0.5,0.5,-0.5]]`, written out. Its inputs are always
7
+ * integer lattice coordinates and the factor is a power of two, so every operation here is exact.
8
+ *
9
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
10
+ * @see https://github.com/stegu/psrdnoise/
11
+ * @type {CodeChunk}
12
+ */
13
+ export const chunk_psrdnoise3_unskew = CodeChunk.from(
14
+ //language=WGSL
15
+ `
16
+ fn psrdnoise3_unskew(
17
+ i: vec3<f32>
18
+ ) -> vec3<f32> {
19
+ return 0.5 * vec3<f32>(i.y + i.z - i.x, i.z + i.x - i.y, i.x + i.y - i.z);
20
+ }
21
+ `
22
+ );
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 2-D simplex noise with rotating gradients and an analytic derivative — `psrdnoise` without the
3
+ * `p`, for fields that never need to tile.
4
+ *
5
+ * Returns `vec3(noise, gradient.x, gradient.y)`: the noise value is in `.x`, in `[-1, 1]`, and
6
+ * `.yz` is its exact gradient. Ask for only `.x` and the compiler drops the derivative.
7
+ *
8
+ * `alpha` turns every gradient in the field by that many radians. Animating it swirls the pattern
9
+ * in place — see {@link chunk_psrdnoise2_kernel} for what that buys and why it is nearly free.
10
+ *
11
+ * This is {@link chunk_psrdnoise2} with the wrap deleted, not a call into it with a zero period: it
12
+ * exists so a caller whose period is a runtime value it never sets does not pay for the branch and
13
+ * the modulo. It still repeats every 289 cells — that is the hash's modulus, not a choice — so it
14
+ * is "non-periodic" only in the sense that it does not tile to a period you name.
15
+ *
16
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
17
+ * @see https://github.com/stegu/psrdnoise/
18
+ * @type {CodeChunk}
19
+ */
20
+ export const chunk_srdnoise2: CodeChunk;
21
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
22
+ //# sourceMappingURL=chunk_srdnoise2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_srdnoise2.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAFU,SAAS,CAsCjB;0BA1DwB,gCAAgC"}
@@ -0,0 +1,59 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_psrdnoise2_kernel } from "./chunk_psrdnoise2_kernel.js";
3
+
4
+ /**
5
+ * 2-D simplex noise with rotating gradients and an analytic derivative — `psrdnoise` without the
6
+ * `p`, for fields that never need to tile.
7
+ *
8
+ * Returns `vec3(noise, gradient.x, gradient.y)`: the noise value is in `.x`, in `[-1, 1]`, and
9
+ * `.yz` is its exact gradient. Ask for only `.x` and the compiler drops the derivative.
10
+ *
11
+ * `alpha` turns every gradient in the field by that many radians. Animating it swirls the pattern
12
+ * in place — see {@link chunk_psrdnoise2_kernel} for what that buys and why it is nearly free.
13
+ *
14
+ * This is {@link chunk_psrdnoise2} with the wrap deleted, not a call into it with a zero period: it
15
+ * exists so a caller whose period is a runtime value it never sets does not pay for the branch and
16
+ * the modulo. It still repeats every 289 cells — that is the hash's modulus, not a choice — so it
17
+ * is "non-periodic" only in the sense that it does not tile to a period you name.
18
+ *
19
+ * psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
20
+ * @see https://github.com/stegu/psrdnoise/
21
+ * @type {CodeChunk}
22
+ */
23
+ export const chunk_srdnoise2 = CodeChunk.from(
24
+ //language=WGSL
25
+ `
26
+ fn srdnoise2(
27
+ x: vec2<f32>,
28
+ alpha: f32
29
+ ) -> vec3<f32> {
30
+ // into simplex space — an axis-aligned hexagonal grid, stretched in y so it can tile
31
+ let uv = vec2<f32>(x.x + x.y * 0.5, x.y);
32
+
33
+ // which simplex we are in. i0 is the base corner, o1 the offset to the second: the cell is a
34
+ // rhombus split along its diagonal, and which half we are in decides which corner joins
35
+ let i0 = floor(uv);
36
+ let f0 = uv - i0;
37
+ let o1 = select(vec2<f32>(0.0, 1.0), vec2<f32>(1.0, 0.0), f0.x > f0.y);
38
+
39
+ let i1 = i0 + o1;
40
+ let i2 = i0 + vec2<f32>(1.0);
41
+
42
+ // the three corners back in texture space
43
+ let v0 = vec2<f32>(i0.x - i0.y * 0.5, i0.y);
44
+ let v1 = vec2<f32>(v0.x + o1.x - o1.y * 0.5, v0.y + o1.y);
45
+ let v2 = vec2<f32>(v0.x + 0.5, v0.y + 1.0);
46
+
47
+ return psrdnoise2_kernel(
48
+ vec3<f32>(i0.x, i1.x, i2.x),
49
+ vec3<f32>(i0.y, i1.y, i2.y),
50
+ x - v0,
51
+ x - v1,
52
+ x - v2,
53
+ alpha
54
+ );
55
+ }
56
+ `, [
57
+ chunk_psrdnoise2_kernel,
58
+ ]
59
+ );