@zephyr3d/scene 0.9.26 → 0.10.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/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +146 -30
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +300 -56
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +177 -3
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +178 -200
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +30475 -19865
- package/dist/index.js +67 -12
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/hairstrand.js +235 -235
- package/dist/material/hairstrand.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +362 -300
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +223 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +733 -190
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +2009 -201
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +668 -63
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +48 -50
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +34 -15
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +40 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +328 -62
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +26 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +53 -53
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +8 -13
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +268 -136
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +113 -28
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/hzb.js +80 -22
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +23 -9
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/oit.js +11 -11
- package/dist/render/oit.js.map +1 -1
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +198 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +14 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +15 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +585 -59
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +524 -0
- package/dist/render/underwater.js.map +1 -0
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +1195 -0
- package/dist/render/water_caustics.js.map +1 -0
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +36 -36
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +997 -96
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +40 -87
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +42 -0
- package/dist/shaders/water_medium.js.map +1 -0
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +87 -49
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +36 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +77 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +140 -279
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +2473 -114
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +97 -109
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
|
@@ -2,34 +2,34 @@ import { HairMaterial } from './hair.js';
|
|
|
2
2
|
import { ShaderHelper } from './shader/helper.js';
|
|
3
3
|
import { Vector4 } from '@zephyr3d/base';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Hair material that expands strand control points into ribbons on the GPU.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Where {@link HairMaterial} shades ribbon geometry that something else built,
|
|
10
|
-
* this material builds the ribbon itself. The vertex shader derives which strand,
|
|
11
|
-
* which segment and which corner it is drawing from the vertex index alone, reads
|
|
12
|
-
* the control points from a storage buffer, and emits a camera-facing quad. No
|
|
13
|
-
* position, normal, tangent or texture coordinate attribute is read.
|
|
14
|
-
*
|
|
15
|
-
* Two things fall out of that, and both are the reason to do it:
|
|
16
|
-
*
|
|
17
|
-
* - **Memory.** A CPU-built ribbon mesh for a full 69k-strand hair set costs
|
|
18
|
-
* around 266 MB of vertex data. The control points it is built from are about
|
|
19
|
-
* 20 MB, and that is all this material needs resident.
|
|
20
|
-
* - **Orientation.** A stored ribbon has a fixed plane, so there is a viewing
|
|
21
|
-
* angle at which it degenerates to an edge, and a whole coplanar group of
|
|
22
|
-
* strands can vanish at once. A quad expanded toward the camera never does.
|
|
23
|
-
*
|
|
24
|
-
* Lighting is inherited unchanged from {@link HairMaterial}, so the two paths
|
|
25
|
-
* shade identically and can be compared against each other.
|
|
26
|
-
*
|
|
27
|
-
* Control points are read in the drawing node's local space and put through its
|
|
28
|
-
* world matrix, so a groom follows the node it hangs off - a head bone, say -
|
|
29
|
-
* and several nodes can share one set of strands at different transforms.
|
|
30
|
-
*
|
|
31
|
-
* Requires storage buffers in the vertex stage, which means WebGPU.
|
|
32
|
-
* @public
|
|
5
|
+
/**
|
|
6
|
+
* Hair material that expands strand control points into ribbons on the GPU.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Where {@link HairMaterial} shades ribbon geometry that something else built,
|
|
10
|
+
* this material builds the ribbon itself. The vertex shader derives which strand,
|
|
11
|
+
* which segment and which corner it is drawing from the vertex index alone, reads
|
|
12
|
+
* the control points from a storage buffer, and emits a camera-facing quad. No
|
|
13
|
+
* position, normal, tangent or texture coordinate attribute is read.
|
|
14
|
+
*
|
|
15
|
+
* Two things fall out of that, and both are the reason to do it:
|
|
16
|
+
*
|
|
17
|
+
* - **Memory.** A CPU-built ribbon mesh for a full 69k-strand hair set costs
|
|
18
|
+
* around 266 MB of vertex data. The control points it is built from are about
|
|
19
|
+
* 20 MB, and that is all this material needs resident.
|
|
20
|
+
* - **Orientation.** A stored ribbon has a fixed plane, so there is a viewing
|
|
21
|
+
* angle at which it degenerates to an edge, and a whole coplanar group of
|
|
22
|
+
* strands can vanish at once. A quad expanded toward the camera never does.
|
|
23
|
+
*
|
|
24
|
+
* Lighting is inherited unchanged from {@link HairMaterial}, so the two paths
|
|
25
|
+
* shade identically and can be compared against each other.
|
|
26
|
+
*
|
|
27
|
+
* Control points are read in the drawing node's local space and put through its
|
|
28
|
+
* world matrix, so a groom follows the node it hangs off - a head bone, say -
|
|
29
|
+
* and several nodes can share one set of strands at different transforms.
|
|
30
|
+
*
|
|
31
|
+
* Requires storage buffers in the vertex stage, which means WebGPU.
|
|
32
|
+
* @public
|
|
33
33
|
*/ class HairStrandMaterial extends HairMaterial {
|
|
34
34
|
/** @internal Enables per-strand distance decimation in the vertex shader. */ static FEATURE_STRAND_LOD = this.defineFeature();
|
|
35
35
|
/** @internal Samples a second point buffer to build motion vectors. */ static FEATURE_STRAND_MOTION = this.defineFeature();
|
|
@@ -46,8 +46,8 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
46
46
|
/** @internal Scratch vector, so applying uniforms allocates nothing. */ _strandScratch;
|
|
47
47
|
/** @internal Scratch vector for the LOD uniform. */ _lodScratch;
|
|
48
48
|
/** @internal Scratch vector for the shape uniform. */ _shapeScratch;
|
|
49
|
-
/**
|
|
50
|
-
* Creates a GPU strand material.
|
|
49
|
+
/**
|
|
50
|
+
* Creates a GPU strand material.
|
|
51
51
|
*/ constructor(){
|
|
52
52
|
super();
|
|
53
53
|
this._strands = null;
|
|
@@ -114,13 +114,13 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
114
114
|
this.uniformChanged();
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Ribbon segments generated per strand.
|
|
119
|
-
*
|
|
120
|
-
* @remarks
|
|
121
|
-
* The primary quality/cost dial, and independent of the control point count:
|
|
122
|
-
* the shader resamples the curve, so the same 30-point strand can be drawn with
|
|
123
|
-
* 12 segments up close and 3 far away.
|
|
117
|
+
/**
|
|
118
|
+
* Ribbon segments generated per strand.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* The primary quality/cost dial, and independent of the control point count:
|
|
122
|
+
* the shader resamples the curve, so the same 30-point strand can be drawn with
|
|
123
|
+
* 12 segments up close and 3 far away.
|
|
124
124
|
*/ get segmentsPerStrand() {
|
|
125
125
|
return this._segmentsPerStrand;
|
|
126
126
|
}
|
|
@@ -150,15 +150,15 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
150
150
|
this.uniformChanged();
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Lower bound on ribbon width in pixels.
|
|
155
|
-
*
|
|
156
|
-
* @remarks
|
|
157
|
-
* A strand narrower than a pixel rasterises to a flickering dotted line,
|
|
158
|
-
* because whether a given segment covers a sample point changes with subpixel
|
|
159
|
-
* position. Clamping the quad to about a pixel and scaling alpha by how much it
|
|
160
|
-
* was widened keeps total energy roughly constant, so the strand reads as
|
|
161
|
-
* fainter rather than as broken. Set to 0 to disable.
|
|
153
|
+
/**
|
|
154
|
+
* Lower bound on ribbon width in pixels.
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* A strand narrower than a pixel rasterises to a flickering dotted line,
|
|
158
|
+
* because whether a given segment covers a sample point changes with subpixel
|
|
159
|
+
* position. Clamping the quad to about a pixel and scaling alpha by how much it
|
|
160
|
+
* was widened keeps total energy roughly constant, so the strand reads as
|
|
161
|
+
* fainter rather than as broken. Set to 0 to disable.
|
|
162
162
|
*/ get minPixelWidth() {
|
|
163
163
|
return this._minPixelWidth;
|
|
164
164
|
}
|
|
@@ -169,45 +169,45 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
169
169
|
this.uniformChanged();
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Trades strand count for strand opacity with distance.
|
|
174
|
-
*
|
|
175
|
-
* @remarks
|
|
176
|
-
* Past the point where a strand is thinner than a pixel, {@link minPixelWidth}
|
|
177
|
-
* widens it and pays the widening back as alpha, so a distant groom is drawn as
|
|
178
|
-
* tens of thousands of ribbons each contributing a few percent of a pixel. That
|
|
179
|
-
* is correct on average and unstable in practice: any per-fragment stochastic
|
|
180
|
-
* alpha - `alphaDither`, alpha-to-coverage - is sampling a five percent event
|
|
181
|
-
* once per pixel per frame, and the variance reads as pixel-level crawl that a
|
|
182
|
-
* temporal filter's short history cannot average away.
|
|
183
|
-
*
|
|
184
|
-
* This moves the randomness from the fragment to the strand. Each strand is
|
|
185
|
-
* kept with a probability equal to the coverage it would have been drawn at and
|
|
186
|
-
* the survivors are drawn at full coverage, which puts the same quantity of hair
|
|
187
|
-
* on screen: `N` strands at alpha `a` and `N*a` strands at alpha 1 integrate to
|
|
188
|
-
* the same image. The difference is that the draw is decided once per strand
|
|
189
|
-
* from a fixed seed rather than once per fragment per frame, so the result is
|
|
190
|
-
* stable across frames, and the culled strands cost no fragments at all.
|
|
191
|
-
*
|
|
192
|
-
* Off by default: it changes which strands are drawn, so it is opted into
|
|
193
|
-
* rather than applied to existing grooms silently.
|
|
172
|
+
/**
|
|
173
|
+
* Trades strand count for strand opacity with distance.
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* Past the point where a strand is thinner than a pixel, {@link minPixelWidth}
|
|
177
|
+
* widens it and pays the widening back as alpha, so a distant groom is drawn as
|
|
178
|
+
* tens of thousands of ribbons each contributing a few percent of a pixel. That
|
|
179
|
+
* is correct on average and unstable in practice: any per-fragment stochastic
|
|
180
|
+
* alpha - `alphaDither`, alpha-to-coverage - is sampling a five percent event
|
|
181
|
+
* once per pixel per frame, and the variance reads as pixel-level crawl that a
|
|
182
|
+
* temporal filter's short history cannot average away.
|
|
183
|
+
*
|
|
184
|
+
* This moves the randomness from the fragment to the strand. Each strand is
|
|
185
|
+
* kept with a probability equal to the coverage it would have been drawn at and
|
|
186
|
+
* the survivors are drawn at full coverage, which puts the same quantity of hair
|
|
187
|
+
* on screen: `N` strands at alpha `a` and `N*a` strands at alpha 1 integrate to
|
|
188
|
+
* the same image. The difference is that the draw is decided once per strand
|
|
189
|
+
* from a fixed seed rather than once per fragment per frame, so the result is
|
|
190
|
+
* stable across frames, and the culled strands cost no fragments at all.
|
|
191
|
+
*
|
|
192
|
+
* Off by default: it changes which strands are drawn, so it is opted into
|
|
193
|
+
* rather than applied to existing grooms silently.
|
|
194
194
|
*/ get strandLOD() {
|
|
195
195
|
return this.featureUsed(HairStrandMaterial.FEATURE_STRAND_LOD);
|
|
196
196
|
}
|
|
197
197
|
set strandLOD(val) {
|
|
198
198
|
this.useFeature(HairStrandMaterial.FEATURE_STRAND_LOD, !!val);
|
|
199
199
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Control points as of the previously rendered frame, or null.
|
|
202
|
-
*
|
|
203
|
-
* @remarks
|
|
204
|
-
* Set by {@link HairNode} while a simulation is running. Without it the
|
|
205
|
-
* previous position is the *current* control point put through the previous
|
|
206
|
-
* world matrix, which carries the node's motion but none of the strand's own -
|
|
207
|
-
* so a groom swinging under a still head reports no motion at all, and a
|
|
208
|
-
* temporal filter blends a history that has nothing to do with the pixel.
|
|
209
|
-
* Costs four extra point fetches per vertex, hence a feature rather than an
|
|
210
|
-
* always-on path: a static groom does not need it.
|
|
200
|
+
/**
|
|
201
|
+
* Control points as of the previously rendered frame, or null.
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* Set by {@link HairNode} while a simulation is running. Without it the
|
|
205
|
+
* previous position is the *current* control point put through the previous
|
|
206
|
+
* world matrix, which carries the node's motion but none of the strand's own -
|
|
207
|
+
* so a groom swinging under a still head reports no motion at all, and a
|
|
208
|
+
* temporal filter blends a history that has nothing to do with the pixel.
|
|
209
|
+
* Costs four extra point fetches per vertex, hence a feature rather than an
|
|
210
|
+
* always-on path: a static groom does not need it.
|
|
211
211
|
*/ get prevPoints() {
|
|
212
212
|
return this._prevPoints;
|
|
213
213
|
}
|
|
@@ -218,14 +218,14 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
218
218
|
/** Whether motion vectors follow the control points. @internal */ get strandMotion() {
|
|
219
219
|
return this.featureUsed(HairStrandMaterial.FEATURE_STRAND_MOTION);
|
|
220
220
|
}
|
|
221
|
-
/**
|
|
222
|
-
* Floor on the fraction of strands {@link strandLOD} keeps.
|
|
223
|
-
*
|
|
224
|
-
* @remarks
|
|
225
|
-
* Decimation follows coverage, and coverage falls without bound as the groom
|
|
226
|
-
* recedes, so an unclamped ratio eventually culls every strand and the hair
|
|
227
|
-
* disappears. This is the point past which thinning stops and the remaining
|
|
228
|
-
* strands simply fade instead. Defaults to 0.05.
|
|
221
|
+
/**
|
|
222
|
+
* Floor on the fraction of strands {@link strandLOD} keeps.
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* Decimation follows coverage, and coverage falls without bound as the groom
|
|
226
|
+
* recedes, so an unclamped ratio eventually culls every strand and the hair
|
|
227
|
+
* disappears. This is the point past which thinning stops and the remaining
|
|
228
|
+
* strands simply fade instead. Defaults to 0.05.
|
|
229
229
|
*/ get minStrandLODRatio() {
|
|
230
230
|
return this._minStrandLODRatio;
|
|
231
231
|
}
|
|
@@ -236,25 +236,25 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
236
236
|
this.uniformChanged();
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
/**
|
|
240
|
-
* How far the shading normal bends across the ribbon, in [0, 1].
|
|
241
|
-
*
|
|
242
|
-
* @remarks
|
|
243
|
-
* The quad is a stand-in for a cylinder, and this is how much it is shaded like
|
|
244
|
-
* one. At 1 the normal sweeps a full half turn about the curve tangent between
|
|
245
|
-
* the two edges, as the visible surface of a fibre does; at 0 it stays the
|
|
246
|
-
* quad's own normal and every fragment across the width shades identically,
|
|
247
|
-
* which is the flat ribbon this material drew before.
|
|
248
|
-
*
|
|
249
|
-
* It matters more than its size suggests. A flat ribbon has one normal, so the
|
|
250
|
-
* specular lobes either fire across the strand's whole width or not at all, and
|
|
251
|
-
* a groom becomes a field of uniformly bright or uniformly dull tape. Bending
|
|
252
|
-
* the normal puts a narrow highlight down the length of each strand and lets the
|
|
253
|
-
* edges fall off, which is most of what separates strands from one another when
|
|
254
|
-
* they are all the same colour.
|
|
255
|
-
*
|
|
256
|
-
* Values below 1 keep the highlight but widen it, which reads as a softer,
|
|
257
|
-
* thicker fibre; artists after a stylised look sometimes want that.
|
|
239
|
+
/**
|
|
240
|
+
* How far the shading normal bends across the ribbon, in [0, 1].
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* The quad is a stand-in for a cylinder, and this is how much it is shaded like
|
|
244
|
+
* one. At 1 the normal sweeps a full half turn about the curve tangent between
|
|
245
|
+
* the two edges, as the visible surface of a fibre does; at 0 it stays the
|
|
246
|
+
* quad's own normal and every fragment across the width shades identically,
|
|
247
|
+
* which is the flat ribbon this material drew before.
|
|
248
|
+
*
|
|
249
|
+
* It matters more than its size suggests. A flat ribbon has one normal, so the
|
|
250
|
+
* specular lobes either fire across the strand's whole width or not at all, and
|
|
251
|
+
* a groom becomes a field of uniformly bright or uniformly dull tape. Bending
|
|
252
|
+
* the normal puts a narrow highlight down the length of each strand and lets the
|
|
253
|
+
* edges fall off, which is most of what separates strands from one another when
|
|
254
|
+
* they are all the same colour.
|
|
255
|
+
*
|
|
256
|
+
* Values below 1 keep the highlight but widen it, which reads as a softer,
|
|
257
|
+
* thicker fibre; artists after a stylised look sometimes want that.
|
|
258
258
|
*/ get strandRoundness() {
|
|
259
259
|
return this._strandRoundness;
|
|
260
260
|
}
|
|
@@ -265,28 +265,28 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
265
265
|
this.uniformChanged();
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Strength of the root-depth ambient occlusion, in [0, 1].
|
|
270
|
-
*
|
|
271
|
-
* @remarks
|
|
272
|
-
* Environment irradiance is not attenuated by anything - a shadow map answers
|
|
273
|
-
* for one light, not for the sky - so without this every strand of a groom
|
|
274
|
-
* receives the full sky, and a dense hairstyle lights up as brightly in its
|
|
275
|
-
* interior as on its surface. That reads as a flat silhouette with no volume,
|
|
276
|
-
* and it is most obvious on pale hair, where there is little pigment to darken
|
|
277
|
-
* the interior instead.
|
|
278
|
-
*
|
|
279
|
-
* Real occlusion would need to know how much hair sits between a fibre and the
|
|
280
|
-
* sky. This approximates that by where along the strand the fragment is: roots
|
|
281
|
-
* grow from the scalp, buried under everything above them, while tips are on
|
|
282
|
-
* the outside. It is only an approximation - a tip tucked under a fringe is
|
|
283
|
-
* treated as exposed - but it is free, it needs no texture coordinates, which
|
|
284
|
-
* this material has none of, and it captures the dominant effect. Set to 0 to
|
|
285
|
-
* disable.
|
|
286
|
-
*
|
|
287
|
-
* Applied to ambient light and the scatter term only. Direct light keeps its
|
|
288
|
-
* own answer - the shadow map, or DOM's graded transmittance - and multiplying
|
|
289
|
-
* this on top would count the same blockage twice.
|
|
268
|
+
/**
|
|
269
|
+
* Strength of the root-depth ambient occlusion, in [0, 1].
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* Environment irradiance is not attenuated by anything - a shadow map answers
|
|
273
|
+
* for one light, not for the sky - so without this every strand of a groom
|
|
274
|
+
* receives the full sky, and a dense hairstyle lights up as brightly in its
|
|
275
|
+
* interior as on its surface. That reads as a flat silhouette with no volume,
|
|
276
|
+
* and it is most obvious on pale hair, where there is little pigment to darken
|
|
277
|
+
* the interior instead.
|
|
278
|
+
*
|
|
279
|
+
* Real occlusion would need to know how much hair sits between a fibre and the
|
|
280
|
+
* sky. This approximates that by where along the strand the fragment is: roots
|
|
281
|
+
* grow from the scalp, buried under everything above them, while tips are on
|
|
282
|
+
* the outside. It is only an approximation - a tip tucked under a fringe is
|
|
283
|
+
* treated as exposed - but it is free, it needs no texture coordinates, which
|
|
284
|
+
* this material has none of, and it captures the dominant effect. Set to 0 to
|
|
285
|
+
* disable.
|
|
286
|
+
*
|
|
287
|
+
* Applied to ambient light and the scatter term only. Direct light keeps its
|
|
288
|
+
* own answer - the shadow map, or DOM's graded transmittance - and multiplying
|
|
289
|
+
* this on top would count the same blockage twice.
|
|
290
290
|
*/ get rootOcclusion() {
|
|
291
291
|
return this._rootOcclusion;
|
|
292
292
|
}
|
|
@@ -297,13 +297,13 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
297
297
|
this.uniformChanged();
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
/**
|
|
301
|
-
* How far along a strand the root occlusion reaches, in (0, 1].
|
|
302
|
-
*
|
|
303
|
-
* @remarks
|
|
304
|
-
* The fraction of the strand's length over which occlusion fades from full at
|
|
305
|
-
* the root to none. Short for a groom whose strands leave the scalp quickly,
|
|
306
|
-
* longer for one where they lie against each other most of their length.
|
|
300
|
+
/**
|
|
301
|
+
* How far along a strand the root occlusion reaches, in (0, 1].
|
|
302
|
+
*
|
|
303
|
+
* @remarks
|
|
304
|
+
* The fraction of the strand's length over which occlusion fades from full at
|
|
305
|
+
* the root to none. Short for a groom whose strands leave the scalp quickly,
|
|
306
|
+
* longer for one where they lie against each other most of their length.
|
|
307
307
|
*/ get rootOcclusionRange() {
|
|
308
308
|
return this._rootOcclusionRange;
|
|
309
309
|
}
|
|
@@ -314,24 +314,24 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
314
314
|
this.uniformChanged();
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
/**
|
|
318
|
-
* Vertex count needed to draw the current strand set.
|
|
319
|
-
*
|
|
320
|
-
* @remarks
|
|
321
|
-
* Assign this to the primitive's `indexCount`. Drawing is non-indexed, with six
|
|
322
|
-
* vertices per ribbon segment forming two triangles.
|
|
317
|
+
/**
|
|
318
|
+
* Vertex count needed to draw the current strand set.
|
|
319
|
+
*
|
|
320
|
+
* @remarks
|
|
321
|
+
* Assign this to the primitive's `indexCount`. Drawing is non-indexed, with six
|
|
322
|
+
* vertices per ribbon segment forming two triangles.
|
|
323
323
|
*/ get vertexCount() {
|
|
324
324
|
return this._strands ? this._strands.strandCount * this._segmentsPerStrand * 6 : 0;
|
|
325
325
|
}
|
|
326
|
-
/**
|
|
327
|
-
* Albedo, with alpha scaled by how much the ribbon was widened to meet the
|
|
328
|
-
* pixel floor.
|
|
329
|
-
*
|
|
330
|
-
* @remarks
|
|
331
|
-
* Widening a sub-pixel strand to a pixel adds coverage that is not physically
|
|
332
|
-
* there. Scaling alpha by the inverse keeps the strand's contribution roughly
|
|
333
|
-
* constant, so distant hair thins out in opacity instead of breaking into a
|
|
334
|
-
* flickering dotted line.
|
|
326
|
+
/**
|
|
327
|
+
* Albedo, with alpha scaled by how much the ribbon was widened to meet the
|
|
328
|
+
* pixel floor.
|
|
329
|
+
*
|
|
330
|
+
* @remarks
|
|
331
|
+
* Widening a sub-pixel strand to a pixel adds coverage that is not physically
|
|
332
|
+
* there. Scaling alpha by the inverse keeps the strand's contribution roughly
|
|
333
|
+
* constant, so distant hair thins out in opacity instead of breaking into a
|
|
334
|
+
* flickering dotted line.
|
|
335
335
|
*/ calculateAlbedoColor(scope, uv) {
|
|
336
336
|
const pb = scope.$builder;
|
|
337
337
|
const albedo = super.calculateAlbedoColor(scope, uv);
|
|
@@ -385,36 +385,36 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
385
385
|
}
|
|
386
386
|
ShaderHelper.setClipSpacePosition(scope, pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.strand.worldPos, 1)));
|
|
387
387
|
}
|
|
388
|
-
/**
|
|
389
|
-
* Rebuilds the cylinder normal the flat quad stands for.
|
|
390
|
-
*
|
|
391
|
-
* @remarks
|
|
392
|
-
* The quad's own normal points at the camera everywhere on it, so every fragment
|
|
393
|
-
* across a strand's width shades the same and the strand reads as tape. A real
|
|
394
|
-
* fibre presents a curved surface: at the centre of the visible side its normal
|
|
395
|
-
* faces the viewer, and by the silhouette edges it has turned a quarter turn to
|
|
396
|
-
* lie perpendicular to the view. With `a` the interpolated sine of that angle,
|
|
397
|
-
* the normal is `side * a + faceNormal * cos`, and `cos = sqrt(1 - a * a)`.
|
|
398
|
-
*
|
|
399
|
-
* Built from the varyings rather than from the interpolated TBN on purpose. The
|
|
400
|
-
* TBN may be flipped for back faces, and the sine carried alongside it would not
|
|
401
|
-
* be, which would turn the fibre inside out; the varyings need no flip, because
|
|
402
|
-
* a camera-facing quad's normal already points at the camera by construction.
|
|
403
|
-
* @internal
|
|
404
|
-
*/ /**
|
|
405
|
-
* Ambient occlusion from how deep in the groom the fragment sits.
|
|
406
|
-
*
|
|
407
|
-
* @remarks
|
|
408
|
-
* Stands in for the occlusion map the inherited path uses, which this material
|
|
409
|
-
* cannot sample: it emits no texture coordinates. See
|
|
410
|
-
* {@link HairStrandMaterial.rootOcclusion} for why an approximation is worth
|
|
411
|
-
* having at all.
|
|
412
|
-
*
|
|
413
|
-
* Only the ambient hook is overridden. The inherited direct hook resolves to
|
|
414
|
-
* one here - there is no occlusion map - which is correct: the geometric term
|
|
415
|
-
* describes being buried in the groom, and for direct light that is exactly
|
|
416
|
-
* what the shadow map already measures.
|
|
417
|
-
* @internal
|
|
388
|
+
/**
|
|
389
|
+
* Rebuilds the cylinder normal the flat quad stands for.
|
|
390
|
+
*
|
|
391
|
+
* @remarks
|
|
392
|
+
* The quad's own normal points at the camera everywhere on it, so every fragment
|
|
393
|
+
* across a strand's width shades the same and the strand reads as tape. A real
|
|
394
|
+
* fibre presents a curved surface: at the centre of the visible side its normal
|
|
395
|
+
* faces the viewer, and by the silhouette edges it has turned a quarter turn to
|
|
396
|
+
* lie perpendicular to the view. With `a` the interpolated sine of that angle,
|
|
397
|
+
* the normal is `side * a + faceNormal * cos`, and `cos = sqrt(1 - a * a)`.
|
|
398
|
+
*
|
|
399
|
+
* Built from the varyings rather than from the interpolated TBN on purpose. The
|
|
400
|
+
* TBN may be flipped for back faces, and the sine carried alongside it would not
|
|
401
|
+
* be, which would turn the fibre inside out; the varyings need no flip, because
|
|
402
|
+
* a camera-facing quad's normal already points at the camera by construction.
|
|
403
|
+
* @internal
|
|
404
|
+
*/ /**
|
|
405
|
+
* Ambient occlusion from how deep in the groom the fragment sits.
|
|
406
|
+
*
|
|
407
|
+
* @remarks
|
|
408
|
+
* Stands in for the occlusion map the inherited path uses, which this material
|
|
409
|
+
* cannot sample: it emits no texture coordinates. See
|
|
410
|
+
* {@link HairStrandMaterial.rootOcclusion} for why an approximation is worth
|
|
411
|
+
* having at all.
|
|
412
|
+
*
|
|
413
|
+
* Only the ambient hook is overridden. The inherited direct hook resolves to
|
|
414
|
+
* one here - there is no occlusion map - which is correct: the geometric term
|
|
415
|
+
* describes being buried in the groom, and for direct light that is exactly
|
|
416
|
+
* what the shadow map already measures.
|
|
417
|
+
* @internal
|
|
418
418
|
*/ calculateHairOcclusion(scope) {
|
|
419
419
|
const pb = scope.$builder;
|
|
420
420
|
// Evaluated at the vertex stage and interpolated, the same way the roundness
|
|
@@ -495,12 +495,12 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
495
495
|
bindGroup.setValue('zStrandLOD', this._lodScratch.setXYZW(this._minStrandLODRatio, 0, 0, 0));
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
/**
|
|
499
|
-
* Declares the strand storage buffers and expansion parameters.
|
|
500
|
-
*
|
|
501
|
-
* @remarks
|
|
502
|
-
* Group 2 is the material's own bind group, matching the inherited uniforms.
|
|
503
|
-
* @internal
|
|
498
|
+
/**
|
|
499
|
+
* Declares the strand storage buffers and expansion parameters.
|
|
500
|
+
*
|
|
501
|
+
* @remarks
|
|
502
|
+
* Group 2 is the material's own bind group, matching the inherited uniforms.
|
|
503
|
+
* @internal
|
|
504
504
|
*/ declareStrandBindings(scope) {
|
|
505
505
|
const pb = scope.$builder;
|
|
506
506
|
scope.zStrandHeaders = pb.uint[0]().storageBufferReadonly(2);
|
|
@@ -514,9 +514,9 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
514
514
|
scope.zStrandLOD = pb.vec4().uniform(2);
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
/**
|
|
518
|
-
* Reads one control point as position in xyz and width in w.
|
|
519
|
-
* @internal
|
|
517
|
+
/**
|
|
518
|
+
* Reads one control point as position in xyz and width in w.
|
|
519
|
+
* @internal
|
|
520
520
|
*/ fetchStrandPoint(scope, index, prev = false) {
|
|
521
521
|
const pb = scope.$builder;
|
|
522
522
|
const funcName = prev ? 'Z_strandPointPrev' : 'Z_strandPoint';
|
|
@@ -537,30 +537,30 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
537
537
|
});
|
|
538
538
|
return pb.getGlobalScope()[funcName](index);
|
|
539
539
|
}
|
|
540
|
-
/**
|
|
541
|
-
* Evaluates a strand at parameter `t`, returning position, width and tangent.
|
|
542
|
-
*
|
|
543
|
-
* @remarks
|
|
544
|
-
* A Catmull-Rom spline through the control points, not the control polygon
|
|
545
|
-
* itself, and both quantities come from the same curve: the sample is the
|
|
546
|
-
* spline's value, the tangent its analytic derivative.
|
|
547
|
-
*
|
|
548
|
-
* The reason is the tangent. A polyline's derivative is constant within a span
|
|
549
|
-
* and jumps at every control point, and the anisotropic lobes are a function of
|
|
550
|
-
* that direction raised to a large power, so what is a slight kink in the
|
|
551
|
-
* silhouette becomes a hard step in the highlight - each span of a strand shading
|
|
552
|
-
* as its own uniformly bright or dark facet. Interpolating the position more
|
|
553
|
-
* accurately is the lesser half of the change.
|
|
554
|
-
*
|
|
555
|
-
* The curve matters too once {@link segmentsPerStrand} is below the control
|
|
556
|
-
* point count, which is the normal case: the default draws 8 segments from
|
|
557
|
-
* strands carrying 30 points, so a polyline reading cuts the corner across three
|
|
558
|
-
* points at a time and quietly straightens out every curl in the groom. A spline
|
|
559
|
-
* sampled at the same rate keeps the bend.
|
|
560
|
-
*
|
|
561
|
-
* Costs four control point fetches against the three the polyline reading of
|
|
562
|
-
* position and tangent needed between them.
|
|
563
|
-
* @internal
|
|
540
|
+
/**
|
|
541
|
+
* Evaluates a strand at parameter `t`, returning position, width and tangent.
|
|
542
|
+
*
|
|
543
|
+
* @remarks
|
|
544
|
+
* A Catmull-Rom spline through the control points, not the control polygon
|
|
545
|
+
* itself, and both quantities come from the same curve: the sample is the
|
|
546
|
+
* spline's value, the tangent its analytic derivative.
|
|
547
|
+
*
|
|
548
|
+
* The reason is the tangent. A polyline's derivative is constant within a span
|
|
549
|
+
* and jumps at every control point, and the anisotropic lobes are a function of
|
|
550
|
+
* that direction raised to a large power, so what is a slight kink in the
|
|
551
|
+
* silhouette becomes a hard step in the highlight - each span of a strand shading
|
|
552
|
+
* as its own uniformly bright or dark facet. Interpolating the position more
|
|
553
|
+
* accurately is the lesser half of the change.
|
|
554
|
+
*
|
|
555
|
+
* The curve matters too once {@link segmentsPerStrand} is below the control
|
|
556
|
+
* point count, which is the normal case: the default draws 8 segments from
|
|
557
|
+
* strands carrying 30 points, so a polyline reading cuts the corner across three
|
|
558
|
+
* points at a time and quietly straightens out every curl in the groom. A spline
|
|
559
|
+
* sampled at the same rate keeps the bend.
|
|
560
|
+
*
|
|
561
|
+
* Costs four control point fetches against the three the polyline reading of
|
|
562
|
+
* position and tangent needed between them.
|
|
563
|
+
* @internal
|
|
564
564
|
*/ evaluateStrand(scope, firstPoint, pointCount, t, prev = false) {
|
|
565
565
|
const pb = scope.$builder;
|
|
566
566
|
const that = this;
|
|
@@ -622,19 +622,19 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
622
622
|
});
|
|
623
623
|
return pb.getGlobalScope()[funcName](firstPoint, pointCount, t);
|
|
624
624
|
}
|
|
625
|
-
/**
|
|
626
|
-
* Rotates a strand direction into world space and renormalises it.
|
|
627
|
-
*
|
|
628
|
-
* @remarks
|
|
629
|
-
* The direction is transformed by the world matrix rather than by its inverse
|
|
630
|
-
* transpose on purpose: this is a tangent, not a normal. The shading normal is
|
|
631
|
-
* rebuilt from the tangent and the ribbon's side vector after the fact, so a
|
|
632
|
-
* non-uniform scale reaches the lighting through the frame it actually bends.
|
|
633
|
-
*
|
|
634
|
-
* A degenerate scale can collapse the direction entirely, which would leave a
|
|
635
|
-
* zero-length tangent and produce NaN once it is normalised, so the untransformed
|
|
636
|
-
* direction stands in for that case.
|
|
637
|
-
* @internal
|
|
625
|
+
/**
|
|
626
|
+
* Rotates a strand direction into world space and renormalises it.
|
|
627
|
+
*
|
|
628
|
+
* @remarks
|
|
629
|
+
* The direction is transformed by the world matrix rather than by its inverse
|
|
630
|
+
* transpose on purpose: this is a tangent, not a normal. The shading normal is
|
|
631
|
+
* rebuilt from the tangent and the ribbon's side vector after the fact, so a
|
|
632
|
+
* non-uniform scale reaches the lighting through the frame it actually bends.
|
|
633
|
+
*
|
|
634
|
+
* A degenerate scale can collapse the direction entirely, which would leave a
|
|
635
|
+
* zero-length tangent and produce NaN once it is normalised, so the untransformed
|
|
636
|
+
* direction stands in for that case.
|
|
637
|
+
* @internal
|
|
638
638
|
*/ transformStrandDirection(scope, worldMatrix, direction) {
|
|
639
639
|
const pb = scope.$builder;
|
|
640
640
|
const funcName = 'Z_strandDirectionToWorld';
|
|
@@ -651,15 +651,15 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
651
651
|
});
|
|
652
652
|
return pb.getGlobalScope()[funcName](worldMatrix, direction);
|
|
653
653
|
}
|
|
654
|
-
/**
|
|
655
|
-
* Derives this vertex's ribbon corner from the vertex index.
|
|
656
|
-
*
|
|
657
|
-
* @remarks
|
|
658
|
-
* Six vertices per segment form two triangles over a quad whose corners are
|
|
659
|
-
* indexed by (ring, side). Independent triangles rather than a strip means no
|
|
660
|
-
* degenerate vertices are needed to cut between strands, and the duplicated
|
|
661
|
-
* corners cost nothing because corners are computed rather than fetched.
|
|
662
|
-
* @internal
|
|
654
|
+
/**
|
|
655
|
+
* Derives this vertex's ribbon corner from the vertex index.
|
|
656
|
+
*
|
|
657
|
+
* @remarks
|
|
658
|
+
* Six vertices per segment form two triangles over a quad whose corners are
|
|
659
|
+
* indexed by (ring, side). Independent triangles rather than a strip means no
|
|
660
|
+
* degenerate vertices are needed to cut between strands, and the duplicated
|
|
661
|
+
* corners cost nothing because corners are computed rather than fetched.
|
|
662
|
+
* @internal
|
|
663
663
|
*/ expandStrandVertex(scope) {
|
|
664
664
|
const pb = scope.$builder;
|
|
665
665
|
const funcName = 'Z_expandStrandVertex';
|