@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdf.js","sources":["../../src/shaders/sdf.ts"],"sourcesContent":["import type { PBGlobalScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { getDevice } from '../app/api';\r\n\r\n/** Uniform names of the global field, see {@link declareGlobalSDFUniforms}. */\r\nexport const GLOBAL_SDF_TEXTURE = 'zGlobalSDFTex';\r\nexport const GLOBAL_SDF_LEVELS = 'zGlobalSDFLevels';\r\nexport const GLOBAL_SDF_PARAMS = 'zGlobalSDFParams';\r\nexport const GLOBAL_SDF_TAGS = 'zGlobalSDFTags';\r\n/** Voxels along a brick edge of the global field, the unit it is composited and tagged in. */\r\nexport const GLOBAL_SDF_BRICK = 8;\r\n/** Uniform names of the dynamic instances, see {@link declareDynamicSDFUniforms}. */\r\nexport const SDF_ATLAS_TEXTURE = 'zSDFAtlasTex';\r\nexport const SDF_DYNAMIC_INSTANCES = 'zSDFDynamic';\r\nexport const SDF_DYNAMIC_INFO = 'zSDFDynamicInfo';\r\n/** Most dynamic instances a shader merges into the field. */\r\nexport const MAX_DYNAMIC_SDF_INSTANCES = 16;\r\n/**\r\n * vec4s per packed instance: world-to-local rows (3), (field box min, voxel size),\r\n * (field box max, world scale), (atlas slot offset, thin). `thin` = half thickness in world\r\n * units of a two-sided field's surface, -1 for one-sided; see `expand` of {@link sampleInstancesSDF}.\r\n */\r\nexport const SDF_INSTANCE_VEC4S = 6;\r\n\r\n/**\r\n * Declares the uniforms {@link sampleGlobalSDF} reads.\r\n *\r\n * - texture: levels stacked along z, `resolution + 1` slices each (last repeats the first),\r\n * in {@link globalSDFFormat}; see {@link isGlobalSDFFilterable}.\r\n * - tags: rgba32f, one texel per brick, stacked the same way: (world brick x, y, z, 1) of the\r\n * brick last composited there.\r\n * - levels[i]: (window origin in voxels, voxel size).\r\n * - params: (resolution, number of levels, band in voxels, current mask); bit i set when\r\n * every brick of level i is current (tags need not be read).\r\n *\r\n * @param levels - Clipmap levels; a compile-time constant of the program.\r\n * @internal\r\n */\r\nexport function declareGlobalSDFUniforms(scope: PBGlobalScope, group: number, levels: number) {\r\n const pb = scope.$builder;\r\n scope[GLOBAL_SDF_TEXTURE] = isGlobalSDFFilterable()\r\n ? pb.tex3D().uniform(group)\r\n : pb.tex3D().sampleType('unfilterable-float').uniform(group);\r\n scope[GLOBAL_SDF_TAGS] = pb.tex3D().sampleType('unfilterable-float').uniform(group);\r\n scope[GLOBAL_SDF_LEVELS] = pb.vec4[levels]().uniform(group);\r\n scope[GLOBAL_SDF_PARAMS] = pb.vec4().uniform(group);\r\n}\r\n\r\n/**\r\n * Texel format of the global field: r16f where compute-writable (WebGPU texture-formats-tier1),\r\n * else r32f. Half precision suffices since only distances within the band are stored.\r\n * @internal\r\n */\r\nexport function globalSDFFormat(): 'r16f' | 'r32f' {\r\n return getDevice().getDeviceCaps().textureCaps.getTextureFormatInfo('r16f')?.writable ? 'r16f' : 'r32f';\r\n}\r\n\r\n/**\r\n * True when the device filters the global field's format (r16f always, r32f with\r\n * float32-filterable); otherwise trilinear is done by hand from eight loads.\r\n * @internal\r\n */\r\nexport function isGlobalSDFFilterable() {\r\n return !!getDevice().getDeviceCaps().textureCaps.getTextureFormatInfo(globalSDFFormat())?.filterable;\r\n}\r\n\r\n/**\r\n * Declares the uniforms {@link sampleDynamicSDF} reads: the mesh field atlas,\r\n * up to {@link MAX_DYNAMIC_SDF_INSTANCES} packed instances and\r\n * (instance count, 1 / atlas size).\r\n * @internal\r\n */\r\nexport function declareDynamicSDFUniforms(scope: PBGlobalScope, group: number) {\r\n const pb = scope.$builder;\r\n scope[SDF_ATLAS_TEXTURE] = pb.tex3D().uniform(group);\r\n scope[SDF_DYNAMIC_INSTANCES] = pb.vec4[MAX_DYNAMIC_SDF_INSTANCES * SDF_INSTANCE_VEC4S]().uniform(group);\r\n scope[SDF_DYNAMIC_INFO] = pb.vec4().uniform(group);\r\n}\r\n\r\n/**\r\n * Distance in local units from a local position to one packed instance's field: trilinear\r\n * atlas lookup inside the box, border value plus box distance outside. `bmin` is (box min,\r\n * voxel size), `bmax` (box max, world scale), `slot` the atlas slot offset.\r\n * @internal\r\n */\r\nexport function sampleInstanceField(\r\n scope: PBInsideFunctionScope,\r\n lp: PBShaderExp,\r\n bmin: PBShaderExp,\r\n bmax: PBShaderExp,\r\n slot: PBShaderExp,\r\n atlas: PBShaderExp,\r\n atlasInvSize: PBShaderExp\r\n) {\r\n const pb = scope.$builder;\r\n const funcName = `Z_sampleInstanceField_${atlas.$str}`;\r\n pb.func(\r\n funcName,\r\n [pb.vec3('lp'), pb.vec4('bmin'), pb.vec4('bmax'), pb.vec4('slot'), pb.vec3('invSize')],\r\n function () {\r\n this.$l.c = pb.clamp(this.lp, this.bmin.xyz, this.bmax.xyz);\r\n this.$l.outside = pb.length(pb.sub(this.lp, this.c));\r\n this.$l.res = pb.div(pb.sub(this.bmax.xyz, this.bmin.xyz), this.bmin.w);\r\n // Clamped to the outer sample centres, so the filter never reads a neighbour's slot\r\n this.$l.f = pb.clamp(\r\n pb.div(pb.sub(this.c, this.bmin.xyz), this.bmin.w),\r\n pb.vec3(0.5),\r\n pb.sub(this.res, pb.vec3(0.5))\r\n );\r\n this.$l.uvw = pb.mul(pb.add(this.slot.xyz, this.f), this.invSize);\r\n this.$return(pb.add(pb.textureSampleLevel(atlas, this.uvw, 0).r, this.outside));\r\n }\r\n );\r\n return scope[funcName](lp, bmin, bmax, slot, atlasInvSize) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Signed distance from a world position to the nearest of a set of packed instances\r\n * (layout at {@link SDF_INSTANCE_VEC4S}), or `maxDist` when none is nearer. `baseOf(k)` gives\r\n * the first vec4 of the k-th instance, `instance(i)` reads vec4 `i`. If `bestIndex` names an\r\n * int variable, the nearest k is written to it.\r\n *\r\n * `expand` (world units) is the minimum half thickness given to two-sided surfaces so coarser\r\n * grids don't step over them: half the voxel size of the grid being written, 0 for point samples.\r\n * @internal\r\n */\r\nexport function sampleInstancesSDF(\r\n scope: PBInsideFunctionScope,\r\n p: PBShaderExp,\r\n count: PBShaderExp,\r\n maxDist: PBShaderExp,\r\n baseOf: (scope: PBInsideFunctionScope, k: PBShaderExp) => PBShaderExp,\r\n instance: (scope: PBInsideFunctionScope, index: PBShaderExp) => PBShaderExp,\r\n atlas: PBShaderExp,\r\n atlasInvSize: PBShaderExp,\r\n expand: PBShaderExp,\r\n bestIndex?: string\r\n) {\r\n const pb = scope.$builder;\r\n scope.$l.sdfBest = maxDist;\r\n scope.$l.sdfP4 = pb.vec4(p, 1);\r\n scope.$l.sdfExpand = expand;\r\n scope.$for(pb.uint('sdfK'), 0, count, function () {\r\n this.$l.base = baseOf(this, this.sdfK);\r\n this.$l.r0 = instance(this, this.base);\r\n this.$l.r1 = instance(this, pb.add(this.base, 1));\r\n this.$l.r2 = instance(this, pb.add(this.base, 2));\r\n this.$l.bmin = instance(this, pb.add(this.base, 3));\r\n this.$l.bmax = instance(this, pb.add(this.base, 4));\r\n this.$l.slot = instance(this, pb.add(this.base, 5));\r\n this.$l.lp = pb.vec3(\r\n pb.dot(this.r0, this.sdfP4),\r\n pb.dot(this.r1, this.sdfP4),\r\n pb.dot(this.r2, this.sdfP4)\r\n );\r\n this.$l.c = pb.clamp(this.lp, this.bmin.xyz, this.bmax.xyz);\r\n // World length of a unit along each local axis\r\n this.$l.axisScale = pb.div(\r\n pb.vec3(1),\r\n pb.vec3(pb.length(this.r0.xyz), pb.length(this.r1.xyz), pb.length(this.r2.xyz))\r\n );\r\n // World distance to the field box, exact under non-uniform scale; only the\r\n // field's own value takes the smallest axis scale\r\n this.$l.outside = pb.length(pb.mul(pb.sub(this.lp, this.c), this.axisScale));\r\n // How far a two-sided surface is pushed out to reach the half thickness asked for\r\n this.$l.grow = this.$choice(\r\n pb.greaterThanEqual(this.slot.w, 0),\r\n pb.max(pb.sub(this.sdfExpand, this.slot.w), 0),\r\n pb.float(0)\r\n );\r\n // A field box farther than the current best cannot improve it\r\n this.$if(pb.lessThan(pb.sub(this.outside, this.grow), this.sdfBest), function () {\r\n this.$l.cand = pb.sub(\r\n pb.add(\r\n pb.mul(\r\n sampleInstanceField(this, this.c, this.bmin, this.bmax, this.slot, atlas, atlasInvSize),\r\n this.bmax.w\r\n ),\r\n this.outside\r\n ),\r\n this.grow\r\n );\r\n this.$if(pb.lessThan(this.cand, this.sdfBest), function () {\r\n this.sdfBest = this.cand;\r\n if (bestIndex) {\r\n this[bestIndex] = pb.int(this.sdfK);\r\n }\r\n });\r\n });\r\n });\r\n return scope.sdfBest as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Signed distance to the dynamic instances at their current transforms, or `maxDist`.\r\n * @internal\r\n */\r\nexport function sampleDynamicSDF(scope: PBInsideFunctionScope, worldPos: PBShaderExp, maxDist: PBShaderExp) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sampleDynamicSDF';\r\n pb.func(funcName, [pb.vec3('p'), pb.float('maxDist')], function () {\r\n this.$return(\r\n sampleInstancesSDF(\r\n this,\r\n this.p,\r\n pb.uint(this[SDF_DYNAMIC_INFO].x),\r\n this.maxDist,\r\n (s, k) => pb.mul(k, SDF_INSTANCE_VEC4S),\r\n (s, i) => s[SDF_DYNAMIC_INSTANCES].at(i),\r\n this[SDF_ATLAS_TEXTURE],\r\n this[SDF_DYNAMIC_INFO].yzw,\r\n pb.float(0)\r\n )\r\n );\r\n });\r\n return scope[funcName](worldPos, maxDist) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Signed distance to the whole scene field: global clipmap merged with dynamic instances.\r\n * Needs {@link declareGlobalSDFUniforms} and {@link declareDynamicSDFUniforms}.\r\n * @internal\r\n */\r\nexport function sampleSceneSDF(scope: PBInsideFunctionScope, worldPos: PBShaderExp, levels: number) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sampleSceneSDF';\r\n pb.func(funcName, [pb.vec3('p')], function () {\r\n this.$l.g = sampleGlobalSDF(this, this.p, levels);\r\n this.$return(sampleDynamicSDF(this, this.p, this.g));\r\n });\r\n return scope[funcName](worldPos) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * {@link sampleSceneSDF} returning (distance, voxel size); voxel size 0 where a dynamic\r\n * instance is nearer.\r\n * @internal\r\n */\r\nexport function sampleSceneSDFWithVoxel(scope: PBInsideFunctionScope, worldPos: PBShaderExp, levels: number) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sampleSceneSDFWithVoxel';\r\n pb.func(funcName, [pb.vec3('p')], function () {\r\n this.$l.g = sampleGlobalSDFWithVoxel(this, this.p, levels);\r\n this.$l.d = sampleDynamicSDF(this, this.p, this.g.x);\r\n this.$return(pb.vec2(this.d, this.$choice(pb.lessThan(this.d, this.g.x), pb.float(0), this.g.y)));\r\n });\r\n return scope[funcName](worldPos) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Surface expand scale in bricks holding two-sided meshes (1 elsewhere)\r\n * @internal\r\n */\r\nexport const SDF_NOT_COVERED_EXPAND_SCALE = 0.6;\r\n\r\n/**\r\n * Tag alpha of a brick holding two-sided meshes (1 otherwise); see\r\n * {@link SDF_NOT_COVERED_EXPAND_SCALE}.\r\n * @internal\r\n */\r\nexport const GLOBAL_SDF_TAG_NOT_COVERED = 2;\r\n\r\n/**\r\n * False where the global field brick holding a position (finest level) was composited with\r\n * two-sided meshes; true otherwise, including outside every window or for stale bricks.\r\n * @internal\r\n */\r\nexport function globalSDFCovered(scope: PBInsideFunctionScope, worldPos: PBShaderExp, levels: number) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_globalSDFCovered';\r\n pb.func(funcName, [pb.vec3('p')], function () {\r\n this.$l.res = pb.int(this[GLOBAL_SDF_PARAMS].x);\r\n this.$l.nbi = pb.ivec3(pb.div(this.res, GLOBAL_SDF_BRICK));\r\n for (let i = 0; i < levels; i++) {\r\n this.$l[`cvInfo${i}`] = this[GLOBAL_SDF_LEVELS].at(i);\r\n this.$l[`cvV${i}`] = pb.ivec3(pb.floor(pb.div(this.p, this[`cvInfo${i}`].w)));\r\n this.$l[`cvO${i}`] = pb.ivec3(this[`cvInfo${i}`].xyz);\r\n this.$if(\r\n pb.and(\r\n pb.all(pb.greaterThanEqual(this[`cvV${i}`], this[`cvO${i}`])),\r\n pb.all(pb.lessThan(this[`cvV${i}`], pb.add(this[`cvO${i}`], pb.ivec3(this.res))))\r\n ),\r\n function () {\r\n this.$l.b = pb.ivec3(pb.floor(pb.div(pb.vec3(this[`cvV${i}`]), GLOBAL_SDF_BRICK)));\r\n this.$l.w = wrap(this, this.b, this.nbi);\r\n this.$l.tag = pb.textureLoad(\r\n this[GLOBAL_SDF_TAGS],\r\n pb.ivec3(this.w.x, this.w.y, pb.add(this.w.z, pb.mul(this.nbi.z, i))),\r\n 0\r\n );\r\n this.$return(\r\n pb.not(\r\n pb.and(\r\n pb.greaterThan(this.tag.w, GLOBAL_SDF_TAG_NOT_COVERED - 0.5),\r\n pb.equal(pb.ivec3(this.tag.xyz), this.b)\r\n )\r\n )\r\n );\r\n }\r\n );\r\n }\r\n this.$return(true);\r\n });\r\n return scope[funcName](worldPos) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Lumen surface expand (GlobalDistanceFieldUtils.ush) for a {@link sampleSceneSDFWithVoxel}\r\n * sample at `p`, `t` along a trace: one voxel of the level read ({@link SDF_NOT_COVERED_EXPAND_SCALE}\r\n * in two-sided bricks), ramping from 0 over the first two voxels. Zero for dynamic instances.\r\n * @internal\r\n */\r\nexport function sdfSurfaceExpand(\r\n scope: PBInsideFunctionScope,\r\n p: PBShaderExp,\r\n sample: PBShaderExp,\r\n t: PBShaderExp,\r\n levels: number\r\n) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sdfSurfaceExpand';\r\n pb.func(funcName, [pb.vec3('p'), pb.vec2('s'), pb.float('t')], function () {\r\n this.$l.e = pb.mul(this.s.y, pb.clamp(pb.div(this.t, pb.max(pb.mul(this.s.y, 2), 1e-6)), 0, 1));\r\n this.$if(\r\n pb.and(\r\n pb.lessThan(this.s.x, this.e),\r\n pb.greaterThanEqual(this.s.x, pb.mul(this.e, SDF_NOT_COVERED_EXPAND_SCALE))\r\n ),\r\n function () {\r\n this.$if(pb.not(globalSDFCovered(this, this.p, levels)), function () {\r\n this.e = pb.mul(this.e, SDF_NOT_COVERED_EXPAND_SCALE);\r\n });\r\n }\r\n );\r\n this.$return(this.e);\r\n });\r\n return scope[funcName](p, sample, t) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Voxels over which a global field level blends into the next coarser one near its window\r\n * edge; wider than a brick (the window move step) so the hand-over never jumps.\r\n * @internal\r\n */\r\nexport const SDF_LEVEL_BLEND_VOXELS = 16;\r\n\r\n/**\r\n * Signed distance (world units, negative inside) from the global clipmap field.\r\n *\r\n * The finest level holding the point within its band answers, blending into the next coarser\r\n * level near window edges and band edges. Past all windows or with every level saturated, the\r\n * coarsest value is returned as a lower bound, keeping sphere tracing safe. Windows are toroidal;\r\n * non-filterable formats use manual trilinear. A level answers only where all bricks under the\r\n * filter are tagged current, so stale bricks after a window move are ignored.\r\n * @internal\r\n */\r\nexport function sampleGlobalSDF(scope: PBInsideFunctionScope, worldPos: PBShaderExp, levels: number) {\r\n return sampleGlobalSDFWithVoxel(scope, worldPos, levels).x as PBShaderExp;\r\n}\r\n\r\n/**\r\n * First level worth reading after a sphere-trace step read `prevDist`; finer levels saturate.\r\n * @internal\r\n */\r\nfunction sdfStartLevel(scope: PBInsideFunctionScope, prevDist: PBShaderExp, levels: number) {\r\n const pb = scope.$builder;\r\n let start: PBShaderExp = pb.int(0);\r\n for (let i = 0; i < levels - 1; i++) {\r\n start = pb.add(\r\n start,\r\n pb.int(\r\n pb.greaterThanEqual(\r\n prevDist,\r\n pb.mul(scope[GLOBAL_SDF_PARAMS].z, scope[GLOBAL_SDF_LEVELS].at(i).w, 0.95)\r\n )\r\n )\r\n );\r\n }\r\n return start;\r\n}\r\n\r\n/**\r\n * {@link sampleGlobalSDFWithVoxel} for sphere tracing: starts at the level `prevDist` needs,\r\n * rereading from the finest level near a surface. Levels finer than `minLevel` are never .\r\n * @internal\r\n */\r\nexport function sampleGlobalSDFHinted(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n prevDist: PBShaderExp,\r\n levels: number,\r\n minLevel?: PBShaderExp\r\n) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sampleGlobalSDFHinted';\r\n pb.func(funcName, [pb.vec3('p'), pb.float('prevDist'), pb.int('minLevel')], function () {\r\n this.$l.start = pb.max(sdfStartLevel(this, this.prevDist, levels), this.minLevel);\r\n this.$l.g = sampleGlobalSDFWithVoxel(this, this.p, levels, this.start);\r\n this.$if(pb.greaterThan(this.start, this.minLevel), function () {\r\n this.$if(\r\n pb.lessThan(\r\n this.g.x,\r\n pb.mul(this[GLOBAL_SDF_PARAMS].z, this[GLOBAL_SDF_LEVELS].at(pb.sub(this.start, 1)).w)\r\n ),\r\n function () {\r\n this.g = sampleGlobalSDFWithVoxel(this, this.p, levels, this.minLevel);\r\n }\r\n );\r\n });\r\n this.$return(this.g);\r\n });\r\n return scope[funcName](worldPos, prevDist, minLevel ?? pb.int(0)) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * {@link sampleSceneSDFWithVoxel} for sphere tracing, using {@link sampleGlobalSDFHinted}.\r\n * @internal\r\n */\r\nexport function sampleSceneSDFHinted(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n prevDist: PBShaderExp,\r\n levels: number,\r\n minLevel?: PBShaderExp\r\n) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sampleSceneSDFHinted';\r\n pb.func(funcName, [pb.vec3('p'), pb.float('prevDist'), pb.int('minLevel')], function () {\r\n this.$l.g = sampleGlobalSDFHinted(this, this.p, this.prevDist, levels, this.minLevel);\r\n this.$l.d = sampleDynamicSDF(this, this.p, this.g.x);\r\n this.$return(pb.vec2(this.d, this.$choice(pb.lessThan(this.d, this.g.x), pb.float(0), this.g.y)));\r\n });\r\n return scope[funcName](worldPos, prevDist, minLevel ?? pb.int(0)) as PBShaderExp;\r\n}\r\n\r\n/** Steps {@link sdfRefineHit} takes past a hit on the swollen surface. @internal */\r\nexport const SDF_REFINE_STEPS = 8;\r\n\r\n/**\r\n * Refines a sphere-trace hit on the surface swollen by {@link sdfSurfaceExpand} to the field's\r\n * own surface: steps on from `t` (distance `d`, answering `voxel` size, 0 for dynamic) to the zero\r\n * crossing or minimum, at most {@link SDF_REFINE_STEPS} steps of at least 1/8 voxel. Needed because\r\n * the swollen surface lies up to a voxel short, notably in concave corners.\r\n * @internal\r\n */\r\nexport function sdfRefineHit(\r\n scope: PBInsideFunctionScope,\r\n origin: PBShaderExp,\r\n dir: PBShaderExp,\r\n t: PBShaderExp,\r\n d: PBShaderExp,\r\n voxel: PBShaderExp,\r\n minLevel: PBShaderExp,\r\n levels: number\r\n) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_sdfRefineHit';\r\n pb.func(\r\n funcName,\r\n [pb.vec3('o'), pb.vec3('dir'), pb.float('t'), pb.float('d'), pb.float('voxel'), pb.int('minLevel')],\r\n function () {\r\n // Stopped inside: back out by as much\r\n this.$if(pb.lessThanEqual(this.d, 0), function () {\r\n this.$return(pb.max(pb.add(this.t, this.d), 0));\r\n });\r\n this.$l.rt = this.t;\r\n this.$l.rd = this.d;\r\n this.$l.rStep = pb.mul(pb.max(this.voxel, this[GLOBAL_SDF_LEVELS].at(0).w), 0.125);\r\n this.$for(pb.int('r'), 0, SDF_REFINE_STEPS, function () {\r\n this.$l.nt = pb.add(this.rt, pb.max(this.rd, this.rStep));\r\n this.$l.nd = sampleSceneSDFHinted(\r\n this,\r\n pb.add(this.o, pb.mul(this.dir, this.nt)),\r\n this.rd,\r\n levels,\r\n this.minLevel\r\n ).x;\r\n this.$if(pb.lessThanEqual(this.nd, 0), function () {\r\n this.$return(\r\n pb.add(this.rt, pb.mul(pb.sub(this.nt, this.rt), pb.div(this.rd, pb.sub(this.rd, this.nd))))\r\n );\r\n });\r\n this.$if(pb.greaterThanEqual(this.nd, this.rd), function () {\r\n this.$break();\r\n });\r\n this.rt = this.nt;\r\n this.rd = this.nd;\r\n });\r\n this.$return(this.rt);\r\n }\r\n );\r\n return scope[funcName](origin, dir, t, d, voxel, minLevel) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * {@link sampleGlobalSDF} returning (distance, voxel size) in world units; levels finer than\r\n * `minLevel` are skipped.\r\n * @internal\r\n */\r\nexport function sampleGlobalSDFWithVoxel(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n levels: number,\r\n minLevel?: PBShaderExp\r\n) {\r\n const pb = scope.$builder;\r\n const filterable = isGlobalSDFFilterable();\r\n const funcName = 'Z_sampleGlobalSDFWithVoxel';\r\n pb.func(funcName, [pb.vec3('p'), pb.int('minLevel')], function () {\r\n this.$l.res = pb.int(this[GLOBAL_SDF_PARAMS].x);\r\n this.$l.resF = this[GLOBAL_SDF_PARAMS].x;\r\n this.$l.band = this[GLOBAL_SDF_PARAMS].z;\r\n // Weighted sums of the levels read, and the weight still left to coarser levels\r\n this.$l.sum = pb.float(0);\r\n this.$l.sumVoxel = pb.float(0);\r\n this.$l.remaining = pb.float(1);\r\n // The coarsest value read: a bound when every level read was saturated\r\n this.$l.last = pb.mul(this.band, this[GLOBAL_SDF_LEVELS].at(levels - 1).w);\r\n this.$l.lastVoxel = this[GLOBAL_SDF_LEVELS].at(levels - 1).w;\r\n this.$l.valid = false;\r\n this.$l.base = pb.vec3(0);\r\n this.$l.t = pb.vec3(0);\r\n this.$l.v0 = pb.ivec3(0);\r\n for (let i = 0; i < levels; i++) {\r\n // Finest first, each level taking the share its finer levels left\r\n const wanted =\r\n i === levels - 1\r\n ? pb.greaterThan(this.remaining, 1e-4)\r\n : pb.and(pb.greaterThan(this.remaining, 1e-4), pb.lessThanEqual(this.minLevel, i));\r\n this.$if(wanted, function () {\r\n this.$l.info = this[GLOBAL_SDF_LEVELS].at(i);\r\n // Position in voxels of the window, sample centres at integers\r\n this.$l.f = pb.sub(pb.div(this.p, this.info.w), pb.add(this.info.xyz, pb.vec3(0.5)));\r\n this.$l.inside = pb.and(\r\n pb.all(pb.greaterThanEqual(this.f, pb.vec3(0))),\r\n pb.all(pb.lessThanEqual(this.f, pb.vec3(pb.sub(this.resF, 1))))\r\n );\r\n this.valid = false;\r\n this.$if(this.inside, function () {\r\n this.$if(levelCurrent(this, i), function () {\r\n this.valid = true;\r\n }).$else(function () {\r\n // World voxel index of the filter's lower corner\r\n this.valid = bricksCurrent(this, pb.add(pb.ivec3(pb.floor(this.f)), pb.ivec3(this.info.xyz)), i);\r\n });\r\n });\r\n this.$if(this.valid, function () {\r\n if (filterable) {\r\n // World voxel position, sample centres at integers, wrapped into the window\r\n this.$l.vw = pb.add(this.f, this.info.xyz);\r\n this.vw = pb.sub(this.vw, pb.mul(pb.floor(pb.div(this.vw, this.resF)), this.resF));\r\n this.$l.depth = pb.add(this.resF, 1);\r\n this.$l.d = pb.textureSampleLevel(\r\n this[GLOBAL_SDF_TEXTURE],\r\n pb.vec3(\r\n pb.div(pb.add(this.vw.xy, pb.vec2(0.5)), this.resF),\r\n pb.div(pb.add(this.vw.z, pb.add(pb.mul(this.depth, i), 0.5)), pb.mul(this.depth, levels))\r\n ),\r\n 0\r\n ).r;\r\n } else {\r\n this.base = pb.floor(this.f);\r\n this.t = pb.sub(this.f, this.base);\r\n // World voxel index of the lower corner, then toroidal texel\r\n this.v0 = pb.add(pb.ivec3(this.base), pb.ivec3(this.info.xyz));\r\n this.$l.c000 = loadWrapped(this, this.v0, 0, 0, 0, i);\r\n this.$l.c100 = loadWrapped(this, this.v0, 1, 0, 0, i);\r\n this.$l.c010 = loadWrapped(this, this.v0, 0, 1, 0, i);\r\n this.$l.c110 = loadWrapped(this, this.v0, 1, 1, 0, i);\r\n this.$l.c001 = loadWrapped(this, this.v0, 0, 0, 1, i);\r\n this.$l.c101 = loadWrapped(this, this.v0, 1, 0, 1, i);\r\n this.$l.c011 = loadWrapped(this, this.v0, 0, 1, 1, i);\r\n this.$l.c111 = loadWrapped(this, this.v0, 1, 1, 1, i);\r\n this.$l.d = pb.mix(\r\n pb.mix(\r\n pb.mix(this.c000, this.c100, this.t.x),\r\n pb.mix(this.c010, this.c110, this.t.x),\r\n this.t.y\r\n ),\r\n pb.mix(\r\n pb.mix(this.c001, this.c101, this.t.x),\r\n pb.mix(this.c011, this.c111, this.t.x),\r\n this.t.y\r\n ),\r\n this.t.z\r\n );\r\n }\r\n this.last = this.d;\r\n this.lastVoxel = this.info.w;\r\n if (i === levels - 1) {\r\n this.$l.w = pb.float(1);\r\n } else {\r\n // Hand over near the window edge and near the band edge (beyond which values are lower bounds)\r\n this.$l.lo = pb.min(pb.min(this.f.x, this.f.y), this.f.z);\r\n this.$l.hi = pb.sub(pb.sub(this.resF, 1), pb.max(pb.max(this.f.x, this.f.y), this.f.z));\r\n this.$l.edge = pb.min(this.lo, this.hi);\r\n this.$l.bandW = pb.mul(this.band, this.info.w);\r\n this.$l.w = pb.mul(\r\n pb.smoothStep(1, 1 + SDF_LEVEL_BLEND_VOXELS, this.edge),\r\n pb.sub(1, pb.smoothStep(pb.mul(this.bandW, 0.75), pb.mul(this.bandW, 0.95), pb.abs(this.d)))\r\n );\r\n }\r\n this.$l.share = pb.mul(this.remaining, this.w);\r\n this.sum = pb.add(this.sum, pb.mul(this.share, this.d));\r\n this.sumVoxel = pb.add(this.sumVoxel, pb.mul(this.share, this.info.w));\r\n this.remaining = pb.sub(this.remaining, this.share);\r\n });\r\n });\r\n }\r\n // What no level answered for: past the coarsest window, or every level saturated\r\n this.$l.result = pb.add(this.sum, pb.mul(this.remaining, this.last));\r\n this.$l.resultVoxel = pb.add(this.sumVoxel, pb.mul(this.remaining, this.lastVoxel));\r\n this.$return(pb.vec2(this.result, this.resultVoxel));\r\n });\r\n return scope[funcName](worldPos, minLevel ?? pb.int(0)) as PBShaderExp;\r\n}\r\n\r\n/**\r\n * Signed distance from one global clipmap level chosen at run time, with no blending or brick\r\n * currency check.\r\n * @internal\r\n */\r\nexport function sampleGlobalSDFLevel(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n level: PBShaderExp,\r\n levels: number\r\n) {\r\n const pb = scope.$builder;\r\n const filterable = isGlobalSDFFilterable();\r\n const funcName = 'Z_sampleGlobalSDFLevel';\r\n pb.func(funcName, [pb.vec3('p'), pb.int('level')], function () {\r\n this.$l.res = pb.int(this[GLOBAL_SDF_PARAMS].x);\r\n this.$l.resF = this[GLOBAL_SDF_PARAMS].x;\r\n this.$l.info = this[GLOBAL_SDF_LEVELS].at(this.level);\r\n // Position in voxels of the window, sample centres at integers\r\n this.$l.f = pb.sub(pb.div(this.p, this.info.w), pb.add(this.info.xyz, pb.vec3(0.5)));\r\n // Slice of the level's first z, `resolution + 1` slices a level\r\n this.$l.z0 = pb.mul(pb.add(this.res, 1), this.level);\r\n if (filterable) {\r\n this.$l.vw = pb.add(this.f, this.info.xyz);\r\n this.vw = pb.sub(this.vw, pb.mul(pb.floor(pb.div(this.vw, this.resF)), this.resF));\r\n this.$l.depth = pb.add(this.resF, 1);\r\n this.$return(\r\n pb.textureSampleLevel(\r\n this[GLOBAL_SDF_TEXTURE],\r\n pb.vec3(\r\n pb.div(pb.add(this.vw.xy, pb.vec2(0.5)), this.resF),\r\n pb.div(pb.add(this.vw.z, pb.add(pb.float(this.z0), 0.5)), pb.mul(this.depth, levels))\r\n ),\r\n 0\r\n ).r\r\n );\r\n } else {\r\n this.$l.base = pb.floor(this.f);\r\n this.$l.t = pb.sub(this.f, this.base);\r\n this.$l.v0 = pb.add(pb.ivec3(this.base), pb.ivec3(this.info.xyz));\r\n const load = (dx: number, dy: number, dz: number) => {\r\n const v = pb.add(this.v0, pb.ivec3(dx, dy, dz));\r\n const w = wrap(this, v, pb.ivec3(this.res));\r\n return pb.textureLoad(this[GLOBAL_SDF_TEXTURE], pb.ivec3(w.x, w.y, pb.add(w.z, this.z0)), 0).r;\r\n };\r\n this.$return(\r\n pb.mix(\r\n pb.mix(\r\n pb.mix(load(0, 0, 0), load(1, 0, 0), this.t.x),\r\n pb.mix(load(0, 1, 0), load(1, 1, 0), this.t.x),\r\n this.t.y\r\n ),\r\n pb.mix(\r\n pb.mix(load(0, 0, 1), load(1, 0, 1), this.t.x),\r\n pb.mix(load(0, 1, 1), load(1, 1, 1), this.t.x),\r\n this.t.y\r\n ),\r\n this.t.z\r\n )\r\n );\r\n }\r\n });\r\n return scope[funcName](worldPos, level) as PBShaderExp;\r\n}\r\n\r\n/** ((v % n) + n) % n, the remainder of a negative index being negative */\r\nfunction wrap(scope: PBInsideFunctionScope, v: PBShaderExp, n: PBShaderExp) {\r\n const pb = scope.$builder;\r\n return pb.mod(pb.add(pb.mod(v, n), n), n);\r\n}\r\n\r\n/**\r\n * True when the brick of a level holding world voxel `v` is tagged with its own\r\n * world brick coordinates, i.e. composited for the current window.\r\n * @internal\r\n */\r\nexport function globalSDFVoxelCurrent(scope: PBInsideFunctionScope, v: PBShaderExp, level: number) {\r\n const pb = scope.$builder;\r\n const funcName = `Z_globalSDFVoxelCurrent${level}`;\r\n pb.func(funcName, [pb.ivec3('v')], function () {\r\n this.$if(levelCurrent(this, level), function () {\r\n this.$return(true);\r\n });\r\n this.$l.nbi = pb.ivec3(pb.int(pb.div(this[GLOBAL_SDF_PARAMS].x, GLOBAL_SDF_BRICK)));\r\n this.$l.b = pb.ivec3(pb.floor(pb.div(pb.vec3(this.v), GLOBAL_SDF_BRICK)));\r\n this.$l.w = wrap(this, this.b, this.nbi);\r\n this.$l.tag = pb.textureLoad(\r\n this[GLOBAL_SDF_TAGS],\r\n pb.ivec3(this.w.x, this.w.y, pb.add(this.w.z, pb.mul(this.nbi.z, level))),\r\n 0\r\n );\r\n this.$return(pb.and(pb.greaterThan(this.tag.w, 0.5), pb.equal(pb.ivec3(this.tag.xyz), this.b)));\r\n });\r\n return scope[funcName](v) as PBShaderExp;\r\n}\r\n\r\n/** True when every brick of a level is current, by the mask in the params' w. */\r\nfunction levelCurrent(scope: PBInsideFunctionScope, level: number) {\r\n const pb = scope.$builder;\r\n return pb.notEqual(pb.compAnd(pb.uint(scope[GLOBAL_SDF_PARAMS].w), pb.uint(1 << level)), pb.uint(0));\r\n}\r\n\r\n/**\r\n * True when every brick covering voxels v0..v0+1 of a level is tagged current (one to eight bricks).\r\n */\r\nfunction bricksCurrent(scope: PBInsideFunctionScope, v0: PBShaderExp, level: number) {\r\n const pb = scope.$builder;\r\n const funcName = `Z_globalSDFBricksCurrent${level}`;\r\n pb.func(funcName, [pb.ivec3('v0')], function () {\r\n this.$l.nb = pb.div(this[GLOBAL_SDF_PARAMS].x, GLOBAL_SDF_BRICK);\r\n this.$l.nbi = pb.ivec3(pb.int(this.nb));\r\n // Floor division of possibly negative voxel indices\r\n this.$l.lo = pb.ivec3(pb.floor(pb.div(pb.vec3(this.v0), GLOBAL_SDF_BRICK)));\r\n this.$l.hi = pb.ivec3(pb.floor(pb.div(pb.vec3(pb.add(this.v0, pb.ivec3(1))), GLOBAL_SDF_BRICK)));\r\n this.$l.ok = true;\r\n for (let c = 0; c < 8; c++) {\r\n const bits = [c & 1, (c >> 1) & 1, (c >> 2) & 1];\r\n // A corner using the upper brick on an axis matters only where the footprint crosses into it\r\n const needs = ['x', 'y', 'z'].filter((_, a) => bits[a]).map((a) => pb.notEqual(this.lo[a], this.hi[a]));\r\n const body = function (this: PBInsideFunctionScope) {\r\n this.$l.b = pb.ivec3(\r\n bits[0] ? this.hi.x : this.lo.x,\r\n bits[1] ? this.hi.y : this.lo.y,\r\n bits[2] ? this.hi.z : this.lo.z\r\n );\r\n this.$l.w = wrap(this, this.b, this.nbi);\r\n this.$l.tag = pb.textureLoad(\r\n this[GLOBAL_SDF_TAGS],\r\n pb.ivec3(this.w.x, this.w.y, pb.add(this.w.z, pb.mul(this.nbi.z, level))),\r\n 0\r\n );\r\n this.ok = pb.and(\r\n this.ok,\r\n pb.and(pb.greaterThan(this.tag.w, 0.5), pb.equal(pb.ivec3(this.tag.xyz), this.b))\r\n );\r\n };\r\n if (needs.length === 0) {\r\n body.call(this);\r\n } else {\r\n this.$if(\r\n needs.reduce((x, y) => pb.and(x, y)),\r\n body\r\n );\r\n }\r\n }\r\n this.$return(this.ok);\r\n });\r\n return scope[funcName](v0) as PBShaderExp;\r\n}\r\n\r\nfunction loadWrapped(\r\n scope: PBInsideFunctionScope,\r\n v0: PBShaderExp,\r\n dx: number,\r\n dy: number,\r\n dz: number,\r\n level: number\r\n) {\r\n const pb = scope.$builder;\r\n const v = pb.add(v0, pb.ivec3(dx, dy, dz));\r\n // ((v % n) + n) % n, the remainder of a negative index being negative\r\n const t = pb.mod(pb.add(pb.mod(v, pb.ivec3(scope.res)), pb.ivec3(scope.res)), pb.ivec3(scope.res));\r\n return pb.textureLoad(\r\n scope[GLOBAL_SDF_TEXTURE],\r\n pb.ivec3(t.x, t.y, pb.add(t.z, pb.mul(pb.add(scope.res, 1), level))),\r\n 0\r\n ).r;\r\n}\r\n"],"names":["GLOBAL_SDF_TEXTURE","GLOBAL_SDF_LEVELS","GLOBAL_SDF_PARAMS","GLOBAL_SDF_TAGS","GLOBAL_SDF_BRICK","SDF_ATLAS_TEXTURE","SDF_DYNAMIC_INSTANCES","SDF_DYNAMIC_INFO","MAX_DYNAMIC_SDF_INSTANCES","SDF_INSTANCE_VEC4S","declareGlobalSDFUniforms","scope","group","levels","pb","$builder","isGlobalSDFFilterable","tex3D","uniform","sampleType","vec4","globalSDFFormat","getDevice","getDeviceCaps","textureCaps","getTextureFormatInfo","writable","filterable","declareDynamicSDFUniforms","sampleInstanceField","lp","bmin","bmax","slot","atlas","atlasInvSize","funcName","$str","func","vec3","$l","c","clamp","xyz","outside","length","sub","res","div","w","f","uvw","mul","add","invSize","$return","textureSampleLevel","r","sampleInstancesSDF","p","count","maxDist","baseOf","instance","expand","bestIndex","sdfBest","sdfP4","sdfExpand","$for","uint","base","sdfK","r0","r1","r2","dot","axisScale","grow","$choice","greaterThanEqual","max","float","$if","lessThan","cand","int","sampleDynamicSDF","worldPos","x","s","k","i","at","yzw","sampleSceneSDF","g","sampleGlobalSDF","SDF_NOT_COVERED_EXPAND_SCALE","GLOBAL_SDF_TAG_NOT_COVERED","globalSDFCovered","nbi","ivec3","floor","and","all","b","wrap","tag","textureLoad","y","z","not","greaterThan","equal","sdfSurfaceExpand","sample","t","vec2","e","SDF_LEVEL_BLEND_VOXELS","sampleGlobalSDFWithVoxel","sdfStartLevel","prevDist","start","sampleGlobalSDFHinted","minLevel","sampleSceneSDFHinted","d","SDF_REFINE_STEPS","sdfRefineHit","origin","dir","voxel","lessThanEqual","rt","rd","rStep","nt","nd","o","$break","resF","band","sum","sumVoxel","remaining","last","lastVoxel","valid","v0","wanted","info","inside","levelCurrent","$else","bricksCurrent","vw","depth","xy","c000","loadWrapped","c100","c010","c110","c001","c101","c011","c111","mix","lo","min","hi","edge","bandW","smoothStep","abs","share","result","resultVoxel","sampleGlobalSDFLevel","level","z0","load","dx","dy","dz","v","n","mod","globalSDFVoxelCurrent","notEqual","compAnd","nb","ok","bits","needs","filter","_","a","map","body","call","reduce"],"mappings":";;AAGA,gFACaA,MAAAA,kBAAAA,GAAqB;AAC3B,MAAMC,oBAAoB;AAC1B,MAAMC,oBAAoB;AAC1B,MAAMC,kBAAkB;AAC/B,+FACaC,MAAAA,gBAAAA,GAAmB;AAChC,sFACaC,MAAAA,iBAAAA,GAAoB;AAC1B,MAAMC,wBAAwB;AAC9B,MAAMC,mBAAmB;AAChC,8DACaC,MAAAA,yBAAAA,GAA4B;AACzC;;;;IAKaC,MAAAA,kBA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nBlG,KAAK,CAACX,kBAAmB,CAAA,EACzBc,EAAGwF,CAAAA,KAAK,CAACe,CAAE5B,CAAAA,CAAC,EAAE4B,CAAAA,CAAEP,CAAC,EAAEhG,EAAAA,CAAGuC,GAAG,CAACgE,CAAEN,CAAAA,CAAC,EAAEjG,EAAAA,CAAGsC,GAAG,CAACtC,EAAAA,CAAGuC,GAAG,CAAC1C,MAAMoC,GAAG,EAAE,CAAIsI,CAAAA,EAAAA,KAAAA,CAAAA,CAAAA,CAAAA,EAC5D,GACA5H,CAAC;AACL;;;;"}
|
package/dist/shaders/shadow.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { hasDepthChannel } from '@zephyr3d/device';
|
|
2
2
|
import { REVERSE_Z, DEPTH_FARTHEST } from '@zephyr3d/base';
|
|
3
|
-
import { LIGHT_TYPE_DIRECTIONAL,
|
|
3
|
+
import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
|
|
4
4
|
import { encodeNormalizedFloatToRGBA, decode2HalfFromRGBA, decodeNormalizedFloatFromRGBA } from './misc.js';
|
|
5
5
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
6
6
|
import { smoothNoise3D } from './noise.js';
|
|
7
|
-
import { getDevice } from '../app/api.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Whether the shadow-space depth compared by a filter is the device depth
|
|
@@ -349,21 +348,6 @@ import { getDevice } from '../app/api.js';
|
|
|
349
348
|
];
|
|
350
349
|
/** @internal */ function getProgressivePoissonDiscSample(scope, index) {
|
|
351
350
|
const pb = scope.$builder;
|
|
352
|
-
if (pb.getDevice().type === 'webgl') {
|
|
353
|
-
const funcName = 'lib_getProgressivePoissonDiscSampleWebGL1';
|
|
354
|
-
pb.func(funcName, [
|
|
355
|
-
pb.int('index')
|
|
356
|
-
], function() {
|
|
357
|
-
for(let i = 0; i < PCF_POISSON_DISC.length; i++){
|
|
358
|
-
const sample = PCF_POISSON_DISC[i * 19 % PCF_POISSON_DISC.length];
|
|
359
|
-
this.$if(pb.equal(this.index, i), function() {
|
|
360
|
-
this.$return(pb.vec2(sample[0], sample[1]));
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
this.$return(pb.vec2(PCF_POISSON_DISC[0][0], PCF_POISSON_DISC[0][1]));
|
|
364
|
-
});
|
|
365
|
-
return pb.getGlobalScope()[funcName](index);
|
|
366
|
-
}
|
|
367
351
|
if (!pb.getGlobalScope().PCSSpdSamples) {
|
|
368
352
|
pb.getGlobalScope().PCSSpdSamples = PCF_POISSON_DISC.map((sample)=>pb.vec2(sample[0], sample[1]));
|
|
369
353
|
}
|
|
@@ -404,7 +388,7 @@ function getShadowMapSize(scope) {
|
|
|
404
388
|
} else {
|
|
405
389
|
this.$l.depth = pb.float();
|
|
406
390
|
this.$l.lightType = ShaderHelper.getLightTypeForShadow(this);
|
|
407
|
-
this.$if(pb.
|
|
391
|
+
this.$if(pb.equal(this.lightType, LIGHT_TYPE_DIRECTIONAL), function() {
|
|
408
392
|
this.depth = pb.emulateDepthClamp ? pb.clamp(this.$inputs.clamppedDepth, 0, 1) : this.$builtins.fragCoord.z;
|
|
409
393
|
}).$elseif(pb.equal(this.lightType, LIGHT_TYPE_POINT), function() {
|
|
410
394
|
this.$l.lightSpacePos = pb.mul(ShaderHelper.getLightViewMatrixForShadow(this), pb.vec4(this.worldPos, 1));
|
|
@@ -463,9 +447,9 @@ function sampleShadowMapPCF(scope, shadowMapFormat, pos, offset, depth, cascade)
|
|
|
463
447
|
const sampleDepth = this.z;
|
|
464
448
|
const uv = pb.add(this.coords, this.offset);
|
|
465
449
|
if (nativeShadowMap) {
|
|
466
|
-
this.$return(cascade
|
|
450
|
+
this.$return(cascade ? pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), uv, this.cascade, sampleDepth) : pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), uv, sampleDepth));
|
|
467
451
|
} else {
|
|
468
|
-
this.$l.shadowTex = cascade
|
|
452
|
+
this.$l.shadowTex = cascade ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), uv, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), uv, 0);
|
|
469
453
|
if (shadowMapFormat === 'rgba8unorm') {
|
|
470
454
|
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
471
455
|
}
|
|
@@ -495,7 +479,7 @@ function sampleShadowDepthPCSS(scope, shadowMapFormat, deviceEncoded, pos, bound
|
|
|
495
479
|
this.$if(this.sampleInside, function() {
|
|
496
480
|
this.$l.boundsPadding = pb.mul(pb.sub(this.bounds.zw, this.bounds.xy), getShadowMapTexelSize(this), 0.5);
|
|
497
481
|
this.$l.sampleCoord = pb.clamp(this.coords, pb.add(this.bounds.xy, this.boundsPadding), pb.sub(this.bounds.zw, this.boundsPadding));
|
|
498
|
-
this.$l.shadowTex = cascade
|
|
482
|
+
this.$l.shadowTex = cascade ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.sampleCoord, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.sampleCoord, 0);
|
|
499
483
|
this.depth = shadowMapFormat === 'rgba8unorm' ? decodeNormalizedFloatFromRGBA(this, this.shadowTex) : this.shadowTex.x;
|
|
500
484
|
});
|
|
501
485
|
this.$return(this.depth);
|
|
@@ -585,7 +569,7 @@ function sampleShadowPCFPCSS(scope, shadowMapFormat, deviceEncoded, pos, bounds,
|
|
|
585
569
|
cascade
|
|
586
570
|
] : []);
|
|
587
571
|
}
|
|
588
|
-
function samplePointShadowPCFPCSS(scope, shadowMapFormat, dir, compareDepth, texelSize, tangent, bitangent) {
|
|
572
|
+
function samplePointShadowPCFPCSS(scope, shadowMapFormat, dir, compareDepth, texelSize, tangent, bitangent, plane, depthParams) {
|
|
589
573
|
const funcName = `lib_samplePointShadowPCFPCSS_${shadowMapFormat}`;
|
|
590
574
|
const pb = scope.$builder;
|
|
591
575
|
pb.func(funcName, [
|
|
@@ -593,7 +577,9 @@ function samplePointShadowPCFPCSS(scope, shadowMapFormat, dir, compareDepth, tex
|
|
|
593
577
|
pb.float('compareDepth'),
|
|
594
578
|
pb.float('texelSize'),
|
|
595
579
|
pb.vec3('tangent'),
|
|
596
|
-
pb.vec3('bitangent')
|
|
580
|
+
pb.vec3('bitangent'),
|
|
581
|
+
pb.vec4('plane'),
|
|
582
|
+
pb.vec2('depthParams')
|
|
597
583
|
], function() {
|
|
598
584
|
this.$l.shadow = pb.float(0);
|
|
599
585
|
this.$l.transitionWidth = pb.float(1 / 65535);
|
|
@@ -622,16 +608,17 @@ function samplePointShadowPCFPCSS(scope, shadowMapFormat, dir, compareDepth, tex
|
|
|
622
608
|
this.offset = pb.mul(pb.vec2(ox, oy), this.texelSize);
|
|
623
609
|
this.sampleDir = pb.normalize(pb.add(this.dir, pb.add(pb.mul(this.tangent, this.offset.x), pb.mul(this.bitangent, this.offset.y))));
|
|
624
610
|
this.sampleDepth = samplePointShadowDepthPCSS(this, shadowMapFormat, this.sampleDir);
|
|
625
|
-
|
|
611
|
+
// Each sub-tap reads its own texel, so each is compared against the
|
|
612
|
+
// receiver there - see pointReceiverPlaneDepth.
|
|
613
|
+
this.shadow = pb.add(this.shadow, compareShadowDepthPCSS(this, this.sampleDepth, pointReceiverPlaneDepth(this, this.sampleDir, this.plane, this.compareDepth, this.depthParams), this.transitionWidth, false));
|
|
626
614
|
}
|
|
627
615
|
this.$return(pb.mul(this.shadow, 0.25));
|
|
628
616
|
});
|
|
629
|
-
return pb.getGlobalScope()[funcName](dir, compareDepth, texelSize, tangent, bitangent);
|
|
617
|
+
return pb.getGlobalScope()[funcName](dir, compareDepth, texelSize, tangent, bitangent, plane, depthParams);
|
|
630
618
|
}
|
|
631
619
|
function findBlockerPCSS(scope, shadowMapFormat, deviceEncoded, tapCount, texCoord, bounds, searchRadius, transitionWidth, matrix, cascade) {
|
|
632
620
|
const funcName = `lib_findBlockerPCSS_${shadowMapFormat}_${cascade ? 1 : 0}${REVERSE_Z && deviceEncoded ? '_rev' : ''}`;
|
|
633
621
|
const pb = scope.$builder;
|
|
634
|
-
const webgl1 = pb.getDevice().type === 'webgl';
|
|
635
622
|
pb.func(funcName, [
|
|
636
623
|
pb.vec4('texCoord'),
|
|
637
624
|
pb.vec4('bounds'),
|
|
@@ -649,12 +636,7 @@ function findBlockerPCSS(scope, shadowMapFormat, deviceEncoded, tapCount, texCoo
|
|
|
649
636
|
this.$l.sampleCoord = pb.vec2();
|
|
650
637
|
this.$l.sampleDepth = pb.float();
|
|
651
638
|
this.$l.blockerWeight = pb.float();
|
|
652
|
-
this.$for(pb.float('i'), 0,
|
|
653
|
-
if (webgl1) {
|
|
654
|
-
this.$if(pb.greaterThanEqual(this.i, this.tapCount), function() {
|
|
655
|
-
this.$break();
|
|
656
|
-
});
|
|
657
|
-
}
|
|
639
|
+
this.$for(pb.float('i'), 0, this.tapCount, function() {
|
|
658
640
|
this.duv = pb.mul(pb.mul(this.matrix, getProgressivePoissonDiscSample(this, pb.int(this.i))), this.searchRadius);
|
|
659
641
|
this.sampleCoord = pb.add(this.texCoord.xy, this.duv);
|
|
660
642
|
this.sampleDepth = sampleShadowDepthPCSS(this, shadowMapFormat, deviceEncoded, this.sampleCoord, this.bounds, this.cascade);
|
|
@@ -670,10 +652,54 @@ function findBlockerPCSS(scope, shadowMapFormat, deviceEncoded, tapCount, texCoo
|
|
|
670
652
|
cascade
|
|
671
653
|
] : []);
|
|
672
654
|
}
|
|
673
|
-
|
|
655
|
+
/**
|
|
656
|
+
* Normalized radial depth of the receiver's plane along a cube tap direction.
|
|
657
|
+
*
|
|
658
|
+
* @remarks
|
|
659
|
+
* The cube counterpart of `computeReceiverPlaneDepthBias`. A cube map stores
|
|
660
|
+
* distance from the light, so across a filter kernel the receiver's own depth
|
|
661
|
+
* changes with direction - on any plane not facing the light head-on, and
|
|
662
|
+
* even on one that does, since radial distance to a plane grows off its
|
|
663
|
+
* normal. Comparing every tap against the centre's depth makes the receiver
|
|
664
|
+
* occlude itself on one side of the kernel, which at PCSS kernel sizes turns a
|
|
665
|
+
* wide penumbra into a flat plateau of false shadow that snaps to fully lit
|
|
666
|
+
* where the blocker search runs out.
|
|
667
|
+
*
|
|
668
|
+
* Along the tap itself rather than at a texel centre, because the cube is
|
|
669
|
+
* sampled bilinearly: what a tap reads is the stored plane depths interpolated
|
|
670
|
+
* to its direction, which matches the plane there to second order.
|
|
671
|
+
*
|
|
672
|
+
* `plane` is the receiver's light-space plane as `(normal, dot(p, normal))` for
|
|
673
|
+
* the light-to-receiver vector `p`; a zero normal, a tap parallel to the plane
|
|
674
|
+
* or one that would meet it behind the light fall back to `centerDepth`.
|
|
675
|
+
* `depthParams` is `(1 / range, depth bias)`.
|
|
676
|
+
*
|
|
677
|
+
* @internal
|
|
678
|
+
*/ function pointReceiverPlaneDepth(scope, dir, plane, centerDepth, depthParams) {
|
|
679
|
+
const pb = scope.$builder;
|
|
680
|
+
pb.func('lib_pointReceiverPlaneDepth', [
|
|
681
|
+
pb.vec3('dir'),
|
|
682
|
+
pb.vec4('plane'),
|
|
683
|
+
pb.float('centerDepth'),
|
|
684
|
+
pb.vec2('depthParams')
|
|
685
|
+
], function() {
|
|
686
|
+
this.$l.denom = pb.dot(this.dir, this.plane.xyz);
|
|
687
|
+
this.$if(pb.lessThan(pb.abs(this.denom), 1e-8), function() {
|
|
688
|
+
this.$return(this.centerDepth);
|
|
689
|
+
});
|
|
690
|
+
// Where the ray meets the plane, as a distance along it. `dir` need not be
|
|
691
|
+
// unit length: the parameter scales inversely with it.
|
|
692
|
+
this.$l.t = pb.div(this.plane.w, this.denom);
|
|
693
|
+
this.$if(pb.lessThanEqual(this.t, 0), function() {
|
|
694
|
+
this.$return(this.centerDepth);
|
|
695
|
+
});
|
|
696
|
+
this.$return(pb.sub(pb.mul(this.t, pb.length(this.dir), this.depthParams.x), this.depthParams.y));
|
|
697
|
+
});
|
|
698
|
+
return pb.getGlobalScope().lib_pointReceiverPlaneDepth(dir, plane, centerDepth, depthParams);
|
|
699
|
+
}
|
|
700
|
+
function findPointBlockerPCSS(scope, shadowMapFormat, tapCount, dir, compareDepth, searchRadius, transitionWidth, matrix, tangent, bitangent, plane, depthParams) {
|
|
674
701
|
const funcName = `lib_findPointBlockerPCSS_${shadowMapFormat}`;
|
|
675
702
|
const pb = scope.$builder;
|
|
676
|
-
const webgl1 = pb.getDevice().type === 'webgl';
|
|
677
703
|
pb.func(funcName, [
|
|
678
704
|
pb.vec3('dir'),
|
|
679
705
|
pb.float('compareDepth'),
|
|
@@ -682,7 +708,9 @@ function findPointBlockerPCSS(scope, shadowMapFormat, tapCount, dir, compareDept
|
|
|
682
708
|
pb.float('transitionWidth'),
|
|
683
709
|
pb.mat2('matrix'),
|
|
684
710
|
pb.vec3('tangent'),
|
|
685
|
-
pb.vec3('bitangent')
|
|
711
|
+
pb.vec3('bitangent'),
|
|
712
|
+
pb.vec4('plane'),
|
|
713
|
+
pb.vec2('depthParams')
|
|
686
714
|
], function() {
|
|
687
715
|
this.$l.blockerDepthSum = pb.float(0);
|
|
688
716
|
this.$l.blockerCount = pb.float(0);
|
|
@@ -690,22 +718,17 @@ function findPointBlockerPCSS(scope, shadowMapFormat, tapCount, dir, compareDept
|
|
|
690
718
|
this.$l.sampleDir = pb.vec3();
|
|
691
719
|
this.$l.sampleDepth = pb.float();
|
|
692
720
|
this.$l.blockerWeight = pb.float();
|
|
693
|
-
this.$for(pb.float('i'), 0,
|
|
694
|
-
if (webgl1) {
|
|
695
|
-
this.$if(pb.greaterThanEqual(this.i, this.tapCount), function() {
|
|
696
|
-
this.$break();
|
|
697
|
-
});
|
|
698
|
-
}
|
|
721
|
+
this.$for(pb.float('i'), 0, this.tapCount, function() {
|
|
699
722
|
this.duv = pb.mul(pb.mul(this.matrix, getProgressivePoissonDiscSample(this, pb.int(this.i))), this.searchRadius);
|
|
700
723
|
this.sampleDir = pb.normalize(pb.add(this.dir, pb.add(pb.mul(this.tangent, this.duv.x), pb.mul(this.bitangent, this.duv.y))));
|
|
701
724
|
this.sampleDepth = samplePointShadowDepthPCSS(this, shadowMapFormat, this.sampleDir);
|
|
702
|
-
this.blockerWeight = pb.sub(1, pb.smoothStep(pb.neg(this.transitionWidth), this.transitionWidth, pb.sub(this.sampleDepth, this.compareDepth)));
|
|
725
|
+
this.blockerWeight = pb.sub(1, pb.smoothStep(pb.neg(this.transitionWidth), this.transitionWidth, pb.sub(this.sampleDepth, pointReceiverPlaneDepth(this, this.sampleDir, this.plane, this.compareDepth, this.depthParams))));
|
|
703
726
|
this.blockerDepthSum = pb.add(this.blockerDepthSum, pb.mul(this.sampleDepth, this.blockerWeight));
|
|
704
727
|
this.blockerCount = pb.add(this.blockerCount, this.blockerWeight);
|
|
705
728
|
});
|
|
706
729
|
this.$return(pb.vec2(this.$choice(pb.greaterThan(this.blockerCount, 0), pb.div(this.blockerDepthSum, pb.max(this.blockerCount, 0.0001)), -1), this.blockerCount));
|
|
707
730
|
});
|
|
708
|
-
return pb.getGlobalScope()[funcName](dir, compareDepth, searchRadius, tapCount, transitionWidth, matrix, tangent, bitangent);
|
|
731
|
+
return pb.getGlobalScope()[funcName](dir, compareDepth, searchRadius, tapCount, transitionWidth, matrix, tangent, bitangent, plane, depthParams);
|
|
709
732
|
}
|
|
710
733
|
function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
711
734
|
const flip = REVERSE_Z && deviceEncoded;
|
|
@@ -749,7 +772,7 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
749
772
|
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xyz, 0);
|
|
750
773
|
this.$return(chebyshevUpperBound(this, this.texCoord.w, shadowMapFormat === 'rgba8unorm' ? pb.vec3(decode2HalfFromRGBA(this, this.shadowTex), 1) : this.shadowTex.rgb, false));
|
|
751
774
|
} else {
|
|
752
|
-
if (
|
|
775
|
+
if (cascade) {
|
|
753
776
|
this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xy, this.cascade, 0);
|
|
754
777
|
} else {
|
|
755
778
|
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xy, 0);
|
|
@@ -780,7 +803,7 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
780
803
|
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
781
804
|
}
|
|
782
805
|
} else {
|
|
783
|
-
if (cascade
|
|
806
|
+
if (cascade) {
|
|
784
807
|
this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xy, this.cascade, 0);
|
|
785
808
|
} else {
|
|
786
809
|
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xy, 0);
|
|
@@ -902,7 +925,6 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
902
925
|
/** @internal */ function filterShadowPCSS(scope, lightType, shadowMapFormat, texCoord, receiverPlaneDepthBias, cascade, temporalJitter = true, numCascades = 1) {
|
|
903
926
|
const funcNameFilterShadowPCSS = `lib_filterShadowPCSS_${lightType}_${shadowMapFormat}_${receiverPlaneDepthBias ? 1 : 0}_${cascade ? 1 : 0}_${temporalJitter ? 1 : 0}_${numCascades}`;
|
|
904
927
|
const pb = scope.$builder;
|
|
905
|
-
const webgl1 = pb.getDevice().type === 'webgl';
|
|
906
928
|
pb.func(funcNameFilterShadowPCSS, [
|
|
907
929
|
pb.vec4('texCoord'),
|
|
908
930
|
...receiverPlaneDepthBias ? [
|
|
@@ -916,7 +938,11 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
916
938
|
this.$l.PCSSfilterSampleCount = ShaderHelper.getShadowImplParams(this).z;
|
|
917
939
|
this.$l.PCSSlightRadius = ShaderHelper.getShadowImplParams(this).x;
|
|
918
940
|
this.$l.PCSSmaxFilterRadius = ShaderHelper.getShadowImplParams(this).w;
|
|
919
|
-
|
|
941
|
+
// A negative light radius is a physical source radius in world units rather
|
|
942
|
+
// than a size in texels - see PCSS.physicalLightRadius. Only the cube
|
|
943
|
+
// branch below reads it that way; the search itself spans the whole filter
|
|
944
|
+
// budget either way.
|
|
945
|
+
this.$l.PCSSsearchRadius = this.$choice(pb.notEqual(this.PCSSlightRadius, 0), pb.max(pb.abs(this.PCSSlightRadius), this.PCSSmaxFilterRadius), 0);
|
|
920
946
|
if (lightType === LIGHT_TYPE_POINT) {
|
|
921
947
|
this.$l.lightDepth = this.texCoord.w;
|
|
922
948
|
this.$l.sampleDir = pb.normalize(this.texCoord.xyz);
|
|
@@ -927,24 +953,45 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
927
953
|
this.$l.up = this.$choice(pb.lessThan(pb.abs(this.sampleDir.y), 0.999), pb.vec3(0, 1, 0), pb.vec3(1, 0, 0));
|
|
928
954
|
this.$l.tangent = pb.normalize(pb.cross(this.up, this.sampleDir));
|
|
929
955
|
this.$l.bitangent = pb.cross(this.sampleDir, this.tangent);
|
|
930
|
-
|
|
956
|
+
// For cube maps the receiver-plane slot carries the receiver's light-space
|
|
957
|
+
// plane normal rather than a depth gradient; see pointReceiverPlaneDepth.
|
|
958
|
+
this.$l.receiverPlane = pb.vec4(0);
|
|
959
|
+
this.$l.depthParams = pb.vec2(0);
|
|
960
|
+
if (receiverPlaneDepthBias) {
|
|
961
|
+
this.$l.invRange = pb.div(1, ShaderHelper.getLightPositionAndRangeForShadow(this).w);
|
|
962
|
+
this.receiverPlane = pb.vec4(this.receiverPlaneDepthBias, pb.dot(this.texCoord.xyz, this.receiverPlaneDepthBias));
|
|
963
|
+
// The receiver's own bias, plus one shadow texel's footprint at the
|
|
964
|
+
// receiver. The point light's depth bias is sized to a texel at the near
|
|
965
|
+
// plane, a small fraction of one here; with the slope handled by the
|
|
966
|
+
// plane, what remains to cover is bilinear interpolation error and the
|
|
967
|
+
// storage format's rounding - half a float's relative precision is
|
|
968
|
+
// 2^-11, below a texel's angular size of 2 / size for any map up to
|
|
969
|
+
// 2048 - and without it the comparison flips texel by texel wherever
|
|
970
|
+
// the plane's depth barely changes, which is right under the light:
|
|
971
|
+
// rings of isolated black pixels there.
|
|
972
|
+
this.depthParams = pb.vec2(this.invRange, pb.add(pb.sub(pb.mul(pb.length(this.texCoord.xyz), this.invRange), this.lightDepth), pb.mul(this.lightDepth, this.shadowMapTexelSize)));
|
|
973
|
+
}
|
|
974
|
+
this.$l.blocker = findPointBlockerPCSS(this, shadowMapFormat, this.PCSSblockerSampleCount, this.sampleDir, this.lightDepth, this.searchRadius, this.blockerTransitionWidth, this.matrix, this.tangent, this.bitangent, this.receiverPlane, this.depthParams);
|
|
931
975
|
this.$if(pb.lessThanEqual(this.blocker.y, 0), function() {
|
|
932
976
|
this.$return(pb.float(1));
|
|
933
977
|
});
|
|
934
978
|
this.$l.penumbra = pb.div(pb.max(pb.sub(this.lightDepth, this.blocker.x), 0), pb.max(this.blocker.x, 0.0001));
|
|
935
|
-
|
|
979
|
+
// With a physical source radius R, the penumbra at the receiver is
|
|
980
|
+
// R * (dr - db) / db wide, and seen from the light that is an angle of
|
|
981
|
+
// penumbra * R / dr - which is what an offset on the unit-length sample
|
|
982
|
+
// direction measures. So the light's size in texels follows the
|
|
983
|
+
// receiver's distance, instead of being one fixed texel count that
|
|
984
|
+
// over-blurs near the light and under-blurs far from it.
|
|
985
|
+
this.$l.receiverDistance = pb.max(pb.mul(this.lightDepth, ShaderHelper.getLightPositionAndRangeForShadow(this).w), 0.0001);
|
|
986
|
+
this.$l.lightRadiusTexels = this.$choice(pb.lessThan(this.PCSSlightRadius, 0), pb.div(pb.div(pb.neg(this.PCSSlightRadius), this.receiverDistance), this.shadowMapTexelSize), this.PCSSlightRadius);
|
|
987
|
+
this.$l.filterRadius = pb.mul(pb.clamp(pb.mul(this.penumbra, this.lightRadiusTexels), 0, pb.max(0, this.PCSSmaxFilterRadius)), this.shadowMapTexelSize);
|
|
936
988
|
this.$l.shadow = pb.float(0);
|
|
937
989
|
this.$l.duv = pb.vec2();
|
|
938
990
|
this.$l.samplePointDir = pb.vec3();
|
|
939
|
-
this.$for(pb.float('i'), 0,
|
|
940
|
-
if (webgl1) {
|
|
941
|
-
this.$if(pb.greaterThanEqual(this.i, this.PCSSfilterSampleCount), function() {
|
|
942
|
-
this.$break();
|
|
943
|
-
});
|
|
944
|
-
}
|
|
991
|
+
this.$for(pb.float('i'), 0, this.PCSSfilterSampleCount, function() {
|
|
945
992
|
this.duv = pb.mul(pb.mul(this.matrix, getProgressivePoissonDiscSample(this, pb.int(this.i))), this.filterRadius);
|
|
946
993
|
this.samplePointDir = pb.normalize(pb.add(this.sampleDir, pb.add(pb.mul(this.tangent, this.duv.x), pb.mul(this.bitangent, this.duv.y))));
|
|
947
|
-
this.shadow = pb.add(this.shadow, samplePointShadowPCFPCSS(this, shadowMapFormat, this.samplePointDir, this.lightDepth, this.shadowMapTexelSize, this.tangent, this.bitangent));
|
|
994
|
+
this.shadow = pb.add(this.shadow, samplePointShadowPCFPCSS(this, shadowMapFormat, this.samplePointDir, this.lightDepth, this.shadowMapTexelSize, this.tangent, this.bitangent, this.receiverPlane, this.depthParams));
|
|
948
995
|
});
|
|
949
996
|
this.shadow = pb.div(this.shadow, this.PCSSfilterSampleCount);
|
|
950
997
|
this.$return(this.shadow);
|
|
@@ -957,14 +1004,6 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
957
1004
|
// The scalar `.z` guard is gone (see computeReceiverPlaneDepthBias); the
|
|
958
1005
|
// per-tap plane gradient below is the part that was ever load bearing.
|
|
959
1006
|
this.$l.sampleBounds = pb.vec4(0, 0, 1, 1);
|
|
960
|
-
if (cascade && getDevice().type === 'webgl' && numCascades > 1) {
|
|
961
|
-
const numCols = numCascades > 1 ? 2 : 1;
|
|
962
|
-
const numRows = numCascades > 2 ? 2 : 1;
|
|
963
|
-
this.$l.cascadeIndex = pb.float(this.cascade);
|
|
964
|
-
this.$l.cascadeCol = pb.mod(this.cascadeIndex, 2);
|
|
965
|
-
this.$l.cascadeRow = pb.floor(pb.mul(this.cascadeIndex, 0.5));
|
|
966
|
-
this.sampleBounds = pb.vec4(pb.mul(this.cascadeCol, 1 / numCols), pb.mul(this.cascadeRow, 1 / numRows), pb.mul(pb.add(this.cascadeCol, 1), 1 / numCols), pb.mul(pb.add(this.cascadeRow, 1), 1 / numRows));
|
|
967
|
-
}
|
|
968
1007
|
this.$l.shadowMapTexelSize = pb.mul(pb.sub(this.sampleBounds.zw, this.sampleBounds.xy), getShadowMapTexelSize(this));
|
|
969
1008
|
this.$l.matrix = getPCSSRotationMatrix(this, pb.mul(this.texCoord.xy, pb.vec2(getShadowMapSize(this))), temporalJitter);
|
|
970
1009
|
this.$l.searchRadius = pb.mul(pb.clamp(this.PCSSsearchRadius, 0, pb.max(0, this.PCSSmaxFilterRadius)), this.shadowMapTexelSize);
|
|
@@ -981,12 +1020,7 @@ function chebyshevUpperBound(scope, distance, occluder, deviceEncoded) {
|
|
|
981
1020
|
this.$l.duv = pb.vec2();
|
|
982
1021
|
this.$l.sampleCoord = pb.vec2();
|
|
983
1022
|
this.$l.compareDepth = pb.float();
|
|
984
|
-
this.$for(pb.float('i'), 0,
|
|
985
|
-
if (webgl1) {
|
|
986
|
-
this.$if(pb.greaterThanEqual(this.i, this.PCSSfilterSampleCount), function() {
|
|
987
|
-
this.$break();
|
|
988
|
-
});
|
|
989
|
-
}
|
|
1023
|
+
this.$for(pb.float('i'), 0, this.PCSSfilterSampleCount, function() {
|
|
990
1024
|
this.duv = pb.mul(pb.mul(this.matrix, getProgressivePoissonDiscSample(this, pb.int(this.i))), this.filterRadius);
|
|
991
1025
|
this.sampleCoord = pb.add(this.texCoord.xy, this.duv);
|
|
992
1026
|
this.compareDepth = receiverPlaneDepthBias ? pb.add(this.lightDepth, pb.dot(this.duv, this.receiverPlaneDepthBias.xy)) : this.lightDepth;
|