@woosh/meep-engine 3.76.0 → 3.78.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 (265) hide show
  1. package/editor/particles/effect/ParticleReferenceSimulation.d.ts +11 -0
  2. package/editor/particles/effect/ParticleReferenceSimulation.d.ts.map +1 -1
  3. package/editor/particles/effect/ParticleReferenceSimulation.js +14 -0
  4. package/editor/view/particles/effect/ParticleGraphEditorView.js +1 -1
  5. package/package.json +3 -2
  6. package/src/engine/EngineHarness.d.ts +4 -6
  7. package/src/engine/EngineHarness.d.ts.map +1 -1
  8. package/src/engine/EngineHarness.js +11 -19
  9. package/src/engine/asset/loaders/GroomAssetLoader.d.ts +1 -1
  10. package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
  11. package/src/engine/asset/loaders/GroomAssetLoader.js +16 -2
  12. package/src/engine/graphics/ecs/hair/Hair.d.ts +7 -0
  13. package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -1
  14. package/src/engine/graphics/ecs/hair/Hair.js +9 -0
  15. package/src/engine/graphics/ecs/hair/HairDynamics.d.ts +63 -0
  16. package/src/engine/graphics/ecs/hair/HairDynamics.d.ts.map +1 -0
  17. package/src/engine/graphics/ecs/hair/HairDynamics.js +82 -0
  18. package/src/engine/graphics/hair/Groom.d.ts +45 -0
  19. package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
  20. package/src/engine/graphics/hair/Groom.js +56 -0
  21. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +27 -1
  22. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
  23. package/src/engine/graphics/hair/GroomSerializationAdapter.js +105 -32
  24. package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts +8 -0
  25. package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts.map +1 -0
  26. package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.js +31 -0
  27. package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +85 -0
  28. package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts.map +1 -0
  29. package/src/engine/graphics/hair/groom_bind_to_mesh.js +216 -0
  30. package/src/engine/graphics/hair/groom_build_group.d.ts +7 -2
  31. package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
  32. package/src/engine/graphics/hair/groom_build_group.js +11 -2
  33. package/src/engine/graphics/hair/groom_build_guides.d.ts +43 -0
  34. package/src/engine/graphics/hair/groom_build_guides.d.ts.map +1 -0
  35. package/src/engine/graphics/hair/groom_build_guides.js +267 -0
  36. package/src/engine/graphics/hair/groom_root_spacing.d.ts +6 -4
  37. package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -1
  38. package/src/engine/graphics/hair/groom_root_spacing.js +199 -66
  39. package/src/engine/graphics3/HairColliderSystem.d.ts +59 -0
  40. package/src/engine/graphics3/HairColliderSystem.d.ts.map +1 -0
  41. package/src/engine/graphics3/HairColliderSystem.js +270 -0
  42. package/src/engine/graphics3/HairSystem.d.ts +21 -4
  43. package/src/engine/graphics3/HairSystem.d.ts.map +1 -1
  44. package/src/engine/graphics3/HairSystem.js +270 -4
  45. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  46. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +0 -1
  47. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  48. package/src/engine/sound/sopra/runtime/EventInstance.js +0 -1
  49. package/src/shade/assets/textures/hair_scattering.bin +0 -0
  50. package/src/shade/playground/hair/main.js +27 -4
  51. package/src/shade/playground/hair_skinned/index.html +192 -0
  52. package/src/shade/playground/hair_skinned/main.d.ts +7 -0
  53. package/src/shade/playground/hair_skinned/main.d.ts.map +1 -0
  54. package/src/shade/playground/hair_skinned/main.js +481 -0
  55. package/src/shade/playground/hair_skinned/skinned_hair.d.ts +49 -0
  56. package/src/shade/playground/hair_skinned/skinned_hair.d.ts.map +1 -0
  57. package/src/shade/playground/hair_skinned/skinned_hair.js +362 -0
  58. package/src/shade/playground/sparks/README.md +36 -0
  59. package/src/shade/playground/sparks/index.html +145 -0
  60. package/src/shade/playground/sparks/main.d.ts +7 -0
  61. package/src/shade/playground/sparks/main.d.ts.map +1 -0
  62. package/src/shade/playground/sparks/main.js +312 -0
  63. package/src/shade/playground/sparks/sparks_effect.d.ts +72 -0
  64. package/src/shade/playground/sparks/sparks_effect.d.ts.map +1 -0
  65. package/src/shade/playground/sparks/sparks_effect.js +180 -0
  66. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  67. package/src/shade/renderer/Renderer.js +18 -3
  68. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  69. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
  70. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  71. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +3 -2
  72. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  73. package/src/shade/renderer/animation/GPUAnimationManager.js +74 -3
  74. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +13 -3
  75. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  76. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +16 -5
  77. package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +8 -8
  78. package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +2 -2
  79. package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +4 -2
  80. package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
  81. package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +7 -3
  82. package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +1 -1
  83. package/src/shade/renderer/extension/ShadowAtlas.d.ts +77 -0
  84. package/src/shade/renderer/extension/ShadowAtlas.d.ts.map +1 -0
  85. package/src/shade/renderer/extension/ShadowAtlas.js +135 -0
  86. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  87. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  88. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  89. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  90. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  91. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
  92. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +37 -7
  93. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
  94. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +132 -8
  95. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +3 -1
  96. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  97. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +6 -2
  98. package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts +0 -18
  99. package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts.map +1 -1
  100. package/src/shade/renderer/global_illumination/sharc/sharc_constants.js +1 -21
  101. package/src/shade/renderer/hair/GPUHairSystem.d.ts +121 -2
  102. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  103. package/src/shade/renderer/hair/GPUHairSystem.js +1187 -56
  104. package/src/shade/renderer/hair/HAIR.d.ts +22 -3
  105. package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
  106. package/src/shade/renderer/hair/HAIR.js +25 -4
  107. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
  108. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +33 -0
  109. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +4 -0
  110. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -1
  111. package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +24 -2
  112. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +139 -0
  113. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -0
  114. package/src/shade/renderer/hair/HAIR_SIMULATION.js +160 -0
  115. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +9 -2
  116. package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
  117. package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +40 -13
  118. package/src/shade/renderer/hair/chunk_hair_guide.d.ts +59 -0
  119. package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -0
  120. package/src/shade/renderer/hair/chunk_hair_guide.js +179 -0
  121. package/src/shade/renderer/hair/chunk_hair_volume.d.ts +4 -3
  122. package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -1
  123. package/src/shade/renderer/hair/chunk_hair_volume.js +21 -12
  124. package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
  125. package/src/shade/renderer/hair/hair_lighting.js +16 -7
  126. package/src/shade/renderer/hair/hair_scattering_lut.js +13 -13
  127. package/src/shade/renderer/hair/hair_shadow_draw.d.ts +32 -0
  128. package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -0
  129. package/src/shade/renderer/hair/hair_shadow_draw.js +123 -0
  130. package/src/shade/renderer/hair/shader_hair_classes.d.ts +2 -1
  131. package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -1
  132. package/src/shade/renderer/hair/shader_hair_classes.js +6 -2
  133. package/src/shade/renderer/hair/shader_hair_cull.d.ts +8 -2
  134. package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
  135. package/src/shade/renderer/hair/shader_hair_cull.js +74 -17
  136. package/src/shade/renderer/hair/shader_hair_lod.d.ts +9 -3
  137. package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -1
  138. package/src/shade/renderer/hair/shader_hair_lod.js +125 -31
  139. package/src/shade/renderer/hair/shader_hair_roots.d.ts +36 -0
  140. package/src/shade/renderer/hair/shader_hair_roots.d.ts.map +1 -0
  141. package/src/shade/renderer/hair/shader_hair_roots.js +261 -0
  142. package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +44 -0
  143. package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -0
  144. package/src/shade/renderer/hair/shader_hair_shadow_list.js +240 -0
  145. package/src/shade/renderer/hair/shader_hair_simulate.d.ts +55 -0
  146. package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -0
  147. package/src/shade/renderer/hair/shader_hair_simulate.js +563 -0
  148. package/src/shade/renderer/hair/shader_hair_volume.d.ts +3 -3
  149. package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -1
  150. package/src/shade/renderer/hair/shader_hair_volume.js +4 -17
  151. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  152. package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +8 -3
  153. package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -1
  154. package/src/shade/renderer/loader/usd/usd_groom_extension.js +58 -5
  155. package/src/shade/renderer/particles/GPUParticleSystem.d.ts +8 -0
  156. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  157. package/src/shade/renderer/particles/GPUParticleSystem.js +28 -0
  158. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts.map +1 -1
  159. package/src/shade/renderer/particles/graph/ParticleNodeRegistry.js +22 -0
  160. package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.d.ts.map +1 -1
  161. package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.js +4 -0
  162. package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts +32 -0
  163. package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts.map +1 -0
  164. package/src/shade/renderer/particles/graph/groups/particle_groups_scene.js +80 -0
  165. package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts.map +1 -1
  166. package/src/shade/renderer/particles/graph/particle_node_parameters.js +1 -0
  167. package/src/shade/renderer/particles/graph/particle_node_presentation.d.ts.map +1 -1
  168. package/src/shade/renderer/particles/graph/particle_node_presentation.js +12 -0
  169. package/src/shade/renderer/particles/graph_particles.d.ts +5 -1
  170. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  171. package/src/shade/renderer/particles/graph_particles.js +18 -3
  172. package/src/shade/renderer/particles/isa/InstructionStream.d.ts +25 -0
  173. package/src/shade/renderer/particles/isa/InstructionStream.d.ts.map +1 -1
  174. package/src/shade/renderer/particles/isa/InstructionStream.js +25 -0
  175. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +9 -0
  176. package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
  177. package/src/shade/renderer/particles/isa/ParticleVMISA.js +20 -0
  178. package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts +9 -0
  179. package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts.map +1 -0
  180. package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.js +29 -0
  181. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts +2 -1
  182. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts.map +1 -1
  183. package/src/shade/renderer/particles/optimizer/particle_program_equivalence.js +27 -5
  184. package/src/shade/renderer/particles/optimizer/particle_program_fuzz.js +1 -1
  185. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
  186. package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +5 -0
  187. package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +7 -0
  188. package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
  189. package/src/shade/renderer/particles/runtime/EmitterRegistry.js +10 -0
  190. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +5 -0
  191. package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
  192. package/src/shade/renderer/particles/runtime/ParticleEmitter.js +5 -0
  193. package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts +8 -0
  194. package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts.map +1 -1
  195. package/src/shade/renderer/particles/runtime/ProgramHeap.js +25 -0
  196. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts +1 -1
  197. package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
  198. package/src/shade/renderer/particles/shaders/shader_particle_emit.js +9 -3
  199. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts.map +1 -1
  200. package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.js +4 -2
  201. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts +2 -2
  202. package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
  203. package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +10 -4
  204. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts.map +1 -1
  205. package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.js +4 -2
  206. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +14 -1
  207. package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
  208. package/src/shade/renderer/particles/vm/ParticleVMReference.js +34 -1
  209. package/src/shade/renderer/particles/vm/chunk_particle_vm.d.ts.map +1 -1
  210. package/src/shade/renderer/particles/vm/chunk_particle_vm.js +10 -0
  211. package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts +39 -0
  212. package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts.map +1 -0
  213. package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.js +90 -0
  214. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts +4 -1
  215. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
  216. package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +14 -2
  217. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts +1 -1
  218. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts.map +1 -1
  219. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.js +9 -3
  220. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.d.ts.map +1 -1
  221. package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.js +4 -2
  222. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  223. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -4
  224. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  225. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +26 -16
  226. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts +7 -4
  227. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts.map +1 -1
  228. package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.js +66 -14
  229. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +20 -0
  230. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts.map +1 -0
  231. package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +149 -0
  232. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts +8 -0
  233. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
  234. package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +100 -33
  235. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts +11 -0
  236. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts.map +1 -1
  237. package/src/shade/renderer/rasterize/native/rasterization_shader_resources.js +24 -11
  238. package/src/shade/renderer/scene/GPUSceneContext.d.ts +7 -0
  239. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  240. package/src/shade/renderer/scene/GPUSceneContext.js +18 -0
  241. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts +13 -0
  242. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts.map +1 -0
  243. package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.js +42 -0
  244. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts +20 -0
  245. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts.map +1 -0
  246. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.js +134 -0
  247. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts +15 -0
  248. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
  249. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +83 -5
  250. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +34 -0
  251. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -0
  252. package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +106 -0
  253. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts +16 -0
  254. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts.map +1 -0
  255. package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.js +50 -0
  256. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +25 -0
  257. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -0
  258. package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +42 -0
  259. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts +10 -0
  260. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts.map +1 -0
  261. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.js +22 -0
  262. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.d.ts +1 -1
  263. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.js +5 -5
  264. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  265. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
@@ -11,9 +11,15 @@ import { WebGPUArray } from "../shader/type/WebGPUArray.js";
11
11
  import { WebGPUBufferType } from "../shader/type/WebGPUBufferType.js";
12
12
  import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
13
13
  import { chunk_hair_lod } from "./chunk_hair_strand.js";
14
- import { HAIR_COUNTER_POINTS, HAIR_COUNTER_VOXELS, HAIR_VOLUME_DIMENSION_LIMIT, HAIR_VOLUME_MIPS } from "./HAIR.js";
14
+ import {
15
+ HAIR_COUNTER_POINTS,
16
+ HAIR_COUNTER_SHADOW_STRANDS,
17
+ HAIR_COUNTER_VOXELS,
18
+ HAIR_VOLUME_DIMENSION_LIMIT
19
+ } from "./HAIR.js";
15
20
  import { HAIR_INSTANCE_DESCRIPTOR } from "./HAIR_DATABASE_SPEC.js";
16
- import { HAIR_LOD_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
21
+ import { HAIR_BINDING_NONE, HAIR_GUIDE_BOUNDS_WORDS, HAIR_STATE_NONE } from "./HAIR_SIMULATION.js";
22
+ import { HAIR_LOD_STRUCT, HAIR_SHADOW_VIEW_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
17
23
 
18
24
  /**
19
25
  * Threads per workgroup, a row each. The page iterator wants a multiple of 32.
@@ -36,6 +42,8 @@ export const HAIR_LOD_SETTINGS = WebGPUStruct.from({
36
42
  point_capacity: u32,
37
43
  /** voxels the frame's voxel buffer holds */
38
44
  voxel_capacity: u32,
45
+ /** shadow views the strands draw into this frame, the first of `hair_shadow_views`; 0 where they cast none */
46
+ shadow_view_count: u32,
39
47
  }, "HairLodSettings");
40
48
 
41
49
  const resources = new ShaderResourceSetDescriptor();
@@ -46,10 +54,13 @@ resources.createGroup()
46
54
  .add(CAMERA_RESOURCE)
47
55
  .addStorageBuffer("hair_database", WebGPUBufferType.unsized, false)
48
56
  .addStorageBuffer("scene_database", WebGPUBufferType.unsized, false)
57
+ .addStorageBuffer("hair_guide_bounds", WebGPUArray.u32, false)
49
58
  .addStorageBuffer("hair_counts", COLLECTION_U32_STRUCT_READ, true)
50
- .addStorageBuffer("hair_volume_counts", COLLECTION_U32_STRUCT_READ, true)
59
+ .addStorageBuffer("hair_mip_1_counts", COLLECTION_U32_STRUCT_READ, true)
60
+ .addStorageBuffer("hair_mip_2_counts", COLLECTION_U32_STRUCT_READ, true)
51
61
  .addStorageBuffer("hair_lod", WebGPUArray.from(HAIR_LOD_STRUCT), true)
52
- .addStorageBuffer("hair_counters", WebGPUArray.from(atomic_u32), true);
62
+ .addStorageBuffer("hair_counters", WebGPUArray.from(atomic_u32), true)
63
+ .addStorageBuffer("hair_shadow_views", WebGPUArray.from(HAIR_SHADOW_VIEW_STRUCT), false);
53
64
 
54
65
  const body = CodeChunk.from(
55
66
  //language=WGSL
@@ -60,6 +71,40 @@ fn hair_decimation_error(instance: ${HAIR_INSTANCE_DESCRIPTOR.type.wgsl_ref}, le
60
71
  return quad[level & 3u];
61
72
  }
62
73
 
74
+ // a float from the u32 that orders as it does
75
+ fn hair_unordered(u: u32) -> f32 {
76
+ return bitcast<f32>(select(~u, u ^ 0x80000000u, (u & 0x80000000u) != 0u));
77
+ }
78
+
79
+ // the finest texel, world metres, of the shadow views a box reaches into, the near plane aside (the shadow draw holds
80
+ // what is nearer the light on it): 0 where the box reaches the eye of one, whose texels it cannot bound; negative
81
+ // where it reaches none
82
+ fn hair_shadow_texel(centre: vec3<f32>, half_extent: vec3<f32>) -> f32 {
83
+ var finest = -1.0;
84
+
85
+ for (var v = 0u; v < min(settings.shadow_view_count, arrayLength(&hair_shadow_views)); v++) {
86
+ let view = hair_shadow_views[v];
87
+
88
+ var inside = true;
89
+
90
+ for (var p = 0u; p < 5u; p++) {
91
+ let plane = view.planes[p];
92
+
93
+ inside = inside && dot(plane.xyz, centre) + plane.w + dot(abs(plane.xyz), half_extent) >= 0.0;
94
+ }
95
+
96
+ if (inside) {
97
+ // the box's least clip w: its nearest depth to a spot light, one in an orthographic cascade
98
+ let w = dot(view.depth.xyz, centre) + view.depth.w - dot(abs(view.depth.xyz), half_extent);
99
+ let texel = view.texel * max(w, 0.0);
100
+
101
+ finest = select(texel, min(finest, texel), finest >= 0.0);
102
+ }
103
+ }
104
+
105
+ return finest;
106
+ }
107
+
63
108
  fn hair_pack_pixel(p: vec2<f32>) -> u32 {
64
109
  let q = vec2<u32>(clamp(p, vec2<f32>(0.0), vec2<f32>(65535.0)));
65
110
 
@@ -75,7 +120,8 @@ fn main(
75
120
  // is unallocated
76
121
  if (wg_id.x == 0u && local_id == 0u) {
77
122
  hair_counts.count = settings.capacity;
78
- hair_volume_counts.count = settings.capacity;
123
+ hair_mip_1_counts.count = settings.capacity;
124
+ hair_mip_2_counts.count = settings.capacity;
79
125
  }
80
126
 
81
127
  if (!${PG}_setup(&hair_database, wg_id.x, local_id)) {
@@ -95,18 +141,52 @@ fn main(
95
141
 
96
142
  var lod: ${HAIR_LOD_STRUCT.wgsl_ref};
97
143
 
98
- lod.scale = max(length(m[0].xyz), max(length(m[1].xyz), length(m[2].xyz)));
144
+ // a bound group's strands are carried by the mesh's world matrix, through their root frames, and are as wide as it
145
+ // makes them
146
+ var carrier = m;
147
+
148
+ if (instance.mesh_node != ${HAIR_BINDING_NONE}u) {
149
+ carrier = scene_read_node(&scene_database, instance.mesh_node).global;
150
+ }
151
+
152
+ lod.scale = max(length(carrier[0].xyz), max(length(carrier[1].xyz), length(carrier[2].xyz)));
99
153
 
100
154
  // the group's box in the world: its quantization box, widened by the widest strand
101
155
  let centre_local = instance.bounds_min + 0.5 * instance.bounds_extent;
102
156
  let half_local = 0.5 * instance.bounds_extent + vec3<f32>(0.5 * instance.width_max);
103
157
 
104
- let centre = (m * vec4<f32>(centre_local, 1.0)).xyz;
105
- let half_extent = abs(m[0].xyz) * half_local.x + abs(m[1].xyz) * half_local.y + abs(m[2].xyz) * half_local.z;
158
+ var centre = (m * vec4<f32>(centre_local, 1.0)).xyz;
159
+ var half_extent = abs(m[0].xyz) * half_local.x + abs(m[1].xyz) * half_local.y + abs(m[2].xyz) * half_local.z;
160
+
161
+ // a simulated group's strands are where its guides are, as far off them as its reach and as wide as its widest; a
162
+ // bound group's that rides its roots as far again as its longest guide from where its roots are
163
+ let gathered = row * ${HAIR_GUIDE_BOUNDS_WORDS}u;
164
+ let gathers = instance.state != ${HAIR_STATE_NONE}u || instance.mesh_node != ${HAIR_BINDING_NONE}u;
165
+
166
+ if (gathers && hair_guide_bounds[gathered + 6u] == instance.epoch && hair_guide_bounds[gathered] != 0u) {
167
+ let high = vec3<f32>(hair_unordered(hair_guide_bounds[gathered]), hair_unordered(hair_guide_bounds[gathered + 1u]), hair_unordered(hair_guide_bounds[gathered + 2u]));
168
+ let low = vec3<f32>(hair_unordered(~hair_guide_bounds[gathered + 3u]), hair_unordered(~hair_guide_bounds[gathered + 4u]), hair_unordered(~hair_guide_bounds[gathered + 5u]));
169
+
170
+ centre = m[3].xyz + 0.5 * (low + high);
171
+ // rigid strands reach their length from their roots; a bound group's strands each ride their own root frame,
172
+ // which the skin turns apart from their guide's, so they too may reach their length from where their roots are
173
+ let along = select(0.0, instance.guide_length_max, instance.state == ${HAIR_STATE_NONE}u || instance.mesh_node != ${HAIR_BINDING_NONE}u);
174
+
175
+ half_extent = 0.5 * (high - low) + vec3<f32>((along + instance.guide_reach + 0.5 * instance.width_max) * lod.scale);
176
+ }
106
177
 
107
178
  let box = ${AABB3_STRUCT.wgsl_ref}(centre - half_extent, centre + half_extent);
108
179
 
109
- if (instance.strand_count > 0u && aabb3_intersects_frustum(box, camera.frustum)) {
180
+ let seen = instance.strand_count > 0u && aabb3_intersects_frustum(box, camera.frustum);
181
+
182
+ // the world size of a pixel the strands are thinned at, and the narrowest they are drawn, pixels; negative where
183
+ // no view draws them
184
+ var pixel_size = -1.0;
185
+ var floor_pixels = settings.pixel_floor;
186
+
187
+ lod.fixed_pixel = -1.0;
188
+
189
+ if (seen) {
110
190
  var depth_near = 3.4e38;
111
191
  var depth_far = -3.4e38;
112
192
 
@@ -119,8 +199,8 @@ fn main(
119
199
  }
120
200
 
121
201
  let near = camera.clip_near_far.x;
122
- let pixel_size = hair_pixel_size(max(depth_near, near), settings.resolution.y);
123
- let kept = hair_kept_fraction(instance.width_mean * lod.scale, pixel_size, settings.pixel_floor);
202
+
203
+ pixel_size = hair_pixel_size(max(depth_near, near), settings.resolution.y);
124
204
 
125
205
  // a kept strand is widened by the reciprocal of its share, which is least at the far side of the box: the
126
206
  // rectangle holds the widest it can be drawn
@@ -157,6 +237,17 @@ fn main(
157
237
 
158
238
  lod.rect_min = hair_pack_pixel(floor(max(rect_min - margin, vec2<f32>(0.0))));
159
239
  lod.rect_max = hair_pack_pixel(ceil(min(rect_max + margin, settings.resolution)));
240
+ } else if (instance.strand_count > 0u && settings.shadow_view_count > 0u) {
241
+ // off the view, but it may cast into it: thinned at the finest texel of the shadow views that hold it, to a
242
+ // texel's width, the narrowest the shadow draw draws a strand
243
+ pixel_size = hair_shadow_texel(centre, half_extent);
244
+ floor_pixels = 1.0;
245
+
246
+ lod.fixed_pixel = pixel_size;
247
+ }
248
+
249
+ if (pixel_size >= 0.0) {
250
+ let kept = hair_kept_fraction(instance.width_mean * lod.scale, pixel_size, floor_pixels);
160
251
 
161
252
  var prefix = min(instance.strand_count, u32(ceil(kept * f32(instance.strand_count))));
162
253
 
@@ -181,7 +272,9 @@ fn main(
181
272
  // the frame's points are full: the count asked for grows them for the frames after
182
273
  prefix = 0u;
183
274
  } else {
184
- atomicAdd(&hair_counters[point_class], prefix);
275
+ // the shadow views' own strands have a part of the class's region of their own, which the view's
276
+ // draws leave out
277
+ atomicAdd(&hair_counters[select(${HAIR_COUNTER_SHADOW_STRANDS}u, 0u, seen) + point_class], prefix);
185
278
 
186
279
  lod.point_base = base;
187
280
  }
@@ -193,26 +286,20 @@ fn main(
193
286
 
194
287
  // the density volume: cubes a pixel across at the box's nearest point, and no finer than the strands laid into
195
288
  // it are apart, the roots' spacing over the root of the share kept: finer would resolve single strands, which
196
- // the thinning moves as the distance changes; no more than the limit along the box's longest side
197
- if (prefix > 0u) {
289
+ // the thinning moves as the distance changes; no more than the limit along the box's longest side. Only the
290
+ // view lights the strands: those only the shadow views draw have none
291
+ if (prefix > 0u && seen) {
198
292
  let size = 2.0 * half_extent;
199
293
  let spacing = instance.root_spacing * lod.scale / sqrt(max(kept, 1e-6));
200
294
  let edge = max(max(pixel_size, spacing), max(size.x, max(size.y, size.z)) / ${HAIR_VOLUME_DIMENSION_LIMIT}.0);
201
295
  let dims = clamp(vec3<u32>(ceil(size / edge)), vec3<u32>(1u), vec3<u32>(${HAIR_VOLUME_DIMENSION_LIMIT}u));
202
296
 
203
- var voxels = 0u;
204
- var coarser = 0u;
205
-
206
- for (var mip = 0u; mip < ${HAIR_VOLUME_MIPS}u; mip++) {
207
- let d = (dims + vec3<u32>((1u << mip) - 1u)) >> vec3<u32>(mip);
208
- let n = d.x * d.y * d.z;
209
-
210
- voxels += n;
211
-
212
- if (mip > 0u) {
213
- coarser += n;
214
- }
215
- }
297
+ // a level's voxels: the level under it halved, rounded up
298
+ let d1 = (dims + vec3<u32>(1u)) >> vec3<u32>(1u);
299
+ let d2 = (dims + vec3<u32>(3u)) >> vec3<u32>(2u);
300
+ let n1 = d1.x * d1.y * d1.z;
301
+ let n2 = d2.x * d2.y * d2.z;
302
+ let voxels = dims.x * dims.y * dims.z + n1 + n2;
216
303
 
217
304
  let base = atomicAdd(&hair_counters[${HAIR_COUNTER_VOXELS}u], voxels);
218
305
 
@@ -223,7 +310,8 @@ fn main(
223
310
  lod.volume_dims = dims;
224
311
  lod.volume_origin = centre - 0.5 * edge * vec3<f32>(dims);
225
312
 
226
- hair_volume_counts.elements[row] = coarser;
313
+ hair_mip_1_counts.elements[row] = n1;
314
+ hair_mip_2_counts.elements[row] = n2;
227
315
  }
228
316
  }
229
317
  }
@@ -241,7 +329,12 @@ fn main(
241
329
  /**
242
330
  * Each instance's level of detail for the frame, a thread a row of the instance table through its page iterator:
243
331
  *
244
- * - its group's box, in the world, against the view's frustum; an instance outside it draws nothing;
332
+ * - its group's box, in the world, against the view's frustum. A simulated group's box is its guides' bounds as the
333
+ * solver gathered them (`hair_guide_bounds`), widened by its reach and its widest strand. An instance outside the
334
+ * frustum is drawn only by the shadow views (`hair_shadow_views`, the first `settings.shadow_view_count`) its box
335
+ * reaches into, their near planes aside, and by no view where it reaches none. It is then thinned at the finest of
336
+ * their texels to a texel's width (`fixed_pixel`), its strands are counted apart from the view's
337
+ * (`HAIR_COUNTER_SHADOW_STRANDS`), and it has no rectangle and no volume;
245
338
  * - its screen rectangle: the box widened by the widest a kept strand is drawn (its widest point over its share kept
246
339
  * at the box's far side), projected, and widened again by the pixel floor; or the whole view when the box reaches
247
340
  * behind the eye;
@@ -253,8 +346,9 @@ fn main(
253
346
  * spacing (the roots' over the root of the share kept) and the box's longest side over
254
347
  * `HAIR_VOLUME_DIMENSION_LIMIT`, every level reserved from the frame's voxels.
255
348
  *
256
- * Writes the row's points, `prefix × (2^class + 1)`, into `hair_counts`, the list the cull's scan sums; its coarser
257
- * voxels into `hair_volume_counts`, the list the mip pass's scan sums; and its record into `hair_lod`. Rows it does
349
+ * Writes the row's points, `prefix × (2^class + 1)`, into `hair_counts`, the list the cull's scan sums; its voxels
350
+ * of level 1 and of level 2 into `hair_mip_1_counts` and `hair_mip_2_counts`, the lists the mip passes' scans sum;
351
+ * and its record into `hair_lod`. Rows it does
258
352
  * not visit keep what the buffers were cleared to. `hair_counters` is zero on entry. Points past
259
353
  * `settings.point_capacity` are refused: the instance draws nothing this frame, and the count it asked for stays
260
354
  * in the counters for its owner to read.
@@ -0,0 +1,36 @@
1
+ export const HAIR_ROOTS_SETTINGS: WebGPUStruct;
2
+ /**
3
+ * A triangle's frame, Unreal's: the tangent along its first edge, the normal of its face, the bitangent the normal
4
+ * across the tangent, as the columns of a rotation:
5
+ *
6
+ * ```wgsl
7
+ * fn hair_triangle_frame(a: vec3<f32>, b: vec3<f32>, c: vec3<f32>) -> mat3x3<f32>
8
+ * ```
9
+ *
10
+ * The same frame `groom_bind_to_mesh` records at the bind pose.
11
+ *
12
+ * @type {CodeChunk}
13
+ */
14
+ export const chunk_hair_triangle_frame: CodeChunk;
15
+ /**
16
+ * Where each bound strand's root is: a thread a strand of every bound instance (`HAIR_SIMULATION.js`), the threads of
17
+ * a row found from the inclusive sums of the bound rows' strand counts.
18
+ *
19
+ * The strand's binding (`groom_bind_to_mesh`) names a triangle of the bound mesh, the root's weights on it, and the
20
+ * triangle's frame at the bind pose with the root's point as its origin. The same triangle where the mesh is now
21
+ * gives the frame again (`hair_triangle_frame`), and the strand's root frame is the turn and move from the rest frame
22
+ * to it, carried into the world by the mesh's world matrix: the groom's rest points are in the mesh's space at its
23
+ * bind pose, so a root on its triangle stays on it however the mesh deforms. The frame a frame ago is made the same
24
+ * way, from a skinned clone's previous positions, which its skinning blends against the mesh's world matrix as it is
25
+ * now (and so are carried by it), or a rigid mesh's own positions and its world matrix a frame ago.
26
+ *
27
+ * Both are written as affine rows into the instance's root frames in the guide state pool, and the strand's own root
28
+ * (which may stand off its triangle by its binding's distance), from the instance's own entity, is gathered into its row's guide bounds, reduced across the subgroup first.
29
+ *
30
+ * @type {ComputeShader}
31
+ */
32
+ export const shader_hair_roots: ComputeShader;
33
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
34
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
35
+ import { ComputeShader } from "../shader/ComputeShader.js";
36
+ //# sourceMappingURL=shader_hair_roots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_hair_roots.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_roots.js"],"names":[],"mappings":"AAsBA,+CAGwB;AAkBxB;;;;;;;;;;;GAWG;AACH,wCAFU,SAAS,CAWhB;AA+KH;;;;;;;;;;;;;;;;GAgBG;AACH,gCAFU,aAAa,CAMpB;6BApP0B,gCAAgC;0BAPnC,iCAAiC;8BAE7B,4BAA4B"}
@@ -0,0 +1,261 @@
1
+ import { GROOM_BINDING_WORDS } from "../../../engine/graphics/hair/groom_bind_to_mesh.js";
2
+ import { COLLECTION_U32_STRUCT_READ } from "../gpu_primitive/COLLECTION_U32_STRUCT_READ.js";
3
+ import { GEOMETRY_ATTRIBUTE_DATA_TYPE } from "../geometry/GEOMETRY_ATTRIBUTE_DATA_TYPE.js";
4
+ import { MESHLET_METADATA_STRUCT } from "../geometry/meshlet/encoding/MESHLET_METADATA_STRUCT.js";
5
+ import { chunk_scene_database_access } from "../scene/chunk_scene_database_access.js";
6
+ import { chunk_read_meshlet_triangle_positions } from "../shader/chunk/geometry/meshlet/chunk_read_meshlet_triangle_positions.js";
7
+ import { chunk_read_meshlet_resolved_index } from "../shader/chunk/geometry/meshlet/chunk_read_meshlet_resolved_index.js";
8
+ import { chunk_folded_workgroup_index } from "../shader/chunk/grid/chunk_folded_workgroup_index.js";
9
+ import { chunk_lower_bound_branchless } from "../shader/chunk/math/chunk_lower_bound_branchless.js";
10
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
11
+ import { COMPUTE_SHADER_DEFAULT_GROUP_SIZE } from "../shader/COMPUTE_SHADER_DEFAULT_GROUP_SIZE.js";
12
+ import { ComputeShader } from "../shader/ComputeShader.js";
13
+ import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
14
+ import { atomic_u32, u32, vec4f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
15
+ import { WebGPUArray } from "../shader/type/WebGPUArray.js";
16
+ import { WebGPUBufferType } from "../shader/type/WebGPUBufferType.js";
17
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
18
+ import { WebGPUExtensionType } from "../../descriptor/WebGPUExtensionType.js";
19
+ import { chunk_hair_rest_point, HAIR_GROOMS_RESOURCE } from "./chunk_hair_strand.js";
20
+ import { HAIR_INSTANCE_DESCRIPTOR } from "./HAIR_DATABASE_SPEC.js";
21
+ import { HAIR_BINDING_NONE, HAIR_GUIDE_BOUNDS_WORDS, HAIR_ROOT_FRAME_VECTORS } from "./HAIR_SIMULATION.js";
22
+
23
+ export const HAIR_ROOTS_SETTINGS = WebGPUStruct.from({
24
+ /** 1 when the skinning's previous positions are bound, 0 when its buffers are placeholders */
25
+ skinning_active: u32,
26
+ }, "HairRootsSettings");
27
+
28
+ const resources = new ShaderResourceSetDescriptor();
29
+
30
+ resources.setImmediate("settings", HAIR_ROOTS_SETTINGS);
31
+
32
+ resources.createGroup()
33
+ .add(HAIR_GROOMS_RESOURCE)
34
+ .addStorageBuffer("hair_database", WebGPUBufferType.unsized, false)
35
+ .addStorageBuffer("scene_database", WebGPUBufferType.unsized, false)
36
+ .addStorageBuffer("root_sums", COLLECTION_U32_STRUCT_READ, false)
37
+ .addStorageBuffer("meshlet_metadata", WebGPUArray.from(MESHLET_METADATA_STRUCT), false)
38
+ .addStorageBuffer("meshlet_data", GEOMETRY_ATTRIBUTE_DATA_TYPE, false)
39
+ .addStorageBuffer("prev_position_offsets", WebGPUArray.from(u32), false)
40
+ .addStorageBuffer("prev_positions", WebGPUArray.from(u32), false)
41
+ .addStorageBuffer("hair_guide_state", WebGPUArray.from(vec4f), true)
42
+ .addStorageBuffer("hair_guide_bounds", WebGPUArray.from(atomic_u32), true);
43
+
44
+ /**
45
+ * A triangle's frame, Unreal's: the tangent along its first edge, the normal of its face, the bitangent the normal
46
+ * across the tangent, as the columns of a rotation:
47
+ *
48
+ * ```wgsl
49
+ * fn hair_triangle_frame(a: vec3<f32>, b: vec3<f32>, c: vec3<f32>) -> mat3x3<f32>
50
+ * ```
51
+ *
52
+ * The same frame `groom_bind_to_mesh` records at the bind pose.
53
+ *
54
+ * @type {CodeChunk}
55
+ */
56
+ export const chunk_hair_triangle_frame = CodeChunk.from(
57
+ //language=WGSL
58
+ `
59
+ fn hair_triangle_frame(a: vec3<f32>, b: vec3<f32>, c: vec3<f32>) -> mat3x3<f32> {
60
+ let tangent = normalize(b - a);
61
+ let normal = normalize(cross(b - a, c - a));
62
+
63
+ return mat3x3<f32>(tangent, cross(normal, tangent), normal);
64
+ }
65
+ `);
66
+
67
+ const body = CodeChunk.from(
68
+ //language=WGSL
69
+ `
70
+ // a float as a u32 that orders as the float does
71
+ fn hair_root_ordered(v: f32) -> u32 {
72
+ let bits = bitcast<u32>(v);
73
+
74
+ return bits ^ select(0x80000000u, 0xFFFFFFFFu, (bits & 0x80000000u) != 0u);
75
+ }
76
+
77
+ fn hair_previous_position(base: u32, vertex: u32) -> vec3<f32> {
78
+ let at = base + vertex * 3u;
79
+
80
+ return vec3<f32>(bitcast<f32>(prev_positions[at]), bitcast<f32>(prev_positions[at + 1u]), bitcast<f32>(prev_positions[at + 2u]));
81
+ }
82
+
83
+ // a frame as the rows of an affine 3 x 4 matrix, into the pool
84
+ fn hair_write_root_frame(at: u32, linear: mat3x3<f32>, origin: vec3<f32>) {
85
+ hair_guide_state[at] = vec4<f32>(linear[0].x, linear[1].x, linear[2].x, origin.x);
86
+ hair_guide_state[at + 1u] = vec4<f32>(linear[0].y, linear[1].y, linear[2].y, origin.y);
87
+ hair_guide_state[at + 2u] = vec4<f32>(linear[0].z, linear[1].z, linear[2].z, origin.z);
88
+ }
89
+
90
+ // a bound strand's root frames, written; its root from the instance's own entity, returned
91
+ fn hair_root_place(instance: ${HAIR_INSTANCE_DESCRIPTOR.type.wgsl_ref}, strand: u32) -> vec3<f32> {
92
+ // the binding: the triangle, the root's weights on it, its rest frame and the root's rest point on it
93
+ let at = instance.bindings + strand * ${GROOM_BINDING_WORDS}u;
94
+
95
+ let triangle = hair_grooms[at];
96
+ let wa = bitcast<f32>(hair_grooms[at + 1u]);
97
+ let wb = bitcast<f32>(hair_grooms[at + 2u]);
98
+ let wc = 1.0 - wa - wb;
99
+
100
+ let rest_tangent = bitcast<vec3<f32>>(vec3<u32>(hair_grooms[at + 4u], hair_grooms[at + 5u], hair_grooms[at + 6u]));
101
+ let rest_bitangent = bitcast<vec3<f32>>(vec3<u32>(hair_grooms[at + 8u], hair_grooms[at + 9u], hair_grooms[at + 10u]));
102
+ let rest_normal = bitcast<vec3<f32>>(vec3<u32>(hair_grooms[at + 12u], hair_grooms[at + 13u], hair_grooms[at + 14u]));
103
+ let rest_origin = bitcast<vec3<f32>>(vec3<u32>(hair_grooms[at + 7u], hair_grooms[at + 11u], hair_grooms[at + 15u]));
104
+
105
+ // the rest frame's inverse: its transpose
106
+ let unrest = transpose(mat3x3<f32>(rest_tangent, rest_bitangent, rest_normal));
107
+
108
+ let meshlet = instance.meshlet_base + (triangle >> 8u);
109
+ let corner = triangle & 0xFFu;
110
+
111
+ // the triangle where the mesh is now, in its own space: a skinned clone's meshlets hold its deformed positions
112
+ let now = read_meshlet_triangle_positions(meshlet, corner);
113
+
114
+ let node = scene_read_node(&scene_database, instance.mesh_node);
115
+ let g = node.global;
116
+ let g_linear = mat3x3<f32>(g[0].xyz, g[1].xyz, g[2].xyz);
117
+
118
+ // a frame ago: a skinned clone's previous positions, which its skinning blends against the mesh's world matrix
119
+ // as it is now, so the world matrix now carries them; a rigid mesh's are its own, carried by its world matrix then
120
+ var before = now;
121
+ var g_before = g;
122
+
123
+ // the table covers the clones' rows; a rigid mesh's rows may lie past it
124
+ let listed = settings.skinning_active != 0u && meshlet < arrayLength(&prev_position_offsets);
125
+ let previous = select(0xFFFFFFFFu, prev_position_offsets[min(meshlet, arrayLength(&prev_position_offsets) - 1u)], listed);
126
+
127
+ if (previous != 0xFFFFFFFFu) {
128
+ let header = meshlet_metadata[meshlet];
129
+ let last_vertex = header.vertex_count - 1u;
130
+
131
+ before.a = hair_previous_position(previous, min(read_meshlet_resolved_index(header, corner * 3u), last_vertex));
132
+ before.b = hair_previous_position(previous, min(read_meshlet_resolved_index(header, corner * 3u + 1u), last_vertex));
133
+ before.c = hair_previous_position(previous, min(read_meshlet_resolved_index(header, corner * 3u + 2u), last_vertex));
134
+ } else {
135
+ g_before = node.prev_global;
136
+ }
137
+
138
+ let g_before_linear = mat3x3<f32>(g_before[0].xyz, g_before[1].xyz, g_before[2].xyz);
139
+
140
+ // the turn and move from the rest frame to the frame now, in the mesh's space, then into the world
141
+ let turn = hair_triangle_frame(now.a, now.b, now.c) * unrest;
142
+ let origin = now.a * wa + now.b * wb + now.c * wc;
143
+
144
+ let turn_before = hair_triangle_frame(before.a, before.b, before.c) * unrest;
145
+ let origin_before = before.a * wa + before.b * wb + before.c * wc;
146
+
147
+ let out = instance.roots + strand * ${HAIR_ROOT_FRAME_VECTORS}u;
148
+
149
+ hair_write_root_frame(out, g_linear * turn, g_linear * (origin - turn * rest_origin) + g[3].xyz);
150
+ hair_write_root_frame(out + 3u, g_before_linear * turn_before, g_before_linear * (origin_before - turn_before * rest_origin) + g_before[3].xyz);
151
+
152
+ let anchor = scene_read_node(&scene_database, instance.node).global[3].xyz;
153
+
154
+ // the strand's own root, which may stand off its triangle by its binding's distance
155
+ return g_linear * (origin + turn * (hair_rest_point(instance, strand, 0u).xyz - rest_origin)) + g[3].xyz - anchor;
156
+ }
157
+
158
+ // the roots into their rows' bounds: a round a row the subgroup holds, the round's lanes reduced and the first of
159
+ // them gathering for all, so a row's bounds take one atomic a subgroup rather than one a strand. Called by every lane,
160
+ // in subgroup-uniform control flow; a lane with no root holds ${HAIR_BINDING_NONE}.
161
+ // the trip count is uniform across the subgroup by construction: every lane sees the same minimum
162
+ @diagnostic(off, subgroup_uniformity)
163
+ fn hair_root_gather(key: u32, root: vec3<f32>) {
164
+ var outstanding = key;
165
+
166
+ let high = vec3<u32>(hair_root_ordered(root.x), hair_root_ordered(root.y), hair_root_ordered(root.z));
167
+ let low = ~high;
168
+
169
+ loop {
170
+ let round = subgroupMin(outstanding);
171
+
172
+ if (round == ${HAIR_BINDING_NONE}u) {
173
+ break;
174
+ }
175
+
176
+ let in_round = outstanding == round;
177
+ let first = subgroupExclusiveAdd(select(0u, 1u, in_round)) == 0u;
178
+
179
+ let round_high = subgroupMax(select(vec3<u32>(0u), high, in_round));
180
+ let round_low = subgroupMax(select(vec3<u32>(0u), low, in_round));
181
+
182
+ if (in_round && first) {
183
+ let at = round * ${HAIR_GUIDE_BOUNDS_WORDS}u;
184
+
185
+ atomicMax(&hair_guide_bounds[at], round_high.x);
186
+ atomicMax(&hair_guide_bounds[at + 1u], round_high.y);
187
+ atomicMax(&hair_guide_bounds[at + 2u], round_high.z);
188
+ atomicMax(&hair_guide_bounds[at + 3u], round_low.x);
189
+ atomicMax(&hair_guide_bounds[at + 4u], round_low.y);
190
+ atomicMax(&hair_guide_bounds[at + 5u], round_low.z);
191
+ }
192
+
193
+ if (in_round) {
194
+ outstanding = ${HAIR_BINDING_NONE}u;
195
+ }
196
+ }
197
+ }
198
+
199
+ @compute @workgroup_size(${COMPUTE_SHADER_DEFAULT_GROUP_SIZE})
200
+ fn main(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(local_invocation_index) lane: u32) {
201
+ let thread = folded_workgroup_index(workgroup_id) * ${COMPUTE_SHADER_DEFAULT_GROUP_SIZE}u + lane;
202
+
203
+ // the sums are inclusive: a thread belongs to the first row whose sum is past it
204
+ let rows = root_sums.count;
205
+ let row = lower_bound_branchless(&root_sums.elements, thread + 1u, rows);
206
+
207
+ var key = ${HAIR_BINDING_NONE}u;
208
+ var root = vec3<f32>(0.0);
209
+
210
+ if (row < rows) {
211
+ var strand = thread;
212
+
213
+ if (row > 0u) {
214
+ strand -= root_sums.elements[row - 1u];
215
+ }
216
+
217
+ let instance = ${HAIR_INSTANCE_DESCRIPTOR.marshalling_method_read}(&hair_database, row);
218
+
219
+ if (instance.mesh_node != ${HAIR_BINDING_NONE}u && strand < instance.strand_count) {
220
+ root = hair_root_place(instance, strand);
221
+ key = row;
222
+ }
223
+ }
224
+
225
+ hair_root_gather(key, root);
226
+ }
227
+ `, [
228
+ HAIR_INSTANCE_DESCRIPTOR.chunk_read,
229
+ chunk_folded_workgroup_index,
230
+ chunk_lower_bound_branchless,
231
+ chunk_scene_database_access,
232
+ chunk_read_meshlet_triangle_positions,
233
+ chunk_read_meshlet_resolved_index,
234
+ chunk_hair_triangle_frame,
235
+ chunk_hair_rest_point,
236
+ ]);
237
+
238
+ body.addExtension(WebGPUExtensionType.Subgroups);
239
+
240
+ /**
241
+ * Where each bound strand's root is: a thread a strand of every bound instance (`HAIR_SIMULATION.js`), the threads of
242
+ * a row found from the inclusive sums of the bound rows' strand counts.
243
+ *
244
+ * The strand's binding (`groom_bind_to_mesh`) names a triangle of the bound mesh, the root's weights on it, and the
245
+ * triangle's frame at the bind pose with the root's point as its origin. The same triangle where the mesh is now
246
+ * gives the frame again (`hair_triangle_frame`), and the strand's root frame is the turn and move from the rest frame
247
+ * to it, carried into the world by the mesh's world matrix: the groom's rest points are in the mesh's space at its
248
+ * bind pose, so a root on its triangle stays on it however the mesh deforms. The frame a frame ago is made the same
249
+ * way, from a skinned clone's previous positions, which its skinning blends against the mesh's world matrix as it is
250
+ * now (and so are carried by it), or a rigid mesh's own positions and its world matrix a frame ago.
251
+ *
252
+ * Both are written as affine rows into the instance's root frames in the guide state pool, and the strand's own root
253
+ * (which may stand off its triangle by its binding's distance), from the instance's own entity, is gathered into its row's guide bounds, reduced across the subgroup first.
254
+ *
255
+ * @type {ComputeShader}
256
+ */
257
+ export const shader_hair_roots = ComputeShader.from({
258
+ label: "Hair Roots",
259
+ resources,
260
+ body,
261
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The shadow views' lists, as the passes below share them.
3
+ *
4
+ * **A shadow view's list** is laid out as the frame's draw list is (`HAIR.js`): view `v`'s from entry
5
+ * `v × list capacity`, each class's region from the draw list's start of it, its strands from the region's start, as
6
+ * many as the view's count of the class (`hair_shadow_counts`, `v × HAIR_CLASS_COUNT + class`).
7
+ */
8
+ export const HAIR_SHADOW_LIST_SETTINGS: WebGPUStruct;
9
+ /**
10
+ * The folded command {@link shader_hair_shadow_list} is dispatched through: a thread for each entry of the frame's
11
+ * draw list in each shadow view. One thread.
12
+ *
13
+ * @type {ComputeShader}
14
+ */
15
+ export const shader_hair_shadow_list_command: ComputeShader;
16
+ /**
17
+ * Lists, for each shadow view, the strands of the frame's draw list that it draws, a thread an entry of the list in
18
+ * a view (views apart by the list's entries), dispatched through {@link shader_hair_shadow_list_command}'s command.
19
+ *
20
+ * An entry is read where the cull wrote one: in its class's region, among the strands listed for the view or among
21
+ * those listed for the shadow views alone. The strand is drawn by the view when both hold:
22
+ *
23
+ * - the ball about its root as wide as its reach (its shadow words) is inside the view's planes, the near one aside;
24
+ * - its widest point, at the finest the view's texels are within that ball, is drawn by the shadow draw: wider than
25
+ * its stratified share of half a texel, the share and the test of `hair_shadow_draw.js`. Where the ball reaches
26
+ * the eye of a perspective view, its texels are not bounded, and the strand is drawn.
27
+ *
28
+ * A drawn strand is appended to its class's region of the view's list (`chunk_subgroup_keyed_append` on the view's
29
+ * count of the class).
30
+ *
31
+ * @type {ComputeShader}
32
+ */
33
+ export const shader_hair_shadow_list: ComputeShader;
34
+ /**
35
+ * The shadow draw's indirect draws, one a point class of each shadow view (`HAIR_DRAW_ARGS_WORDS` words each, at
36
+ * `view × HAIR_CLASS_COUNT + class`): as the id raster's (`shader_hair_draw_args`), over the class's region of the
37
+ * view's list. A workgroup a view, a thread a class.
38
+ *
39
+ * @type {ComputeShader}
40
+ */
41
+ export const shader_hair_shadow_draw_args: ComputeShader;
42
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
43
+ import { ComputeShader } from "../shader/ComputeShader.js";
44
+ //# sourceMappingURL=shader_hair_shadow_list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_hair_shadow_list.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_shadow_list.js"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AAEH,qDAK6B;AA6B7B;;;;;GAKG;AACH,8CAFU,aAAa,CAkBpB;AAcH;;;;;;;;;;;;;;;;GAgBG;AACH,sCAFU,aAAa,CA8EpB;AAWH;;;;;;GAMG;AACH,2CAFU,aAAa,CAyBpB;6BAjO0B,gCAAgC;8BAJ/B,4BAA4B"}