@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.
- package/editor/particles/effect/ParticleEffectDocument.d.ts +21 -6
- package/editor/particles/effect/ParticleEffectDocument.d.ts.map +1 -1
- package/editor/particles/effect/ParticleEffectDocument.js +38 -17
- package/editor/view/node-graph/NodeGraphClipboard.d.ts +186 -0
- package/editor/view/node-graph/NodeGraphClipboard.d.ts.map +1 -0
- package/editor/view/node-graph/NodeGraphClipboard.js +231 -0
- package/editor/view/node-graph/NodeGraphEditorView.d.ts +59 -1
- package/editor/view/node-graph/NodeGraphEditorView.d.ts.map +1 -1
- package/editor/view/node-graph/NodeGraphEditorView.js +248 -5
- package/editor/view/node-graph/NodeGraphView.d.ts.map +1 -1
- package/editor/view/node-graph/NodeGraphView.js +84 -8
- package/editor/view/node-graph/actions/connection_bind_actions.d.ts +23 -0
- package/editor/view/node-graph/actions/connection_bind_actions.d.ts.map +1 -0
- package/editor/view/node-graph/actions/connection_bind_actions.js +39 -0
- package/editor/view/particles/effect/ParticleCodeEditorView.d.ts.map +1 -1
- package/editor/view/particles/effect/ParticleCodeEditorView.js +4 -3
- package/editor/view/particles/effect/ParticleCurveEditorView.d.ts +20 -0
- package/editor/view/particles/effect/ParticleCurveEditorView.d.ts.map +1 -0
- package/editor/view/particles/effect/ParticleCurveEditorView.js +574 -0
- package/editor/view/particles/effect/ParticleEmitterInspectorView.d.ts.map +1 -1
- package/editor/view/particles/effect/ParticleEmitterInspectorView.js +27 -1
- package/editor/view/particles/effect/ParticleGradientEditorView.d.ts +24 -0
- package/editor/view/particles/effect/ParticleGradientEditorView.d.ts.map +1 -0
- package/editor/view/particles/effect/ParticleGradientEditorView.js +472 -0
- package/editor/view/particles/effect/ParticleGraphEditorView.d.ts +5 -0
- package/editor/view/particles/effect/ParticleGraphEditorView.d.ts.map +1 -1
- package/editor/view/particles/effect/ParticleGraphEditorView.js +61 -31
- package/editor/view/particles/effect/ParticleNodeParametersView.d.ts.map +1 -1
- package/editor/view/particles/effect/ParticleNodeParametersView.js +33 -0
- package/editor/view/particles/effect/particle-editor.css +123 -35
- package/package.json +1 -1
- package/src/core/binary/allocator/OffsetAllocator.d.ts +25 -16
- package/src/core/binary/allocator/OffsetAllocator.d.ts.map +1 -1
- package/src/core/binary/allocator/OffsetAllocator.js +10 -1
- package/src/core/collection/array/typed/float32_array_hash.d.ts +21 -0
- package/src/core/collection/array/typed/float32_array_hash.d.ts.map +1 -0
- package/src/core/collection/array/typed/float32_array_hash.js +38 -0
- package/src/core/graph/csr/CSRGraph.d.ts +8 -1
- package/src/core/graph/csr/CSRGraph.d.ts.map +1 -1
- package/src/core/graph/csr/CSRGraph.js +14 -6
- package/src/core/model/node-graph/visual/layout/LayoutProblem.d.ts +24 -0
- package/src/core/model/node-graph/visual/layout/LayoutProblem.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/LayoutProblem.js +27 -0
- package/src/core/model/node-graph/visual/layout/NodeGraphLayoutOptions.d.ts +26 -0
- package/src/core/model/node-graph/visual/layout/NodeGraphLayoutOptions.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/NodeGraphLayoutOptions.js +28 -0
- package/src/core/model/node-graph/visual/layout/RouteGrid.d.ts +92 -3
- package/src/core/model/node-graph/visual/layout/RouteGrid.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/RouteGrid.js +405 -242
- package/src/core/model/node-graph/visual/layout/RouteSearch.d.ts +50 -5
- package/src/core/model/node-graph/visual/layout/RouteSearch.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/RouteSearch.js +160 -24
- package/src/core/model/node-graph/visual/layout/RouteSet.d.ts +7 -0
- package/src/core/model/node-graph/visual/layout/RouteSet.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/RouteSet.js +8 -0
- package/src/core/model/node-graph/visual/layout/layout_assign_coordinates.js +9 -3
- package/src/core/model/node-graph/visual/layout/layout_build_problem.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/layout_build_problem.js +7 -0
- package/src/core/model/node-graph/visual/layout/layout_insert_lanes.d.ts +9 -3
- package/src/core/model/node-graph/visual/layout/layout_insert_lanes.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/layout_insert_lanes.js +17 -3
- package/src/core/model/node-graph/visual/layout/layout_node_graph.d.ts +9 -6
- package/src/core/model/node-graph/visual/layout/layout_node_graph.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/layout_node_graph.js +49 -7
- package/src/core/model/node-graph/visual/layout/layout_order_layers.d.ts +11 -1
- package/src/core/model/node-graph/visual/layout/layout_order_layers.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/layout_order_layers.js +135 -16
- package/src/core/model/node-graph/visual/layout/route_connections.d.ts +29 -0
- package/src/core/model/node-graph/visual/layout/route_connections.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/route_connections.js +716 -309
- package/src/core/model/node-graph/visual/layout/route_grid_build.d.ts +3 -2
- package/src/core/model/node-graph/visual/layout/route_grid_build.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/route_grid_build.js +7 -15
- package/src/core/model/node-graph/visual/layout/route_nudge.d.ts +6 -0
- package/src/core/model/node-graph/visual/layout/route_nudge.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/route_nudge.js +42 -13
- package/src/engine/animation/AnimationUtils.js +246 -246
- package/src/engine/animation/Animations.js +74 -74
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +2078 -2078
- package/src/engine/ecs/EventType.d.ts +0 -1
- package/src/engine/ecs/EventType.js +1 -26
- package/src/engine/ecs/ik/ik_write_local_rotation.d.ts +1 -1
- package/src/engine/ecs/ik/ik_write_local_rotation.d.ts.map +1 -1
- package/src/engine/ecs/ik/ik_write_local_rotation.js +3 -7
- package/src/engine/ecs/parent/EntityNode.d.ts.map +1 -1
- package/src/engine/ecs/parent/EntityNode.js +4 -9
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +360 -364
- package/src/engine/ecs/transform/TRANSFORM64_EVENT_CHANGE.d.ts +41 -0
- package/src/engine/ecs/transform/TRANSFORM64_EVENT_CHANGE.d.ts.map +1 -0
- package/src/engine/ecs/transform/TRANSFORM64_EVENT_CHANGE.js +40 -0
- package/src/engine/ecs/transform/TRANSFORM64_MIGRATION_PLAN_2026_09_04.md +8 -0
- package/src/engine/ecs/transform/t64_announce_change.d.ts +10 -7
- package/src/engine/ecs/transform/t64_announce_change.d.ts.map +1 -1
- package/src/engine/ecs/transform/t64_announce_change.js +12 -12
- package/src/engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.d.ts +30 -0
- package/src/engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.d.ts.map +1 -0
- package/src/engine/ecs/transform-attachment/TRANSFORM_ATTACHMENT_EVENT_CHANGE.js +29 -0
- package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.d.ts.map +1 -1
- package/src/engine/ecs/transform-attachment/TransformAttachmentSystem.js +13 -21
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +4 -8
- package/src/engine/graphics3/LightSystem.d.ts.map +1 -1
- package/src/engine/graphics3/LightSystem.js +4 -8
- package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
- package/src/engine/graphics3/MeshSystem.js +9 -19
- package/src/engine/graphics3/ParticleEmitterSystem.d.ts.map +1 -1
- package/src/engine/graphics3/ParticleEmitterSystem.js +4 -8
- package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -1
- package/src/engine/graphics3/ShadedGeometrySystem.js +4 -10
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.d.ts +1 -1
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.d.ts.map +1 -1
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +4 -8
- package/src/engine/intelligence/behavior/ecs/OrbitingBehavior.js +218 -218
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +2 -5
- package/src/engine/sound/ecs/SoundListenerSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/SoundListenerSystem.js +6 -8
- package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.d.ts +0 -4
- package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.d.ts.map +1 -1
- package/src/engine/sound/simulation/ecs/AcousticSimulationSystem.js +5 -11
- package/src/shade/playground/particle_editor/README.md +43 -2
- package/src/shade/playground/particle_system/particle_prototype.d.ts.map +1 -1
- package/src/shade/playground/particle_system/particle_prototype.js +4 -5
- package/src/shade/playground/particle_system/particle_scene.js +4 -4
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +13 -1
- package/src/shade/renderer/particles/DESIGN.md +104 -19
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts +64 -50
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
- package/src/shade/renderer/particles/GPUParticleSystem.js +176 -78
- package/src/shade/renderer/particles/ParticleConstants.d.ts +59 -23
- package/src/shade/renderer/particles/ParticleConstants.d.ts.map +1 -1
- package/src/shade/renderer/particles/ParticleConstants.js +66 -23
- package/src/shade/renderer/particles/ParticleRenderMode.d.ts +19 -0
- package/src/shade/renderer/particles/ParticleRenderMode.d.ts.map +1 -0
- package/src/shade/renderer/particles/ParticleRenderMode.js +33 -0
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_STRUCT.js +167 -166
- package/src/shade/renderer/particles/data/particle_emitter_record.d.ts +37 -0
- package/src/shade/renderer/particles/data/particle_emitter_record.d.ts.map +1 -0
- package/src/shade/renderer/particles/data/particle_emitter_record.js +109 -0
- package/src/shade/renderer/particles/graph/ParticleGroupBuilder.d.ts +3 -3
- package/src/shade/renderer/particles/graph/ParticleGroupBuilder.js +303 -303
- package/src/shade/renderer/particles/graph/ParticleNodeDescription.d.ts +18 -0
- package/src/shade/renderer/particles/graph/ParticleNodeDescription.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/ParticleNodeDescription.js +152 -133
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts +0 -11
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.js +720 -621
- package/src/shade/renderer/particles/graph/compile_particle_graph.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/compile_particle_graph.js +8 -3
- package/src/shade/renderer/particles/graph/flatten_particle_graph.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/flatten_particle_graph.js +244 -213
- package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.js +6 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_geometry.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/groups/particle_groups_geometry.js +294 -319
- package/src/shade/renderer/particles/graph/groups/particle_groups_noise.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/groups/particle_groups_noise.js +524 -517
- package/src/shade/renderer/particles/graph/groups/particle_groups_psrdnoise.d.ts +22 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_psrdnoise.d.ts.map +1 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_psrdnoise.js +517 -0
- package/src/shade/renderer/particles/graph/groups/simplex_reference.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/groups/simplex_reference.js +185 -159
- package/src/shade/renderer/particles/graph/make_particle_group.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/make_particle_group.js +2 -20
- package/src/shade/renderer/particles/graph/particle_compare_ops.d.ts +17 -0
- package/src/shade/renderer/particles/graph/particle_compare_ops.d.ts.map +1 -0
- package/src/shade/renderer/particles/graph/particle_compare_ops.js +22 -0
- package/src/shade/renderer/particles/graph/particle_graph_diagnostic.d.ts +28 -8
- package/src/shade/renderer/particles/graph/particle_graph_diagnostic.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_graph_diagnostic.js +49 -25
- package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts +40 -0
- package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_node_parameters.js +312 -234
- package/src/shade/renderer/particles/graph/particle_node_presentation.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_node_presentation.js +59 -3
- package/src/shade/renderer/particles/graph/particle_ramp.d.ts +230 -0
- package/src/shade/renderer/particles/graph/particle_ramp.d.ts.map +1 -0
- package/src/shade/renderer/particles/graph/particle_ramp.js +403 -0
- package/src/shade/renderer/particles/graph/validate_particle_graph.d.ts +7 -1
- package/src/shade/renderer/particles/graph/validate_particle_graph.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/validate_particle_graph.js +66 -10
- package/src/shade/renderer/particles/graph_particles.d.ts +23 -69
- package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles.js +105 -262
- package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles_avboit.js +3 -2
- package/src/shade/renderer/particles/graph_particles_billboard.d.ts +37 -0
- package/src/shade/renderer/particles/graph_particles_billboard.d.ts.map +1 -0
- package/src/shade/renderer/particles/graph_particles_billboard.js +93 -0
- package/src/shade/renderer/particles/isa/InstructionStream.d.ts +51 -22
- package/src/shade/renderer/particles/isa/InstructionStream.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/InstructionStream.js +98 -38
- package/src/shade/renderer/particles/isa/ParticleProgram.d.ts +49 -8
- package/src/shade/renderer/particles/isa/ParticleProgram.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/ParticleProgram.js +95 -150
- package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +306 -64
- package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/ParticleVMISA.js +505 -136
- package/src/shade/renderer/particles/isa/particle_assembly.d.ts +36 -12
- package/src/shade/renderer/particles/isa/particle_assembly.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/particle_assembly.js +354 -139
- package/src/shade/renderer/particles/isa/validate_particle_program.d.ts +9 -0
- package/src/shade/renderer/particles/isa/validate_particle_program.d.ts.map +1 -0
- package/src/shade/renderer/particles/isa/validate_particle_program.js +128 -0
- package/src/shade/renderer/particles/layout/ParticleLayout.d.ts +23 -0
- package/src/shade/renderer/particles/layout/ParticleLayout.d.ts.map +1 -1
- package/src/shade/renderer/particles/layout/ParticleLayout.js +68 -0
- package/src/shade/renderer/particles/optimizer/dag/optimize_particle_program_vector.d.ts +77 -0
- package/src/shade/renderer/particles/optimizer/dag/optimize_particle_program_vector.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/optimize_particle_program_vector.js +219 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.d.ts +83 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_extract.js +283 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_graph.d.ts +133 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_graph.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_graph.js +334 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_groups.d.ts +117 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_groups.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_groups.js +70 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_lift.d.ts +97 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_lift.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_lift.js +462 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_lower.d.ts +116 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_lower.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_lower.js +687 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_pack.d.ts +57 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_pack.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_pack.js +860 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_rules.d.ts +115 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_rules.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/dag/particle_vector_rules.js +264 -0
- package/src/shade/renderer/particles/optimizer/optimize_particle_program.d.ts +81 -42
- package/src/shade/renderer/particles/optimizer/optimize_particle_program.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/optimize_particle_program.js +477 -478
- package/src/shade/renderer/particles/optimizer/particle_integer_bounds.d.ts +100 -0
- package/src/shade/renderer/particles/optimizer/particle_integer_bounds.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/particle_integer_bounds.js +236 -0
- package/src/shade/renderer/particles/optimizer/particle_program_analysis.d.ts +139 -59
- package/src/shade/renderer/particles/optimizer/particle_program_analysis.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_program_analysis.js +764 -647
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts +40 -7
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.js +376 -213
- package/src/shade/renderer/particles/optimizer/particle_program_fuzz.d.ts +30 -3
- package/src/shade/renderer/particles/optimizer/particle_program_fuzz.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_program_fuzz.js +337 -223
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts +24 -38
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +166 -206
- package/src/shade/renderer/particles/optimizer/pass_allocate_registers.d.ts +99 -0
- package/src/shade/renderer/particles/optimizer/pass_allocate_registers.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/pass_allocate_registers.js +313 -0
- package/src/shade/renderer/particles/optimizer/pass_dedup_constants.d.ts +3 -2
- package/src/shade/renderer/particles/optimizer/pass_dedup_constants.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_dedup_constants.js +198 -197
- package/src/shade/renderer/particles/optimizer/pass_eliminate_dead_code.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_fold_constants.d.ts +19 -0
- package/src/shade/renderer/particles/optimizer/pass_fold_constants.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_fold_constants.js +678 -561
- package/src/shade/renderer/particles/optimizer/pass_inline_constants.d.ts +22 -0
- package/src/shade/renderer/particles/optimizer/pass_inline_constants.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/pass_inline_constants.js +221 -0
- package/src/shade/renderer/particles/optimizer/pass_narrow_widths.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_narrow_widths.js +63 -72
- package/src/shade/renderer/particles/optimizer/pass_pack_registers.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_pack_registers.js +87 -86
- package/src/shade/renderer/particles/optimizer/pass_peephole.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_peephole.js +392 -271
- package/src/shade/renderer/particles/optimizer/pass_propagate_copies.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_propagate_copies.js +361 -268
- package/src/shade/renderer/particles/optimizer/pass_schedule.d.ts +4 -0
- package/src/shade/renderer/particles/optimizer/pass_schedule.d.ts.map +1 -0
- package/src/shade/renderer/particles/optimizer/pass_schedule.js +244 -0
- package/src/shade/renderer/particles/optimizer/pass_share_subexpressions.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/pass_share_subexpressions.js +154 -151
- package/src/shade/renderer/particles/particle_test_fixtures.d.ts +20 -0
- package/src/shade/renderer/particles/particle_test_fixtures.d.ts.map +1 -1
- package/src/shade/renderer/particles/particle_test_fixtures.js +229 -203
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +99 -25
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/EmitterRegistry.js +438 -286
- package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.d.ts +109 -0
- package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.d.ts.map +1 -0
- package/src/shade/renderer/particles/runtime/GPUParticleEmitterContext.js +127 -0
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +87 -102
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ParticleEmitter.js +184 -163
- package/src/shade/renderer/particles/runtime/ProgramArena.d.ts +26 -0
- package/src/shade/renderer/particles/runtime/ProgramArena.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts +130 -0
- package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts.map +1 -0
- package/src/shade/renderer/particles/runtime/ProgramHeap.js +595 -0
- package/src/shade/renderer/particles/runtime/ProgramPlacement.d.ts +91 -0
- package/src/shade/renderer/particles/runtime/ProgramPlacement.d.ts.map +1 -0
- package/src/shade/renderer/particles/runtime/ProgramPlacement.js +106 -0
- package/src/shade/renderer/particles/runtime/create_particle_effect.d.ts +5 -2
- package/src/shade/renderer/particles/runtime/create_particle_effect.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/create_particle_effect.js +22 -19
- package/src/shade/renderer/particles/shaders/chunk_particle_emit_step.d.ts +28 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_emit_step.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_emit_step.js +136 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_simulate_step.d.ts +35 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_simulate_step.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/chunk_particle_simulate_step.js +133 -0
- package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts +18 -9
- package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit.js +20 -80
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts +33 -0
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.js +114 -0
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts +8 -0
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +33 -101
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts +45 -0
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts.map +1 -0
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.js +123 -0
- package/src/shade/renderer/particles/sort/graph_particle_sort.d.ts +51 -0
- package/src/shade/renderer/particles/sort/graph_particle_sort.d.ts.map +1 -0
- package/src/shade/renderer/particles/sort/graph_particle_sort.js +120 -0
- package/src/shade/renderer/particles/vm/PARTICLE_VM_CONTEXT_STRUCT.d.ts +6 -0
- package/src/shade/renderer/particles/vm/PARTICLE_VM_CONTEXT_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/particles/vm/PARTICLE_VM_CONTEXT_STRUCT.js +16 -0
- package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +4 -1
- package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
- package/src/shade/renderer/particles/vm/ParticleVMReference.js +261 -140
- package/src/shade/renderer/particles/vm/chunk_particle_vm.d.ts.map +1 -1
- package/src/shade/renderer/particles/vm/chunk_particle_vm.js +217 -255
- package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_fast.d.ts +43 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_fast.d.ts.map +1 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_fast.js +55 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.d.ts +62 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.d.ts.map +1 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.js +86 -0
- package/src/shade/renderer/shader/chunk/math/chunk_mod_v3f.d.ts +22 -0
- package/src/shade/renderer/shader/chunk/math/chunk_mod_v3f.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/math/chunk_mod_v3f.js +32 -0
- package/src/shade/renderer/shader/chunk/math/chunk_mod_v4f.d.ts +9 -0
- package/src/shade/renderer/shader/chunk/math/chunk_mod_v4f.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/math/chunk_mod_v4f.js +19 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/README.md +65 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.d.ts +24 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.js +83 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.d.ts +25 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.js +42 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.d.ts +31 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.js +80 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.d.ts +26 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3.js +109 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.d.ts +38 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_kernel.js +129 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.d.ts +21 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_permute.js +35 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.d.ts +19 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_skew.js +28 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.d.ts +13 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise3_unskew.js +22 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.d.ts +22 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise2.js +59 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise3.d.ts +23 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise3.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_srdnoise3.js +74 -0
- package/src/shade/wgsl/emulator/ComputeShaderEmulator.d.ts +34 -1
- package/src/shade/wgsl/emulator/ComputeShaderEmulator.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/ComputeShaderEmulator.js +41 -1
- package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts +3 -2
- package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.d.ts.map +1 -1
- package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +49 -10
- package/src/view/minimap/dom/MinimapCameraView.d.ts.map +1 -1
- package/src/view/minimap/dom/MinimapCameraView.js +4 -9
- package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.d.ts +0 -15
- package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.d.ts.map +0 -1
- package/src/core/model/node-graph/visual/layout/ConnectedBoxLayouter.d.ts +0 -45
- package/src/core/model/node-graph/visual/layout/ConnectedBoxLayouter.d.ts.map +0 -1
- package/src/core/model/node-graph/visual/layout/ConnectionEndpointLayoutSpec.d.ts +0 -24
- package/src/core/model/node-graph/visual/layout/ConnectionEndpointLayoutSpec.d.ts.map +0 -1
- package/src/core/model/node-graph/visual/layout/ConnectionLayoutSpec.d.ts +0 -19
- package/src/core/model/node-graph/visual/layout/ConnectionLayoutSpec.d.ts.map +0 -1
- package/src/engine/ecs/transform/__probe.d.ts +0 -4
- package/src/engine/ecs/transform/__probe.d.ts.map +0 -1
- package/src/engine/ecs/util/hideEntityGracefully.d.ts +0 -9
- package/src/engine/ecs/util/hideEntityGracefully.d.ts.map +0 -1
- package/src/shade/renderer/buffer/table/gpu_database_emulator_image.d.ts +0 -27
- package/src/shade/renderer/buffer/table/gpu_database_emulator_image.d.ts.map +0 -1
- package/src/shade/renderer/particles/cull/chunk_particle_cull.d.ts +0 -14
- package/src/shade/renderer/particles/cull/chunk_particle_cull.d.ts.map +0 -1
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_LAYOUT.d.ts +0 -156
- package/src/shade/renderer/particles/data/PARTICLE_EMITTER_LAYOUT.d.ts.map +0 -1
- package/src/shade/renderer/particles/runtime/Emitter.d.ts +0 -219
- package/src/shade/renderer/particles/runtime/Emitter.d.ts.map +0 -1
- package/src/shade/renderer/particles/runtime/ParticleSpawnScheduler.d.ts +0 -77
- package/src/shade/renderer/particles/runtime/ParticleSpawnScheduler.d.ts.map +0 -1
- package/src/shade/renderer/particles/runtime/ProgramArena.js +0 -155
- package/src/shade/renderer/particles/runtime/emitter_database_image.d.ts +0 -15
- package/src/shade/renderer/particles/runtime/emitter_database_image.d.ts.map +0 -1
- package/src/shade/renderer/particles/runtime/spawn_request_encoding.d.ts +0 -34
- package/src/shade/renderer/particles/runtime/spawn_request_encoding.d.ts.map +0 -1
- package/src/shade/renderer/particles/shaders/chunk_particle_context.d.ts +0 -32
- package/src/shade/renderer/particles/shaders/chunk_particle_context.d.ts.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { PARTICLE_VM_FAST_REGISTER_SLOTS } from "../ParticleConstants.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The fast register backing for {@link ./chunk_particle_vm.js}: the VM's register file as a
|
|
6
|
+
* `var<private>` array of {@link ../ParticleConstants.js PARTICLE_VM_FAST_REGISTER_SLOTS} floats.
|
|
7
|
+
*
|
|
8
|
+
* This is the interpreter the system runs on. The array is dynamically indexed — an operand's base
|
|
9
|
+
* comes out of the instruction word — which is what keeps it in registers rather than scratch, and
|
|
10
|
+
* therefore what makes the file's size the shader's register footprint outright. Every program pays
|
|
11
|
+
* that footprint, not only the ones with a wide working set, so the slot count is a whole-system
|
|
12
|
+
* cost and not a per-effect one. See {@link ../ParticleConstants.js} for what it was measured at.
|
|
13
|
+
*
|
|
14
|
+
* The file is zero when a program starts, and the language is what says so: WGSL zero-initialises a
|
|
15
|
+
* `var<private>` declared without an initializer, once per invocation, and a fast pass runs exactly
|
|
16
|
+
* one program per invocation ({@link ../shaders/shader_particle_simulate.js},
|
|
17
|
+
* {@link ../shaders/shader_particle_emit.js}). Nothing in the compiler's output reads a slot it has
|
|
18
|
+
* not written — the graph allocator assigns a register at the instruction that defines the value — so
|
|
19
|
+
* that zero is not what makes correct programs work. It is what makes an INCORRECT program
|
|
20
|
+
* deterministic, and that matters because it is the behaviour {@link ./ParticleVMReference.js}
|
|
21
|
+
* defines and the parity spec holds the two to. The wide backing cannot offer the same guarantee and
|
|
22
|
+
* does not try; see {@link ./chunk_particle_vm_registers_wide.js}.
|
|
23
|
+
*
|
|
24
|
+
* Nothing here clears the file. A `vm_reg_clear` used to zero it in a loop on top of the
|
|
25
|
+
* initialisation above, which could only ever be a second pass over the same slots; it outlived its
|
|
26
|
+
* reason when {@link ../../../wgsl/emulator/ComputeShaderEmulator.js} learned to reset private state
|
|
27
|
+
* per dispatch, and an empty one outlived its reason with it. Removed 2026-09-06.
|
|
28
|
+
*
|
|
29
|
+
* Measured before removing, compiled to RDNA2 (gfx1030): the two zeroing passes folded into one, so
|
|
30
|
+
* the loop cost 2 instructions of 917 at unchanged VGPRs — what a compiler that sees through it
|
|
31
|
+
* charges. One pass is about 22 instructions there (893 with no zeroing, 915 with the mandatory
|
|
32
|
+
* one), which is what a driver that does not see through it charges again on every particle.
|
|
33
|
+
*
|
|
34
|
+
* A fast pass that ran more than one program per invocation — the grid-stride shape the wide passes
|
|
35
|
+
* use — would not inherit the guarantee, since the second program would start on the first's
|
|
36
|
+
* registers. That pass would zero the file itself, in the loop it needs and where its cost is
|
|
37
|
+
* visible, rather than every pass carrying a call for it.
|
|
38
|
+
*
|
|
39
|
+
* The enclosing shader includes this chunk or the wide one, never both — they define the same two
|
|
40
|
+
* symbols.
|
|
41
|
+
*
|
|
42
|
+
* @type {CodeChunk}
|
|
43
|
+
*/
|
|
44
|
+
export const chunk_particle_vm_registers_fast = CodeChunk.from(/* language=wgsl */ `
|
|
45
|
+
// One f32 per slot. A value of width w occupies w consecutive slots, and an operand names the first.
|
|
46
|
+
var<private> vm_reg : array<f32, ${PARTICLE_VM_FAST_REGISTER_SLOTS}>;
|
|
47
|
+
|
|
48
|
+
fn vm_reg_read(index : u32) -> f32 {
|
|
49
|
+
return vm_reg[index];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fn vm_reg_write(index : u32, value : f32) {
|
|
53
|
+
vm_reg[index] = value;
|
|
54
|
+
}
|
|
55
|
+
`);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wide register backing for {@link ./chunk_particle_vm.js}: the VM's register file in a storage
|
|
3
|
+
* buffer, {@link ../ParticleConstants.js PARTICLE_VM_REGISTER_SLOTS} slots deep — every slot the
|
|
4
|
+
* instruction set can name.
|
|
5
|
+
*
|
|
6
|
+
* This is the fallback. It exists so that "the effect is too big for the register file" is not a
|
|
7
|
+
* thing an author of a particle graph can be told. It is slow, and it is meant to be: it runs when
|
|
8
|
+
* the alternative is not running at all.
|
|
9
|
+
*
|
|
10
|
+
* ## Why it is slow
|
|
11
|
+
*
|
|
12
|
+
* Both, and neither is fixable within this shape. Every operand access becomes a memory access —
|
|
13
|
+
* three sources of up to four lanes each and four write-back lanes, so up to twelve loads and four
|
|
14
|
+
* stores per instruction where the fast backing has none. And it gives up the scalar register
|
|
15
|
+
* indexing that the wave-uniform section decode in the simulate pass buys: the fast file is indexed
|
|
16
|
+
* through M0, this one through a per-lane address. Instruction fetch and the opcode switch stay
|
|
17
|
+
* scalar, so the loss is narrower than it could be, but it is real.
|
|
18
|
+
*
|
|
19
|
+
* ## Slot-major, and why it is not negotiable
|
|
20
|
+
*
|
|
21
|
+
* \`vm_registers[slot * PARTICLE_VM_WIDE_LAUNCH_LANES + lane]\`. The slot moves slowly, the lane fast,
|
|
22
|
+
* so the lanes of one wave reading one slot read consecutive floats — a single coalesced run, and a
|
|
23
|
+
* whole workgroup's file stays resident in L1.
|
|
24
|
+
*
|
|
25
|
+
* Laid out the other way round — \`[lane * SLOTS + slot]\`, which is the way it reads more naturally
|
|
26
|
+
* — each lane would stride a kilobyte and every operand access would touch a distinct cache line per
|
|
27
|
+
* lane. That is roughly an order of magnitude, in a shader that is already the slow path, and it is
|
|
28
|
+
* invisible afterwards. Hence the note.
|
|
29
|
+
*
|
|
30
|
+
* ## The file is never cleared
|
|
31
|
+
*
|
|
32
|
+
* Nothing zeroes this file, and the buffer backing it is transient — recycled frame to frame,
|
|
33
|
+
* holding whatever the last user left. Reading a register before writing it is a corrupt program,
|
|
34
|
+
* not a defined one, and the compiler does not emit them: the graph allocator assigns a value its
|
|
35
|
+
* register at the instruction that defines it, so every read follows a write.
|
|
36
|
+
*
|
|
37
|
+
* This is the one place the two backings are not interchangeable. The fast file zeroes, so a corrupt
|
|
38
|
+
* program reads 0.0 there and in {@link ./ParticleVMReference.js} — defined, and the same in both.
|
|
39
|
+
* Here it reads the previous batch. Anything that generates programs without the def-before-use
|
|
40
|
+
* guarantee (the fuzzer, hand-written test assembly) must not be run against this backing and expect
|
|
41
|
+
* to match the reference; the parity spec zeroes the buffer to close that gap for tests only.
|
|
42
|
+
*
|
|
43
|
+
* Zeroing in production would be its own cost — {@link ../ParticleConstants.js
|
|
44
|
+
* PARTICLE_VM_REGISTER_SLOTS} stores per particle, before a single instruction runs, on the path
|
|
45
|
+
* that is already the slow one.
|
|
46
|
+
*
|
|
47
|
+
* ## Binding contract
|
|
48
|
+
*
|
|
49
|
+
* The enclosing shader must declare a read_write storage buffer named \`vm_registers\` of
|
|
50
|
+
* \`array<f32>\`, at least \`PARTICLE_VM_WIDE_LAUNCH_LANES * PARTICLE_VM_REGISTER_SLOTS\` elements, and
|
|
51
|
+
* must call \`particle_vm_bind_registers(lane)\` once per invocation with a lane index below
|
|
52
|
+
* {@link ../ParticleConstants.js PARTICLE_VM_WIDE_LAUNCH_LANES} — which is what the wide passes'
|
|
53
|
+
* bounded launch guarantees, and why they have one.
|
|
54
|
+
*
|
|
55
|
+
* The enclosing shader includes this chunk or the fast one, never both — they define the same two
|
|
56
|
+
* symbols.
|
|
57
|
+
*
|
|
58
|
+
* @type {CodeChunk}
|
|
59
|
+
*/
|
|
60
|
+
export const chunk_particle_vm_registers_wide: CodeChunk;
|
|
61
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
62
|
+
//# sourceMappingURL=chunk_particle_vm_registers_wide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_particle_vm_registers_wide.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/particles/vm/chunk_particle_vm_registers_wide.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,+CAFU,SAAS,CAyBhB;0BArFuB,oCAAoC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { PARTICLE_VM_REGISTER_SLOTS, PARTICLE_VM_WIDE_LAUNCH_LANES } from "../ParticleConstants.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The wide register backing for {@link ./chunk_particle_vm.js}: the VM's register file in a storage
|
|
6
|
+
* buffer, {@link ../ParticleConstants.js PARTICLE_VM_REGISTER_SLOTS} slots deep — every slot the
|
|
7
|
+
* instruction set can name.
|
|
8
|
+
*
|
|
9
|
+
* This is the fallback. It exists so that "the effect is too big for the register file" is not a
|
|
10
|
+
* thing an author of a particle graph can be told. It is slow, and it is meant to be: it runs when
|
|
11
|
+
* the alternative is not running at all.
|
|
12
|
+
*
|
|
13
|
+
* ## Why it is slow
|
|
14
|
+
*
|
|
15
|
+
* Both, and neither is fixable within this shape. Every operand access becomes a memory access —
|
|
16
|
+
* three sources of up to four lanes each and four write-back lanes, so up to twelve loads and four
|
|
17
|
+
* stores per instruction where the fast backing has none. And it gives up the scalar register
|
|
18
|
+
* indexing that the wave-uniform section decode in the simulate pass buys: the fast file is indexed
|
|
19
|
+
* through M0, this one through a per-lane address. Instruction fetch and the opcode switch stay
|
|
20
|
+
* scalar, so the loss is narrower than it could be, but it is real.
|
|
21
|
+
*
|
|
22
|
+
* ## Slot-major, and why it is not negotiable
|
|
23
|
+
*
|
|
24
|
+
* \`vm_registers[slot * PARTICLE_VM_WIDE_LAUNCH_LANES + lane]\`. The slot moves slowly, the lane fast,
|
|
25
|
+
* so the lanes of one wave reading one slot read consecutive floats — a single coalesced run, and a
|
|
26
|
+
* whole workgroup's file stays resident in L1.
|
|
27
|
+
*
|
|
28
|
+
* Laid out the other way round — \`[lane * SLOTS + slot]\`, which is the way it reads more naturally
|
|
29
|
+
* — each lane would stride a kilobyte and every operand access would touch a distinct cache line per
|
|
30
|
+
* lane. That is roughly an order of magnitude, in a shader that is already the slow path, and it is
|
|
31
|
+
* invisible afterwards. Hence the note.
|
|
32
|
+
*
|
|
33
|
+
* ## The file is never cleared
|
|
34
|
+
*
|
|
35
|
+
* Nothing zeroes this file, and the buffer backing it is transient — recycled frame to frame,
|
|
36
|
+
* holding whatever the last user left. Reading a register before writing it is a corrupt program,
|
|
37
|
+
* not a defined one, and the compiler does not emit them: the graph allocator assigns a value its
|
|
38
|
+
* register at the instruction that defines it, so every read follows a write.
|
|
39
|
+
*
|
|
40
|
+
* This is the one place the two backings are not interchangeable. The fast file zeroes, so a corrupt
|
|
41
|
+
* program reads 0.0 there and in {@link ./ParticleVMReference.js} — defined, and the same in both.
|
|
42
|
+
* Here it reads the previous batch. Anything that generates programs without the def-before-use
|
|
43
|
+
* guarantee (the fuzzer, hand-written test assembly) must not be run against this backing and expect
|
|
44
|
+
* to match the reference; the parity spec zeroes the buffer to close that gap for tests only.
|
|
45
|
+
*
|
|
46
|
+
* Zeroing in production would be its own cost — {@link ../ParticleConstants.js
|
|
47
|
+
* PARTICLE_VM_REGISTER_SLOTS} stores per particle, before a single instruction runs, on the path
|
|
48
|
+
* that is already the slow one.
|
|
49
|
+
*
|
|
50
|
+
* ## Binding contract
|
|
51
|
+
*
|
|
52
|
+
* The enclosing shader must declare a read_write storage buffer named \`vm_registers\` of
|
|
53
|
+
* \`array<f32>\`, at least \`PARTICLE_VM_WIDE_LAUNCH_LANES * PARTICLE_VM_REGISTER_SLOTS\` elements, and
|
|
54
|
+
* must call \`particle_vm_bind_registers(lane)\` once per invocation with a lane index below
|
|
55
|
+
* {@link ../ParticleConstants.js PARTICLE_VM_WIDE_LAUNCH_LANES} — which is what the wide passes'
|
|
56
|
+
* bounded launch guarantees, and why they have one.
|
|
57
|
+
*
|
|
58
|
+
* The enclosing shader includes this chunk or the fast one, never both — they define the same two
|
|
59
|
+
* symbols.
|
|
60
|
+
*
|
|
61
|
+
* @type {CodeChunk}
|
|
62
|
+
*/
|
|
63
|
+
export const chunk_particle_vm_registers_wide = CodeChunk.from(/* language=wgsl */ `
|
|
64
|
+
const PARTICLE_VM_WIDE_LAUNCH_LANES : u32 = ${PARTICLE_VM_WIDE_LAUNCH_LANES}u;
|
|
65
|
+
|
|
66
|
+
// This invocation's column in the register file. Set once, before any program runs.
|
|
67
|
+
var<private> vm_reg_lane : u32;
|
|
68
|
+
|
|
69
|
+
fn particle_vm_bind_registers(lane : u32) {
|
|
70
|
+
vm_reg_lane = lane;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Slot-major: one slot's lanes are consecutive, so a wave reads a coalesced run. See the note above
|
|
74
|
+
// before changing this.
|
|
75
|
+
fn vm_reg_index(index : u32) -> u32 {
|
|
76
|
+
return index * PARTICLE_VM_WIDE_LAUNCH_LANES + vm_reg_lane;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn vm_reg_read(index : u32) -> f32 {
|
|
80
|
+
return vm_registers[vm_reg_index(index)];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fn vm_reg_write(index : u32, value : f32) {
|
|
84
|
+
vm_registers[vm_reg_index(index)] = value;
|
|
85
|
+
}
|
|
86
|
+
`);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floored modulo of a `vec3<f32>` by a scalar — GLSL's `mod(x, y)`, which WGSL does not have.
|
|
3
|
+
*
|
|
4
|
+
* WGSL's `%` is a *remainder*: it takes the sign of the dividend, so `-1.0 % 289.0` is `-1.0`. A
|
|
5
|
+
* modulo takes the sign of the divisor, so the same expression is `288.0` here. The two agree for
|
|
6
|
+
* non-negative input and disagree everywhere else, which is exactly where a lattice hash and a
|
|
7
|
+
* tiling wrap live — noise sampled left of the origin has negative cell coordinates, and `%` would
|
|
8
|
+
* fold them onto the wrong side of the period and mirror the field about zero.
|
|
9
|
+
*
|
|
10
|
+
* The divisor is a scalar because every caller wraps three components of one axis by one period.
|
|
11
|
+
* {@link chunk_mod_v3i} is the integer counterpart and takes a vector divisor; the two are not
|
|
12
|
+
* interchangeable.
|
|
13
|
+
*
|
|
14
|
+
* Inherited from the GLSL definition, and worth knowing: for a small negative `value` the quotient
|
|
15
|
+
* rounds to a whole number and the result can come back as exactly `divisor` rather than `0`. Every
|
|
16
|
+
* consumer here feeds the result to a hash or to a `floor`, both of which tolerate it.
|
|
17
|
+
*
|
|
18
|
+
* @type {CodeChunk}
|
|
19
|
+
*/
|
|
20
|
+
export const chunk_mod_v3f: CodeChunk;
|
|
21
|
+
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
22
|
+
//# sourceMappingURL=chunk_mod_v3f.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_mod_v3f.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/math/chunk_mod_v3f.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,4BAFU,SAAS,CAYjB;0BA/BwB,6BAA6B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Floored modulo of a `vec3<f32>` by a scalar — GLSL's `mod(x, y)`, which WGSL does not have.
|
|
5
|
+
*
|
|
6
|
+
* WGSL's `%` is a *remainder*: it takes the sign of the dividend, so `-1.0 % 289.0` is `-1.0`. A
|
|
7
|
+
* modulo takes the sign of the divisor, so the same expression is `288.0` here. The two agree for
|
|
8
|
+
* non-negative input and disagree everywhere else, which is exactly where a lattice hash and a
|
|
9
|
+
* tiling wrap live — noise sampled left of the origin has negative cell coordinates, and `%` would
|
|
10
|
+
* fold them onto the wrong side of the period and mirror the field about zero.
|
|
11
|
+
*
|
|
12
|
+
* The divisor is a scalar because every caller wraps three components of one axis by one period.
|
|
13
|
+
* {@link chunk_mod_v3i} is the integer counterpart and takes a vector divisor; the two are not
|
|
14
|
+
* interchangeable.
|
|
15
|
+
*
|
|
16
|
+
* Inherited from the GLSL definition, and worth knowing: for a small negative `value` the quotient
|
|
17
|
+
* rounds to a whole number and the result can come back as exactly `divisor` rather than `0`. Every
|
|
18
|
+
* consumer here feeds the result to a hash or to a `floor`, both of which tolerate it.
|
|
19
|
+
*
|
|
20
|
+
* @type {CodeChunk}
|
|
21
|
+
*/
|
|
22
|
+
export const chunk_mod_v3f = CodeChunk.from(
|
|
23
|
+
//language=WGSL
|
|
24
|
+
`
|
|
25
|
+
fn mod_v3f(
|
|
26
|
+
value: vec3<f32>,
|
|
27
|
+
divisor: f32
|
|
28
|
+
) -> vec3<f32> {
|
|
29
|
+
return value - floor(value / divisor) * divisor;
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floored modulo of a `vec4<f32>` by a scalar. The four-wide {@link chunk_mod_v3f}; see it for why
|
|
3
|
+
* WGSL's `%` is not this.
|
|
4
|
+
*
|
|
5
|
+
* @type {CodeChunk}
|
|
6
|
+
*/
|
|
7
|
+
export const chunk_mod_v4f: CodeChunk;
|
|
8
|
+
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
9
|
+
//# sourceMappingURL=chunk_mod_v4f.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_mod_v4f.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/math/chunk_mod_v4f.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,4BAFU,SAAS,CAYjB;0BAlBwB,6BAA6B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Floored modulo of a `vec4<f32>` by a scalar. The four-wide {@link chunk_mod_v3f}; see it for why
|
|
5
|
+
* WGSL's `%` is not this.
|
|
6
|
+
*
|
|
7
|
+
* @type {CodeChunk}
|
|
8
|
+
*/
|
|
9
|
+
export const chunk_mod_v4f = CodeChunk.from(
|
|
10
|
+
//language=WGSL
|
|
11
|
+
`
|
|
12
|
+
fn mod_v4f(
|
|
13
|
+
value: vec4<f32>,
|
|
14
|
+
divisor: f32
|
|
15
|
+
) -> vec4<f32> {
|
|
16
|
+
return value - floor(value / divisor) * divisor;
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# psrdnoise
|
|
2
|
+
|
|
3
|
+
**P**eriodic **s**implex noise with **r**otating gradients and analytic **d**erivatives, by Stefan
|
|
4
|
+
Gustavson and Ian McEwan.
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan.
|
|
8
|
+
Published under the MIT license.
|
|
9
|
+
https://github.com/stegu/psrdnoise/
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Three properties, none of which classic simplex noise has:
|
|
13
|
+
|
|
14
|
+
- **it tiles.** The lattice is axis-aligned in texture space rather than skewed, so a rectangular
|
|
15
|
+
period can be imposed on it. Any integer period up to 289 per axis (2-D: even periods in y).
|
|
16
|
+
- **its gradients rotate.** One `alpha` turns every gradient in the field. Animating it swirls the
|
|
17
|
+
pattern in place instead of crossfading between two fields, which is what flow noise is.
|
|
18
|
+
- **its derivative is exact.** Analytic, and roughly free — the terms are already computed. Curl
|
|
19
|
+
noise, erosion and normal generation all need it, and a finite difference is both three times the
|
|
20
|
+
cost and wrong at cell boundaries.
|
|
21
|
+
|
|
22
|
+
## What is here
|
|
23
|
+
|
|
24
|
+
| chunk | signature |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `psrdnoise2` | `(x: vec2<f32>, period: vec2<f32>, alpha: f32) -> vec3<f32>` |
|
|
27
|
+
| `srdnoise2` | `(x: vec2<f32>, alpha: f32) -> vec3<f32>` |
|
|
28
|
+
| `psrdnoise3` | `(x: vec3<f32>, period: vec3<f32>, alpha: f32) -> vec4<f32>` |
|
|
29
|
+
| `srdnoise3` | `(x: vec3<f32>, alpha: f32) -> vec4<f32>` |
|
|
30
|
+
|
|
31
|
+
The noise value is in `.x` and the gradient in the remaining components. Upstream returns a struct
|
|
32
|
+
per dimension (`NG2`, `NG3`); packing into a vector instead means no chunk declares a type, so
|
|
33
|
+
nothing that includes one of these has to have the declaration in scope.
|
|
34
|
+
|
|
35
|
+
The `s*` variants are the non-periodic ones — the same function with the wrap deleted, so a caller
|
|
36
|
+
that never tiles does not pay for the branch. Everything after the lattice is shared with the
|
|
37
|
+
periodic version through `psrdnoise{2,3}_kernel`, which is where the cost of a sample actually is.
|
|
38
|
+
|
|
39
|
+
Supporting chunks: `psrdnoise2_hash`, `psrdnoise3_permute` (the modulo-289 hashes),
|
|
40
|
+
`psrdnoise3_skew` / `psrdnoise3_unskew` (the lattice transform and its inverse), and
|
|
41
|
+
`math/chunk_mod_v3f` / `chunk_mod_v4f` (GLSL's floored `mod`, which WGSL's remainder `%` is not, and
|
|
42
|
+
which both the hashes and the period wrap need).
|
|
43
|
+
|
|
44
|
+
## What is not here, and why
|
|
45
|
+
|
|
46
|
+
- **the value-only variants** (`psrnoise2`, `snoise3`, …). Upstream ships eight functions per
|
|
47
|
+
dimension because in 2021 it did not trust WGSL's dead-code elimination. Write `.x` and let the
|
|
48
|
+
compiler drop the derivative; that is what upstream's own GLSL relies on.
|
|
49
|
+
- **the `alpha = 0` wrappers** (`psdnoise2`, `sdnoise3`, …). Pass `0.0`. In 3-D that value is also
|
|
50
|
+
what selects the cheap gradient path at runtime, so nothing is lost by not naming it.
|
|
51
|
+
- **`FASTROTATION`.** A second gradient rotation, ~10% cheaper but with no shortcut at `alpha = 0`,
|
|
52
|
+
and it does not agree with the default at `alpha = 0` either. One rotation, one field.
|
|
53
|
+
- **`PERLINGRID`.** An alternative lattice that costs 1% more and constrains every period to a
|
|
54
|
+
multiple of 3.
|
|
55
|
+
- **`psrddnoise2/3`.** Second derivatives. They return a Hessian on top of the gradient — 6 more
|
|
56
|
+
floats in 2-D, 6 in 3-D — which no longer fits in a vector return, and nothing here needs them.
|
|
57
|
+
- **`mpsrdnoise2`.** A 16-bit variant, for platforms without `f32`.
|
|
58
|
+
|
|
59
|
+
## Period, and the 289 in everything
|
|
60
|
+
|
|
61
|
+
The hash is a permutation polynomial modulo 289 (= 17²), and coordinates congruent modulo 289 hash
|
|
62
|
+
identically. So the field repeats every 289 cells whether or not a period was asked for, a period
|
|
63
|
+
longer than 289 does not tile but corrupts, and the modulus cannot simply be raised: the
|
|
64
|
+
coefficients are sized to keep the polynomial's intermediate products exactly representable in an
|
|
65
|
+
`f32`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Periodic (tiling) 2-D simplex noise with rotating gradients and an analytic derivative.
|
|
3
|
+
*
|
|
4
|
+
* Returns `vec3(noise, gradient.x, gradient.y)`: the noise value is in `.x`, in `[-1, 1]`, and
|
|
5
|
+
* `.yz` is its exact gradient. Ask for only `.x` and the compiler drops the derivative.
|
|
6
|
+
*
|
|
7
|
+
* **What tiles.** The lattice is axis-aligned and stretched in y precisely so a rectangular period
|
|
8
|
+
* can be imposed on it, which ordinary simplex noise's skewed grid cannot do. `period.x` may be any
|
|
9
|
+
* integer up to 289; `period.y` must be *even* — the hexagonal rows alternate by half a cell, so an
|
|
10
|
+
* odd y period tiles at twice the number given. Zero or negative on either axis skips the wrap for
|
|
11
|
+
* that axis, and `vec2(0.0)` on both takes a shortcut worth about 15% by upstream's measurement of
|
|
12
|
+
* the GLSL. A caller that always passes zero should call {@link chunk_srdnoise2} instead and not pay
|
|
13
|
+
* for the branch at all. 289 is the hash's modulus, so it is a hard ceiling, not a recommendation.
|
|
14
|
+
*
|
|
15
|
+
* **What `alpha` does.** It turns every gradient in the field by that many radians. Animating it
|
|
16
|
+
* swirls the pattern in place rather than crossfading it — see {@link chunk_psrdnoise2_kernel}.
|
|
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_psrdnoise2: CodeChunk;
|
|
23
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
24
|
+
//# sourceMappingURL=chunk_psrdnoise2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_psrdnoise2.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,+BAFU,SAAS,CA2DjB;0BAlFwB,gCAAgC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
2
|
+
import { chunk_mod_v3f } from "../../math/chunk_mod_v3f.js";
|
|
3
|
+
import { chunk_psrdnoise2_kernel } from "./chunk_psrdnoise2_kernel.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Periodic (tiling) 2-D simplex noise with rotating gradients and an analytic derivative.
|
|
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
|
+
* **What tiles.** The lattice is axis-aligned and stretched in y precisely so a rectangular period
|
|
12
|
+
* can be imposed on it, which ordinary simplex noise's skewed grid cannot do. `period.x` may be any
|
|
13
|
+
* integer up to 289; `period.y` must be *even* — the hexagonal rows alternate by half a cell, so an
|
|
14
|
+
* odd y period tiles at twice the number given. Zero or negative on either axis skips the wrap for
|
|
15
|
+
* that axis, and `vec2(0.0)` on both takes a shortcut worth about 15% by upstream's measurement of
|
|
16
|
+
* the GLSL. A caller that always passes zero should call {@link chunk_srdnoise2} instead and not pay
|
|
17
|
+
* for the branch at all. 289 is the hash's modulus, so it is a hard ceiling, not a recommendation.
|
|
18
|
+
*
|
|
19
|
+
* **What `alpha` does.** It turns every gradient in the field by that many radians. Animating it
|
|
20
|
+
* swirls the pattern in place rather than crossfading it — see {@link chunk_psrdnoise2_kernel}.
|
|
21
|
+
*
|
|
22
|
+
* psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
|
|
23
|
+
* @see https://github.com/stegu/psrdnoise/
|
|
24
|
+
* @type {CodeChunk}
|
|
25
|
+
*/
|
|
26
|
+
export const chunk_psrdnoise2 = CodeChunk.from(
|
|
27
|
+
//language=WGSL
|
|
28
|
+
`
|
|
29
|
+
fn psrdnoise2(
|
|
30
|
+
x: vec2<f32>,
|
|
31
|
+
period: vec2<f32>,
|
|
32
|
+
alpha: f32
|
|
33
|
+
) -> vec3<f32> {
|
|
34
|
+
// into simplex space — an axis-aligned hexagonal grid, stretched in y so it can tile
|
|
35
|
+
let uv = vec2<f32>(x.x + x.y * 0.5, x.y);
|
|
36
|
+
|
|
37
|
+
// which simplex we are in. i0 is the base corner, o1 the offset to the second: the cell is a
|
|
38
|
+
// rhombus split along its diagonal, and which half we are in decides which corner joins
|
|
39
|
+
let i0 = floor(uv);
|
|
40
|
+
let f0 = uv - i0;
|
|
41
|
+
let o1 = select(vec2<f32>(0.0, 1.0), vec2<f32>(1.0, 0.0), f0.x > f0.y);
|
|
42
|
+
|
|
43
|
+
let i1 = i0 + o1;
|
|
44
|
+
let i2 = i0 + vec2<f32>(1.0);
|
|
45
|
+
|
|
46
|
+
// the three corners back in texture space
|
|
47
|
+
let v0 = vec2<f32>(i0.x - i0.y * 0.5, i0.y);
|
|
48
|
+
let v1 = vec2<f32>(v0.x + o1.x - o1.y * 0.5, v0.y + o1.y);
|
|
49
|
+
let v2 = vec2<f32>(v0.x + 0.5, v0.y + 1.0);
|
|
50
|
+
|
|
51
|
+
var iu = vec3<f32>(i0.x, i1.x, i2.x);
|
|
52
|
+
var iv = vec3<f32>(i0.y, i1.y, i2.y);
|
|
53
|
+
|
|
54
|
+
if (any(period > vec2<f32>(0.0))) {
|
|
55
|
+
// the wrap has to happen in texture space, where the period is rectangular, and the corners
|
|
56
|
+
// then go back to simplex space to be hashed. Only the hash inputs move; the offsets below
|
|
57
|
+
// stay measured from the unwrapped corners, which is what keeps the field continuous
|
|
58
|
+
// across the seam
|
|
59
|
+
var xw = vec3<f32>(v0.x, v1.x, v2.x);
|
|
60
|
+
var yw = vec3<f32>(v0.y, v1.y, v2.y);
|
|
61
|
+
|
|
62
|
+
if (period.x > 0.0) {
|
|
63
|
+
xw = mod_v3f(xw, period.x);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (period.y > 0.0) {
|
|
67
|
+
yw = mod_v3f(yw, period.y);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// xw + 0.5*yw is the skew back to simplex space, where the corners are integer lattice
|
|
71
|
+
// points — but the wrap leaves them a hair off one, so the trailing +0.5 under the floor
|
|
72
|
+
// rounds to nearest rather than truncating into the neighbouring cell
|
|
73
|
+
iu = floor(xw + 0.5 * yw + 0.5);
|
|
74
|
+
iv = floor(yw + 0.5);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return psrdnoise2_kernel(iu, iv, x - v0, x - v1, x - v2, alpha);
|
|
78
|
+
}
|
|
79
|
+
`, [
|
|
80
|
+
chunk_mod_v3f,
|
|
81
|
+
chunk_psrdnoise2_kernel,
|
|
82
|
+
]
|
|
83
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One pseudo-random value per corner of a 2-D simplex, from the corner's lattice coordinates.
|
|
3
|
+
*
|
|
4
|
+
* Permutation polynomials modulo 289, composed — the "mod289" hash of the Perlin/McEwan noise
|
|
5
|
+
* lineage, evaluated on all three corners at once. The modulus is what bounds the period: coordinates
|
|
6
|
+
* congruent modulo 289 hash the same, so the noise field repeats every 289 cells whether or not a
|
|
7
|
+
* period was asked for, and a period larger than that cannot be represented.
|
|
8
|
+
*
|
|
9
|
+
* `289` is `17²`, and the coefficients are sized so the intermediate products stay inside the range
|
|
10
|
+
* an `f32` represents exactly — which is why the modulus cannot simply be raised to lengthen the
|
|
11
|
+
* period. They are not free parameters: what the hash owes its caller is that the three corners of a
|
|
12
|
+
* cell get three unrelated values and that the whole of `[0, 289)` is reached, and its spec checks
|
|
13
|
+
* both rather than trusting the constants.
|
|
14
|
+
*
|
|
15
|
+
* The two coordinate arguments are transposed with respect to the corners: `iu` holds the u
|
|
16
|
+
* coordinate of all three corners and `iv` the v coordinate, which is the layout the caller already
|
|
17
|
+
* has and what makes this three hashes for the price of one.
|
|
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_psrdnoise2_hash: CodeChunk;
|
|
24
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
25
|
+
//# sourceMappingURL=chunk_psrdnoise2_hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_psrdnoise2_hash.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_hash.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,oCAFU,SAAS,CAkBjB;0BAzCwB,gCAAgC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
2
|
+
import { chunk_mod_v3f } from "../../math/chunk_mod_v3f.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One pseudo-random value per corner of a 2-D simplex, from the corner's lattice coordinates.
|
|
6
|
+
*
|
|
7
|
+
* Permutation polynomials modulo 289, composed — the "mod289" hash of the Perlin/McEwan noise
|
|
8
|
+
* lineage, evaluated on all three corners at once. The modulus is what bounds the period: coordinates
|
|
9
|
+
* congruent modulo 289 hash the same, so the noise field repeats every 289 cells whether or not a
|
|
10
|
+
* period was asked for, and a period larger than that cannot be represented.
|
|
11
|
+
*
|
|
12
|
+
* `289` is `17²`, and the coefficients are sized so the intermediate products stay inside the range
|
|
13
|
+
* an `f32` represents exactly — which is why the modulus cannot simply be raised to lengthen the
|
|
14
|
+
* period. They are not free parameters: what the hash owes its caller is that the three corners of a
|
|
15
|
+
* cell get three unrelated values and that the whole of `[0, 289)` is reached, and its spec checks
|
|
16
|
+
* both rather than trusting the constants.
|
|
17
|
+
*
|
|
18
|
+
* The two coordinate arguments are transposed with respect to the corners: `iu` holds the u
|
|
19
|
+
* coordinate of all three corners and `iv` the v coordinate, which is the layout the caller already
|
|
20
|
+
* has and what makes this three hashes for the price of one.
|
|
21
|
+
*
|
|
22
|
+
* psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
|
|
23
|
+
* @see https://github.com/stegu/psrdnoise/
|
|
24
|
+
* @type {CodeChunk}
|
|
25
|
+
*/
|
|
26
|
+
export const chunk_psrdnoise2_hash = CodeChunk.from(
|
|
27
|
+
//language=WGSL
|
|
28
|
+
`
|
|
29
|
+
fn psrdnoise2_hash(
|
|
30
|
+
iu: vec3<f32>,
|
|
31
|
+
iv: vec3<f32>
|
|
32
|
+
) -> vec3<f32> {
|
|
33
|
+
var hash = mod_v3f(iu, 289.0);
|
|
34
|
+
|
|
35
|
+
hash = mod_v3f((hash * 51.0 + 2.0) * hash + iv, 289.0);
|
|
36
|
+
|
|
37
|
+
return mod_v3f((hash * 34.0 + 10.0) * hash, 289.0);
|
|
38
|
+
}
|
|
39
|
+
`, [
|
|
40
|
+
chunk_mod_v3f,
|
|
41
|
+
]
|
|
42
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything a 2-D psrdnoise sample does once its simplex is known: hash the three corners, turn
|
|
3
|
+
* each hash into a rotating unit gradient, and sum the radially-weighted ramps into a noise value
|
|
4
|
+
* and its 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_psrdnoise2} and the non-periodic {@link chunk_srdnoise2} — the two differ
|
|
8
|
+
* only in how they arrive at `iu`/`iv`, and sharing this keeps that difference down to the wrap
|
|
9
|
+
* itself.
|
|
10
|
+
*
|
|
11
|
+
* **Rotating gradients.** Each corner's gradient is a *unit vector at an angle*, not a table entry:
|
|
12
|
+
* `psi` is the hashed angle and `alpha` turns every gradient in the field by the same amount. The
|
|
13
|
+
* result is a swirl rather than a crossfade, which is what "flow noise" is — animate `alpha` and the
|
|
14
|
+
* pattern rotates in place instead of dissolving. The rotation is a single add, so unlike the 3-D
|
|
15
|
+
* version there is nothing to gain from `alpha == 0`.
|
|
16
|
+
*
|
|
17
|
+
* **Why the derivative is free.** `w⁴·(g·x)` is a product of two things whose derivatives are
|
|
18
|
+
* already computed, so the product rule costs a handful of multiply-adds and no transcendentals.
|
|
19
|
+
* Curl noise, normal mapping and erosion all need the gradient, and a finite difference would cost
|
|
20
|
+
* three more evaluations and be wrong at the cell boundaries.
|
|
21
|
+
*
|
|
22
|
+
* Returns `vec3(noise, gradient.x, gradient.y)` — the noise value in `.x`, so a caller that wants
|
|
23
|
+
* only the value writes `.x` and lets the compiler drop the derivative tail.
|
|
24
|
+
*
|
|
25
|
+
* psrdnoise (c) 2021 Stefan Gustavson and Ian McEwan. Published under the MIT license.
|
|
26
|
+
* @see https://github.com/stegu/psrdnoise/
|
|
27
|
+
* @type {CodeChunk}
|
|
28
|
+
*/
|
|
29
|
+
export const chunk_psrdnoise2_kernel: CodeChunk;
|
|
30
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
31
|
+
//# sourceMappingURL=chunk_psrdnoise2_kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_psrdnoise2_kernel.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/noise/psrdnoise/chunk_psrdnoise2_kernel.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,sCAFU,SAAS,CAkDjB;0BA/EwB,gCAAgC"}
|