@woosh/meep-engine 3.76.0 → 3.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +3 -2
- package/src/engine/EngineHarness.d.ts +4 -6
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +11 -19
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts +1 -1
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/GroomAssetLoader.js +16 -2
- package/src/engine/graphics/ecs/hair/Hair.d.ts +7 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -1
- package/src/engine/graphics/ecs/hair/Hair.js +9 -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 +45 -0
- package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
- package/src/engine/graphics/hair/Groom.js +56 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +27 -1
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/hair/GroomSerializationAdapter.js +105 -32
- 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 +7 -2
- package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
- package/src/engine/graphics/hair/groom_build_group.js +11 -2
- 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_root_spacing.d.ts +6 -4
- package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -1
- package/src/engine/graphics/hair/groom_root_spacing.js +199 -66
- 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 +21 -4
- package/src/engine/graphics3/HairSystem.d.ts.map +1 -1
- package/src/engine/graphics3/HairSystem.js +270 -4
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts +0 -1
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/EventInstance.js +0 -1
- package/src/shade/assets/textures/hair_scattering.bin +0 -0
- package/src/shade/playground/hair/main.js +27 -4
- 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/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 +18 -3
- 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_shade_direct_lights.js +2 -2
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +4 -2
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +7 -3
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +1 -1
- package/src/shade/renderer/extension/ShadowAtlas.d.ts +77 -0
- package/src/shade/renderer/extension/ShadowAtlas.d.ts.map +1 -0
- package/src/shade/renderer/extension/ShadowAtlas.js +135 -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/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -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/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 +121 -2
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
- package/src/shade/renderer/hair/GPUHairSystem.js +1187 -56
- package/src/shade/renderer/hair/HAIR.d.ts +22 -3
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR.js +25 -4
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +33 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +4 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -1
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +24 -2
- 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/chunk_hair_dual_scattering.d.ts +9 -2
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +40 -13
- 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_volume.d.ts +4 -3
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_volume.js +21 -12
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_lighting.js +16 -7
- package/src/shade/renderer/hair/hair_scattering_lut.js +13 -13
- 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/shader_hair_classes.d.ts +2 -1
- package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_classes.js +6 -2
- package/src/shade/renderer/hair/shader_hair_cull.d.ts +8 -2
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_cull.js +74 -17
- package/src/shade/renderer/hair/shader_hair_lod.d.ts +9 -3
- package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_lod.js +125 -31
- 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 +3 -3
- package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -1
- package/src/shade/renderer/hair/shader_hair_volume.js +4 -17
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +8 -3
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_groom_extension.js +58 -5
- 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/postprocess/nss/NSS.d.ts +1 -1
- 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/draw/chunk_meshlet_draw_vertex.d.ts +7 -4
- package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/draw/chunk_meshlet_draw_vertex.js +66 -14
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +20 -0
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +149 -0
- package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts +8 -0
- package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +100 -33
- package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts +11 -0
- package/src/shade/renderer/rasterize/native/rasterization_shader_resources.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/rasterization_shader_resources.js +24 -11
- 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/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts +13 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_vertex_normal.js +42 -0
- 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/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 +83 -5
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +34 -0
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -0
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +106 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts +16 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.d.ts.map +1 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_cascade_caster_position.js +50 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +25 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -0
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +42 -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_directional_cascades.d.ts +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_directional_cascades.js +5 -5
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
|
@@ -19,14 +19,21 @@ export const HAIR_SCATTERING_LUT_RESOURCE = ShaderResourceDescriptor.texture("tH
|
|
|
19
19
|
* ```wgsl
|
|
20
20
|
* fn hair_scattering(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32,
|
|
21
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>
|
|
22
24
|
* ```
|
|
23
25
|
*
|
|
24
26
|
* `hair_count` is the number of strands between the point and the light (the density volume's march); one is taken
|
|
25
27
|
* off it for the strand's own. The global term passes the light through them, attenuated by the average front
|
|
26
28
|
* scattering to the power of their count and spread by their roughness; the local term adds what scatters back
|
|
27
29
|
* from the strands around the point. The average scatterings come from the table at the light's angle to the fibre,
|
|
28
|
-
* the roughness and the colour.
|
|
29
|
-
*
|
|
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.
|
|
30
37
|
*
|
|
31
38
|
* @type {CodeChunk}
|
|
32
39
|
*/
|
|
@@ -38,13 +45,14 @@ fn hair_gaussian_unnormalized(v: f32, theta: f32) -> f32 {
|
|
|
38
45
|
return exp(-0.5 * theta * theta / max(v, 1e-10));
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
// the table's average front and back scattering, a channel each
|
|
49
|
+
struct HairAverageScattering {
|
|
50
|
+
front: vec3<f32>,
|
|
51
|
+
back: vec3<f32>,
|
|
52
|
+
}
|
|
46
53
|
|
|
47
|
-
|
|
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 {
|
|
48
56
|
let color = hair_absorption_to_color(absorption);
|
|
49
57
|
let z = sqrt(saturate(color));
|
|
50
58
|
let x = saturate(abs(sin_l));
|
|
@@ -54,8 +62,25 @@ fn hair_scattering(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f3
|
|
|
54
62
|
let s_g = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.g), 0.0).rg;
|
|
55
63
|
let s_b = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.b), 0.0).rg;
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
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;
|
|
59
84
|
|
|
60
85
|
const MAX_AVERAGE = 0.99;
|
|
61
86
|
|
|
@@ -69,9 +94,11 @@ fn hair_scattering(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f3
|
|
|
69
94
|
let a3 = ab * ab2 * af2 / (one_minus_af2 * one_minus_af2 * one_minus_af2);
|
|
70
95
|
let a_b = a1 + a3;
|
|
71
96
|
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
let
|
|
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);
|
|
75
102
|
|
|
76
103
|
const SHIFT_R = -0.035 * 2.0;
|
|
77
104
|
const SHIFT_TT = 0.035;
|
|
@@ -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
|
+
|
|
@@ -13,15 +13,16 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export const chunk_hair_volume_layout: CodeChunk;
|
|
15
15
|
/**
|
|
16
|
-
* The number of strands between a point and the edge of its instance's volume, along a
|
|
16
|
+
* The number of strands between a point and the edge of its instance's volume, or a point `distance` away, along a
|
|
17
|
+
* direction:
|
|
17
18
|
*
|
|
18
19
|
* ```wgsl
|
|
19
|
-
* fn hair_count_along(lod: HairLod, position: vec3<f32>, direction: vec3<f32>, jitter: f32) -> f32
|
|
20
|
+
* fn hair_count_along(lod: HairLod, position: vec3<f32>, direction: vec3<f32>, jitter: f32, distance: f32) -> f32
|
|
20
21
|
* ```
|
|
21
22
|
*
|
|
22
23
|
* Eight taps, a constant trip count: the march starts one voxel out, steps one voxel twice, then doubles its step
|
|
23
24
|
* each tap, reading the mip whose voxel matches the step (the last, past it), so it reaches 128 voxels. A tap outside
|
|
24
|
-
* the volume reads nothing. `jitter` in [0, 1) moves the taps along the ray by up to a step, for the frame's
|
|
25
|
+
* the volume, or past `distance`, reads nothing. `jitter` in [0, 1) moves the taps along the ray by up to a step, for the frame's
|
|
25
26
|
* accumulation to filter the voxels' edges. Reads `hair_volume`.
|
|
26
27
|
*
|
|
27
28
|
* @type {CodeChunk}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_hair_volume.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_volume.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,uCAFU,SAAS,CA0BqB;AAExC
|
|
1
|
+
{"version":3,"file":"chunk_hair_volume.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_volume.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,uCAFU,SAAS,CA0BqB;AAExC;;;;;;;;;;;;;;GAcG;AACH,qCAFU,SAAS,CA0DY;0BAlHL,iCAAiC"}
|
|
@@ -42,15 +42,16 @@ fn hair_volume_index(lod: ${HAIR_LOD_STRUCT.wgsl_ref}, cell: vec3<u32>, mip: u32
|
|
|
42
42
|
`, [HAIR_LOD_STRUCT.declaration_chunk]);
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* The number of strands between a point and the edge of its instance's volume, along a
|
|
45
|
+
* The number of strands between a point and the edge of its instance's volume, or a point `distance` away, along a
|
|
46
|
+
* direction:
|
|
46
47
|
*
|
|
47
48
|
* ```wgsl
|
|
48
|
-
* fn hair_count_along(lod: HairLod, position: vec3<f32>, direction: vec3<f32>, jitter: f32) -> f32
|
|
49
|
+
* fn hair_count_along(lod: HairLod, position: vec3<f32>, direction: vec3<f32>, jitter: f32, distance: f32) -> f32
|
|
49
50
|
* ```
|
|
50
51
|
*
|
|
51
52
|
* Eight taps, a constant trip count: the march starts one voxel out, steps one voxel twice, then doubles its step
|
|
52
53
|
* each tap, reading the mip whose voxel matches the step (the last, past it), so it reaches 128 voxels. A tap outside
|
|
53
|
-
* the volume reads nothing. `jitter` in [0, 1) moves the taps along the ray by up to a step, for the frame's
|
|
54
|
+
* the volume, or past `distance`, reads nothing. `jitter` in [0, 1) moves the taps along the ray by up to a step, for the frame's
|
|
54
55
|
* accumulation to filter the voxels' edges. Reads `hair_volume`.
|
|
55
56
|
*
|
|
56
57
|
* @type {CodeChunk}
|
|
@@ -58,11 +59,12 @@ fn hair_volume_index(lod: ${HAIR_LOD_STRUCT.wgsl_ref}, cell: vec3<u32>, mip: u32
|
|
|
58
59
|
export const chunk_hair_count_along = CodeChunk.from(
|
|
59
60
|
//language=WGSL
|
|
60
61
|
`
|
|
61
|
-
// the voxel of one level under a point, its level's size and first voxel
|
|
62
|
-
|
|
62
|
+
// the voxel of one level under a point, the tap "along" voxels down the march, its level's size and first voxel
|
|
63
|
+
// given; nothing outside the volume, nor past "reach" voxels
|
|
64
|
+
fn hair_volume_read(voxel: vec3<f32>, along: f32, reach: f32, mip: u32, dims: vec3<u32>, offset: u32) -> f32 {
|
|
63
65
|
let cell = floor(voxel / f32(1u << mip));
|
|
64
66
|
|
|
65
|
-
if (any(cell < vec3<f32>(0.0)) || any(cell >= vec3<f32>(dims))) {
|
|
67
|
+
if (along > reach || any(cell < vec3<f32>(0.0)) || any(cell >= vec3<f32>(dims))) {
|
|
66
68
|
return 0.0;
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -71,7 +73,7 @@ fn hair_volume_read(voxel: vec3<f32>, mip: u32, dims: vec3<u32>, offset: u32) ->
|
|
|
71
73
|
return f32(hair_volume[offset + (c.z * dims.y + c.y) * dims.x + c.x]) * (1.0 / ${HAIR_VOLUME_FIXED_ONE}.0);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
fn hair_count_along(lod: ${HAIR_LOD_STRUCT.wgsl_ref}, position: vec3<f32>, direction: vec3<f32>, jitter: f32) -> f32 {
|
|
76
|
+
fn hair_count_along(lod: ${HAIR_LOD_STRUCT.wgsl_ref}, position: vec3<f32>, direction: vec3<f32>, jitter: f32, distance: f32) -> f32 {
|
|
75
77
|
if (lod.voxel_size <= 0.0) {
|
|
76
78
|
return 0.0;
|
|
77
79
|
}
|
|
@@ -85,19 +87,26 @@ fn hair_count_along(lod: ${HAIR_LOD_STRUCT.wgsl_ref}, position: vec3<f32>, direc
|
|
|
85
87
|
let o2 = o1 + d1.x * d1.y * d1.z;
|
|
86
88
|
|
|
87
89
|
let start = (position - lod.volume_origin) / lod.voxel_size;
|
|
90
|
+
let reach = distance / lod.voxel_size;
|
|
88
91
|
|
|
89
92
|
// 1, 1, 2, 4, then 8, 16, 32, 64 voxels a tap, the last four from the coarsest level
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
let t0 = 1.0 + jitter;
|
|
94
|
+
let t1 = 2.0 + jitter;
|
|
95
|
+
let t2 = 3.0 + 2.0 * jitter;
|
|
96
|
+
let t3 = 5.0 + 4.0 * jitter;
|
|
97
|
+
|
|
98
|
+
var count = hair_volume_read(start + direction * t0, t0, reach, 0u, d0, o0)
|
|
99
|
+
+ hair_volume_read(start + direction * t1, t1, reach, 0u, d0, o0)
|
|
100
|
+
+ 2.0 * hair_volume_read(start + direction * t2, t2, reach, 1u, d1, o1)
|
|
101
|
+
+ 4.0 * hair_volume_read(start + direction * t3, t3, reach, 2u, d2, o2);
|
|
94
102
|
|
|
95
103
|
var travelled = 9.0;
|
|
96
104
|
|
|
97
105
|
for (var k = 0u; k < 4u; k++) {
|
|
98
106
|
let size = f32(8u << k);
|
|
107
|
+
let t = travelled + size * jitter;
|
|
99
108
|
|
|
100
|
-
count += size * hair_volume_read(start + direction *
|
|
109
|
+
count += size * hair_volume_read(start + direction * t, t, reach, 2u, d2, o2);
|
|
101
110
|
travelled += size;
|
|
102
111
|
}
|
|
103
112
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hair_lighting.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/hair_lighting.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hair_lighting.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/hair_lighting.js"],"names":[],"mappings":"AAkOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iDAJW,OAAO,uCAAuC,EAAE,eAAe,6BAE7D,wBAAwB,CA+BpC;AAtPD;;;GAGG;AACH,uCAFU,6BAA6B,CAM8B;AAErE;;;;GAIG;AACH,uCAFU,6BAA6B,CAaA;AAYvC;;;;;GAKG;AACH,sCAFU,2BAA2B,CAEY;AAyIjD;;;;GAIG;AACH,qCAFU,gBAAgB,CAEgC;yCAxNjB,8DAA8D;8CAYzD,qDAAqD;4CACvD,mDAAmD;iCAC9D,+BAA+B"}
|
|
@@ -102,9 +102,16 @@ struct DirectLightContext {
|
|
|
102
102
|
lod: ${HAIR_LOD_STRUCT.wgsl_ref},
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
// the strands between the point and the light, from the instance's density volume, scatter the light that reaches it
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
// the strands between the point and the light, from the instance's density volume, scatter the light that reaches it;
|
|
106
|
+
// strands drawn into the light's shadow map are shadowed toward it by the map, their own among the casters, and the
|
|
107
|
+
// volume would take them off twice
|
|
108
|
+
fn direct_light_lobe(context: ptr<function, DirectLightContext>, light: ${INCIDENT_LIGHT_STRUCT.wgsl_ref}, atlas_casters: bool) {
|
|
109
|
+
var count = 0.0;
|
|
110
|
+
|
|
111
|
+
if (hair_view.casts_shadows == 0u || !atlas_casters) {
|
|
112
|
+
// only the strands short of the light: a local light inside the hair has strands beyond it too
|
|
113
|
+
count = hair_count_along((*context).lod, (*context).position, light.direction, (*context).jitter, light.distance);
|
|
114
|
+
}
|
|
108
115
|
|
|
109
116
|
(*context).radiance += light.color * hair_scattering(light.direction, (*context).view_direction, (*context).tangent, (*context).absorption, (*context).roughness, count, 1.0, 0.0);
|
|
110
117
|
}
|
|
@@ -172,10 +179,12 @@ fn fs_main(in: HairQuadVertex) -> @location(0) vec4<f32> {
|
|
|
172
179
|
|
|
173
180
|
forward_sample_indirect(position, view_direction, normal, instance.roughness, &radiance, &irradiance);
|
|
174
181
|
|
|
175
|
-
// through the strands between the point and the open air about its normal: sky occlusion
|
|
176
|
-
|
|
177
|
-
let
|
|
178
|
-
let
|
|
182
|
+
// through the strands between the point and the open air about its normal: sky occlusion, the energy they pass
|
|
183
|
+
// forward
|
|
184
|
+
let count_around = hair_count_along(lod, position, normal, noise.y, 1e30);
|
|
185
|
+
let indirect_shading = min(vec3<f32>(1.0), 3.14159265 * hair_shading(normal, view_direction, towards_root, absorption, instance.roughness, 0.0, 0.2));
|
|
186
|
+
let transmittance = hair_forward_transmittance(normal, towards_root, absorption, instance.roughness, count_around);
|
|
187
|
+
let indirect = irradiance * (1.0 / 3.14159265) * indirect_shading * transmittance;
|
|
179
188
|
|
|
180
189
|
// the fog between the eye and the strand: the composite has already put its in-scatter here, over a surface it
|
|
181
190
|
// took to be black metal; the strand's own light is attenuated by the same transmittance, and the colour
|
|
@@ -158,7 +158,7 @@ export function hair_shading_twin(u, cos_phi, u_v, absorption, roughness) {
|
|
|
158
158
|
return Math.max(sum, 0);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// Gauss-Hermite, 16 nodes: the positive half of the nodes and their weights
|
|
161
|
+
// Gauss-Hermite, 16 nodes: the positive half of the nodes and their weights, which sum to sqrt(pi) over all 16
|
|
162
162
|
const GH_X = [0.27348104613815, 0.82295144914466, 1.38025853919888, 1.95178799091625, 2.54620215784748, 3.17699916197996, 3.86944790486012, 4.68873893930582];
|
|
163
163
|
const GH_W = [0.50792947901661, 0.28064745852853, 0.08381004139899, 0.01288031153551, 0.00093228400862, 0.00002711860093, 0.00000023209808, 0.00000000026548];
|
|
164
164
|
const SQRT_PI = Math.sqrt(Math.PI);
|
|
@@ -188,38 +188,38 @@ export function hair_average_scattering(u_v, roughness, color, phi_steps = 128)
|
|
|
188
188
|
let sum = 0;
|
|
189
189
|
|
|
190
190
|
for (let p = 0; p < 3; p++) {
|
|
191
|
-
// the Gaussian's width and centre do not depend on u
|
|
191
|
+
// the Gaussian's width and centre away from the pole, where they do not depend on u
|
|
192
192
|
hair_lobe(p, 0, cos_phi, u_v, absorption, roughness, lobe);
|
|
193
193
|
|
|
194
194
|
const beta = Math.max(lobe[0], 1e-5);
|
|
195
195
|
const centre = lobe[1];
|
|
196
|
+
const reach = Math.SQRT2 * beta * GH_X[7];
|
|
196
197
|
|
|
197
|
-
if (beta < 0.06) {
|
|
198
|
-
// narrow
|
|
198
|
+
if (beta < 0.06 && Math.abs(centre) + reach <= 1) {
|
|
199
|
+
// narrow, every node inside [-1, 1]: Gauss-Hermite about the centre
|
|
199
200
|
for (let i = 0; i < 8; i++) {
|
|
200
201
|
for (const sign of [-1, 1]) {
|
|
201
202
|
const u = centre + sign * Math.SQRT2 * beta * GH_X[i];
|
|
202
203
|
|
|
203
|
-
if (u < -1 || u > 1) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
204
|
hair_lobe(p, u, cos_phi, u_v, absorption, roughness, lobe);
|
|
208
205
|
|
|
209
206
|
sum += GH_W[i] / SQRT_PI * lobe[2];
|
|
210
207
|
}
|
|
211
208
|
}
|
|
212
209
|
} else {
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
const
|
|
210
|
+
// otherwise the integrand as it is, the lobe's width and centre taken at each u, by the midpoint rule
|
|
211
|
+
// over its support within [-1, 1]: eight widths either side of its centre, 32 steps a width
|
|
212
|
+
const lo = Math.max(-1, centre - 8 * beta);
|
|
213
|
+
const hi = Math.min(1, centre + 8 * beta);
|
|
214
|
+
const steps = Math.min(8192, Math.max(64, Math.ceil(32 * (hi - lo) / beta)));
|
|
215
|
+
const du = (hi - lo) / steps;
|
|
216
216
|
|
|
217
217
|
for (let i = 0; i < steps; i++) {
|
|
218
|
-
const u =
|
|
218
|
+
const u = lo + (i + 0.5) * du;
|
|
219
219
|
|
|
220
220
|
hair_lobe(p, u, cos_phi, u_v, absorption, roughness, lobe);
|
|
221
221
|
|
|
222
|
-
sum += gaussian(
|
|
222
|
+
sum += gaussian(lobe[0], u - lobe[1]) * lobe[2] * du;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A shadow view's rectangle as the hair draws into it.
|
|
3
|
+
* @type {WebGPUStruct}
|
|
4
|
+
*/
|
|
5
|
+
export const HAIR_SHADOW_TARGET_STRUCT: WebGPUStruct;
|
|
6
|
+
/**
|
|
7
|
+
* The bindings of {@link HAIR_SHADOW_PIPELINE}: `camera` (the shadow view's), `hair_shadow_view`, `hair_list` (the
|
|
8
|
+
* shadow views' lists) and `hair_points` (the frame's deformed points).
|
|
9
|
+
*
|
|
10
|
+
* @type {ShaderResourceSetDescriptor}
|
|
11
|
+
*/
|
|
12
|
+
export const HAIR_SHADOW_RESOURCES: ShaderResourceSetDescriptor;
|
|
13
|
+
/**
|
|
14
|
+
* Draws the frame's strands into a shadow view's depth with the rasterizer's bias (`DEPTH_STENCIL_STATE_SHADOW`), in
|
|
15
|
+
* cascades as well: a strand has no surface normal for the cascade casters' vertex-stage push to read.
|
|
16
|
+
*
|
|
17
|
+
* An instance is an entry of the view's list (`shader_hair_shadow_list`), a strand, drawn as `hair_id_draw.js` draws
|
|
18
|
+
* it for the eye: a triangle strip a pair of vertices at each of its points, `2 (2^class + 1)` vertices, one draw a
|
|
19
|
+
* point class (`shader_hair_shadow_draw_args`),
|
|
20
|
+
* across the strand's tangent and the way to the light. Its width is the strand's own, as its point carries it, also
|
|
21
|
+
* where the camera's view drew it at none. Under a texel, a point is drawn a texel wide by the strands whose
|
|
22
|
+
* stratified share is under its width's fraction of the texel, and at none by the rest, so the covered area is the
|
|
23
|
+
* strands' own at any texel size. A point nearer the light than the view's near plane is drawn on the plane. Both faces
|
|
24
|
+
* are drawn.
|
|
25
|
+
*
|
|
26
|
+
* @type {RenderPipelineDescriptor}
|
|
27
|
+
*/
|
|
28
|
+
export const HAIR_SHADOW_PIPELINE: RenderPipelineDescriptor;
|
|
29
|
+
import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
|
|
30
|
+
import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
|
|
31
|
+
import { RenderPipelineDescriptor } from "../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
|
|
32
|
+
//# sourceMappingURL=hair_shadow_draw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hair_shadow_draw.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/hair_shadow_draw.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wCAFU,YAAY,CAKQ;AA2E9B;;;;;GAKG;AACH,oCAFU,2BAA2B,CAEU;AAE/C;;;;;;;;;;;;;;GAcG;AACH,mCAFU,wBAAwB,CAQ/B;6BAlH0B,gCAAgC;4CAJjB,mDAAmD;yCAJtD,8DAA8D"}
|