@zephyr3d/scene 0.9.27 → 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 +54 -0
- 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 +279 -55
- 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 +171 -1
- 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 +104 -178
- 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 +25436 -15990
- package/dist/index.js +65 -11
- 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/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +66 -4
- 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 +191 -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 +333 -191
- 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 +1261 -1438
- 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 +106 -106
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +2 -6
- 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 +4 -13
- 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 +3 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +179 -64
- 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 +25 -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 +5 -5
- 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 +5 -10
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +247 -157
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +16 -38
- 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/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +19 -8
- 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/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 +162 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +10 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +14 -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 +272 -55
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +41 -0
- package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
- 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 +58 -158
- package/dist/render/underwater.js.map +1 -1
- 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 +134 -319
- package/dist/render/water_caustics.js.map +1 -1
- 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 +3 -3
- 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 +633 -268
- 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/ssgi.js +63 -0
- package/dist/shaders/ssgi.js.map +1 -0
- package/dist/shaders/ssgi_reprojection.js +118 -0
- package/dist/shaders/ssgi_reprojection.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 +32 -82
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +7 -21
- package/dist/shaders/water_medium.js.map +1 -1
- 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 +40 -2
- 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 +34 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +46 -5
- 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 +87 -254
- 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 +1543 -264
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +10 -22
- 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
- package/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
import { Vector4 } from '@zephyr3d/base';
|
|
2
|
+
import { getDevice } from '../../app/api.js';
|
|
3
|
+
import { buildSDFProgram } from '../sdf/sdf_programs.js';
|
|
4
|
+
import { drawFullscreenQuad } from '../fullscreenquad.js';
|
|
5
|
+
import { fetchSampler } from '../../utility/misc.js';
|
|
6
|
+
import { getGICacheExposure } from '../../utility/physical.js';
|
|
7
|
+
import { LIGHT_TYPE_RECT, LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_SPOT } from '../../values.js';
|
|
8
|
+
import { defineLTCEdgeFunctions } from '../../shaders/ltc_rect.js';
|
|
9
|
+
import { declareGlobalSDFUniforms, declareDynamicSDFUniforms, GLOBAL_SDF_LEVELS, sampleGlobalSDFWithVoxel, GLOBAL_SDF_PARAMS } from '../../shaders/sdf.js';
|
|
10
|
+
import { sdfConeShadow } from '../../shaders/gi.js';
|
|
11
|
+
import { declareProbeUniforms, sampleProbeIrradiance } from '../../shaders/probes.js';
|
|
12
|
+
import { getActiveProbeVolume } from './probe_volume.js';
|
|
13
|
+
|
|
14
|
+
/** Most lights the voxels are lit by, the sun aside. */ const MAX_VOXEL_LIGHTS = 64;
|
|
15
|
+
/**
|
|
16
|
+
* vec4s per packed light: (position, range), (direction, cutoff), (colour, intensity), extra,
|
|
17
|
+
* (shadowed, 0, 0, 0).
|
|
18
|
+
*/ const LIGHT_VEC4S = 5;
|
|
19
|
+
/** Material voxels along a brick edge of the global field, whose bricks are 8³ field voxels. */ const BRICK_VOXELS = 4;
|
|
20
|
+
/**
|
|
21
|
+
* Format of the second aniso texture, two faces (-y, -z): rg8unorm where the
|
|
22
|
+
* device can write it from a shader (texture-formats-tier1), else rgba8unorm.
|
|
23
|
+
*/ function aniso1Format() {
|
|
24
|
+
return getDevice().getDeviceCaps().textureCaps.getTextureFormatInfo('rg8unorm')?.writable ? 'rg8unorm' : 'rgba8unorm';
|
|
25
|
+
}
|
|
26
|
+
/** Most local lights whose voxel lighting is shadowed, the nearest the camera first. */ const MAX_SHADOWED_VOXEL_LIGHTS = 8;
|
|
27
|
+
/**
|
|
28
|
+
* Cone of a local light shadow ray. Lumen traces these as hard hit tests; a vanishing cone through
|
|
29
|
+
* {@link sdfConeShadow} is the same test with its expanded surfaces.
|
|
30
|
+
*/ const HARD_SHADOW_TAN = 1e-4;
|
|
31
|
+
/** Cone tracing steps of the sun shadow and the local light shadows. */ const SHADOW_STEPS = 24;
|
|
32
|
+
/** The axis faces of a voxel, in the order of the aniso textures. */ const ANISO_DIRS = [
|
|
33
|
+
[
|
|
34
|
+
1,
|
|
35
|
+
0,
|
|
36
|
+
0
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
0,
|
|
40
|
+
1,
|
|
41
|
+
0
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
1
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
-1,
|
|
50
|
+
0,
|
|
51
|
+
0
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
0,
|
|
55
|
+
-1,
|
|
56
|
+
0
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
-1
|
|
62
|
+
]
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* Lights the voxel scene: per material voxel, the sun (cone-traced field shadow, see
|
|
66
|
+
* {@link sdfConeShadow}), punctual lights in range (rect lights by their one-sided
|
|
67
|
+
* polygon form factor per voxel face, as surfaces shade them; shadowed by one hard field ray for
|
|
68
|
+
* the nearest {@link MAX_SHADOWED_VOXEL_LIGHTS} local lights casting shadows) and sky irradiance,
|
|
69
|
+
* times albedo,
|
|
70
|
+
* plus emissive, into the radiance clipmap. Kept at the fixed cache exposure
|
|
71
|
+
* (getGICacheExposure) so probes accumulating it don't drift with camera exposure.
|
|
72
|
+
*
|
|
73
|
+
* A fragment pass, one fragment per voxel of a slab of z slices rotating through every
|
|
74
|
+
* level, so the scene refreshes over a few frames. Voxels without material write zero.
|
|
75
|
+
*
|
|
76
|
+
* @internal
|
|
77
|
+
*/ class VoxelLighting {
|
|
78
|
+
_scene;
|
|
79
|
+
_radiance;
|
|
80
|
+
_aniso0;
|
|
81
|
+
_aniso1;
|
|
82
|
+
_resolution;
|
|
83
|
+
_levels;
|
|
84
|
+
_program;
|
|
85
|
+
_programKey;
|
|
86
|
+
_bindGroup;
|
|
87
|
+
_brickProgram;
|
|
88
|
+
_brickBindGroup;
|
|
89
|
+
_brickBuffer;
|
|
90
|
+
_renderStates;
|
|
91
|
+
_lightData;
|
|
92
|
+
_zStart;
|
|
93
|
+
_passes;
|
|
94
|
+
_sunDir;
|
|
95
|
+
_sunColor;
|
|
96
|
+
_params;
|
|
97
|
+
_slab;
|
|
98
|
+
constructor(scene){
|
|
99
|
+
this._scene = scene;
|
|
100
|
+
this._radiance = null;
|
|
101
|
+
this._aniso0 = null;
|
|
102
|
+
this._aniso1 = null;
|
|
103
|
+
this._resolution = 0;
|
|
104
|
+
this._levels = 0;
|
|
105
|
+
this._program = null;
|
|
106
|
+
this._programKey = '';
|
|
107
|
+
this._bindGroup = null;
|
|
108
|
+
this._brickProgram = null;
|
|
109
|
+
this._brickBindGroup = null;
|
|
110
|
+
this._brickBuffer = null;
|
|
111
|
+
this._renderStates = null;
|
|
112
|
+
this._lightData = new Float32Array(MAX_VOXEL_LIGHTS * LIGHT_VEC4S * 4);
|
|
113
|
+
this._zStart = 0;
|
|
114
|
+
this._passes = 0;
|
|
115
|
+
this._sunDir = new Vector4();
|
|
116
|
+
this._sunColor = new Vector4();
|
|
117
|
+
this._params = new Vector4();
|
|
118
|
+
this._slab = new Vector4();
|
|
119
|
+
}
|
|
120
|
+
/** Outgoing radiance clipmap, rgba16f, laid out like the albedo. */ get radiance() {
|
|
121
|
+
if (!this._radiance) {
|
|
122
|
+
throw new Error('VoxelLighting: no radiance before the first update');
|
|
123
|
+
}
|
|
124
|
+
return this._radiance;
|
|
125
|
+
}
|
|
126
|
+
/** Share of the radiance each voxel face carries, (+x, +y, +z, -x); see declareVoxelSceneUniforms. */ get aniso0() {
|
|
127
|
+
if (!this._aniso0) {
|
|
128
|
+
throw new Error('VoxelLighting: no radiance before the first update');
|
|
129
|
+
}
|
|
130
|
+
return this._aniso0;
|
|
131
|
+
}
|
|
132
|
+
/** Share of the radiance each voxel face carries, (-y, -z) in rg. */ get aniso1() {
|
|
133
|
+
if (!this._aniso1) {
|
|
134
|
+
throw new Error('VoxelLighting: no radiance before the first update');
|
|
135
|
+
}
|
|
136
|
+
return this._aniso1;
|
|
137
|
+
}
|
|
138
|
+
get ready() {
|
|
139
|
+
return !!this._radiance;
|
|
140
|
+
}
|
|
141
|
+
/** Lighting passes run so far. */ get passes() {
|
|
142
|
+
return this._passes;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Lights the next slab of every level.
|
|
146
|
+
* @param albedo - The albedo clipmap, `resolution`³ per level.
|
|
147
|
+
* @param emissive - The emissive clipmap.
|
|
148
|
+
*/ update(global, albedo, emissive, resolution, camera, options) {
|
|
149
|
+
const device = getDevice();
|
|
150
|
+
const scene = this._scene;
|
|
151
|
+
if (!this._radiance || this._resolution !== resolution || this._levels !== global.levels) {
|
|
152
|
+
this._radiance?.dispose();
|
|
153
|
+
this._aniso0?.dispose();
|
|
154
|
+
this._aniso1?.dispose();
|
|
155
|
+
this._resolution = resolution;
|
|
156
|
+
this._levels = global.levels;
|
|
157
|
+
const depth = resolution * global.levels;
|
|
158
|
+
this._radiance = device.createTexture3D('rgba16f', resolution, resolution, depth, {
|
|
159
|
+
mipmapping: false,
|
|
160
|
+
writable: true
|
|
161
|
+
});
|
|
162
|
+
this._radiance.name = '@VoxelSceneRadiance';
|
|
163
|
+
this._aniso0 = device.createTexture3D('rgba8unorm', resolution, resolution, depth, {
|
|
164
|
+
mipmapping: false,
|
|
165
|
+
writable: true
|
|
166
|
+
});
|
|
167
|
+
this._aniso0.name = '@VoxelSceneAniso0';
|
|
168
|
+
this._aniso1 = device.createTexture3D(aniso1Format(), resolution, resolution, depth, {
|
|
169
|
+
mipmapping: false,
|
|
170
|
+
writable: true
|
|
171
|
+
});
|
|
172
|
+
this._aniso1.name = '@VoxelSceneAniso1';
|
|
173
|
+
this._zStart = 0;
|
|
174
|
+
}
|
|
175
|
+
const envLight = scene.env.light.envLight;
|
|
176
|
+
const physical = scene.lightingMode === 'physical';
|
|
177
|
+
// Fixed cache exposure; the sky bake uses the same exposure, so it takes the strength alone
|
|
178
|
+
const cacheExposure = getGICacheExposure(scene.lightingMode);
|
|
179
|
+
const envStrength = scene.env.light.strength ?? 0;
|
|
180
|
+
// No sky without an environment light (its stand-in carries only the probes)
|
|
181
|
+
const skyIrradiance = scene.env.light.type !== 'none' && envLight.hasIrradiance();
|
|
182
|
+
const probes = getActiveProbeVolume(scene);
|
|
183
|
+
const key = `${global.levels}:${scene.lightingMode}:${skyIrradiance ? envLight.getType() : 'none'}:${skyIrradiance ? this.envVariant() : ''}:probes${probes ? 1 : 0}`;
|
|
184
|
+
if (!this._program || this._programKey !== key) {
|
|
185
|
+
this.disposePrograms();
|
|
186
|
+
this._program = this.createProgram(global.levels, physical, skyIrradiance, !!probes, false);
|
|
187
|
+
this._programKey = key;
|
|
188
|
+
this._bindGroup = device.createBindGroup(this._program.bindGroupLayouts[0]);
|
|
189
|
+
}
|
|
190
|
+
const numLights = this.collectLights(camera, cacheExposure, options.localLightShadows);
|
|
191
|
+
const slices = Math.max(1, Math.min(resolution, Math.floor(options.slicesPerFrame)));
|
|
192
|
+
const tanHalf = Math.tan(Math.max(0.1, options.sunShadowConeAngle) * Math.PI / 180);
|
|
193
|
+
this._params.setXYZW(numLights, envStrength, tanHalf, 0);
|
|
194
|
+
this._slab.setXYZW(resolution, global.levels, slices, this._zStart);
|
|
195
|
+
const bind = (bg)=>{
|
|
196
|
+
global.applyBindGroup(bg);
|
|
197
|
+
bg.setTexture('albedoTex', albedo, fetchSampler('clamp_nearest_nomip'));
|
|
198
|
+
bg.setTexture('emissiveTex', emissive, fetchSampler('clamp_nearest_nomip'));
|
|
199
|
+
bg.setTexture('radianceOut', this._radiance);
|
|
200
|
+
bg.setTexture('aniso0Out', this._aniso0);
|
|
201
|
+
bg.setTexture('aniso1Out', this._aniso1);
|
|
202
|
+
bg.setValue('lights', this._lightData);
|
|
203
|
+
bg.setValue('sunDir', this._sunDir);
|
|
204
|
+
bg.setValue('sunColor', this._sunColor);
|
|
205
|
+
bg.setValue('params', this._params);
|
|
206
|
+
bg.setValue('slab', this._slab);
|
|
207
|
+
if (skyIrradiance) {
|
|
208
|
+
envLight.updateBindGroup(bg);
|
|
209
|
+
}
|
|
210
|
+
probes?.applyBindGroup(bg);
|
|
211
|
+
};
|
|
212
|
+
if (!this._renderStates) {
|
|
213
|
+
this._renderStates = device.createRenderStateSet();
|
|
214
|
+
this._renderStates.useDepthState().enableTest(false).enableWrite(false);
|
|
215
|
+
this._renderStates.useRasterizerState().setCullMode('none');
|
|
216
|
+
this._renderStates.useColorState().setColorMask(false, false, false, false);
|
|
217
|
+
}
|
|
218
|
+
const draw = (program, bg, width, height)=>{
|
|
219
|
+
let fb = null;
|
|
220
|
+
device.pushDeviceStates();
|
|
221
|
+
try {
|
|
222
|
+
fb = device.pool.fetchTemporalFramebuffer(false, width, height, 'rgba8unorm');
|
|
223
|
+
device.setFramebuffer(fb);
|
|
224
|
+
device.setViewport([
|
|
225
|
+
0,
|
|
226
|
+
0,
|
|
227
|
+
width,
|
|
228
|
+
height
|
|
229
|
+
]);
|
|
230
|
+
device.setScissor([
|
|
231
|
+
0,
|
|
232
|
+
0,
|
|
233
|
+
width,
|
|
234
|
+
height
|
|
235
|
+
]);
|
|
236
|
+
device.setProgram(program);
|
|
237
|
+
device.setBindGroup(0, bg);
|
|
238
|
+
drawFullscreenQuad(this._renderStates);
|
|
239
|
+
} finally{
|
|
240
|
+
device.popDeviceStates();
|
|
241
|
+
if (fb) {
|
|
242
|
+
device.pool.releaseFrameBuffer(fb);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
bind(this._bindGroup);
|
|
247
|
+
draw(this._program, this._bindGroup, resolution, resolution * slices * global.levels);
|
|
248
|
+
// Bricks the field composited this frame hold stale radiance; light them now
|
|
249
|
+
// rather than up to resolution / slices frames later
|
|
250
|
+
const fresh = global.freshMaterialBricks;
|
|
251
|
+
if (fresh.count > 0) {
|
|
252
|
+
if (!this._brickProgram) {
|
|
253
|
+
this._brickProgram = this.createProgram(global.levels, physical, skyIrradiance, !!probes, true);
|
|
254
|
+
this._brickBindGroup = device.createBindGroup(this._brickProgram.bindGroupLayouts[0]);
|
|
255
|
+
}
|
|
256
|
+
const bytes = fresh.data.byteLength;
|
|
257
|
+
if (!this._brickBuffer || this._brickBuffer.byteLength < bytes) {
|
|
258
|
+
this._brickBuffer?.dispose();
|
|
259
|
+
this._brickBuffer = device.createBuffer(bytes, {
|
|
260
|
+
usage: 'uniform',
|
|
261
|
+
storage: true
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
this._brickBuffer.bufferSubData(0, fresh.data, 0, fresh.count * 4);
|
|
265
|
+
const bg = this._brickBindGroup;
|
|
266
|
+
bind(bg);
|
|
267
|
+
bg.setBuffer('bricks', this._brickBuffer);
|
|
268
|
+
draw(this._brickProgram, bg, BRICK_VOXELS ** 3, fresh.count);
|
|
269
|
+
}
|
|
270
|
+
this._zStart = (this._zStart + slices) % resolution;
|
|
271
|
+
this._passes++;
|
|
272
|
+
}
|
|
273
|
+
dispose() {
|
|
274
|
+
this._radiance?.dispose();
|
|
275
|
+
this._radiance = null;
|
|
276
|
+
this._aniso0?.dispose();
|
|
277
|
+
this._aniso0 = null;
|
|
278
|
+
this._aniso1?.dispose();
|
|
279
|
+
this._aniso1 = null;
|
|
280
|
+
this.disposePrograms();
|
|
281
|
+
this._brickBuffer?.dispose();
|
|
282
|
+
this._brickBuffer = null;
|
|
283
|
+
}
|
|
284
|
+
/** @internal */ disposePrograms() {
|
|
285
|
+
this._bindGroup?.dispose();
|
|
286
|
+
this._bindGroup = null;
|
|
287
|
+
this._program?.dispose();
|
|
288
|
+
this._program = null;
|
|
289
|
+
this._brickBindGroup?.dispose();
|
|
290
|
+
this._brickBindGroup = null;
|
|
291
|
+
this._brickProgram?.dispose();
|
|
292
|
+
this._brickProgram = null;
|
|
293
|
+
this._programKey = '';
|
|
294
|
+
}
|
|
295
|
+
/** What of the environment light's bindings the program depends on. @internal */ envVariant() {
|
|
296
|
+
const envLight = this._scene.env.light.envLight;
|
|
297
|
+
return `${envLight.irradianceSHFB ? 'fb' : envLight.irradianceSH ? 'buf' : ''}`;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Packs the visible punctual lights: the sun apart (the marked sun light, else the
|
|
301
|
+
* first directional), the rest nearest the camera first, up to {@link MAX_VOXEL_LIGHTS}.
|
|
302
|
+
* The first {@link MAX_SHADOWED_VOXEL_LIGHTS} local lights casting shadows are flagged for a
|
|
303
|
+
* shadow ray when `localShadows` is on.
|
|
304
|
+
* Only the intensity carries the cache exposure, as in the clustered light buffer.
|
|
305
|
+
* @internal
|
|
306
|
+
*/ collectLights(camera, exposure, localShadows) {
|
|
307
|
+
const scene = this._scene;
|
|
308
|
+
const cameraPos = camera.getWorldPosition();
|
|
309
|
+
const found = {
|
|
310
|
+
sun: null
|
|
311
|
+
};
|
|
312
|
+
const others = [];
|
|
313
|
+
scene.rootNode.iterate((node)=>{
|
|
314
|
+
if (node.isPunctualLight() && !node.hidden) {
|
|
315
|
+
if (node.isDirectionLight()) {
|
|
316
|
+
// The marked sun light wins; else the first directional light
|
|
317
|
+
if (!found.sun || node.sunLight) {
|
|
318
|
+
if (found.sun) {
|
|
319
|
+
others.push({
|
|
320
|
+
light: found.sun,
|
|
321
|
+
d: 0
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
found.sun = node;
|
|
325
|
+
} else {
|
|
326
|
+
others.push({
|
|
327
|
+
light: node,
|
|
328
|
+
d: 0
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
const p = node.positionAndRange;
|
|
333
|
+
others.push({
|
|
334
|
+
light: node,
|
|
335
|
+
d: Math.hypot(p.x - cameraPos.x, p.y - cameraPos.y, p.z - cameraPos.z)
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return false;
|
|
340
|
+
});
|
|
341
|
+
const sunLight = found.sun;
|
|
342
|
+
if (sunLight) {
|
|
343
|
+
const dir = sunLight.directionAndCutoff;
|
|
344
|
+
const c = sunLight.diffuseAndIntensity;
|
|
345
|
+
this._sunDir.setXYZW(dir.x, dir.y, dir.z, 1);
|
|
346
|
+
this._sunColor.setXYZW(c.x * c.w * exposure, c.y * c.w * exposure, c.z * c.w * exposure, 0);
|
|
347
|
+
} else {
|
|
348
|
+
this._sunDir.setXYZW(0, -1, 0, 0);
|
|
349
|
+
this._sunColor.setXYZW(0, 0, 0, 0);
|
|
350
|
+
}
|
|
351
|
+
others.sort((a, b)=>a.d - b.d);
|
|
352
|
+
const count = Math.min(others.length, MAX_VOXEL_LIGHTS);
|
|
353
|
+
const data = this._lightData;
|
|
354
|
+
let shadowedCount = 0;
|
|
355
|
+
for(let i = 0; i < count; i++){
|
|
356
|
+
const light = others[i].light;
|
|
357
|
+
const o = i * LIGHT_VEC4S * 4;
|
|
358
|
+
data.set(light.positionAndRange, o);
|
|
359
|
+
data.set(light.directionAndCutoff, o + 4);
|
|
360
|
+
const c = light.diffuseAndIntensity;
|
|
361
|
+
data[o + 8] = c.x;
|
|
362
|
+
data[o + 9] = c.y;
|
|
363
|
+
data[o + 10] = c.z;
|
|
364
|
+
data[o + 11] = c.w * exposure;
|
|
365
|
+
data.set(light.extraParams, o + 12);
|
|
366
|
+
// Local lights only; a directional light besides the sun stays unshadowed
|
|
367
|
+
const shadowed = localShadows && shadowedCount < MAX_SHADOWED_VOXEL_LIGHTS && !light.isDirectionLight() && light.castShadow;
|
|
368
|
+
if (shadowed) {
|
|
369
|
+
shadowedCount++;
|
|
370
|
+
}
|
|
371
|
+
data[o + 16] = shadowed ? 1 : 0;
|
|
372
|
+
data[o + 17] = 0;
|
|
373
|
+
data[o + 18] = 0;
|
|
374
|
+
data[o + 19] = 0;
|
|
375
|
+
}
|
|
376
|
+
return count;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* The lighting program: one fragment per voxel of the slab, or with `bricks`
|
|
380
|
+
* a row of {@link BRICK_VOXELS}³ fragments per listed brick.
|
|
381
|
+
* @internal
|
|
382
|
+
*/ createProgram(levels, physical, skyIrradiance, useProbes, bricks) {
|
|
383
|
+
const scene = this._scene;
|
|
384
|
+
const envLight = scene.env.light.envLight;
|
|
385
|
+
return buildSDFProgram({
|
|
386
|
+
label: bricks ? 'VoxelLightingBricks' : 'VoxelLighting',
|
|
387
|
+
vertex (pb) {
|
|
388
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
389
|
+
pb.main(function() {
|
|
390
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 0, 1);
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
fragment (pb) {
|
|
394
|
+
this.$outputs.color = pb.vec4();
|
|
395
|
+
declareGlobalSDFUniforms(this, 0, levels);
|
|
396
|
+
// Bound by the field alongside the global uniforms, unused here
|
|
397
|
+
declareDynamicSDFUniforms(this, 0);
|
|
398
|
+
this.albedoTex = pb.tex3D().sampleType('unfilterable-float').uniform(0);
|
|
399
|
+
this.emissiveTex = pb.tex3D().sampleType('unfilterable-float').uniform(0);
|
|
400
|
+
this.radianceOut = pb.texStorage3D.rgba16float().storage(0);
|
|
401
|
+
this.aniso0Out = pb.texStorage3D.rgba8unorm().storage(0);
|
|
402
|
+
this.aniso1Out = aniso1Format() === 'rg8unorm' ? pb.texStorage3D.rg8unorm().storage(0) : pb.texStorage3D.rgba8unorm().storage(0);
|
|
403
|
+
this.lights = pb.vec4[MAX_VOXEL_LIGHTS * LIGHT_VEC4S]().uniform(0);
|
|
404
|
+
// (direction the light travels, 1 when there is a sun)
|
|
405
|
+
this.sunDir = pb.vec4().uniform(0);
|
|
406
|
+
this.sunColor = pb.vec4().uniform(0);
|
|
407
|
+
// (light count, environment strength, tan of the shadow cone half angle, 0)
|
|
408
|
+
this.params = pb.vec4().uniform(0);
|
|
409
|
+
// (resolution, levels, slices per pass, first slice)
|
|
410
|
+
this.slab = pb.vec4().uniform(0);
|
|
411
|
+
if (bricks) {
|
|
412
|
+
// Per brick: (first material voxel within its level, level)
|
|
413
|
+
this.bricks = pb.vec4[0]().storageBufferReadonly(0);
|
|
414
|
+
}
|
|
415
|
+
if (skyIrradiance) {
|
|
416
|
+
envLight.initShaderBindings(pb);
|
|
417
|
+
}
|
|
418
|
+
if (useProbes) {
|
|
419
|
+
declareProbeUniforms(this, 0);
|
|
420
|
+
}
|
|
421
|
+
pb.func('Z_pointAttenuation', [
|
|
422
|
+
pb.vec3('p'),
|
|
423
|
+
pb.vec4('posRange')
|
|
424
|
+
], function() {
|
|
425
|
+
this.$l.d = pb.sub(this.p, this.posRange.xyz);
|
|
426
|
+
this.$l.dist2 = pb.dot(this.d, this.d);
|
|
427
|
+
this.$l.atten = pb.div(1, pb.max(this.dist2, 0.0001));
|
|
428
|
+
this.$l.range2 = pb.mul(this.posRange.w, this.posRange.w);
|
|
429
|
+
this.$l.f = pb.div(this.dist2, pb.max(this.range2, 0.0001));
|
|
430
|
+
this.$l.f2 = pb.clamp(pb.sub(1, pb.mul(this.f, this.f)), 0, 1);
|
|
431
|
+
this.$return(pb.mul(this.atten, this.f2, this.f2));
|
|
432
|
+
});
|
|
433
|
+
// Rect lights as the surfaces shade their diffuse part (see evaluateLTCRectLightTerms):
|
|
434
|
+
// the polygon form factor clipped to the horizon (LTC with the identity matrix, Heitz et
|
|
435
|
+
// al. 2016), one-sided about the light plane, with the same range window
|
|
436
|
+
defineLTCEdgeFunctions(this);
|
|
437
|
+
pb.func('Z_rectFormFactor', [
|
|
438
|
+
pb.vec3('p'),
|
|
439
|
+
pb.vec3('N'),
|
|
440
|
+
pb.vec3('V'),
|
|
441
|
+
pb.vec4('posRange'),
|
|
442
|
+
pb.vec3('ax'),
|
|
443
|
+
pb.vec3('ay')
|
|
444
|
+
], function() {
|
|
445
|
+
this.$l.lightNormal = pb.neg(pb.normalize(pb.cross(this.ax, this.ay)));
|
|
446
|
+
this.$l.toPoint = pb.sub(this.p, this.posRange.xyz);
|
|
447
|
+
this.$if(pb.lessThanEqual(pb.dot(this.lightNormal, this.toPoint), 0), function() {
|
|
448
|
+
this.$return(pb.float(0));
|
|
449
|
+
});
|
|
450
|
+
this.$l.falloff = pb.float(1);
|
|
451
|
+
this.$if(pb.greaterThan(this.posRange.w, 0), function() {
|
|
452
|
+
this.falloff = pb.sub(1, pb.smoothStep(pb.mul(this.posRange.w, 0.9), this.posRange.w, pb.length(this.toPoint)));
|
|
453
|
+
});
|
|
454
|
+
this.$l.c = this.posRange.xyz;
|
|
455
|
+
this.$l.ff = this.Z_LTCEvaluateRect(this.N, this.V, this.p, pb.mat3(pb.vec3(1, 0, 0), pb.vec3(0, 1, 0), pb.vec3(0, 0, 1)), pb.sub(pb.sub(this.c, this.ax), this.ay), pb.add(pb.sub(this.c, this.ay), this.ax), pb.add(pb.add(this.c, this.ax), this.ay), pb.add(pb.sub(this.c, this.ax), this.ay)).x;
|
|
456
|
+
this.$return(pb.mul(this.ff, this.falloff));
|
|
457
|
+
});
|
|
458
|
+
pb.func('Z_spotAttenuation', [
|
|
459
|
+
pb.vec3('p'),
|
|
460
|
+
pb.vec4('posRange'),
|
|
461
|
+
pb.vec4('dirCutoff'),
|
|
462
|
+
pb.vec2('angleScaleOffset')
|
|
463
|
+
], function() {
|
|
464
|
+
// The point light's distance falloff in both modes, as the surfaces light them
|
|
465
|
+
this.$l.falloff = this.Z_pointAttenuation(this.p, this.posRange);
|
|
466
|
+
this.$l.cd = pb.dot(pb.normalize(pb.sub(this.p, this.posRange.xyz)), this.dirCutoff.xyz);
|
|
467
|
+
if (physical) {
|
|
468
|
+
this.$l.spot = pb.clamp(pb.add(pb.mul(this.cd, this.angleScaleOffset.x), this.angleScaleOffset.y), 0, 1);
|
|
469
|
+
this.spot = pb.mul(this.spot, this.spot);
|
|
470
|
+
} else {
|
|
471
|
+
this.$l.spot = pb.smoothStep(this.dirCutoff.w, pb.mix(this.dirCutoff.w, 1, 0.5), this.cd);
|
|
472
|
+
}
|
|
473
|
+
this.$return(pb.mul(this.spot, this.falloff));
|
|
474
|
+
});
|
|
475
|
+
pb.main(function() {
|
|
476
|
+
this.$l.res = pb.int(this.slab.x);
|
|
477
|
+
this.$l.fc = pb.ivec2(pb.floor(this.$builtins.fragCoord.xy));
|
|
478
|
+
if (bricks) {
|
|
479
|
+
this.$l.brick = this.bricks.at(this.fc.y);
|
|
480
|
+
this.$l.level = pb.int(this.brick.w);
|
|
481
|
+
this.$l.t = pb.add(pb.ivec3(this.brick.xyz), pb.ivec3(pb.mod(this.fc.x, BRICK_VOXELS), pb.mod(pb.div(this.fc.x, BRICK_VOXELS), BRICK_VOXELS), pb.div(this.fc.x, BRICK_VOXELS * BRICK_VOXELS)));
|
|
482
|
+
} else {
|
|
483
|
+
this.$l.slices = pb.int(this.slab.z);
|
|
484
|
+
this.$l.rowsPerLevel = pb.mul(this.res, this.slices);
|
|
485
|
+
this.$l.level = pb.div(this.fc.y, this.rowsPerLevel);
|
|
486
|
+
this.$l.rem = pb.sub(this.fc.y, pb.mul(this.level, this.rowsPerLevel));
|
|
487
|
+
this.$l.z = pb.add(pb.int(this.slab.w), pb.div(this.rem, this.res));
|
|
488
|
+
this.$l.t = pb.ivec3(this.fc.x, pb.sub(this.rem, pb.mul(pb.div(this.rem, this.res), this.res)), this.z);
|
|
489
|
+
}
|
|
490
|
+
this.$l.tz = pb.add(this.t.z, pb.mul(this.level, this.res));
|
|
491
|
+
this.$l.texel = pb.ivec3(this.t.x, this.t.y, this.tz);
|
|
492
|
+
this.$l.radiance = pb.vec3(0);
|
|
493
|
+
this.$l.aniso0 = pb.vec4(0);
|
|
494
|
+
this.$l.aniso1 = pb.vec4(0);
|
|
495
|
+
this.$l.a = pb.textureLoad(this.albedoTex, this.texel, 0);
|
|
496
|
+
this.$if(pb.greaterThan(this.a.a, 0), function() {
|
|
497
|
+
// World voxel of the texel: the one in the level's window with this toroidal address
|
|
498
|
+
this.$l.info = pb.vec4(0);
|
|
499
|
+
this.$l.fineVs = pb.float(0);
|
|
500
|
+
for(let i = 0; i < levels; i++){
|
|
501
|
+
this.$if(pb.equal(this.level, i), function() {
|
|
502
|
+
this.info = this[GLOBAL_SDF_LEVELS].at(i);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
this.$l.originC = pb.ivec3(pb.floor(pb.div(this.info.xyz, 2)));
|
|
506
|
+
this.$l.resV = pb.ivec3(this.res);
|
|
507
|
+
this.$l.w = pb.add(this.originC, pb.mod(pb.add(pb.mod(pb.sub(this.t, this.originC), this.resV), this.resV), this.resV));
|
|
508
|
+
this.$l.vs = pb.mul(this.info.w, 2);
|
|
509
|
+
this.$l.p = pb.mul(pb.add(pb.vec3(this.w), pb.vec3(0.5)), this.vs);
|
|
510
|
+
// Light per axis face of the voxel, so a floor thinner than the voxel is lit
|
|
511
|
+
// on top and dark below. A face counts as open where the field at its centre
|
|
512
|
+
// is outside the solid.
|
|
513
|
+
this.$l.half = pb.mul(this.vs, 0.5);
|
|
514
|
+
// Read from the voxel's own level on: a finer level resolves more geometry
|
|
515
|
+
for(let k = 0; k < 6; k++){
|
|
516
|
+
this.$l[`open${k}`] = pb.greaterThan(sampleGlobalSDFWithVoxel(this, pb.add(this.p, pb.mul(pb.vec3(...ANISO_DIRS[k]), this.half)), levels, this.level).x, 0);
|
|
517
|
+
this.$l[`acc${k}`] = pb.vec3(0);
|
|
518
|
+
}
|
|
519
|
+
this.$l.albedo = this.a.rgb;
|
|
520
|
+
// Sun: one shadow ray for all faces, started near the voxel corner toward the
|
|
521
|
+
// light and offset along it
|
|
522
|
+
this.$if(pb.greaterThan(this.sunDir.w, 0.5), function() {
|
|
523
|
+
this.$l.L = pb.neg(this.sunDir.xyz);
|
|
524
|
+
this.$l.ps = pb.add(this.p, pb.mul(pb.sign(this.L), this.vs, 0.48), pb.mul(this.L, this.vs, 0.4));
|
|
525
|
+
this.$l.shadow = sdfConeShadow(this, this.ps, this.L, this.params.z, this.vs, pb.mul(this[GLOBAL_SDF_PARAMS].x, this[GLOBAL_SDF_LEVELS].at(levels - 1).w, 0.5), levels, SHADOW_STEPS, this.level);
|
|
526
|
+
this.$if(pb.greaterThan(this.shadow, 0), function() {
|
|
527
|
+
this.$l.sun = pb.mul(this.albedo, this.sunColor.rgb, this.shadow, 1 / Math.PI);
|
|
528
|
+
for(let k = 0; k < 6; k++){
|
|
529
|
+
this.$if(this[`open${k}`], function() {
|
|
530
|
+
this[`acc${k}`] = pb.add(this[`acc${k}`], pb.mul(this.sun, pb.max(pb.dot(pb.vec3(...ANISO_DIRS[k]), this.L), 0)));
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
this.$l.count = pb.int(this.params.x);
|
|
536
|
+
this.$for(pb.int('li'), 0, MAX_VOXEL_LIGHTS, function() {
|
|
537
|
+
this.$if(pb.greaterThanEqual(this.li, this.count), function() {
|
|
538
|
+
this.$break();
|
|
539
|
+
});
|
|
540
|
+
this.$l.base = pb.mul(this.li, LIGHT_VEC4S);
|
|
541
|
+
this.$l.posRange = this.lights.at(this.base);
|
|
542
|
+
this.$l.dirCutoff = this.lights.at(pb.add(this.base, 1));
|
|
543
|
+
this.$l.colorIntensity = this.lights.at(pb.add(this.base, 2));
|
|
544
|
+
this.$l.extra = this.lights.at(pb.add(this.base, 3));
|
|
545
|
+
this.$l.shadowInfo = this.lights.at(pb.add(this.base, 4));
|
|
546
|
+
this.$l.ltype = pb.int(this.extra.w);
|
|
547
|
+
// This light's share of each open face, before the shadow
|
|
548
|
+
for(let k = 0; k < 6; k++){
|
|
549
|
+
this.$l[`lf${k}`] = pb.vec3(0);
|
|
550
|
+
}
|
|
551
|
+
this.$if(pb.equal(this.ltype, LIGHT_TYPE_RECT), function() {
|
|
552
|
+
// Radiance times the form factor seen by each face; (dirCutoff, extra) hold the
|
|
553
|
+
// half-extent axes
|
|
554
|
+
this.$l.rc = pb.mul(this.albedo, this.colorIntensity.rgb, this.colorIntensity.w);
|
|
555
|
+
for(let k = 0; k < 6; k++){
|
|
556
|
+
this.$if(this[`open${k}`], function() {
|
|
557
|
+
// Any direction off the normal: the identity-matrix integral does not
|
|
558
|
+
// depend on the tangent frame
|
|
559
|
+
const v = ANISO_DIRS[k][1] !== 0 ? [
|
|
560
|
+
1,
|
|
561
|
+
0,
|
|
562
|
+
0
|
|
563
|
+
] : [
|
|
564
|
+
0,
|
|
565
|
+
1,
|
|
566
|
+
0
|
|
567
|
+
];
|
|
568
|
+
this[`lf${k}`] = pb.mul(this.rc, this.Z_rectFormFactor(this.p, pb.vec3(...ANISO_DIRS[k]), pb.vec3(...v), this.posRange, this.dirCutoff.xyz, this.extra.xyz));
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}).$else(function() {
|
|
572
|
+
this.$l.atten = pb.float(0);
|
|
573
|
+
this.$l.Ld = pb.vec3(0, 1, 0);
|
|
574
|
+
this.$if(pb.equal(this.ltype, LIGHT_TYPE_DIRECTIONAL), function() {
|
|
575
|
+
this.atten = 1;
|
|
576
|
+
this.Ld = pb.neg(this.dirCutoff.xyz);
|
|
577
|
+
}).$elseif(pb.equal(this.ltype, LIGHT_TYPE_SPOT), function() {
|
|
578
|
+
this.atten = this.Z_spotAttenuation(this.p, this.posRange, this.dirCutoff, this.extra.xy);
|
|
579
|
+
this.Ld = pb.normalize(pb.sub(this.posRange.xyz, this.p));
|
|
580
|
+
}).$else(function() {
|
|
581
|
+
this.atten = this.Z_pointAttenuation(this.p, this.posRange);
|
|
582
|
+
this.Ld = pb.normalize(pb.sub(this.posRange.xyz, this.p));
|
|
583
|
+
});
|
|
584
|
+
this.$l.lc = pb.mul(this.albedo, this.colorIntensity.rgb, pb.mul(this.colorIntensity.w, this.atten, 1 / Math.PI));
|
|
585
|
+
for(let k = 0; k < 6; k++){
|
|
586
|
+
this.$if(this[`open${k}`], function() {
|
|
587
|
+
this[`lf${k}`] = pb.mul(this.lc, pb.max(pb.dot(pb.vec3(...ANISO_DIRS[k]), this.Ld), 0));
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
// Local light shadow, as Lumen's offscreen shadowing through the global field
|
|
592
|
+
// (LumenSceneDirectLightingSoftwareRayTracing.usf, TraceOffscreenShadows): one hard
|
|
593
|
+
// ray from the voxel to the light position, a rect light's centre included,
|
|
594
|
+
// stopping one field voxel short of the light so geometry right next to it does
|
|
595
|
+
// not shadow it (VoxelSizeRelativeRayEndBias). Traced only where it lights a face.
|
|
596
|
+
this.$l.lightSum = pb.add(this.lf0, this.lf1, this.lf2, this.lf3, this.lf4, this.lf5);
|
|
597
|
+
this.$l.lightShadow = pb.float(1);
|
|
598
|
+
this.$if(pb.and(pb.greaterThan(this.shadowInfo.x, 0.5), pb.greaterThan(pb.max(pb.max(this.lightSum.r, this.lightSum.g), this.lightSum.b), 0)), function() {
|
|
599
|
+
this.$l.toLight = pb.sub(this.posRange.xyz, this.p);
|
|
600
|
+
this.$l.SL = pb.normalize(this.toLight);
|
|
601
|
+
// Started as the sun's ray: near the voxel corner toward the light
|
|
602
|
+
this.$l.sps = pb.add(this.p, pb.mul(pb.sign(this.SL), this.vs, 0.48), pb.mul(this.SL, this.vs, 0.4));
|
|
603
|
+
this.$l.slen = pb.sub(pb.dot(pb.sub(this.posRange.xyz, this.sps), this.SL), this.info.w);
|
|
604
|
+
this.$if(pb.greaterThan(this.slen, 0), function() {
|
|
605
|
+
this.lightShadow = sdfConeShadow(this, this.sps, this.SL, pb.float(HARD_SHADOW_TAN), this.vs, this.slen, levels, SHADOW_STEPS, this.level);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
for(let k = 0; k < 6; k++){
|
|
609
|
+
this[`acc${k}`] = pb.add(this[`acc${k}`], pb.mul(this[`lf${k}`], this.lightShadow));
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
// Ambient per open face: sky, or probe irradiance where covered, carrying every
|
|
613
|
+
// earlier bounce (Majercik et al. 2019 sec. 3.2). Albedo clamped below 1 keeps
|
|
614
|
+
// the feedback loop convergent. Emissive leaves every open face.
|
|
615
|
+
this.$l.feedback = pb.min(this.albedo, pb.vec3(0.9));
|
|
616
|
+
this.$l.emissive = pb.textureLoad(this.emissiveTex, this.texel, 0).rgb;
|
|
617
|
+
for(let k = 0; k < 6; k++){
|
|
618
|
+
this.$if(this[`open${k}`], function() {
|
|
619
|
+
this.$l.faceDir = pb.vec3(...ANISO_DIRS[k]);
|
|
620
|
+
this.$l.ambient = pb.vec3(0);
|
|
621
|
+
if (skyIrradiance) {
|
|
622
|
+
this.ambient = pb.mul(envLight.getIrradiance(this, this.faceDir).rgb, this.params.y);
|
|
623
|
+
}
|
|
624
|
+
if (useProbes) {
|
|
625
|
+
this.$l.bounce = sampleProbeIrradiance(this, pb.add(this.p, pb.mul(this.faceDir, this.half)), this.faceDir, this.faceDir, 'feedback');
|
|
626
|
+
this.ambient = pb.mix(this.ambient, this.bounce.rgb, this.bounce.a);
|
|
627
|
+
}
|
|
628
|
+
this[`acc${k}`] = pb.add(this[`acc${k}`], pb.mul(this.feedback, this.ambient), this.emissive);
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
// Stored as the sum, with the share of each face by luminance
|
|
632
|
+
this.radiance = pb.add(this.acc0, this.acc1, this.acc2, this.acc3, this.acc4, this.acc5);
|
|
633
|
+
this.$l.lumaTotal = pb.max(pb.max(this.radiance.r, this.radiance.g), this.radiance.b);
|
|
634
|
+
this.$l.invLuma = this.$choice(pb.greaterThan(this.lumaTotal, 0), pb.div(1, pb.max(this.lumaTotal, 1e-8)), pb.float(0));
|
|
635
|
+
for(let k = 0; k < 6; k++){
|
|
636
|
+
this.$l[`luma${k}`] = pb.mul(pb.max(pb.max(this[`acc${k}`].r, this[`acc${k}`].g), this[`acc${k}`].b), this.invLuma);
|
|
637
|
+
}
|
|
638
|
+
this.aniso0 = pb.vec4(this.luma0, this.luma1, this.luma2, this.luma3);
|
|
639
|
+
this.aniso1 = pb.vec4(this.luma4, this.luma5, 0, 0);
|
|
640
|
+
});
|
|
641
|
+
pb.textureStore(this.radianceOut, pb.uvec3(this.texel), pb.vec4(this.radiance, 1));
|
|
642
|
+
pb.textureStore(this.aniso0Out, pb.uvec3(this.texel), this.aniso0);
|
|
643
|
+
pb.textureStore(this.aniso1Out, pb.uvec3(this.texel), this.aniso1);
|
|
644
|
+
this.$outputs.color = pb.vec4(0);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export { MAX_SHADOWED_VOXEL_LIGHTS, MAX_VOXEL_LIGHTS, VoxelLighting };
|
|
652
|
+
//# sourceMappingURL=voxel_lighting.js.map
|