@woosh/meep-engine 3.74.0 → 3.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -19
- package/package.json +1 -1
- package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts +11 -0
- package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts.map +1 -0
- package/src/core/geom/2d/hilbert/v2_hilbert_encode.js +46 -0
- package/src/engine/asset/GameAssetType.d.ts +1 -0
- package/src/engine/asset/GameAssetType.js +5 -1
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts +33 -0
- package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -0
- package/src/engine/asset/loaders/GroomAssetLoader.js +99 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts +47 -0
- package/src/engine/graphics/ecs/hair/Hair.d.ts.map +1 -0
- package/src/engine/graphics/ecs/hair/Hair.js +61 -0
- package/src/engine/graphics/hair/Groom.d.ts +130 -0
- package/src/engine/graphics/hair/Groom.d.ts.map +1 -0
- package/src/engine/graphics/hair/Groom.js +193 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +24 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/hair/GroomSerializationAdapter.js +77 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts +85 -0
- package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_build_group.js +487 -0
- package/src/engine/graphics/hair/groom_generate_scalp.d.ts +29 -0
- package/src/engine/graphics/hair/groom_generate_scalp.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_generate_scalp.js +184 -0
- package/src/engine/graphics/hair/groom_rank_order.d.ts +15 -0
- package/src/engine/graphics/hair/groom_rank_order.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_rank_order.js +53 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts +12 -0
- package/src/engine/graphics/hair/groom_root_spacing.d.ts.map +1 -0
- package/src/engine/graphics/hair/groom_root_spacing.js +120 -0
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +6 -0
- package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
- package/src/engine/graphics/render/frame_graph/FrameGraph.js +9 -0
- package/src/engine/graphics3/GPUAcousticSystem.d.ts +29 -32
- package/src/engine/graphics3/GPUAcousticSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUAcousticSystem.js +87 -162
- package/src/engine/graphics3/HairSystem.d.ts +102 -0
- package/src/engine/graphics3/HairSystem.d.ts.map +1 -0
- package/src/engine/graphics3/HairSystem.js +456 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +35 -17
- package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
- package/src/engine/sound/ecs/audio/LiveEmitterSet.js +2 -3
- package/src/engine/sound/simulation/AcousticSimulator.d.ts +7 -0
- package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
- package/src/engine/sound/simulation/AcousticSimulator.js +27 -0
- package/src/engine/sound/simulation/README.md +121 -107
- package/src/engine/sound/sopra/README.md +8 -3
- package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts +2 -2
- package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts.map +1 -1
- package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js +4 -3
- package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts +118 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.js +472 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts +166 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbLines.js +447 -0
- package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts +69 -113
- package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.js +143 -491
- package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts +102 -0
- package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/AcousticSpeakers.js +232 -0
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts +17 -3
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/BusGraph.js +55 -5
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts +8 -6
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
- package/src/engine/sound/sopra/runtime/EventInstance.js +113 -105
- package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts +13 -0
- package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.js +15 -0
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +4 -6
- package/src/shade/assets/textures/hair_scattering.bin +0 -0
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts +11 -0
- package/src/shade/device/pipeline/PipelineEnquiry.d.ts.map +1 -1
- package/src/shade/device/pipeline/PipelineEnquiry.js +13 -0
- package/src/shade/playground/hair/index.html +50 -0
- package/src/shade/playground/hair/main.d.ts +2 -0
- package/src/shade/playground/hair/main.d.ts.map +1 -0
- package/src/shade/playground/hair/main.js +274 -0
- package/src/shade/playground/screen_probes/README.md +54 -0
- package/src/shade/playground/screen_probes/index.html +271 -0
- package/src/shade/playground/screen_probes/main.d.ts +8 -0
- package/src/shade/playground/screen_probes/main.d.ts.map +1 -0
- package/src/shade/playground/screen_probes/main.js +527 -0
- package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +4 -5
- package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
- package/src/shade/playground/skinned_blas_refit/main.js +6 -12
- package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
- package/src/shade/playground/skinned_mesh_soup/main.js +1 -2
- package/src/shade/playground/vgeo_scene/README.md +12 -2
- package/src/shade/playground/vgeo_scene/main.js +1 -1
- package/src/shade/playground/volumetrics_froxel/README.md +191 -191
- package/src/shade/playground/volumetrics_froxel/measure.d.ts +3 -3
- package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
- package/src/shade/playground/volumetrics_froxel/measure.js +11 -13
- package/src/shade/playground/vsm/main.d.ts.map +1 -1
- package/src/shade/playground/vsm/main.js +5 -6
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +85 -16
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts +6 -0
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.d.ts.map +1 -1
- package/src/shade/renderer/STATIC_GRAPHICS_ENGINE_ASSETS.js +10 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts +28 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.js +42 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts +58 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.js +108 -0
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +161 -0
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/GPUAcousticProbes.js +760 -0
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts +12 -0
- package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/acoustic_listener_order.js +56 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_direct.js +5 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts +57 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.js +314 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts +15 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_finite.js +21 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_gather.js +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts +27 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_lean.js +42 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts +80 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_listener.js +274 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_partials.d.ts +2 -2
- package/src/shade/renderer/acoustics/chunk_acoustic_partials.js +2 -2
- package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts +7 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_phonon.js +24 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_resample.js +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_reservoir.js +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts +43 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_through.js +153 -0
- package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts +3 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/chunk_acoustic_trace.js +10 -1
- package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts +7 -3
- package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/shader_acoustic_combine.js +22 -6
- package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts +14 -0
- package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_coupling.js +102 -0
- package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts +12 -0
- package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_listener.js +80 -0
- package/src/shade/renderer/acoustics/shader_acoustic_receive.d.ts.map +1 -1
- package/src/shade/renderer/acoustics/shader_acoustic_receive.js +27 -6
- package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts +11 -0
- package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_room.js +111 -0
- package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts +18 -0
- package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts.map +1 -0
- package/src/shade/renderer/acoustics/shader_acoustic_source.js +130 -0
- package/src/shade/renderer/deferred/chunk_read_gBuffer_material.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_read_gBuffer_material.js +3 -1
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts +23 -0
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.d.ts.map +1 -0
- package/src/shade/renderer/deferred/chunk_shade_direct_lights.js +111 -0
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts +17 -6
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_directional_lights.js +26 -21
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts +12 -22
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct.js +20 -100
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.d.ts.map +1 -1
- package/src/shade/renderer/deferred/chunk_shade_standard_material_direct_restir.js +6 -4
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts +15 -0
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.d.ts.map +1 -0
- package/src/shade/renderer/deferred/chunk_standard_material_direct_light_lobe.js +47 -0
- package/src/shade/renderer/extension/ViewLighting.d.ts +101 -0
- package/src/shade/renderer/extension/ViewLighting.d.ts.map +1 -0
- package/src/shade/renderer/extension/ViewLighting.js +168 -0
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +2 -2
- package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts +5 -2
- package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.js +5 -2
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts +9 -2
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +48 -12
- package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts +0 -22
- package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +0 -42
- package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts +2 -18
- package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.js +2 -19
- package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.js +0 -1
- package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts +5 -4
- package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +3 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.js +3 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +0 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +60 -14
- package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +75 -39
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/brick4/gpu/draw/shader_brick4_indirect_lighting.js +3 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +0 -9
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +45 -17
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +7 -3
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +43 -7
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_indirect_lighting.js +3 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +15 -7
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +40 -9
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +23 -0
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +26 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +6 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +13 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +23 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +2 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +29 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +102 -0
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +8 -1
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +27 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +4 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +4 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +11 -5
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +28 -10
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +36 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +149 -4
- package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/shader_resolve_indirect_lighting.js +3 -1
- package/src/shade/renderer/hair/GPUHairSystem.d.ts +159 -0
- package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -0
- package/src/shade/renderer/hair/GPUHairSystem.js +1132 -0
- package/src/shade/renderer/hair/HAIR.d.ts +102 -0
- package/src/shade/renderer/hair/HAIR.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR.js +115 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts +17 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +71 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts +11 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.d.ts.map +1 -0
- package/src/shade/renderer/hair/HAIR_FRAME_STRUCTS.js +48 -0
- package/src/shade/renderer/hair/HairFrame.d.ts +41 -0
- package/src/shade/renderer/hair/HairFrame.d.ts.map +1 -0
- package/src/shade/renderer/hair/HairFrame.js +76 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +42 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_bsdf.js +170 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +30 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +131 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.d.ts +32 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_pixel.js +116 -0
- package/src/shade/renderer/hair/chunk_hair_strand.d.ts +40 -0
- package/src/shade/renderer/hair/chunk_hair_strand.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_strand.js +85 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts +31 -0
- package/src/shade/renderer/hair/chunk_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/chunk_hair_volume.js +106 -0
- package/src/shade/renderer/hair/hair_id_draw.d.ts +24 -0
- package/src/shade/renderer/hair/hair_id_draw.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_id_draw.js +135 -0
- package/src/shade/renderer/hair/hair_lighting.d.ts +53 -0
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_lighting.js +270 -0
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts +75 -0
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_scattering_lut.js +271 -0
- package/src/shade/renderer/hair/hair_stamp.d.ts +33 -0
- package/src/shade/renderer/hair/hair_stamp.d.ts.map +1 -0
- package/src/shade/renderer/hair/hair_stamp.js +175 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts +21 -0
- package/src/shade/renderer/hair/shader_hair_classes.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_classes.js +86 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts +31 -0
- package/src/shade/renderer/hair/shader_hair_cull.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_cull.js +194 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts +33 -0
- package/src/shade/renderer/hair/shader_hair_lod.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_lod.js +268 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts +28 -0
- package/src/shade/renderer/hair/shader_hair_volume.d.ts.map +1 -0
- package/src/shade/renderer/hair/shader_hair_volume.js +167 -0
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts +31 -0
- package/src/shade/renderer/loader/usd/usd_build_scene.d.ts.map +1 -1
- package/src/shade/renderer/loader/usd/usd_build_scene.js +36 -21
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts +60 -0
- package/src/shade/renderer/loader/usd/usd_groom_extension.d.ts.map +1 -0
- package/src/shade/renderer/loader/usd/usd_groom_extension.js +417 -0
- package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +4 -1
- package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.d.ts.map +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_shading_closure_from_material_data.js +3 -1
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts +4 -1
- package/src/shade/renderer/postprocess/ssr/SSR.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/SSR.js +9 -0
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts +16 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +47 -3
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/ssr_resolve_shader.js +5 -3
- package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/ssr/ssr_combine_shader.js +6 -5
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/forward/chunk_forward_shade_standard_fragment.js +5 -2
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/avboit_draw_fragment_body.js +5 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +4 -1
- package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/oit_resolve_fragment_body.js +5 -1
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/oit/shader_oit_generate_moments.js +7 -4
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +13 -8
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +18 -14
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts +3 -2
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/light/chunk_compute_multiscattering_specular.js +12 -4
- package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/material/MATERIAL_SHADING_INFO_STRUCT.js +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_compute_indirect_specular.js +1 -1
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts +16 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/material/chunk_metalness_to_specular_F90.js +25 -0
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +2 -2
- package/src/shade/renderer/shader/compiler/ShaderSwitch.d.ts +1 -1
- package/src/shade/renderer/shader/compiler/ShaderSwitchSet.d.ts +1 -1
- package/src/shade/renderer/shader/resource/ShaderResourceDescriptor.d.ts +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +2 -2
- package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +2 -2
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `B` of Chiang et al.'s colour mapping, the azimuthal roughness it is fitted at; Unreal's default.
|
|
5
|
+
* @type {number}
|
|
6
|
+
*/
|
|
7
|
+
const B = 0.3;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The mapping's denominator at {@link B} (Chiang et al. 2016, eq. 9).
|
|
11
|
+
* @type {number}
|
|
12
|
+
*/
|
|
13
|
+
const D = 5.969 - 0.215 * B + 2.532 * B ** 2 - 10.73 * B ** 3 + 5.574 * B ** 4 + 0.245 * B ** 5;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The colour of hair, as absorption inside the fibre (Chiang et al. 2016, "A Practical and Controllable Hair and Fur
|
|
17
|
+
* Model for Production Path Tracing"; d'Eon et al. 2011 for the pigments):
|
|
18
|
+
*
|
|
19
|
+
* ```wgsl
|
|
20
|
+
* fn hair_absorption(melanin: f32, redness: f32, dye: vec3<f32>) -> vec3<f32>
|
|
21
|
+
* fn hair_color_to_absorption(color: vec3<f32>) -> vec3<f32>
|
|
22
|
+
* fn hair_absorption_to_color(absorption: vec3<f32>) -> vec3<f32>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `melanin` from 0 (none) to 1 (black), `redness` the share of it that is pheomelanin, `dye` a colour whose
|
|
26
|
+
* absorption adds to the pigments' (white adds none). The two mappings are each other's inverse: the colour is what
|
|
27
|
+
* the hair looks after multiple scattering, at {@link B}. Unreal's `GetHairColorFromMelanin`, kept as absorption.
|
|
28
|
+
*
|
|
29
|
+
* @type {CodeChunk}
|
|
30
|
+
*/
|
|
31
|
+
export const chunk_hair_absorption = CodeChunk.from(
|
|
32
|
+
//language=WGSL
|
|
33
|
+
`
|
|
34
|
+
fn hair_color_to_absorption(color: vec3<f32>) -> vec3<f32> {
|
|
35
|
+
let l = log(max(color, vec3<f32>(1e-4))) / ${D};
|
|
36
|
+
|
|
37
|
+
return l * l;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fn hair_absorption_to_color(absorption: vec3<f32>) -> vec3<f32> {
|
|
41
|
+
return exp(-sqrt(absorption) * ${D});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fn hair_absorption(melanin: f32, redness: f32, dye: vec3<f32>) -> vec3<f32> {
|
|
45
|
+
let m = -log(max(1.0 - saturate(melanin), 1e-4));
|
|
46
|
+
|
|
47
|
+
let eumelanin = m * (1.0 - saturate(redness));
|
|
48
|
+
let pheomelanin = m * saturate(redness);
|
|
49
|
+
|
|
50
|
+
return eumelanin * vec3<f32>(0.506, 0.841, 1.653)
|
|
51
|
+
+ pheomelanin * vec3<f32>(0.343, 0.733, 1.924)
|
|
52
|
+
+ hair_color_to_absorption(saturate(dye));
|
|
53
|
+
}
|
|
54
|
+
`);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Light scattered by a hair fibre, single scattering: Unreal 5.4's `HairShading` (HairBsdf.ush), Marschner et al.'s
|
|
58
|
+
* three lobes in Karis's closed forms (Marschner et al. 2003; Pekelis et al. 2015 for the shapes):
|
|
59
|
+
*
|
|
60
|
+
* ```wgsl
|
|
61
|
+
* fn hair_shading(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32,
|
|
62
|
+
* backlit: f32, area: f32) -> vec3<f32>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* `l` towards the light, `v` towards the eye, `t` along the fibre **towards its root**, all unit. `roughness` is the
|
|
66
|
+
* longitudinal roughness; `area` widens every lobe, for light from a solid angle (0 for a point light); `backlit`
|
|
67
|
+
* scales the transmission and the back of the reflection, 1 for a light behind the hair to show through it.
|
|
68
|
+
*
|
|
69
|
+
* R reflects at the cuticle, its shift the cuticle's tilt and its azimuthal width separable (Unreal's strands);
|
|
70
|
+
* TT passes through the fibre, attenuated by `absorption` over its path; TRT reflects once inside. The result is what
|
|
71
|
+
* multiplies a light's radiance: no cosine is left to apply. Never negative.
|
|
72
|
+
*
|
|
73
|
+
* Unreal's Kajiya-Kay diffuse term, its own "hack approximation for multiple scattering", is not here: multiple
|
|
74
|
+
* scattering is dual scattering's to add.
|
|
75
|
+
*
|
|
76
|
+
* @type {CodeChunk}
|
|
77
|
+
*/
|
|
78
|
+
export const chunk_hair_shading = CodeChunk.from(
|
|
79
|
+
//language=WGSL
|
|
80
|
+
`
|
|
81
|
+
// a normalized Gaussian of width b
|
|
82
|
+
fn hair_gaussian(b: f32, theta: f32) -> f32 {
|
|
83
|
+
let w = max(b, 1e-5);
|
|
84
|
+
|
|
85
|
+
return exp(-0.5 * theta * theta / (w * w)) / (2.5066283 * w);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Schlick's approximation for a fibre of index 1.55
|
|
89
|
+
fn hair_fresnel(cos_theta: f32) -> f32 {
|
|
90
|
+
const F0 = 0.04652;
|
|
91
|
+
|
|
92
|
+
let x = 1.0 - cos_theta;
|
|
93
|
+
let x2 = x * x;
|
|
94
|
+
|
|
95
|
+
return F0 + (1.0 - F0) * x2 * x2 * x;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fn hair_shading(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32, backlit: f32, area: f32) -> vec3<f32> {
|
|
99
|
+
let r = clamp(roughness, 1.0 / 255.0, 1.0);
|
|
100
|
+
|
|
101
|
+
let vol = dot(v, l);
|
|
102
|
+
let sin_l = clamp(dot(t, l), -1.0, 1.0);
|
|
103
|
+
let sin_v = clamp(dot(t, v), -1.0, 1.0);
|
|
104
|
+
|
|
105
|
+
let cos_d = max(cos(0.5 * abs(asin(sin_v) - asin(sin_l))), 1e-4);
|
|
106
|
+
|
|
107
|
+
let lp = l - sin_l * t;
|
|
108
|
+
let vp = v - sin_v * t;
|
|
109
|
+
|
|
110
|
+
let cos_phi = dot(lp, vp) * inverseSqrt(dot(lp, lp) * dot(vp, vp) + 1e-4);
|
|
111
|
+
let cos_half_phi = sqrt(saturate(0.5 + 0.5 * cos_phi));
|
|
112
|
+
|
|
113
|
+
let n_prime = 1.19 / cos_d + 0.36 * cos_d;
|
|
114
|
+
|
|
115
|
+
// the cuticle's tilt shifts each lobe along the fibre
|
|
116
|
+
const SHIFT = 0.035;
|
|
117
|
+
const ALPHA_R = -SHIFT * 2.0;
|
|
118
|
+
const ALPHA_TT = SHIFT;
|
|
119
|
+
const ALPHA_TRT = SHIFT * 4.0;
|
|
120
|
+
|
|
121
|
+
let r2 = r * r;
|
|
122
|
+
|
|
123
|
+
var s = vec3<f32>(0.0);
|
|
124
|
+
|
|
125
|
+
// R
|
|
126
|
+
{
|
|
127
|
+
let sa = sin(ALPHA_R);
|
|
128
|
+
let ca = cos(ALPHA_R);
|
|
129
|
+
|
|
130
|
+
let shift = 2.0 * sa * (ca * cos_half_phi * sqrt(1.0 - sin_v * sin_v) + sa * sin_v);
|
|
131
|
+
|
|
132
|
+
let mp = hair_gaussian((area + r2) * 1.4142135 * cos_half_phi, sin_l + sin_v - shift);
|
|
133
|
+
let np = 0.25 * cos_half_phi;
|
|
134
|
+
let fp = hair_fresnel(sqrt(saturate(0.5 + 0.5 * vol)));
|
|
135
|
+
|
|
136
|
+
s += vec3<f32>(mp * np * fp * mix(1.0, backlit, saturate(-vol)));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// TT
|
|
140
|
+
{
|
|
141
|
+
let mp = hair_gaussian(area + r2 * 0.5, sin_l + sin_v - ALPHA_TT);
|
|
142
|
+
|
|
143
|
+
let a = 1.0 / n_prime;
|
|
144
|
+
let h = cos_half_phi * (1.0 + a * (0.6 - 0.8 * cos_phi));
|
|
145
|
+
|
|
146
|
+
let f = hair_fresnel(cos_d * sqrt(saturate(1.0 - h * h)));
|
|
147
|
+
let fp = (1.0 - f) * (1.0 - f);
|
|
148
|
+
|
|
149
|
+
let tp = exp(-absorption * 2.0 * abs(1.0 - (h * a) * (h * a) / cos_d));
|
|
150
|
+
let np = exp(-3.65 * cos_phi - 3.98);
|
|
151
|
+
|
|
152
|
+
s += mp * np * fp * tp * backlit;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// TRT
|
|
156
|
+
{
|
|
157
|
+
let mp = hair_gaussian(area + r2 * 2.0, sin_l + sin_v - ALPHA_TRT);
|
|
158
|
+
|
|
159
|
+
let f = hair_fresnel(cos_d * 0.5);
|
|
160
|
+
let fp = (1.0 - f) * (1.0 - f) * f;
|
|
161
|
+
|
|
162
|
+
let tp = pow(hair_absorption_to_color(absorption), vec3<f32>(0.8 / cos_d));
|
|
163
|
+
let np = exp(17.0 * cos_phi - 16.78);
|
|
164
|
+
|
|
165
|
+
s += mp * np * fp * tp;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return max(s, vec3<f32>(0.0));
|
|
169
|
+
}
|
|
170
|
+
`, [chunk_hair_absorption]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hair's average scattering table (`hair_scattering_lut.js`): x `|sin θ|` to the fibre, y roughness, z the square
|
|
3
|
+
* root of the colour; front, then back.
|
|
4
|
+
*
|
|
5
|
+
* @type {ShaderResourceDescriptor}
|
|
6
|
+
*/
|
|
7
|
+
export const HAIR_SCATTERING_LUT_RESOURCE: ShaderResourceDescriptor;
|
|
8
|
+
/**
|
|
9
|
+
* Light scattered by hair with multiple scattering: dual scattering (Zinke et al. 2008) over the single-scattering
|
|
10
|
+
* BSDF, as Unreal 5.4 composes it (ComputeDualScatteringTerms, HairStrandsDeepTransmittanceDualScattering.ush, and
|
|
11
|
+
* HairShading's `GlobalScattering * (Fs + LocalScattering)`):
|
|
12
|
+
*
|
|
13
|
+
* ```wgsl
|
|
14
|
+
* fn hair_scattering(l: vec3<f32>, v: vec3<f32>, t: vec3<f32>, absorption: vec3<f32>, roughness: f32,
|
|
15
|
+
* hair_count: f32, backlit: f32, area: f32) -> vec3<f32>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* `hair_count` is the number of strands between the point and the light (the density volume's march); one is taken
|
|
19
|
+
* off it for the strand's own. The global term passes the light through them, attenuated by the average front
|
|
20
|
+
* scattering to the power of their count and spread by their roughness; the local term adds what scatters back
|
|
21
|
+
* from the strands around the point. The average scatterings come from the table at the light's angle to the fibre,
|
|
22
|
+
* the roughness and the colour. Unreal's clamp of the roughness to [0.18, 0.6] here, which its source calls "a bit
|
|
23
|
+
* adhoc", is not taken. Its Kajiya-Kay term is not either: this is the multiple scattering it stands in for.
|
|
24
|
+
*
|
|
25
|
+
* @type {CodeChunk}
|
|
26
|
+
*/
|
|
27
|
+
export const chunk_hair_dual_scattering: CodeChunk;
|
|
28
|
+
import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
|
|
29
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
30
|
+
//# sourceMappingURL=chunk_hair_dual_scattering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_hair_dual_scattering.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/hair/chunk_hair_dual_scattering.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,2CAFU,wBAAwB,CAE6E;AAE/G;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAFU,SAAS,CAiGhB;yCA9HsC,gDAAgD;0BAD/D,iCAAiC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* `hair_count` is the number of strands between the point and the light (the density volume's march); one is taken
|
|
25
|
+
* off it for the strand's own. The global term passes the light through them, attenuated by the average front
|
|
26
|
+
* scattering to the power of their count and spread by their roughness; the local term adds what scatters back
|
|
27
|
+
* 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. Unreal's clamp of the roughness to [0.18, 0.6] here, which its source calls "a bit
|
|
29
|
+
* adhoc", is not taken. Its Kajiya-Kay term is not either: this is the multiple scattering it stands in for.
|
|
30
|
+
*
|
|
31
|
+
* @type {CodeChunk}
|
|
32
|
+
*/
|
|
33
|
+
export const chunk_hair_dual_scattering = CodeChunk.from(
|
|
34
|
+
//language=WGSL
|
|
35
|
+
`
|
|
36
|
+
// an unnormalized Gaussian of variance v
|
|
37
|
+
fn hair_gaussian_unnormalized(v: f32, theta: f32) -> f32 {
|
|
38
|
+
return exp(-0.5 * theta * theta / max(v, 1e-10));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
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> {
|
|
42
|
+
let single = hair_shading(l, v, t, absorption, roughness, backlit, area);
|
|
43
|
+
|
|
44
|
+
let sin_l = clamp(dot(t, l), -1.0, 1.0);
|
|
45
|
+
let sin_v = clamp(dot(t, v), -1.0, 1.0);
|
|
46
|
+
|
|
47
|
+
// the table, a channel at a time, at the colour's square root
|
|
48
|
+
let color = hair_absorption_to_color(absorption);
|
|
49
|
+
let z = sqrt(saturate(color));
|
|
50
|
+
let x = saturate(abs(sin_l));
|
|
51
|
+
let y = saturate(roughness);
|
|
52
|
+
|
|
53
|
+
let s_r = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.r), 0.0).rg;
|
|
54
|
+
let s_g = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.g), 0.0).rg;
|
|
55
|
+
let s_b = textureSampleLevel(tHairScattering, sLinear, vec3<f32>(x, y, z.b), 0.0).rg;
|
|
56
|
+
|
|
57
|
+
let a_front = vec3<f32>(s_r.x, s_g.x, s_b.x);
|
|
58
|
+
let a_back = vec3<f32>(s_r.y, s_g.y, s_b.y);
|
|
59
|
+
|
|
60
|
+
const MAX_AVERAGE = 0.99;
|
|
61
|
+
|
|
62
|
+
let af = min(vec3<f32>(MAX_AVERAGE), a_front);
|
|
63
|
+
let af2 = af * af;
|
|
64
|
+
let ab = min(vec3<f32>(MAX_AVERAGE), a_back);
|
|
65
|
+
let ab2 = ab * ab;
|
|
66
|
+
let one_minus_af2 = 1.0 - af2;
|
|
67
|
+
|
|
68
|
+
let a1 = ab * af2 / one_minus_af2;
|
|
69
|
+
let a3 = ab * ab2 * af2 / (one_minus_af2 * one_minus_af2 * one_minus_af2);
|
|
70
|
+
let a_b = a1 + a3;
|
|
71
|
+
|
|
72
|
+
let beta_r = roughness * roughness;
|
|
73
|
+
let beta_tt = (roughness * 0.5) * (roughness * 0.5);
|
|
74
|
+
let beta_trt = (roughness * 2.0) * (roughness * 2.0);
|
|
75
|
+
|
|
76
|
+
const SHIFT_R = -0.035 * 2.0;
|
|
77
|
+
const SHIFT_TT = 0.035;
|
|
78
|
+
const SHIFT_TRT = 0.035 * 4.0;
|
|
79
|
+
|
|
80
|
+
// the paper's density factors
|
|
81
|
+
const DF = 0.7;
|
|
82
|
+
const DB = 0.7;
|
|
83
|
+
|
|
84
|
+
let count = max(0.0, hair_count - 1.0);
|
|
85
|
+
|
|
86
|
+
let af_weights = af / max(af.r + af.g + af.b, 1e-6);
|
|
87
|
+
let beta_f = vec3<f32>(dot(vec3<f32>(beta_r, beta_tt, beta_trt), af_weights));
|
|
88
|
+
let beta_f2 = beta_f * beta_f;
|
|
89
|
+
let sigma_f2 = beta_f2 * max(1.0, count);
|
|
90
|
+
|
|
91
|
+
let theta_h = 0.5 * (asin(sin_l) + asin(sin_v));
|
|
92
|
+
|
|
93
|
+
let sf = vec3<f32>(
|
|
94
|
+
hair_gaussian_unnormalized(sigma_f2.r, theta_h),
|
|
95
|
+
hair_gaussian_unnormalized(sigma_f2.g, theta_h),
|
|
96
|
+
hair_gaussian_unnormalized(sigma_f2.b, theta_h),
|
|
97
|
+
) / 3.14159265;
|
|
98
|
+
|
|
99
|
+
let tf = pow(a_front, vec3<f32>(count));
|
|
100
|
+
|
|
101
|
+
let shift_f = vec3<f32>(dot(vec3<f32>(SHIFT_R, SHIFT_TT, SHIFT_TRT), af_weights));
|
|
102
|
+
let shift_b = shift_f;
|
|
103
|
+
let delta_b = shift_b * (1.0 - 2.0 * ab2 / (one_minus_af2 * one_minus_af2)) * shift_f
|
|
104
|
+
* (2.0 * one_minus_af2 * one_minus_af2 + 4.0 * af2 * ab2) / (one_minus_af2 * one_minus_af2 * one_minus_af2);
|
|
105
|
+
|
|
106
|
+
let ab_weights = ab / max(ab.r + ab.g + ab.b, 1e-6);
|
|
107
|
+
let beta_b = vec3<f32>(dot(vec3<f32>(beta_r, beta_tt, beta_trt), ab_weights));
|
|
108
|
+
let beta_b2 = beta_b * beta_b;
|
|
109
|
+
|
|
110
|
+
let spread = sqrt(2.0 * beta_f2 + beta_b2);
|
|
111
|
+
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));
|
|
112
|
+
let sigma_b2 = sigma_b * sigma_b;
|
|
113
|
+
|
|
114
|
+
let sb = vec3<f32>(
|
|
115
|
+
hair_gaussian_unnormalized(sigma_f2.r + sigma_b2.r, theta_h - delta_b.r),
|
|
116
|
+
hair_gaussian_unnormalized(sigma_f2.g + sigma_b2.g, theta_h - delta_b.g),
|
|
117
|
+
hair_gaussian_unnormalized(sigma_f2.b + sigma_b2.b, theta_h - delta_b.b),
|
|
118
|
+
) / 3.14159265;
|
|
119
|
+
|
|
120
|
+
let global_scattering = mix(vec3<f32>(1.0), tf * sf * DF, saturate(count));
|
|
121
|
+
let local_scattering = 2.0 * a_b * sb * DB;
|
|
122
|
+
|
|
123
|
+
return max(global_scattering * (single + local_scattering), vec3<f32>(0.0));
|
|
124
|
+
}
|
|
125
|
+
`, [
|
|
126
|
+
chunk_hair_absorption,
|
|
127
|
+
chunk_hair_shading,
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
chunk_hair_dual_scattering.requireResource(HAIR_SCATTERING_LUT_RESOURCE);
|
|
131
|
+
chunk_hair_dual_scattering.requireResource(SAMPLER_LINEAR_RESOURCE);
|
|
@@ -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"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CAMERA_RESOURCE } from "../camera/CAMERA_RESOURCE.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 { HAIR_INSTANCE_STRUCT } from "./HAIR_DATABASE_SPEC.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Every groom's rest points and strand words, a run a groom (`GPUHairSystem`), as `u32` words.
|
|
9
|
+
*
|
|
10
|
+
* @type {ShaderResourceDescriptor}
|
|
11
|
+
*/
|
|
12
|
+
export const HAIR_GROOMS_RESOURCE = ShaderResourceDescriptor.storageBuffer("hair_grooms", WebGPUArray.u32);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A rest point of a strand of an instance's group, from the groom pool:
|
|
16
|
+
*
|
|
17
|
+
* ```wgsl
|
|
18
|
+
* fn hair_rest_point(instance: HairInstance, strand: u32, point: u32) -> vec4<f32>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* x, y, z in the groom's metres, then the point's width in them. `strand` is the strand's rank, `point` its index
|
|
22
|
+
* from the root.
|
|
23
|
+
*
|
|
24
|
+
* @type {CodeChunk}
|
|
25
|
+
*/
|
|
26
|
+
export const chunk_hair_rest_point = CodeChunk.from(
|
|
27
|
+
//language=WGSL
|
|
28
|
+
`
|
|
29
|
+
fn hair_rest_point(instance: ${HAIR_INSTANCE_STRUCT.wgsl_ref}, strand: u32, point: u32) -> vec4<f32> {
|
|
30
|
+
let at = instance.points + (strand * instance.point_count + point) * 2u;
|
|
31
|
+
|
|
32
|
+
let w0 = hair_grooms[at];
|
|
33
|
+
let w1 = hair_grooms[at + 1u];
|
|
34
|
+
|
|
35
|
+
let q = vec3<f32>(f32(w0 & 0xFFFFu), f32(w0 >> 16u), f32(w1 & 0xFFFFu)) * (1.0 / 65535.0);
|
|
36
|
+
let width = f32((w1 >> 16u) & 0xFFu) * (1.0 / 255.0) * instance.width_max;
|
|
37
|
+
|
|
38
|
+
return vec4<f32>(instance.bounds_min + q * instance.bounds_extent, width);
|
|
39
|
+
}
|
|
40
|
+
`, [
|
|
41
|
+
HAIR_INSTANCE_STRUCT.declaration_chunk,
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
chunk_hair_rest_point.requireResource(HAIR_GROOMS_RESOURCE);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The level of detail's arithmetic (Cook & Halstead's area rule):
|
|
48
|
+
*
|
|
49
|
+
* ```wgsl
|
|
50
|
+
* fn hair_pixel_size(depth: f32, height: f32) -> f32
|
|
51
|
+
* fn hair_kept_fraction(mean_width: f32, pixel_size: f32, floor_pixels: f32) -> f32
|
|
52
|
+
* fn hair_view_depth(world: vec3<f32>) -> f32
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* `hair_pixel_size` is the world size of a pixel at view depth `depth` for a view `height` pixels tall, under the
|
|
56
|
+
* camera's projection, perspective or orthographic. `hair_kept_fraction` is the share of a group's strands drawn
|
|
57
|
+
* where a pixel is `pixel_size` across: all of them while their mean width is at least `floor_pixels` pixels, and
|
|
58
|
+
* fewer in proportion below it, each widened by the reciprocal so their area is kept. `hair_view_depth` is a world
|
|
59
|
+
* point's planar depth in front of the camera.
|
|
60
|
+
*
|
|
61
|
+
* @type {CodeChunk}
|
|
62
|
+
*/
|
|
63
|
+
export const chunk_hair_lod = CodeChunk.from(
|
|
64
|
+
//language=WGSL
|
|
65
|
+
`
|
|
66
|
+
fn hair_pixel_size(depth: f32, height: f32) -> f32 {
|
|
67
|
+
let p = camera.projection_matrix;
|
|
68
|
+
|
|
69
|
+
// the clip w at that depth: the depth itself under a perspective projection, one under an orthographic one
|
|
70
|
+
let w = -p[2][3] * depth + p[3][3];
|
|
71
|
+
|
|
72
|
+
return 2.0 * w / (height * p[1][1]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fn hair_kept_fraction(mean_width: f32, pixel_size: f32, floor_pixels: f32) -> f32 {
|
|
76
|
+
return min(1.0, mean_width / max(floor_pixels * pixel_size, 1e-20));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
fn hair_view_depth(world: vec3<f32>) -> f32 {
|
|
80
|
+
return -(camera.view_matrix * vec4<f32>(world, 1.0)).z;
|
|
81
|
+
}
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
chunk_hair_lod.requireResource(CAMERA_RESOURCE);
|
|
85
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An instance's density volume (`HAIR.js`), as its LOD record places it in the frame's voxels:
|
|
3
|
+
*
|
|
4
|
+
* ```wgsl
|
|
5
|
+
* fn hair_volume_dims(lod: HairLod, mip: u32) -> vec3<u32>
|
|
6
|
+
* fn hair_volume_index(lod: HairLod, cell: vec3<u32>, mip: u32) -> u32
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* A voxel holds the strands a ray crosses along one voxel edge of the full resolution, in 16.16 fixed point; mip `m`
|
|
10
|
+
* holds the mean of the `2^m`-cubes under it, in the same units.
|
|
11
|
+
*
|
|
12
|
+
* @type {CodeChunk}
|
|
13
|
+
*/
|
|
14
|
+
export const chunk_hair_volume_layout: CodeChunk;
|
|
15
|
+
/**
|
|
16
|
+
* The number of strands between a point and the edge of its instance's volume, along a direction:
|
|
17
|
+
*
|
|
18
|
+
* ```wgsl
|
|
19
|
+
* fn hair_count_along(lod: HairLod, position: vec3<f32>, direction: vec3<f32>, jitter: f32) -> f32
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Eight taps, a constant trip count: the march starts one voxel out, steps one voxel twice, then doubles its step
|
|
23
|
+
* 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
|
+
* accumulation to filter the voxels' edges. Reads `hair_volume`.
|
|
26
|
+
*
|
|
27
|
+
* @type {CodeChunk}
|
|
28
|
+
*/
|
|
29
|
+
export const chunk_hair_count_along: CodeChunk;
|
|
30
|
+
import { CodeChunk } from "../shader/compiler/CodeChunk.js";
|
|
31
|
+
//# sourceMappingURL=chunk_hair_volume.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;GAaG;AACH,qCAFU,SAAS,CAkDY;0BAzGL,iCAAiC"}
|