@woosh/meep-engine 3.75.0 → 3.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/particles/effect/ParticleReferenceSimulation.d.ts +11 -0
- package/editor/particles/effect/ParticleReferenceSimulation.d.ts.map +1 -1
- package/editor/particles/effect/ParticleReferenceSimulation.js +14 -0
- package/editor/view/particles/effect/ParticleGraphEditorView.js +1 -1
- package/package.json +1 -1
- 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 +113 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts +54 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -0
- package/src/engine/graphics/ecs/hair/Hair.js +70 -0
- package/src/engine/graphics/ecs/hair/HairDynamics.d.ts +63 -0
- package/src/engine/graphics/ecs/hair/HairDynamics.d.ts.map +1 -0
- package/src/engine/graphics/ecs/hair/HairDynamics.js +82 -0
- package/src/engine/graphics/hair/Groom.d.ts +175 -0
- package/src/engine/graphics/hair/Groom.d.ts.map +1 -0
- package/src/engine/graphics/hair/Groom.js +249 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +50 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.js +150 -0
- package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts +8 -0
- package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/graphics/hair/GroomSerializationUpgrader_0_1.js +31 -0
- package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +85 -0
- package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_bind_to_mesh.js +216 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts +90 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_build_group.js +496 -0
- package/src/engine/graphics/hair/groom_build_guides.d.ts +43 -0
- package/src/engine/graphics/hair/groom_build_guides.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_build_guides.js +267 -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 +14 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_root_spacing.js +253 -0
- package/src/engine/graphics3/HairColliderSystem.d.ts +59 -0
- package/src/engine/graphics3/HairColliderSystem.d.ts.map +1 -0
- package/src/engine/graphics3/HairColliderSystem.js +270 -0
- package/src/engine/graphics3/HairSystem.d.ts +119 -0
- package/src/engine/graphics3/HairSystem.d.ts.map +1 -0
- package/src/engine/graphics3/HairSystem.js +722 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- 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 +297 -0
- package/src/shade/playground/hair_skinned/index.html +192 -0
- package/src/shade/playground/hair_skinned/main.d.ts +7 -0
- package/src/shade/playground/hair_skinned/main.d.ts.map +1 -0
- package/src/shade/playground/hair_skinned/main.js +481 -0
- package/src/shade/playground/hair_skinned/skinned_hair.d.ts +49 -0
- package/src/shade/playground/hair_skinned/skinned_hair.d.ts.map +1 -0
- package/src/shade/playground/hair_skinned/skinned_hair.js +362 -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/sparks/README.md +36 -0
- package/src/shade/playground/sparks/index.html +145 -0
- package/src/shade/playground/sparks/main.d.ts +7 -0
- package/src/shade/playground/sparks/main.d.ts.map +1 -0
- package/src/shade/playground/sparks/main.js +312 -0
- package/src/shade/playground/sparks/sparks_effect.d.ts +72 -0
- package/src/shade/playground/sparks/sparks_effect.d.ts.map +1 -0
- package/src/shade/playground/sparks/sparks_effect.js +180 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +72 -11
- 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/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts +3 -2
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.js +74 -3
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +13 -3
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +16 -5
- package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +8 -8
- 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 +19 -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 +30 -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/ShadowAtlas.d.ts +75 -0
- package/src/shade/renderer/extension/ShadowAtlas.d.ts.map +1 -0
- package/src/shade/renderer/extension/ShadowAtlas.js +133 -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/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/brick/GPUSceneBrickClipmap.d.ts +37 -7
- 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 +132 -8
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +3 -1
- 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 +6 -2
- 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/global_illumination/sharc/sharc_constants.d.ts +0 -18
- package/src/shade/renderer/global_illumination/sharc/sharc_constants.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/sharc/sharc_constants.js +1 -21
- package/src/shade/renderer/hair/GPUHairSystem.d.ts +278 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -0
- package/src/shade/renderer/hair/GPUHairSystem.js +2263 -0
- package/src/shade/renderer/hair/HAIR.d.ts +121 -0
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR.js +136 -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 +104 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +15 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +70 -0
- package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +139 -0
- package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_SIMULATION.js +160 -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 +37 -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 +158 -0
- package/src/shade/renderer/hair/chunk_hair_guide.d.ts +59 -0
- package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_guide.js +179 -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 +32 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_volume.js +115 -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 +279 -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_shadow_draw.d.ts +32 -0
- package/src/shade/renderer/hair/hair_shadow_draw.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_shadow_draw.js +123 -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 +22 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_classes.js +90 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts +37 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_cull.js +251 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts +39 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_lod.js +362 -0
- package/src/shade/renderer/hair/shader_hair_roots.d.ts +36 -0
- package/src/shade/renderer/hair/shader_hair_roots.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_roots.js +261 -0
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts +44 -0
- package/src/shade/renderer/hair/shader_hair_shadow_list.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_shadow_list.js +240 -0
- package/src/shade/renderer/hair/shader_hair_simulate.d.ts +55 -0
- package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_simulate.js +563 -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 +154 -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 +65 -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 +470 -0
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts +8 -0
- package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
- package/src/shade/renderer/particles/GPUParticleSystem.js +28 -0
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/ParticleNodeRegistry.js +22 -0
- package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/groups/particle_builtin_groups.js +4 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts +32 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_scene.d.ts.map +1 -0
- package/src/shade/renderer/particles/graph/groups/particle_groups_scene.js +80 -0
- package/src/shade/renderer/particles/graph/particle_node_parameters.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_node_parameters.js +1 -0
- package/src/shade/renderer/particles/graph/particle_node_presentation.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph/particle_node_presentation.js +12 -0
- package/src/shade/renderer/particles/graph_particles.d.ts +5 -1
- package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
- package/src/shade/renderer/particles/graph_particles.js +18 -3
- package/src/shade/renderer/particles/isa/InstructionStream.d.ts +25 -0
- package/src/shade/renderer/particles/isa/InstructionStream.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/InstructionStream.js +25 -0
- package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts +9 -0
- package/src/shade/renderer/particles/isa/ParticleVMISA.d.ts.map +1 -1
- package/src/shade/renderer/particles/isa/ParticleVMISA.js +20 -0
- package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts +9 -0
- package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.d.ts.map +1 -0
- package/src/shade/renderer/particles/isa/particle_program_reads_scene_sdf.js +29 -0
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts +2 -1
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_program_equivalence.js +27 -5
- package/src/shade/renderer/particles/optimizer/particle_program_fuzz.js +1 -1
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.d.ts.map +1 -1
- package/src/shade/renderer/particles/optimizer/particle_vm_semantics.js +5 -0
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts +7 -0
- package/src/shade/renderer/particles/runtime/EmitterRegistry.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/EmitterRegistry.js +10 -0
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts +5 -0
- package/src/shade/renderer/particles/runtime/ParticleEmitter.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ParticleEmitter.js +5 -0
- package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts +8 -0
- package/src/shade/renderer/particles/runtime/ProgramHeap.d.ts.map +1 -1
- package/src/shade/renderer/particles/runtime/ProgramHeap.js +25 -0
- package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit.js +9 -3
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_emit_wide.js +4 -2
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts +2 -2
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_simulate.js +10 -4
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.d.ts.map +1 -1
- package/src/shade/renderer/particles/shaders/shader_particle_simulate_wide.js +4 -2
- package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts +14 -1
- package/src/shade/renderer/particles/vm/ParticleVMReference.d.ts.map +1 -1
- package/src/shade/renderer/particles/vm/ParticleVMReference.js +34 -1
- package/src/shade/renderer/particles/vm/chunk_particle_vm.d.ts.map +1 -1
- package/src/shade/renderer/particles/vm/chunk_particle_vm.js +10 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts +39 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.d.ts.map +1 -0
- package/src/shade/renderer/particles/vm/chunk_particle_vm_scene_sdf.js +90 -0
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts +4 -1
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
- package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +14 -2
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts +1 -1
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.d.ts.map +1 -1
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance.js +9 -3
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.d.ts.map +1 -1
- package/src/shade/renderer/particles/warmup/shader_particle_warmup_advance_wide.js +4 -2
- 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/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -4
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +26 -16
- 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/scene/GPUSceneContext.d.ts +7 -0
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +18 -0
- 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/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts +20 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_signed_distance_gradient.js +134 -0
- 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/GPUSceneShadowmapContext.d.ts +15 -0
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +69 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts +10 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.d.ts.map +1 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_directional_atlas_casters.js +22 -0
- 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
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
|
|
3
|
+
import { SAMPLER_LINEAR_RESOURCE } from "../texture/SAMPLER_LINEAR_RESOURCE.js";
|
|
4
|
+
import { chunk_hair_absorption, chunk_hair_shading } from "./chunk_hair_bsdf.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The hair's average scattering table (`hair_scattering_lut.js`): x `|sin θ|` to the fibre, y roughness, z the square
|
|
8
|
+
* root of the colour; front, then back.
|
|
9
|
+
*
|
|
10
|
+
* @type {ShaderResourceDescriptor}
|
|
11
|
+
*/
|
|
12
|
+
export const HAIR_SCATTERING_LUT_RESOURCE = ShaderResourceDescriptor.texture("tHairScattering", "float", "3d");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Light scattered by hair with multiple scattering: dual scattering (Zinke et al. 2008) over the single-scattering
|
|
16
|
+
* BSDF, as Unreal 5.4 composes it (ComputeDualScatteringTerms, HairStrandsDeepTransmittanceDualScattering.ush, and
|
|
17
|
+
* HairShading's `GlobalScattering * (Fs + LocalScattering)`):
|
|
18
|
+
*
|
|
19
|
+
* ```wgsl
|
|
20
|
+
* fn hair_scattering(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32,
|
|
21
|
+
* hair_count: f32, backlit: f32, area: f32) -> vec3<f32>
|
|
22
|
+
* fn hair_forward_transmittance(l: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32,
|
|
23
|
+
* hair_count: f32) -> vec3<f32>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* `hair_count` is the number of strands between the point and the light (the density volume's march); one is taken
|
|
27
|
+
* off it for the strand's own. The global term passes the light through them, attenuated by the average front
|
|
28
|
+
* scattering to the power of their count and spread by their roughness; the local term adds what scatters back
|
|
29
|
+
* from the strands around the point. The average scatterings come from the table at the light's angle to the fibre,
|
|
30
|
+
* the roughness and the colour. As in Unreal, the table is read at the fibre's roughness and the lobes' spreads take
|
|
31
|
+
* it clamped to [0.18, 0.6]: the spreads are Gaussians, and a narrower one would let a single smooth strand in front
|
|
32
|
+
* block all but the light along its own cone (at roughness 0.1 one strand passes a fortieth of what the clamp passes).
|
|
33
|
+
* Unreal's Kajiya-Kay term is not taken: this is the multiple scattering it stands in for.
|
|
34
|
+
*
|
|
35
|
+
* `hair_forward_transmittance` is the global term's energy alone, the average front scattering to the power of the
|
|
36
|
+
* strands passed: what reaches the point from a source as wide as the sky, over which the spread integrates to one.
|
|
37
|
+
*
|
|
38
|
+
* @type {CodeChunk}
|
|
39
|
+
*/
|
|
40
|
+
export const chunk_hair_dual_scattering = CodeChunk.from(
|
|
41
|
+
//language=WGSL
|
|
42
|
+
`
|
|
43
|
+
// an unnormalized Gaussian of variance v
|
|
44
|
+
fn hair_gaussian_unnormalized(v: f32, theta: f32) -> f32 {
|
|
45
|
+
return exp(-0.5 * theta * theta / max(v, 1e-10));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// the table's average front and back scattering, a channel each
|
|
49
|
+
struct HairAverageScattering {
|
|
50
|
+
front: vec3<f32>,
|
|
51
|
+
back: vec3<f32>,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// the table, a channel at a time, at the colour's square root
|
|
55
|
+
fn hair_average_scattering(sin_l: f32, absorption: vec3<f32>, roughness: f32) -> HairAverageScattering {
|
|
56
|
+
let color = hair_absorption_to_color(absorption);
|
|
57
|
+
let z = sqrt(saturate(color));
|
|
58
|
+
let x = saturate(abs(sin_l));
|
|
59
|
+
let y = saturate(roughness);
|
|
60
|
+
|
|
61
|
+
let s_r = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.r), 0.0).rg;
|
|
62
|
+
let s_g = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.g), 0.0).rg;
|
|
63
|
+
let s_b = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.b), 0.0).rg;
|
|
64
|
+
|
|
65
|
+
return HairAverageScattering(vec3<f32>(s_r.x, s_g.x, s_b.x), vec3<f32>(s_r.y, s_g.y, s_b.y));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fn hair_forward_transmittance(l: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32, hair_count: f32) -> vec3<f32> {
|
|
69
|
+
let average = hair_average_scattering(clamp(dot(t, l), -1.0, 1.0), absorption, roughness);
|
|
70
|
+
|
|
71
|
+
return pow(average.front, vec3<f32>(max(0.0, hair_count - 1.0)));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fn hair_scattering(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32, hair_count: f32, backlit: f32, area: f32) -> vec3<f32> {
|
|
75
|
+
let single = hair_shading(l, v, t, absorption, roughness, backlit, area);
|
|
76
|
+
|
|
77
|
+
let sin_l = clamp(dot(t, l), -1.0, 1.0);
|
|
78
|
+
let sin_v = clamp(dot(t, v), -1.0, 1.0);
|
|
79
|
+
|
|
80
|
+
let average = hair_average_scattering(sin_l, absorption, roughness);
|
|
81
|
+
|
|
82
|
+
let a_front = average.front;
|
|
83
|
+
let a_back = average.back;
|
|
84
|
+
|
|
85
|
+
const MAX_AVERAGE = 0.99;
|
|
86
|
+
|
|
87
|
+
let af = min(vec3<f32>(MAX_AVERAGE), a_front);
|
|
88
|
+
let af2 = af * af;
|
|
89
|
+
let ab = min(vec3<f32>(MAX_AVERAGE), a_back);
|
|
90
|
+
let ab2 = ab * ab;
|
|
91
|
+
let one_minus_af2 = 1.0 - af2;
|
|
92
|
+
|
|
93
|
+
let a1 = ab * af2 / one_minus_af2;
|
|
94
|
+
let a3 = ab * ab2 * af2 / (one_minus_af2 * one_minus_af2 * one_minus_af2);
|
|
95
|
+
let a_b = a1 + a3;
|
|
96
|
+
|
|
97
|
+
let spread_roughness = clamp(roughness, 0.18, 0.6);
|
|
98
|
+
|
|
99
|
+
let beta_r = spread_roughness * spread_roughness;
|
|
100
|
+
let beta_tt = (spread_roughness * 0.5) * (spread_roughness * 0.5);
|
|
101
|
+
let beta_trt = (spread_roughness * 2.0) * (spread_roughness * 2.0);
|
|
102
|
+
|
|
103
|
+
const SHIFT_R = -0.035 * 2.0;
|
|
104
|
+
const SHIFT_TT = 0.035;
|
|
105
|
+
const SHIFT_TRT = 0.035 * 4.0;
|
|
106
|
+
|
|
107
|
+
// the paper's density factors
|
|
108
|
+
const DF = 0.7;
|
|
109
|
+
const DB = 0.7;
|
|
110
|
+
|
|
111
|
+
let count = max(0.0, hair_count - 1.0);
|
|
112
|
+
|
|
113
|
+
let af_weights = af / max(af.r + af.g + af.b, 1e-6);
|
|
114
|
+
let beta_f = vec3<f32>(dot(vec3<f32>(beta_r, beta_tt, beta_trt), af_weights));
|
|
115
|
+
let beta_f2 = beta_f * beta_f;
|
|
116
|
+
let sigma_f2 = beta_f2 * max(1.0, count);
|
|
117
|
+
|
|
118
|
+
let theta_h = 0.5 * (asin(sin_l) + asin(sin_v));
|
|
119
|
+
|
|
120
|
+
let sf = vec3<f32>(
|
|
121
|
+
hair_gaussian_unnormalized(sigma_f2.r, theta_h),
|
|
122
|
+
hair_gaussian_unnormalized(sigma_f2.g, theta_h),
|
|
123
|
+
hair_gaussian_unnormalized(sigma_f2.b, theta_h),
|
|
124
|
+
) / 3.14159265;
|
|
125
|
+
|
|
126
|
+
let tf = pow(a_front, vec3<f32>(count));
|
|
127
|
+
|
|
128
|
+
let shift_f = vec3<f32>(dot(vec3<f32>(SHIFT_R, SHIFT_TT, SHIFT_TRT), af_weights));
|
|
129
|
+
let shift_b = shift_f;
|
|
130
|
+
let delta_b = shift_b * (1.0 - 2.0 * ab2 / (one_minus_af2 * one_minus_af2)) * shift_f
|
|
131
|
+
* (2.0 * one_minus_af2 * one_minus_af2 + 4.0 * af2 * ab2) / (one_minus_af2 * one_minus_af2 * one_minus_af2);
|
|
132
|
+
|
|
133
|
+
let ab_weights = ab / max(ab.r + ab.g + ab.b, 1e-6);
|
|
134
|
+
let beta_b = vec3<f32>(dot(vec3<f32>(beta_r, beta_tt, beta_trt), ab_weights));
|
|
135
|
+
let beta_b2 = beta_b * beta_b;
|
|
136
|
+
|
|
137
|
+
let spread = sqrt(2.0 * beta_f2 + beta_b2);
|
|
138
|
+
let sigma_b = (1.0 + DB * af2) * (ab * spread + ab * ab2 * spread) / max(ab + ab * ab2 * (2.0 * beta_f + 3.0 * beta_b), vec3<f32>(1e-6));
|
|
139
|
+
let sigma_b2 = sigma_b * sigma_b;
|
|
140
|
+
|
|
141
|
+
let sb = vec3<f32>(
|
|
142
|
+
hair_gaussian_unnormalized(sigma_f2.r + sigma_b2.r, theta_h - delta_b.r),
|
|
143
|
+
hair_gaussian_unnormalized(sigma_f2.g + sigma_b2.g, theta_h - delta_b.g),
|
|
144
|
+
hair_gaussian_unnormalized(sigma_f2.b + sigma_b2.b, theta_h - delta_b.b),
|
|
145
|
+
) / 3.14159265;
|
|
146
|
+
|
|
147
|
+
let global_scattering = mix(vec3<f32>(1.0), tf * sf * DF, saturate(count));
|
|
148
|
+
let local_scattering = 2.0 * a_b * sb * DB;
|
|
149
|
+
|
|
150
|
+
return max(global_scattering * (single + local_scattering), vec3<f32>(0.0));
|
|
151
|
+
}
|
|
152
|
+
`, [
|
|
153
|
+
chunk_hair_absorption,
|
|
154
|
+
chunk_hair_shading,
|
|
155
|
+
]);
|
|
156
|
+
|
|
157
|
+
chunk_hair_dual_scattering.requireResource(HAIR_SCATTERING_LUT_RESOURCE);
|
|
158
|
+
chunk_hair_dual_scattering.requireResource(SAMPLER_LINEAR_RESOURCE);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Epochs as an f32 holds them exactly, in a guide state header's `w`.
|
|
3
|
+
* @type {number}
|
|
4
|
+
*/
|
|
5
|
+
export const HAIR_EPOCH_MASK: number;
|
|
6
|
+
/**
|
|
7
|
+
* Every simulated instance's guide state, a run an instance (`HAIR_SIMULATION.js`).
|
|
8
|
+
*
|
|
9
|
+
* @type {ShaderResourceDescriptor}
|
|
10
|
+
*/
|
|
11
|
+
export const HAIR_GUIDE_STATE_RESOURCE: ShaderResourceDescriptor;
|
|
12
|
+
/**
|
|
13
|
+
* Where a simulated instance's guide state is, and what its guides are:
|
|
14
|
+
*
|
|
15
|
+
* ```wgsl
|
|
16
|
+
* fn hair_strand_frame(instance: HairInstance, strand: u32, entity: mat4x4<f32>, last: bool) -> mat4x4<f32>
|
|
17
|
+
* fn hair_state_live(instance: HairInstance) -> bool
|
|
18
|
+
* fn hair_state_index(instance: HairInstance, plane: u32, node: u32, guide: u32) -> u32
|
|
19
|
+
* fn hair_guide_record(instance: HairInstance, guide: u32) -> vec4<u32>
|
|
20
|
+
* fn hair_quat_nlerp(a: vec4<f32>, b: vec4<f32>, t: f32) -> vec4<f32>
|
|
21
|
+
* fn hair_drag_rate(speed: f32, diameter: f32, mass_per_length: f32) -> f32
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* `hair_strand_frame` is what carries a strand's rest points into the world: its root frame (`shader_hair_roots.js`)
|
|
25
|
+
* when the instance is bound to a mesh, the `entity` matrix given otherwise; with `last`, a frame ago.
|
|
26
|
+
* `hair_state_live` is whether the instance is simulated and its state was laid for it: a state allocated since the
|
|
27
|
+
* frame's step holds another tenant's nodes, or none, and its strands ride the entity until the next step lays it.
|
|
28
|
+
* Reads the state's header. `hair_state_index` is a vector of the state pool, node-interleaved. `hair_guide_record` is a guide's four words in
|
|
29
|
+
* the groom pool: its strand's rank, its wisp's strand count, its wisp's diameter and its length (f32 bits).
|
|
30
|
+
* `hair_quat_nlerp` blends two unit quaternions along the shorter arc. `hair_drag_rate` is `hair_drag_rate`'s twin
|
|
31
|
+
* (`HAIR_SIMULATION.js`): the rate a node's velocity relaxes toward the air's.
|
|
32
|
+
*
|
|
33
|
+
* @type {CodeChunk}
|
|
34
|
+
*/
|
|
35
|
+
export const chunk_hair_guide: CodeChunk;
|
|
36
|
+
/**
|
|
37
|
+
* A point of a simulated strand, carried by its guide:
|
|
38
|
+
*
|
|
39
|
+
* ```wgsl
|
|
40
|
+
* fn hair_guided_point(instance: HairInstance, strand: u32, point: u32, entity: mat4x4<f32>, anchor: vec3<f32>,
|
|
41
|
+
* last: bool) -> vec3<f32>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* The strand follows its guide (its strand word's high 16 bits). The point's rest place is taken from the chord
|
|
45
|
+
* between the guide's nodes either side of it at the same share of the length, and placed by the strand's own frame
|
|
46
|
+
* (`hair_strand_frame`) applied to three terms: the rest chord, carried by the strand's frame; the guide's move
|
|
47
|
+
* there, the chord where its nodes are less the rest chord carried by the guide's frame; and the point's offset from
|
|
48
|
+
* the rest chord, carried by the strand's frame's linear part and turned by the guide's frame there (the nodes' frames
|
|
49
|
+
* blended along the chord). Exact for any rigid motion of a wisp, so a guide at rest draws its strands as they were
|
|
50
|
+
* made; for strands that ride their entity both frames are the entity's. With `last`, where it was a frame ago: the
|
|
51
|
+
* nodes, frames and root frames of a frame ago, and `entity` the entity's matrix then; `anchor` is this frame's,
|
|
52
|
+
* which the nodes of a frame ago are kept from. World metres.
|
|
53
|
+
*
|
|
54
|
+
* @type {CodeChunk}
|
|
55
|
+
*/
|
|
56
|
+
export const chunk_hair_guided_point: CodeChunk;
|
|
57
|
+
import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
|
|
58
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
59
|
+
//# sourceMappingURL=chunk_hair_guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_hair_guide.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_guide.js"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,8BAFU,MAAM,CAEwB;AAExC;;;;GAIG;AACH,wCAFU,wBAAwB,CAE2F;AAE7H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,+BAFU,SAAS,CAwDhB;AAKH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,sCAFU,SAAS,CAyChB;yCA7KsC,gDAAgD;0BAD/D,iCAAiC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { chunk_quat_rotate_v3 } from "../shader/chunk/geometry/quaternion/chunk_v3_apply_quat.js";
|
|
2
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
3
|
+
import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
|
|
4
|
+
import { WebGPUArray } from "../shader/type/WebGPUArray.js";
|
|
5
|
+
import { vec4f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
6
|
+
import { chunk_hair_rest_point, HAIR_GROOMS_RESOURCE } from "./chunk_hair_strand.js";
|
|
7
|
+
import { HAIR_INSTANCE_STRUCT } from "./HAIR_DATABASE_SPEC.js";
|
|
8
|
+
import {
|
|
9
|
+
HAIR_AIR_DENSITY,
|
|
10
|
+
HAIR_AIR_VISCOSITY,
|
|
11
|
+
HAIR_BINDING_NONE,
|
|
12
|
+
HAIR_ROOT_FRAME_VECTORS,
|
|
13
|
+
HAIR_GUIDE_RECORD_WORDS,
|
|
14
|
+
HAIR_STATE_FRAME,
|
|
15
|
+
HAIR_STATE_HEADER,
|
|
16
|
+
HAIR_STATE_LAST_FRAME,
|
|
17
|
+
HAIR_STATE_LAST_POSITION,
|
|
18
|
+
HAIR_STATE_NONE,
|
|
19
|
+
HAIR_STATE_POSITION
|
|
20
|
+
} from "./HAIR_SIMULATION.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Epochs as an f32 holds them exactly, in a guide state header's `w`.
|
|
24
|
+
* @type {number}
|
|
25
|
+
*/
|
|
26
|
+
export const HAIR_EPOCH_MASK = 0xFFFFFF;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Every simulated instance's guide state, a run an instance (`HAIR_SIMULATION.js`).
|
|
30
|
+
*
|
|
31
|
+
* @type {ShaderResourceDescriptor}
|
|
32
|
+
*/
|
|
33
|
+
export const HAIR_GUIDE_STATE_RESOURCE = ShaderResourceDescriptor.storageBuffer("hair_guide_state", WebGPUArray.from(vec4f));
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Where a simulated instance's guide state is, and what its guides are:
|
|
37
|
+
*
|
|
38
|
+
* ```wgsl
|
|
39
|
+
* fn hair_strand_frame(instance: HairInstance, strand: u32, entity: mat4x4<f32>, last: bool) -> mat4x4<f32>
|
|
40
|
+
* fn hair_state_live(instance: HairInstance) -> bool
|
|
41
|
+
* fn hair_state_index(instance: HairInstance, plane: u32, node: u32, guide: u32) -> u32
|
|
42
|
+
* fn hair_guide_record(instance: HairInstance, guide: u32) -> vec4<u32>
|
|
43
|
+
* fn hair_quat_nlerp(a: vec4<f32>, b: vec4<f32>, t: f32) -> vec4<f32>
|
|
44
|
+
* fn hair_drag_rate(speed: f32, diameter: f32, mass_per_length: f32) -> f32
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* `hair_strand_frame` is what carries a strand's rest points into the world: its root frame (`shader_hair_roots.js`)
|
|
48
|
+
* when the instance is bound to a mesh, the `entity` matrix given otherwise; with `last`, a frame ago.
|
|
49
|
+
* `hair_state_live` is whether the instance is simulated and its state was laid for it: a state allocated since the
|
|
50
|
+
* frame's step holds another tenant's nodes, or none, and its strands ride the entity until the next step lays it.
|
|
51
|
+
* Reads the state's header. `hair_state_index` is a vector of the state pool, node-interleaved. `hair_guide_record` is a guide's four words in
|
|
52
|
+
* the groom pool: its strand's rank, its wisp's strand count, its wisp's diameter and its length (f32 bits).
|
|
53
|
+
* `hair_quat_nlerp` blends two unit quaternions along the shorter arc. `hair_drag_rate` is `hair_drag_rate`'s twin
|
|
54
|
+
* (`HAIR_SIMULATION.js`): the rate a node's velocity relaxes toward the air's.
|
|
55
|
+
*
|
|
56
|
+
* @type {CodeChunk}
|
|
57
|
+
*/
|
|
58
|
+
export const chunk_hair_guide = CodeChunk.from(
|
|
59
|
+
//language=WGSL
|
|
60
|
+
`
|
|
61
|
+
fn hair_strand_frame(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}, strand: u32, entity: mat4x4<f32>, last: bool) -> mat4x4<f32> {
|
|
62
|
+
if (instance.mesh_node == ${HAIR_BINDING_NONE}u) {
|
|
63
|
+
return entity;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let at = instance.roots + strand * ${HAIR_ROOT_FRAME_VECTORS}u + select(0u, 3u, last);
|
|
67
|
+
|
|
68
|
+
let r0 = hair_guide_state[at];
|
|
69
|
+
let r1 = hair_guide_state[at + 1u];
|
|
70
|
+
let r2 = hair_guide_state[at + 2u];
|
|
71
|
+
|
|
72
|
+
return mat4x4<f32>(
|
|
73
|
+
vec4<f32>(r0.x, r1.x, r2.x, 0.0),
|
|
74
|
+
vec4<f32>(r0.y, r1.y, r2.y, 0.0),
|
|
75
|
+
vec4<f32>(r0.z, r1.z, r2.z, 0.0),
|
|
76
|
+
vec4<f32>(r0.w, r1.w, r2.w, 1.0),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn hair_state_live(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}) -> bool {
|
|
81
|
+
if (instance.state == ${HAIR_STATE_NONE}u) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return hair_guide_state[instance.state].w == f32(instance.epoch & ${HAIR_EPOCH_MASK}u);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
fn hair_state_index(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}, plane: u32, node: u32, guide: u32) -> u32 {
|
|
89
|
+
return instance.state + ${HAIR_STATE_HEADER}u + (plane * instance.guide_point_count + node) * instance.guide_count + guide;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fn hair_guide_record(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}, guide: u32) -> vec4<u32> {
|
|
93
|
+
let at = instance.guides + guide * ${HAIR_GUIDE_RECORD_WORDS}u;
|
|
94
|
+
|
|
95
|
+
return vec4<u32>(hair_grooms[at], hair_grooms[at + 1u], hair_grooms[at + 2u], hair_grooms[at + 3u]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fn hair_quat_nlerp(a: vec4<f32>, b: vec4<f32>, t: f32) -> vec4<f32> {
|
|
99
|
+
let side = select(1.0, -1.0, dot(a, b) < 0.0);
|
|
100
|
+
|
|
101
|
+
return normalize(mix(a, b * side, t));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fn hair_drag_rate(speed: f32, diameter: f32, mass_per_length: f32) -> f32 {
|
|
105
|
+
let reynolds_per_speed = ${HAIR_AIR_DENSITY} * diameter / ${HAIR_AIR_VISCOSITY};
|
|
106
|
+
|
|
107
|
+
return 0.5 * ${HAIR_AIR_DENSITY} * diameter / mass_per_length
|
|
108
|
+
* (speed + 10.0 * pow(speed, 1.0 / 3.0) * pow(reynolds_per_speed, -2.0 / 3.0));
|
|
109
|
+
}
|
|
110
|
+
`, [
|
|
111
|
+
HAIR_INSTANCE_STRUCT.declaration_chunk,
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
chunk_hair_guide.requireResource(HAIR_GROOMS_RESOURCE);
|
|
115
|
+
chunk_hair_guide.requireResource(HAIR_GUIDE_STATE_RESOURCE);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A point of a simulated strand, carried by its guide:
|
|
119
|
+
*
|
|
120
|
+
* ```wgsl
|
|
121
|
+
* fn hair_guided_point(instance: HairInstance, strand: u32, point: u32, entity: mat4x4<f32>, anchor: vec3<f32>,
|
|
122
|
+
* last: bool) -> vec3<f32>
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* The strand follows its guide (its strand word's high 16 bits). The point's rest place is taken from the chord
|
|
126
|
+
* between the guide's nodes either side of it at the same share of the length, and placed by the strand's own frame
|
|
127
|
+
* (`hair_strand_frame`) applied to three terms: the rest chord, carried by the strand's frame; the guide's move
|
|
128
|
+
* there, the chord where its nodes are less the rest chord carried by the guide's frame; and the point's offset from
|
|
129
|
+
* the rest chord, carried by the strand's frame's linear part and turned by the guide's frame there (the nodes' frames
|
|
130
|
+
* blended along the chord). Exact for any rigid motion of a wisp, so a guide at rest draws its strands as they were
|
|
131
|
+
* made; for strands that ride their entity both frames are the entity's. With `last`, where it was a frame ago: the
|
|
132
|
+
* nodes, frames and root frames of a frame ago, and `entity` the entity's matrix then; `anchor` is this frame's,
|
|
133
|
+
* which the nodes of a frame ago are kept from. World metres.
|
|
134
|
+
*
|
|
135
|
+
* @type {CodeChunk}
|
|
136
|
+
*/
|
|
137
|
+
export const chunk_hair_guided_point = CodeChunk.from(
|
|
138
|
+
//language=WGSL
|
|
139
|
+
`
|
|
140
|
+
fn hair_guided_point(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}, strand: u32, point: u32, entity: mat4x4<f32>, anchor: vec3<f32>, last: bool) -> vec3<f32> {
|
|
141
|
+
let guide = hair_grooms[instance.strands + strand] >> 16u;
|
|
142
|
+
let record = hair_guide_record(instance, guide);
|
|
143
|
+
|
|
144
|
+
// the node before the point and how far past it, along the guide
|
|
145
|
+
let step = (instance.point_count - 1u) / (instance.guide_point_count - 1u);
|
|
146
|
+
let node = min(point / step, instance.guide_point_count - 2u);
|
|
147
|
+
let t = f32(point - node * step) / f32(step);
|
|
148
|
+
|
|
149
|
+
let rest_a = hair_rest_point(instance, record.x, node * step).xyz;
|
|
150
|
+
let rest_b = hair_rest_point(instance, record.x, (node + 1u) * step).xyz;
|
|
151
|
+
let offset = hair_rest_point(instance, strand, point).xyz - mix(rest_a, rest_b, t);
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
let position_plane = select(${HAIR_STATE_POSITION}u, ${HAIR_STATE_LAST_POSITION}u, last);
|
|
155
|
+
let frame_plane = select(${HAIR_STATE_FRAME}u, ${HAIR_STATE_LAST_FRAME}u, last);
|
|
156
|
+
|
|
157
|
+
let a = hair_guide_state[hair_state_index(instance, position_plane, node, guide)].xyz;
|
|
158
|
+
let b = hair_guide_state[hair_state_index(instance, position_plane, node + 1u, guide)].xyz;
|
|
159
|
+
let qa = hair_guide_state[hair_state_index(instance, frame_plane, node, guide)];
|
|
160
|
+
let qb = hair_guide_state[hair_state_index(instance, frame_plane, node + 1u, guide)];
|
|
161
|
+
|
|
162
|
+
let rest_chord = mix(rest_a, rest_b, t);
|
|
163
|
+
let strand_frame = hair_strand_frame(instance, strand, entity, last);
|
|
164
|
+
let guide_frame = hair_strand_frame(instance, record.x, entity, last);
|
|
165
|
+
let strand_linear = mat3x3<f32>(strand_frame[0].xyz, strand_frame[1].xyz, strand_frame[2].xyz);
|
|
166
|
+
|
|
167
|
+
let moved = anchor + mix(a, b, t) - (guide_frame * vec4<f32>(rest_chord, 1.0)).xyz;
|
|
168
|
+
|
|
169
|
+
return (strand_frame * vec4<f32>(rest_chord, 1.0)).xyz + moved + quat_rotate_v3(hair_quat_nlerp(qa, qb, t), strand_linear * offset);
|
|
170
|
+
}
|
|
171
|
+
`, [
|
|
172
|
+
HAIR_INSTANCE_STRUCT.declaration_chunk,
|
|
173
|
+
chunk_hair_rest_point,
|
|
174
|
+
chunk_hair_guide,
|
|
175
|
+
chunk_quat_rotate_v3,
|
|
176
|
+
]);
|
|
177
|
+
|
|
178
|
+
chunk_hair_guided_point.requireResource(HAIR_GUIDE_STATE_RESOURCE);
|
|
179
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vertex stage of a pass drawn over each instance's screen rectangle, an instance a row:
|
|
3
|
+
*
|
|
4
|
+
* ```wgsl
|
|
5
|
+
* fn hair_quad_vertex(vertex: u32, row: u32) -> HairQuadVertex // 4 vertices, a triangle strip
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Reads `hair_lod` and `hair_view`. A row with nothing on screen is a quad of no area. The fragment's work then
|
|
9
|
+
* follows the hair on screen rather than the screen.
|
|
10
|
+
*
|
|
11
|
+
* @type {CodeChunk}
|
|
12
|
+
*/
|
|
13
|
+
export const chunk_hair_quad_vertex: CodeChunk;
|
|
14
|
+
/**
|
|
15
|
+
* The strand under a pixel of the hair id target, if it belongs to the row:
|
|
16
|
+
*
|
|
17
|
+
* ```wgsl
|
|
18
|
+
* fn hair_pixel(pixel: vec2<f32>, row: u32, hair: ptr<function, HairPixel>) -> bool
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* False where no strand covers the pixel, or where the strand that does is another instance's: overlapping
|
|
22
|
+
* instances, brows under a fringe, are each seen once. Otherwise `hair` holds the pixel's segment, from its start
|
|
23
|
+
* `a` to its end `b` as the points are now (x, y, z, half the drawn width) and as they were a frame ago
|
|
24
|
+
* (`a_before`, `b_before`), how far along it the pixel is, and the strand's variation byte.
|
|
25
|
+
*
|
|
26
|
+
* Reads `hair_ids` and `hair_points`, and `hair_view` for where the points' second half starts.
|
|
27
|
+
*
|
|
28
|
+
* @type {CodeChunk}
|
|
29
|
+
*/
|
|
30
|
+
export const chunk_hair_pixel: CodeChunk;
|
|
31
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
32
|
+
//# sourceMappingURL=chunk_hair_pixel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_hair_pixel.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_pixel.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,qCAFU,SAAS,CA4BhB;AAEH;;;;;;;;;;;;;;;GAeG;AACH,+BAFU,SAAS,CAuDhB;0BAnHuB,iCAAiC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
2
|
+
import { HAIR_ID_ALONG_BITS, HAIR_ID_NONE, HAIR_ROW_BITS } from "./HAIR.js";
|
|
3
|
+
import { HAIR_LOD_STRUCT, HAIR_VIEW_STRUCT } from "./HAIR_FRAME_STRUCTS.js";
|
|
4
|
+
|
|
5
|
+
const ALONG_STEPS = 2 ** HAIR_ID_ALONG_BITS - 1;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The vertex stage of a pass drawn over each instance's screen rectangle, an instance a row:
|
|
9
|
+
*
|
|
10
|
+
* ```wgsl
|
|
11
|
+
* fn hair_quad_vertex(vertex: u32, row: u32) -> HairQuadVertex // 4 vertices, a triangle strip
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Reads `hair_lod` and `hair_view`. A row with nothing on screen is a quad of no area. The fragment's work then
|
|
15
|
+
* follows the hair on screen rather than the screen.
|
|
16
|
+
*
|
|
17
|
+
* @type {CodeChunk}
|
|
18
|
+
*/
|
|
19
|
+
export const chunk_hair_quad_vertex = CodeChunk.from(
|
|
20
|
+
//language=WGSL
|
|
21
|
+
`
|
|
22
|
+
struct HairQuadVertex {
|
|
23
|
+
@builtin(position) position: vec4<f32>,
|
|
24
|
+
@location(0) @interpolate(flat) row: u32,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fn hair_quad_vertex(vertex: u32, row: u32) -> HairQuadVertex {
|
|
28
|
+
let lod = hair_lod[row];
|
|
29
|
+
|
|
30
|
+
let low = vec2<f32>(f32(lod.rect_min & 0xFFFFu), f32(lod.rect_min >> 16u));
|
|
31
|
+
let high = max(vec2<f32>(f32(lod.rect_max & 0xFFFFu), f32(lod.rect_max >> 16u)), low);
|
|
32
|
+
|
|
33
|
+
let pixel = mix(low, high, vec2<f32>(f32(vertex & 1u), f32(vertex >> 1u)));
|
|
34
|
+
|
|
35
|
+
var out: HairQuadVertex;
|
|
36
|
+
|
|
37
|
+
out.position = vec4<f32>(pixel.x / hair_view.resolution.x * 2.0 - 1.0, 1.0 - pixel.y / hair_view.resolution.y * 2.0, 0.0, 1.0);
|
|
38
|
+
out.row = row;
|
|
39
|
+
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
`, [
|
|
43
|
+
HAIR_LOD_STRUCT.declaration_chunk,
|
|
44
|
+
HAIR_VIEW_STRUCT.declaration_chunk,
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The strand under a pixel of the hair id target, if it belongs to the row:
|
|
49
|
+
*
|
|
50
|
+
* ```wgsl
|
|
51
|
+
* fn hair_pixel(pixel: vec2<f32>, row: u32, hair: ptr<function, HairPixel>) -> bool
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* False where no strand covers the pixel, or where the strand that does is another instance's: overlapping
|
|
55
|
+
* instances, brows under a fringe, are each seen once. Otherwise `hair` holds the pixel's segment, from its start
|
|
56
|
+
* `a` to its end `b` as the points are now (x, y, z, half the drawn width) and as they were a frame ago
|
|
57
|
+
* (`a_before`, `b_before`), how far along it the pixel is, and the strand's variation byte.
|
|
58
|
+
*
|
|
59
|
+
* Reads `hair_ids` and `hair_points`, and `hair_view` for where the points' second half starts.
|
|
60
|
+
*
|
|
61
|
+
* @type {CodeChunk}
|
|
62
|
+
*/
|
|
63
|
+
export const chunk_hair_pixel = CodeChunk.from(
|
|
64
|
+
//language=WGSL
|
|
65
|
+
`
|
|
66
|
+
struct HairPixel {
|
|
67
|
+
a: vec4<f32>,
|
|
68
|
+
b: vec4<f32>,
|
|
69
|
+
a_before: vec3<f32>,
|
|
70
|
+
b_before: vec3<f32>,
|
|
71
|
+
along: f32,
|
|
72
|
+
variation: u32,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fn hair_pixel(pixel: vec2<f32>, row: u32, hair: ptr<function, HairPixel>) -> bool {
|
|
76
|
+
let id = textureLoad(hair_ids, vec2<i32>(pixel), 0).x;
|
|
77
|
+
|
|
78
|
+
if (id == ${HAIR_ID_NONE}u) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let slot = (id >> ${HAIR_ID_ALONG_BITS}u) - 1u;
|
|
83
|
+
let before = hair_view.point_capacity + slot;
|
|
84
|
+
|
|
85
|
+
let a_before = hair_points[before];
|
|
86
|
+
|
|
87
|
+
if ((a_before.w & ${2 ** HAIR_ROW_BITS - 1}u) != row) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
(*hair).a = bitcast<vec4<f32>>(hair_points[slot]);
|
|
92
|
+
(*hair).b = bitcast<vec4<f32>>(hair_points[slot + 1u]);
|
|
93
|
+
(*hair).a_before = bitcast<vec3<f32>>(a_before.xyz);
|
|
94
|
+
(*hair).b_before = bitcast<vec3<f32>>(hair_points[before + 1u].xyz);
|
|
95
|
+
(*hair).along = f32(id & ${ALONG_STEPS}u) / ${ALONG_STEPS}.0;
|
|
96
|
+
(*hair).variation = a_before.w >> ${HAIR_ROW_BITS}u;
|
|
97
|
+
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// the way along the strand, root to tip, at the pixel
|
|
102
|
+
fn hair_pixel_tangent(hair: HairPixel) -> vec3<f32> {
|
|
103
|
+
let d = hair.b.xyz - hair.a.xyz;
|
|
104
|
+
let l = length(d);
|
|
105
|
+
|
|
106
|
+
return select(vec3<f32>(0.0, 1.0, 0.0), d / l, l > 1e-20);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// the normal of a strand at a point: the way to the eye, less its part along the strand
|
|
110
|
+
fn hair_normal(tangent: vec3<f32>, view_direction: vec3<f32>) -> vec3<f32> {
|
|
111
|
+
let n = view_direction - tangent * dot(view_direction, tangent);
|
|
112
|
+
let l = length(n);
|
|
113
|
+
|
|
114
|
+
return select(view_direction, n / l, l > 1e-6);
|
|
115
|
+
}
|
|
116
|
+
`);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every groom's rest points and strand words, a run a groom (`GPUHairSystem`), as `u32` words.
|
|
3
|
+
*
|
|
4
|
+
* @type {ShaderResourceDescriptor}
|
|
5
|
+
*/
|
|
6
|
+
export const HAIR_GROOMS_RESOURCE: ShaderResourceDescriptor;
|
|
7
|
+
/**
|
|
8
|
+
* A rest point of a strand of an instance's group, from the groom pool:
|
|
9
|
+
*
|
|
10
|
+
* ```wgsl
|
|
11
|
+
* fn hair_rest_point(instance: HairInstance, strand: u32, point: u32) -> vec4<f32>
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* x, y, z in the groom's metres, then the point's width in them. `strand` is the strand's rank, `point` its index
|
|
15
|
+
* from the root.
|
|
16
|
+
*
|
|
17
|
+
* @type {CodeChunk}
|
|
18
|
+
*/
|
|
19
|
+
export const chunk_hair_rest_point: CodeChunk;
|
|
20
|
+
/**
|
|
21
|
+
* The level of detail's arithmetic (Cook & Halstead's area rule):
|
|
22
|
+
*
|
|
23
|
+
* ```wgsl
|
|
24
|
+
* fn hair_pixel_size(depth: f32, height: f32) -> f32
|
|
25
|
+
* fn hair_kept_fraction(mean_width: f32, pixel_size: f32, floor_pixels: f32) -> f32
|
|
26
|
+
* fn hair_view_depth(world: vec3<f32>) -> f32
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* `hair_pixel_size` is the world size of a pixel at view depth `depth` for a view `height` pixels tall, under the
|
|
30
|
+
* camera's projection, perspective or orthographic. `hair_kept_fraction` is the share of a group's strands drawn
|
|
31
|
+
* where a pixel is `pixel_size` across: all of them while their mean width is at least `floor_pixels` pixels, and
|
|
32
|
+
* fewer in proportion below it, each widened by the reciprocal so their area is kept. `hair_view_depth` is a world
|
|
33
|
+
* point's planar depth in front of the camera.
|
|
34
|
+
*
|
|
35
|
+
* @type {CodeChunk}
|
|
36
|
+
*/
|
|
37
|
+
export const chunk_hair_lod: CodeChunk;
|
|
38
|
+
import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
|
|
39
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
40
|
+
//# sourceMappingURL=chunk_hair_strand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_hair_strand.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_strand.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,mCAFU,wBAAwB,CAEyE;AAE3G;;;;;;;;;;;GAWG;AACH,oCAFU,SAAS,CAkBhB;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,6BAFU,SAAS,CAqBhB;yCA/EsC,gDAAgD;0BAD/D,iCAAiC"}
|