@woosh/meep-engine 3.74.0 → 3.76.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/CHANGELOG.md +20 -19
- package/package.json +1 -1
- package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts +11 -0
- package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts.map +1 -0
- package/src/core/geom/2d/hilbert/v2_hilbert_encode.js +46 -0
- package/src/engine/asset/GameAssetType.d.ts +1 -0
- package/src/engine/asset/GameAssetType.js +5 -1
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts +33 -0
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/GroomAssetLoader.js +99 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts +47 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -0
- package/src/engine/graphics/ecs/hair/Hair.js +61 -0
- package/src/engine/graphics/hair/Groom.d.ts +130 -0
- package/src/engine/graphics/hair/Groom.d.ts.map +1 -0
- package/src/engine/graphics/hair/Groom.js +193 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +24 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.js +77 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts +85 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_build_group.js +487 -0
- package/src/engine/graphics/hair/groom_generate_scalp.d.ts +29 -0
- package/src/engine/graphics/hair/groom_generate_scalp.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_generate_scalp.js +184 -0
- package/src/engine/graphics/hair/groom_rank_order.d.ts +15 -0
- package/src/engine/graphics/hair/groom_rank_order.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_rank_order.js +53 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts +12 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_root_spacing.js +120 -0
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +6 -0
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
- package/src/engine/graphics/render/frame_graph/FrameGraph.js +9 -0
- package/src/engine/graphics3/GPUAcousticSystem.d.ts +29 -32
- package/src/engine/graphics3/GPUAcousticSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUAcousticSystem.js +87 -162
- package/src/engine/graphics3/HairSystem.d.ts +102 -0
- package/src/engine/graphics3/HairSystem.d.ts.map +1 -0
- package/src/engine/graphics3/HairSystem.js +456 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +35 -17
- package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
- package/src/engine/sound/ecs/audio/LiveEmitterSet.js +2 -3
- package/src/engine/sound/simulation/AcousticSimulator.d.ts +7 -0
- package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
- package/src/engine/sound/simulation/AcousticSimulator.js +27 -0
- package/src/engine/sound/simulation/README.md +121 -107
- package/src/engine/sound/sopra/README.md +8 -3
- package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts +2 -2
- package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts.map +1 -1
- package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js +4 -3
- package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts +118 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.js +472 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts +166 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbLines.js +447 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts +69 -113
- package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.js +143 -491
- package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts +102 -0
- package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/AcousticSpeakers.js +232 -0
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts +17 -3
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/BusGraph.js +55 -5
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts +8 -6
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/EventInstance.js +113 -105
- package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts +13 -0
- package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.js +15 -0
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +4 -6
- package/src/shade/assets/textures/hair_scattering.bin +0 -0
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts +11 -0
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts.map +1 -1
- package/src/shade/device/pipeline/PipelineEnquiry.js +13 -0
- package/src/shade/playground/hair/index.html +50 -0
- package/src/shade/playground/hair/main.d.ts +2 -0
- package/src/shade/playground/hair/main.d.ts.map +1 -0
- package/src/shade/playground/hair/main.js +274 -0
- package/src/shade/playground/screen_probes/README.md +54 -0
- package/src/shade/playground/screen_probes/index.html +271 -0
- package/src/shade/playground/screen_probes/main.d.ts +8 -0
- package/src/shade/playground/screen_probes/main.d.ts.map +1 -0
- package/src/shade/playground/screen_probes/main.js +527 -0
- package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +4 -5
- package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/main.js +6 -12
- package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
- package/src/shade/playground/skinned_mesh_soup/main.js +1 -2
- package/src/shade/playground/vgeo_scene/README.md +12 -2
- package/src/shade/playground/vgeo_scene/main.js +1 -1
- package/src/shade/playground/volumetrics_froxel/README.md +191 -191
- package/src/shade/playground/volumetrics_froxel/measure.d.ts +3 -3
- package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
- package/src/shade/playground/volumetrics_froxel/measure.js +11 -13
- package/src/shade/playground/vsm/main.d.ts.map +1 -1
- package/src/shade/playground/vsm/main.js +5 -6
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +85 -16
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts +6 -0
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts.map +1 -1
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.js +10 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts +28 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.js +42 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts +58 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.js +108 -0
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +161 -0
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/GPUAcousticProbes.js +760 -0
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts +12 -0
- package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/acoustic_listener_order.js +56 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_direct.js +5 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts +57 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.js +314 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts +15 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_finite.js +21 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_gather.js +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts +27 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_lean.js +42 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts +80 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_listener.js +274 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_partials.d.ts +2 -2
- package/src/shade/renderer/acoustics/chunk_acoustic_partials.js +2 -2
- package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts +7 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_phonon.js +24 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_resample.js +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_reservoir.js +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts +43 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_through.js +153 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts +3 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_trace.js +10 -1
- package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts +7 -3
- package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/shader_acoustic_combine.js +22 -6
- package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts +14 -0
- package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_coupling.js +102 -0
- package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts +12 -0
- package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_listener.js +80 -0
- package/src/shade/renderer/acoustics/shader_acoustic_receive.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/shader_acoustic_receive.js +27 -6
- package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts +11 -0
- package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_room.js +111 -0
- package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts +18 -0
- package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_source.js +130 -0
- package/src/shade/renderer/deferred/chunk_read_gBuffer_material.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_read_gBuffer_material.js +3 -1
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts +23 -0
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts.map +1 -0
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +111 -0
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +17 -6
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +26 -21
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts +12 -22
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.js +20 -100
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.js +6 -4
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts +15 -0
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts.map +1 -0
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +47 -0
- package/src/shade/renderer/extension/ViewLighting.d.ts +101 -0
- package/src/shade/renderer/extension/ViewLighting.d.ts.map +1 -0
- package/src/shade/renderer/extension/ViewLighting.js +168 -0
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +2 -2
- package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts +5 -2
- package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.js +5 -2
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts +9 -2
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +48 -12
- package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts +0 -22
- package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +0 -42
- package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts +2 -18
- package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.js +2 -19
- package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.js +0 -1
- package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts +5 -4
- package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +3 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.js +3 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +0 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +60 -14
- package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +75 -39
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.js +3 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +0 -9
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +45 -17
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +7 -3
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +43 -7
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.js +3 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +15 -7
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +40 -9
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +23 -0
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +26 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +6 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +13 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +23 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +2 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +29 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +102 -0
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +8 -1
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +27 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +4 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +4 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +11 -5
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +28 -10
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +36 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +149 -4
- package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js +3 -1
- package/src/shade/renderer/hair/GPUHairSystem.d.ts +159 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -0
- package/src/shade/renderer/hair/GPUHairSystem.js +1132 -0
- package/src/shade/renderer/hair/HAIR.d.ts +102 -0
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR.js +115 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts +17 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +71 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +11 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +48 -0
- package/src/shade/renderer/hair/HairFrame.d.ts +41 -0
- package/src/shade/renderer/hair/HairFrame.d.ts.map +1 -0
- package/src/shade/renderer/hair/HairFrame.js +76 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +42 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.js +170 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +30 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +131 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.d.ts +32 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.js +116 -0
- package/src/shade/renderer/hair/chunk_hair_strand.d.ts +40 -0
- package/src/shade/renderer/hair/chunk_hair_strand.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_strand.js +85 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts +31 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_volume.js +106 -0
- package/src/shade/renderer/hair/hair_id_draw.d.ts +24 -0
- package/src/shade/renderer/hair/hair_id_draw.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_id_draw.js +135 -0
- package/src/shade/renderer/hair/hair_lighting.d.ts +53 -0
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_lighting.js +270 -0
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts +75 -0
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_scattering_lut.js +271 -0
- package/src/shade/renderer/hair/hair_stamp.d.ts +33 -0
- package/src/shade/renderer/hair/hair_stamp.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_stamp.js +175 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts +21 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_classes.js +86 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts +31 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_cull.js +194 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts +33 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_lod.js +268 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts +28 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_volume.js +167 -0
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts +31 -0
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.js +36 -21
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +60 -0
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -0
- package/src/shade/renderer/loader/usd/usd_groom_extension.js +417 -0
- package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +4 -1
- package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.js +3 -1
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts +4 -1
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.js +9 -0
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts +16 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +47 -3
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.js +5 -3
- package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.js +6 -5
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.js +5 -2
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +5 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +4 -1
- package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.js +5 -1
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +7 -4
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +13 -8
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +18 -14
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts +3 -2
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.js +12 -4
- package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.js +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_compute_indirect_specular.js +1 -1
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts +16 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.js +25 -0
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +2 -2
- package/src/shade/renderer/shader/compiler/ShaderSwitch.d.ts +1 -1
- package/src/shade/renderer/shader/compiler/ShaderSwitchSet.d.ts +1 -1
- package/src/shade/renderer/shader/resource/ShaderResourceDescriptor.d.ts +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +2 -2
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +2 -2
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { CAMERA_RESOURCE } from "../camera/CAMERA_RESOURCE.js";
|
|
2
|
+
import { COLLECTION_U32_STRUCT_READ } from "../gpu_primitive/COLLECTION_U32_STRUCT_READ.js";
|
|
3
|
+
import { chunk_scene_database_access } from "../scene/chunk_scene_database_access.js";
|
|
4
|
+
import { chunk_folded_workgroup_index } from "../shader/chunk/grid/chunk_folded_workgroup_index.js";
|
|
5
|
+
import { chunk_lower_bound_branchless } from "../shader/chunk/math/chunk_lower_bound_branchless.js";
|
|
6
|
+
import {
|
|
7
|
+
chunk_subgroup_keyed_append,
|
|
8
|
+
SUBGROUP_KEYED_APPEND_NONE
|
|
9
|
+
} from "../shader/chunk/subgroup/chunk_subgroup_keyed_append.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, f32, u32, vec2f, vec4u } 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 { chunk_hair_lod, chunk_hair_rest_point, HAIR_GROOMS_RESOURCE } from "./chunk_hair_strand.js";
|
|
19
|
+
import { chunk_hair_volume_layout } from "./chunk_hair_volume.js";
|
|
20
|
+
import { HAIR_CLASS_SHIFT, HAIR_COUNTER_CURSORS, HAIR_ROW_BITS, HAIR_VOLUME_FIXED_ONE } from "./HAIR.js";
|
|
21
|
+
import { HAIR_INSTANCE_DESCRIPTOR } from "./HAIR_DATABASE_SPEC.js";
|
|
22
|
+
import { HAIR_LOD_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
|
|
23
|
+
|
|
24
|
+
export const HAIR_CULL_SETTINGS = WebGPUStruct.from({
|
|
25
|
+
/** the view's internal size, pixels */
|
|
26
|
+
resolution: vec2f,
|
|
27
|
+
/** the narrowest a strand is drawn, pixels */
|
|
28
|
+
pixel_floor: f32,
|
|
29
|
+
/** points the frame's deformed buffer holds: where its second half starts */
|
|
30
|
+
point_capacity: u32,
|
|
31
|
+
/** entries the frame's draw list holds */
|
|
32
|
+
list_capacity: u32,
|
|
33
|
+
}, "HairCullSettings");
|
|
34
|
+
|
|
35
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
36
|
+
|
|
37
|
+
resources.setImmediate("settings", HAIR_CULL_SETTINGS);
|
|
38
|
+
|
|
39
|
+
resources.createGroup()
|
|
40
|
+
.add(CAMERA_RESOURCE)
|
|
41
|
+
.add(HAIR_GROOMS_RESOURCE)
|
|
42
|
+
.addStorageBuffer("hair_database", WebGPUBufferType.unsized, false)
|
|
43
|
+
.addStorageBuffer("scene_database", WebGPUBufferType.unsized, false)
|
|
44
|
+
.addStorageBuffer("prefix_sums", COLLECTION_U32_STRUCT_READ, false)
|
|
45
|
+
.addStorageBuffer("hair_lod", WebGPUArray.from(HAIR_LOD_STRUCT), false)
|
|
46
|
+
.addStorageBuffer("hair_counters", WebGPUArray.from(atomic_u32), true)
|
|
47
|
+
.addStorageBuffer("hair_points", WebGPUArray.from(vec4u), true)
|
|
48
|
+
.addStorageBuffer("hair_list", WebGPUArray.u32, true)
|
|
49
|
+
.addStorageBuffer("hair_volume", WebGPUArray.from(atomic_u32), true);
|
|
50
|
+
|
|
51
|
+
const body = CodeChunk.from(
|
|
52
|
+
//language=WGSL
|
|
53
|
+
`
|
|
54
|
+
@compute @workgroup_size(${COMPUTE_SHADER_DEFAULT_GROUP_SIZE})
|
|
55
|
+
fn main(
|
|
56
|
+
@builtin(workgroup_id) workgroup_id: vec3<u32>,
|
|
57
|
+
@builtin(local_invocation_index) lane: u32,
|
|
58
|
+
) {
|
|
59
|
+
let thread = folded_workgroup_index(workgroup_id) * ${COMPUTE_SHADER_DEFAULT_GROUP_SIZE}u + lane;
|
|
60
|
+
|
|
61
|
+
// the sums are inclusive: a thread belongs to the first row whose sum is past it
|
|
62
|
+
let rows = prefix_sums.count;
|
|
63
|
+
let row = lower_bound_branchless(&prefix_sums.elements, thread + 1u, rows);
|
|
64
|
+
|
|
65
|
+
var key = ${SUBGROUP_KEYED_APPEND_NONE}u;
|
|
66
|
+
var entry = 0u;
|
|
67
|
+
|
|
68
|
+
if (row < rows) {
|
|
69
|
+
var point = thread;
|
|
70
|
+
|
|
71
|
+
if (row > 0u) {
|
|
72
|
+
point -= prefix_sums.elements[row - 1u];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let instance = ${HAIR_INSTANCE_DESCRIPTOR.marshalling_method_read}(&hair_database, row);
|
|
76
|
+
let lod = hair_lod[row];
|
|
77
|
+
let node = scene_read_node(&scene_database, instance.node);
|
|
78
|
+
|
|
79
|
+
let segments = 1u << lod.point_class;
|
|
80
|
+
let strand = point / (segments + 1u);
|
|
81
|
+
let j = point - strand * (segments + 1u);
|
|
82
|
+
|
|
83
|
+
let m = node.global;
|
|
84
|
+
|
|
85
|
+
// the strand's own share kept, at its root's depth: never more than the prefix's, the root being no nearer
|
|
86
|
+
let root = (m * vec4<f32>(hair_rest_point(instance, strand, 0u).xyz, 1.0)).xyz;
|
|
87
|
+
let depth = max(hair_view_depth(root), camera.clip_near_far.x);
|
|
88
|
+
let kept = hair_kept_fraction(instance.width_mean * lod.scale, hair_pixel_size(depth, settings.resolution.y), settings.pixel_floor);
|
|
89
|
+
|
|
90
|
+
// the strand at the boundary fades by its width, so the kept strands' widths always sum to the group's
|
|
91
|
+
let presence = kept * f32(instance.strand_count) - f32(strand);
|
|
92
|
+
|
|
93
|
+
if (presence > 0.0) {
|
|
94
|
+
let slot = lod.point_base + strand * (segments + 1u);
|
|
95
|
+
|
|
96
|
+
let rest = hair_rest_point(instance, strand, j << lod.level);
|
|
97
|
+
|
|
98
|
+
let now = (m * vec4<f32>(rest.xyz, 1.0)).xyz;
|
|
99
|
+
let before = (node.prev_global * vec4<f32>(rest.xyz, 1.0)).xyz;
|
|
100
|
+
|
|
101
|
+
var half_width = rest.w * saturate(presence) / kept * lod.scale * 0.5;
|
|
102
|
+
|
|
103
|
+
// the segment to the next point, into the density volume: the strands it adds, (pi / 4) w L / h^2 along a
|
|
104
|
+
// voxel's edge, laid at steps of no more than two thirds of a voxel, eight at most
|
|
105
|
+
if (lod.voxel_size > 0.0 && j < segments) {
|
|
106
|
+
let next = (m * vec4<f32>(hair_rest_point(instance, strand, (j + 1u) << lod.level).xyz, 1.0)).xyz;
|
|
107
|
+
let along = next - now;
|
|
108
|
+
let length_ = length(along);
|
|
109
|
+
let steps = clamp(u32(ceil(length_ * 1.5 / lod.voxel_size)), 1u, 8u);
|
|
110
|
+
|
|
111
|
+
let h = lod.voxel_size;
|
|
112
|
+
let deposit = 0.7853982 * (2.0 * half_width) * (length_ / f32(steps)) / (h * h);
|
|
113
|
+
let amount = u32(deposit * ${HAIR_VOLUME_FIXED_ONE}.0 + 0.5);
|
|
114
|
+
|
|
115
|
+
for (var k = 0u; k < steps; k++) {
|
|
116
|
+
let at = (now + along * ((f32(k) + 0.5) / f32(steps)) - lod.volume_origin) / h;
|
|
117
|
+
|
|
118
|
+
if (amount > 0u && all(at >= vec3<f32>(0.0)) && all(at < vec3<f32>(lod.volume_dims))) {
|
|
119
|
+
atomicAdd(&hair_volume[hair_volume_index(lod, vec3<u32>(at), 0u)], amount);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// a point narrower than the floor is drawn at the floor by as many strands as its width is of the floor:
|
|
125
|
+
// by those whose share of the floor, stratified over any run of ranks, is under its width's
|
|
126
|
+
let share = fract(f32(strand) * 0.618034 + 0.5);
|
|
127
|
+
let floor_half = 0.5 * settings.pixel_floor * hair_pixel_size(max(hair_view_depth(now), camera.clip_near_far.x), settings.resolution.y);
|
|
128
|
+
|
|
129
|
+
if (half_width < share * floor_half) {
|
|
130
|
+
// drawn at no width, the floor not applied
|
|
131
|
+
half_width = -1.0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
let variation = hair_grooms[instance.strands + strand] & 0xFFu;
|
|
135
|
+
|
|
136
|
+
hair_points[slot + j] = vec4<u32>(bitcast<vec3<u32>>(now), bitcast<u32>(half_width));
|
|
137
|
+
hair_points[settings.point_capacity + slot + j] = vec4<u32>(bitcast<vec3<u32>>(before), row | (variation << ${HAIR_ROW_BITS}u));
|
|
138
|
+
|
|
139
|
+
// the root's thread lists the strand
|
|
140
|
+
if (j == 0u) {
|
|
141
|
+
key = ${HAIR_COUNTER_CURSORS}u + lod.point_class;
|
|
142
|
+
entry = slot | (lod.point_class << ${HAIR_CLASS_SHIFT}u);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let place = subgroup_keyed_append(&hair_counters, key);
|
|
148
|
+
|
|
149
|
+
if (place < settings.list_capacity) {
|
|
150
|
+
hair_list[place] = entry;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
`, [
|
|
154
|
+
HAIR_INSTANCE_DESCRIPTOR.chunk_read,
|
|
155
|
+
chunk_folded_workgroup_index,
|
|
156
|
+
chunk_lower_bound_branchless,
|
|
157
|
+
chunk_subgroup_keyed_append,
|
|
158
|
+
chunk_scene_database_access,
|
|
159
|
+
chunk_hair_rest_point,
|
|
160
|
+
chunk_hair_lod,
|
|
161
|
+
chunk_hair_volume_layout,
|
|
162
|
+
]);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Deforms and lists the frame's strands, a thread a point of every instance's prefix (dispatched through
|
|
166
|
+
* `shader_prefix_sum_to_command`'s folded command over the sums of the instances' points, `prefix × (2^class + 1)`).
|
|
167
|
+
*
|
|
168
|
+
* A thread finds its row from the sums, and from its place among the row's threads its strand's rank and its point
|
|
169
|
+
* along the strand. The strand is kept when its rank is under its own share of the group (`hair_kept_fraction` at
|
|
170
|
+
* its root's view depth), and then drawn wider by the reciprocal of that share, the strand at the boundary narrowed
|
|
171
|
+
* by how far it is past it, so the kept strands' widths sum to the group's at every distance and none appears or
|
|
172
|
+
* vanishes at once.
|
|
173
|
+
*
|
|
174
|
+
* The point, every `2^level`-th of the strand's rest points, is carried by its entity's world matrix as it is and as
|
|
175
|
+
* it was a frame ago into its place in `hair_points` (`HAIR.js`). No point is drawn narrower than the view's pixel
|
|
176
|
+
* floor, so one narrower than it would be drawn wider than it is: a point of width `w` under the floor `p` at its
|
|
177
|
+
* own depth is drawn, at `p`, only by the strands whose share of the floor (a number in [0, 1) stratified over
|
|
178
|
+
* ranks) is under `w / p`, and at no width by the rest (a negative width). The drawn area is then the strands' own
|
|
179
|
+
* wherever they are, the tapering tips of a thinned fringe included.
|
|
180
|
+
*
|
|
181
|
+
* The thread also lays the segment from its point to the next into the instance's density volume (`HAIR.js`), at
|
|
182
|
+
* the strand's drawn width, which carries the share kept, so a prefix gives an unbiased estimate of the whole group.
|
|
183
|
+
* The volume was cleared by `shader_hair_volume_clear`.
|
|
184
|
+
*
|
|
185
|
+
* The thread of a kept strand's root appends it to its class's region of `hair_list` (`chunk_subgroup_keyed_append`
|
|
186
|
+
* on the class's cursor) as its slot and class. An entry the list cannot hold is dropped; the cursor still counts it.
|
|
187
|
+
*
|
|
188
|
+
* @type {ComputeShader}
|
|
189
|
+
*/
|
|
190
|
+
export const shader_hair_cull = ComputeShader.from({
|
|
191
|
+
label: "Hair Cull",
|
|
192
|
+
resources,
|
|
193
|
+
body,
|
|
194
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threads per workgroup, a row each. The page iterator wants a multiple of 32.
|
|
3
|
+
* @type {number}
|
|
4
|
+
*/
|
|
5
|
+
export const HAIR_LOD_WORKGROUP_SIZE: number;
|
|
6
|
+
export const HAIR_LOD_SETTINGS: WebGPUStruct;
|
|
7
|
+
/**
|
|
8
|
+
* Each instance's level of detail for the frame, a thread a row of the instance table through its page iterator:
|
|
9
|
+
*
|
|
10
|
+
* - its group's box, in the world, against the view's frustum; an instance outside it draws nothing;
|
|
11
|
+
* - its screen rectangle: the box widened by the widest a kept strand is drawn (its widest point over its share kept
|
|
12
|
+
* at the box's far side), projected, and widened again by the pixel floor; or the whole view when the box reaches
|
|
13
|
+
* behind the eye;
|
|
14
|
+
* - its **prefix**: the strands kept at the box's nearest view depth (`hair_kept_fraction` of the group's mean
|
|
15
|
+
* width there), which no strand of it can keep more than, being no nearer;
|
|
16
|
+
* - its **level**: the coarsest decimation whose chord error, in pixels at that depth, is within the tolerance;
|
|
17
|
+
* - its points, `prefix × (2^class + 1)`, reserved from the frame's points, and its prefix added to its class's;
|
|
18
|
+
* - its density volume (`HAIR.js`): the box in cubes the largest of a pixel at its nearest point, the drawn strands'
|
|
19
|
+
* spacing (the roots' over the root of the share kept) and the box's longest side over
|
|
20
|
+
* `HAIR_VOLUME_DIMENSION_LIMIT`, every level reserved from the frame's voxels.
|
|
21
|
+
*
|
|
22
|
+
* Writes the row's points, `prefix × (2^class + 1)`, into `hair_counts`, the list the cull's scan sums; its coarser
|
|
23
|
+
* voxels into `hair_volume_counts`, the list the mip pass's scan sums; and its record into `hair_lod`. Rows it does
|
|
24
|
+
* not visit keep what the buffers were cleared to. `hair_counters` is zero on entry. Points past
|
|
25
|
+
* `settings.point_capacity` are refused: the instance draws nothing this frame, and the count it asked for stays
|
|
26
|
+
* in the counters for its owner to read.
|
|
27
|
+
*
|
|
28
|
+
* @type {ComputeShader}
|
|
29
|
+
*/
|
|
30
|
+
export const shader_hair_lod: ComputeShader;
|
|
31
|
+
import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
|
|
32
|
+
import { ComputeShader } from "../shader/ComputeShader.js";
|
|
33
|
+
//# sourceMappingURL=shader_hair_lod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_hair_lod.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_lod.js"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,sCAFU,MAAM,CAE0B;AAI1C,6CAasB;AA0MtB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8BAFU,aAAa,CAMpB;6BAhQ0B,gCAAgC;8BAL/B,4BAA4B"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { CAMERA_RESOURCE } from "../camera/CAMERA_RESOURCE.js";
|
|
2
|
+
import { COLLECTION_U32_STRUCT_READ } from "../gpu_primitive/COLLECTION_U32_STRUCT_READ.js";
|
|
3
|
+
import { chunk_scene_database_access } from "../scene/chunk_scene_database_access.js";
|
|
4
|
+
import { AABB3_STRUCT } from "../shader/chunk/geometry/aabb3/AABB3_STRUCT.js";
|
|
5
|
+
import { chunk_aabb3_intersects_frustum } from "../shader/chunk/geometry/aabb3/chunk_aabb3_intersects_frustum.js";
|
|
6
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
7
|
+
import { ComputeShader } from "../shader/ComputeShader.js";
|
|
8
|
+
import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
|
|
9
|
+
import { atomic_u32, f32, u32, vec2f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
10
|
+
import { WebGPUArray } from "../shader/type/WebGPUArray.js";
|
|
11
|
+
import { WebGPUBufferType } from "../shader/type/WebGPUBufferType.js";
|
|
12
|
+
import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
|
|
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";
|
|
15
|
+
import { HAIR_INSTANCE_DESCRIPTOR } from "./HAIR_DATABASE_SPEC.js";
|
|
16
|
+
import { HAIR_LOD_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Threads per workgroup, a row each. The page iterator wants a multiple of 32.
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
export const HAIR_LOD_WORKGROUP_SIZE = 64;
|
|
23
|
+
|
|
24
|
+
const PG = HAIR_INSTANCE_DESCRIPTOR.page_iterator_symbol_prefix(HAIR_LOD_WORKGROUP_SIZE, false);
|
|
25
|
+
|
|
26
|
+
export const HAIR_LOD_SETTINGS = WebGPUStruct.from({
|
|
27
|
+
/** the view's internal size, pixels */
|
|
28
|
+
resolution: vec2f,
|
|
29
|
+
/** the narrowest a strand is drawn, pixels */
|
|
30
|
+
pixel_floor: f32,
|
|
31
|
+
/** the most a dropped point may stray from its chord, pixels */
|
|
32
|
+
tolerance: f32,
|
|
33
|
+
/** rows of the instance table: the length of the count list the scan reads */
|
|
34
|
+
capacity: u32,
|
|
35
|
+
/** points the frame's deformed buffer holds */
|
|
36
|
+
point_capacity: u32,
|
|
37
|
+
/** voxels the frame's voxel buffer holds */
|
|
38
|
+
voxel_capacity: u32,
|
|
39
|
+
}, "HairLodSettings");
|
|
40
|
+
|
|
41
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
42
|
+
|
|
43
|
+
resources.setImmediate("settings", HAIR_LOD_SETTINGS);
|
|
44
|
+
|
|
45
|
+
resources.createGroup()
|
|
46
|
+
.add(CAMERA_RESOURCE)
|
|
47
|
+
.addStorageBuffer("hair_database", WebGPUBufferType.unsized, false)
|
|
48
|
+
.addStorageBuffer("scene_database", WebGPUBufferType.unsized, false)
|
|
49
|
+
.addStorageBuffer("hair_counts", COLLECTION_U32_STRUCT_READ, true)
|
|
50
|
+
.addStorageBuffer("hair_volume_counts", COLLECTION_U32_STRUCT_READ, true)
|
|
51
|
+
.addStorageBuffer("hair_lod", WebGPUArray.from(HAIR_LOD_STRUCT), true)
|
|
52
|
+
.addStorageBuffer("hair_counters", WebGPUArray.from(atomic_u32), true);
|
|
53
|
+
|
|
54
|
+
const body = CodeChunk.from(
|
|
55
|
+
//language=WGSL
|
|
56
|
+
`
|
|
57
|
+
fn hair_decimation_error(instance: ${HAIR_INSTANCE_DESCRIPTOR.type.wgsl_ref}, level: u32) -> f32 {
|
|
58
|
+
let quad = select(instance.decimation_high, instance.decimation_low, level < 4u);
|
|
59
|
+
|
|
60
|
+
return quad[level & 3u];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fn hair_pack_pixel(p: vec2<f32>) -> u32 {
|
|
64
|
+
let q = vec2<u32>(clamp(p, vec2<f32>(0.0), vec2<f32>(65535.0)));
|
|
65
|
+
|
|
66
|
+
return q.x | (q.y << 16u);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@compute @workgroup_size(${HAIR_LOD_WORKGROUP_SIZE}, 1, 1)
|
|
70
|
+
fn main(
|
|
71
|
+
@builtin(workgroup_id) wg_id: vec3<u32>,
|
|
72
|
+
@builtin(local_invocation_index) local_id: u32,
|
|
73
|
+
) {
|
|
74
|
+
// the scan reads exactly this many counts; written before the page test, so it lands even when the first page
|
|
75
|
+
// is unallocated
|
|
76
|
+
if (wg_id.x == 0u && local_id == 0u) {
|
|
77
|
+
hair_counts.count = settings.capacity;
|
|
78
|
+
hair_volume_counts.count = settings.capacity;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!${PG}_setup(&hair_database, wg_id.x, local_id)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let slot = ${PG}_slot_in_page(local_id);
|
|
86
|
+
|
|
87
|
+
if (slot >= ${PG}_ELEMENTS_PER_PAGE || !${PG}_is_occupied(slot)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let instance = ${PG}_read(&hair_database, slot);
|
|
92
|
+
let row = ${PG}_slot_to_index(slot);
|
|
93
|
+
|
|
94
|
+
let m = scene_read_node(&scene_database, instance.node).global;
|
|
95
|
+
|
|
96
|
+
var lod: ${HAIR_LOD_STRUCT.wgsl_ref};
|
|
97
|
+
|
|
98
|
+
lod.scale = max(length(m[0].xyz), max(length(m[1].xyz), length(m[2].xyz)));
|
|
99
|
+
|
|
100
|
+
// the group's box in the world: its quantization box, widened by the widest strand
|
|
101
|
+
let centre_local = instance.bounds_min + 0.5 * instance.bounds_extent;
|
|
102
|
+
let half_local = 0.5 * instance.bounds_extent + vec3<f32>(0.5 * instance.width_max);
|
|
103
|
+
|
|
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;
|
|
106
|
+
|
|
107
|
+
let box = ${AABB3_STRUCT.wgsl_ref}(centre - half_extent, centre + half_extent);
|
|
108
|
+
|
|
109
|
+
if (instance.strand_count > 0u && aabb3_intersects_frustum(box, camera.frustum)) {
|
|
110
|
+
var depth_near = 3.4e38;
|
|
111
|
+
var depth_far = -3.4e38;
|
|
112
|
+
|
|
113
|
+
for (var corner = 0u; corner < 8u; corner++) {
|
|
114
|
+
let signs = vec3<f32>(vec3<u32>(corner, corner >> 1u, corner >> 2u) & vec3<u32>(1u)) * 2.0 - 1.0;
|
|
115
|
+
let depth = hair_view_depth(centre + half_extent * signs);
|
|
116
|
+
|
|
117
|
+
depth_near = min(depth_near, depth);
|
|
118
|
+
depth_far = max(depth_far, depth);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
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);
|
|
124
|
+
|
|
125
|
+
// a kept strand is widened by the reciprocal of its share, which is least at the far side of the box: the
|
|
126
|
+
// rectangle holds the widest it can be drawn
|
|
127
|
+
let kept_far = hair_kept_fraction(instance.width_mean * lod.scale, hair_pixel_size(max(depth_far, near), settings.resolution.y), settings.pixel_floor);
|
|
128
|
+
let drawn_extent = half_extent + vec3<f32>(0.5 * instance.width_max * lod.scale / max(kept_far, 1e-6));
|
|
129
|
+
|
|
130
|
+
var rect_min = vec2<f32>(3.4e38);
|
|
131
|
+
var rect_max = vec2<f32>(-3.4e38);
|
|
132
|
+
var behind = false;
|
|
133
|
+
|
|
134
|
+
for (var corner = 0u; corner < 8u; corner++) {
|
|
135
|
+
let signs = vec3<f32>(vec3<u32>(corner, corner >> 1u, corner >> 2u) & vec3<u32>(1u)) * 2.0 - 1.0;
|
|
136
|
+
let clip = camera.view_projection_matrix * vec4<f32>(centre + drawn_extent * signs, 1.0);
|
|
137
|
+
|
|
138
|
+
if (clip.w <= 1e-6) {
|
|
139
|
+
behind = true;
|
|
140
|
+
} else {
|
|
141
|
+
let ndc = clip.xy / clip.w;
|
|
142
|
+
let pixel = vec2<f32>(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5) * settings.resolution;
|
|
143
|
+
|
|
144
|
+
rect_min = min(rect_min, pixel);
|
|
145
|
+
rect_max = max(rect_max, pixel);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (behind) {
|
|
150
|
+
// the box reaches behind the eye: its projection is unbounded
|
|
151
|
+
rect_min = vec2<f32>(0.0);
|
|
152
|
+
rect_max = settings.resolution;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// a strand drawn at the floor reaches past its centre line by half the floor
|
|
156
|
+
let margin = settings.pixel_floor + 1.0;
|
|
157
|
+
|
|
158
|
+
lod.rect_min = hair_pack_pixel(floor(max(rect_min - margin, vec2<f32>(0.0))));
|
|
159
|
+
lod.rect_max = hair_pack_pixel(ceil(min(rect_max + margin, settings.resolution)));
|
|
160
|
+
|
|
161
|
+
var prefix = min(instance.strand_count, u32(ceil(kept * f32(instance.strand_count))));
|
|
162
|
+
|
|
163
|
+
// the coarsest level whose chords stray no more than the tolerance at the nearest point; the table never
|
|
164
|
+
// shrinks with the level
|
|
165
|
+
let allowed = settings.tolerance * pixel_size;
|
|
166
|
+
var level = 0u;
|
|
167
|
+
|
|
168
|
+
for (var j = 1u; j < min(instance.level_count, 8u); j++) {
|
|
169
|
+
if (hair_decimation_error(instance, j) * lod.scale <= allowed) {
|
|
170
|
+
level = j;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let point_class = instance.level_count - 1u - level;
|
|
175
|
+
let points = prefix * ((1u << point_class) + 1u);
|
|
176
|
+
|
|
177
|
+
if (prefix > 0u) {
|
|
178
|
+
let base = atomicAdd(&hair_counters[${HAIR_COUNTER_POINTS}u], points);
|
|
179
|
+
|
|
180
|
+
if (base + points > settings.point_capacity || base + points < base) {
|
|
181
|
+
// the frame's points are full: the count asked for grows them for the frames after
|
|
182
|
+
prefix = 0u;
|
|
183
|
+
} else {
|
|
184
|
+
atomicAdd(&hair_counters[point_class], prefix);
|
|
185
|
+
|
|
186
|
+
lod.point_base = base;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
lod.prefix = prefix;
|
|
191
|
+
lod.level = level;
|
|
192
|
+
lod.point_class = point_class;
|
|
193
|
+
|
|
194
|
+
// the density volume: cubes a pixel across at the box's nearest point, and no finer than the strands laid into
|
|
195
|
+
// 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) {
|
|
198
|
+
let size = 2.0 * half_extent;
|
|
199
|
+
let spacing = instance.root_spacing * lod.scale / sqrt(max(kept, 1e-6));
|
|
200
|
+
let edge = max(max(pixel_size, spacing), max(size.x, max(size.y, size.z)) / ${HAIR_VOLUME_DIMENSION_LIMIT}.0);
|
|
201
|
+
let dims = clamp(vec3<u32>(ceil(size / edge)), vec3<u32>(1u), vec3<u32>(${HAIR_VOLUME_DIMENSION_LIMIT}u));
|
|
202
|
+
|
|
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
|
+
}
|
|
216
|
+
|
|
217
|
+
let base = atomicAdd(&hair_counters[${HAIR_COUNTER_VOXELS}u], voxels);
|
|
218
|
+
|
|
219
|
+
// the frame's voxels are full: the strands are drawn unshadowed, and the count asked for grows them
|
|
220
|
+
if (base + voxels <= settings.voxel_capacity && base + voxels >= base) {
|
|
221
|
+
lod.voxel_base = base;
|
|
222
|
+
lod.voxel_size = edge;
|
|
223
|
+
lod.volume_dims = dims;
|
|
224
|
+
lod.volume_origin = centre - 0.5 * edge * vec3<f32>(dims);
|
|
225
|
+
|
|
226
|
+
hair_volume_counts.elements[row] = coarser;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
hair_counts.elements[row] = lod.prefix * ((1u << lod.point_class) + 1u);
|
|
232
|
+
hair_lod[row] = lod;
|
|
233
|
+
}
|
|
234
|
+
`, [
|
|
235
|
+
HAIR_INSTANCE_DESCRIPTOR.chunk_iterate(HAIR_LOD_WORKGROUP_SIZE, false),
|
|
236
|
+
chunk_scene_database_access,
|
|
237
|
+
chunk_aabb3_intersects_frustum,
|
|
238
|
+
chunk_hair_lod,
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Each instance's level of detail for the frame, a thread a row of the instance table through its page iterator:
|
|
243
|
+
*
|
|
244
|
+
* - its group's box, in the world, against the view's frustum; an instance outside it draws nothing;
|
|
245
|
+
* - its screen rectangle: the box widened by the widest a kept strand is drawn (its widest point over its share kept
|
|
246
|
+
* at the box's far side), projected, and widened again by the pixel floor; or the whole view when the box reaches
|
|
247
|
+
* behind the eye;
|
|
248
|
+
* - its **prefix**: the strands kept at the box's nearest view depth (`hair_kept_fraction` of the group's mean
|
|
249
|
+
* width there), which no strand of it can keep more than, being no nearer;
|
|
250
|
+
* - its **level**: the coarsest decimation whose chord error, in pixels at that depth, is within the tolerance;
|
|
251
|
+
* - its points, `prefix × (2^class + 1)`, reserved from the frame's points, and its prefix added to its class's;
|
|
252
|
+
* - its density volume (`HAIR.js`): the box in cubes the largest of a pixel at its nearest point, the drawn strands'
|
|
253
|
+
* spacing (the roots' over the root of the share kept) and the box's longest side over
|
|
254
|
+
* `HAIR_VOLUME_DIMENSION_LIMIT`, every level reserved from the frame's voxels.
|
|
255
|
+
*
|
|
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
|
|
258
|
+
* not visit keep what the buffers were cleared to. `hair_counters` is zero on entry. Points past
|
|
259
|
+
* `settings.point_capacity` are refused: the instance draws nothing this frame, and the count it asked for stays
|
|
260
|
+
* in the counters for its owner to read.
|
|
261
|
+
*
|
|
262
|
+
* @type {ComputeShader}
|
|
263
|
+
*/
|
|
264
|
+
export const shader_hair_lod = ComputeShader.from({
|
|
265
|
+
label: "Hair LOD",
|
|
266
|
+
resources,
|
|
267
|
+
body,
|
|
268
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const HAIR_VOLUME_SETTINGS: WebGPUStruct;
|
|
2
|
+
/**
|
|
3
|
+
* The dispatch that clears the frame's voxels: a thread a voxel the level of detail reserved, no more than the
|
|
4
|
+
* buffer holds, folded as `shader_prefix_sum_to_command` folds. One thread.
|
|
5
|
+
*
|
|
6
|
+
* @type {ComputeShader}
|
|
7
|
+
*/
|
|
8
|
+
export const shader_hair_volume_command: ComputeShader;
|
|
9
|
+
/**
|
|
10
|
+
* Zeroes the voxels the level of detail reserved, before the cull deposits into them; dispatched through
|
|
11
|
+
* {@link shader_hair_volume_command}'s command.
|
|
12
|
+
*
|
|
13
|
+
* @type {ComputeShader}
|
|
14
|
+
*/
|
|
15
|
+
export const shader_hair_volume_clear: ComputeShader;
|
|
16
|
+
export const HAIR_VOLUME_MIP_SETTINGS: WebGPUStruct;
|
|
17
|
+
/**
|
|
18
|
+
* Fills one coarser level of every volume, `settings.level`, from the level under it: a voxel the mean of the
|
|
19
|
+
* 2 × 2 × 2 under it. Dispatched twice through `shader_prefix_sum_to_command`'s folded command over the sums of the
|
|
20
|
+
* rows' coarse voxels, level 1 then level 2; a thread a coarse voxel of either level, the other level's threads idle.
|
|
21
|
+
* Space outside the volume holds no hair and counts as zero.
|
|
22
|
+
*
|
|
23
|
+
* @type {ComputeShader}
|
|
24
|
+
*/
|
|
25
|
+
export const shader_hair_volume_mips: ComputeShader;
|
|
26
|
+
import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
|
|
27
|
+
import { ComputeShader } from "../shader/ComputeShader.js";
|
|
28
|
+
//# sourceMappingURL=shader_hair_volume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader_hair_volume.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/shader_hair_volume.js"],"names":[],"mappings":"AAiBA,gDAGyB;AAUzB;;;;;GAKG;AACH,yCAFU,aAAa,CAkBpB;AAUH;;;;;GAKG;AACH,uCAFU,aAAa,CAiBpB;AAEH,oDAG4B;AAW5B;;;;;;;GAOG;AACH,sCAFU,aAAa,CA6DpB;6BA1J0B,gCAAgC;8BAJ/B,4BAA4B"}
|