@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/utility/serialization/types.ts"],"sourcesContent":["import type { GenericConstructor, Nullable, RequireOptionals } from '@zephyr3d/base';\r\n\r\n/**\r\n * Enumerates supported data types for serializable properties.\r\n *\r\n * This type informs serializers/editors how to interpret and encode values.\r\n * 'bool'|'int'|'float'|'vec2'|'vec3'|'vec4'|'int2'|'int3'|'int4'|'string'|'rgb'|'rgba'|'object'|'object_array'|'embedded'|'command';\r\n *\r\n * @public\r\n */\r\nexport type PropertyType = string;\r\n\r\n/**\r\n * Maps a property type discriminator to the corresponding value lane key.\r\n *\r\n * @public\r\n */\r\nexport type PropertyToType<T extends string> = T extends\r\n | 'float'\r\n | 'vec2'\r\n | 'vec3'\r\n | 'vec4'\r\n | 'int'\r\n | 'int2'\r\n | 'int3'\r\n | 'int4'\r\n | 'rgb'\r\n | 'rgba'\r\n ? 'num'\r\n : T extends 'bool'\r\n ? 'bool'\r\n : T extends 'string'\r\n ? 'str'\r\n : T extends 'object' | 'object_array'\r\n ? 'object'\r\n : 'num' | 'bool' | 'str' | 'object';\r\n/**\r\n * Container for a serializable property's value.\r\n *\r\n * Values are carried in typed arrays (even for single values) to support\r\n * both scalar and array-like properties in a unified shape.\r\n *\r\n * Conventions:\r\n * - `num` carries numeric data for types like `int`, `float`, `vec*`, `int*`, `rgb`, `rgba`\r\n * - `str` carries string data for `string`\r\n * - `bool` carries boolean data for `bool`\r\n * - `object` carries references/instances for `object`, `object_array`, `embedded`\r\n *\r\n * Only the relevant field(s) for the property's {@link PropertyType} will be populated.\r\n *\r\n * @public\r\n */\r\nexport type PropertyValue = {\r\n /** Numeric lane(s) for numeric, vector, or color types. */\r\n num?: number[];\r\n /** String lane(s) for text properties. */\r\n str?: string[];\r\n /** Boolean lane(s) for boolean properties. */\r\n bool?: boolean[];\r\n /** Object lane(s) for object references or embedded objects. */\r\n object?: Nullable<object>[];\r\n};\r\n\r\n/**\r\n * Editor-oriented edit types that augment how a property is presented/edited.\r\n *\r\n * This is orthogonal to {@link PropertyType} and is purely an editor hint.\r\n *\r\n * @public\r\n */\r\nexport type PropEdit = 'aabb' | 'quaternion' | 'proptrack' | 'curve1f';\r\n\r\n/**\r\n * Extra scene-node picker hints for a property.\r\n *\r\n * @public\r\n */\r\nexport type PropertySceneNodeOptions = {\r\n kind?: 'node' | 'mesh';\r\n};\r\n\r\n/**\r\n * Additional options controlling how a property is displayed, constrained, and edited.\r\n *\r\n * These options are consumed primarily by an editor/inspector UI, but may\r\n * also influence validation and tooling behavior.\r\n *\r\n * @public\r\n */\r\nexport type PropertyAccessorOptions = {\r\n /** Human-friendly label for UI. Defaults to `name` if omitted. */\r\n label?: string;\r\n /** Logical grouping/category in UI. */\r\n group?: string;\r\n /** Whether the inspector group should be expanded by default. */\r\n defaultOpen?: boolean;\r\n /** Editor presentation hint (e.g., quaternion gizmo, animation track). */\r\n edit?: PropEdit;\r\n /** Minimum numeric value (for sliders/spinners). */\r\n minValue?: number;\r\n /** Maximum numeric value (for sliders/spinners). */\r\n maxValue?: number;\r\n /** Whether string property is multiline. */\r\n multiline?: boolean;\r\n /** Step/speed for numeric editing UI. */\r\n speed?: number;\r\n /** Whether the property can be animated/keyframed. */\r\n animatable?: boolean;\r\n /** Allowed MIME types for file-picker-like editors. */\r\n mimeTypes?: string[];\r\n /** Accept scene hierarchy node drag-drop in the inspector. */\r\n sceneNode?: PropertySceneNodeOptions;\r\n /** Render object-array entries inline instead of expandable nested groups. */\r\n inlineObjectArray?: boolean;\r\n /** Allowed constructor types when choosing/creating object references. */\r\n objectTypes?: GenericConstructor[];\r\n /**\r\n * Optional enumeration metadata.\r\n * `labels[i]` corresponds to `values[i]`.\r\n */\r\n enum?: { labels: string[]; values: unknown[] };\r\n};\r\n\r\n/**\r\n * Returns the property accessor list unchanged while preserving typing.\r\n *\r\n * @public\r\n */\r\nexport function defineProps(accessors: PropertyAccessor<any, 'DUMMY'>[]): PropertyAccessor[] {\r\n return accessors;\r\n}\r\n\r\n/**\r\n * Descriptor for a serializable property of a class/type.\r\n *\r\n * This binds together:\r\n * - Metadata: `type`, `name`, `default`, `readonly`, `persistent`, `options`\r\n * - Accessors: `get`, `set`, `add`, `delete`, `create` for manipulating the underlying object state\r\n * - Predicates: `isValid`, `isNullable`, `isHidden` to control UI and validation\r\n * - Commands: `command` for action-style properties (`type: 'command'`)\r\n * - Utilities: `getDefaultValue` to compute defaults dynamically\r\n *\r\n * The accessors are invoked with `this` bound to the owning object instance.\r\n *\r\n * @typeParam T - The instance type that owns the property.\r\n * @public\r\n */\r\nexport type PropertyAccessor<T = object, U extends string = ''> = {\r\n /** The storage/serialization data type. */\r\n type: PropertyType;\r\n /** Unique property name (stable identifier for tooling/serialization). */\r\n name: string;\r\n /** Description of this property */\r\n description?: string;\r\n /**\r\n * Optional evaluation phase/order hint (lower runs earlier).\r\n * Useful for staged initialization or batched updates in editors.\r\n */\r\n phase?: number;\r\n /** If true, the property is read-only in UI and programmatic setters may be disallowed. */\r\n readonly?: boolean;\r\n /** Default value used if none is provided. Can be a primitive, array, or object. */\r\n default?: any;\r\n /**\r\n * If true, the property is persisted during save/serialize.\r\n * Non-persistent properties may be computed or session-only.\r\n */\r\n //persistent?: boolean;\r\n /** Editor and validation options for this property. */\r\n options?: PropertyAccessorOptions;\r\n /**\r\n * Reads the current value from `this` into the provided `value` container.\r\n *\r\n * Implementations should fully populate the appropriate lane(s) (e.g., `num`, `str`, etc.)\r\n * according to the property's {@link PropertyType}.\r\n *\r\n * @param value - Output container to be filled by the getter.\r\n */\r\n get: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>\r\n ) => void;\r\n /**\r\n * Writes an incoming value to `this`.\r\n *\r\n * For array-like properties, `index` can target a specific element.\r\n * Implementations should read from the appropriate lane(s) of `value` according to {@link PropertyType}.\r\n *\r\n * @param value - Input container carrying the new value.\r\n * @param index - Optional element index for array-like properties.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n set?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Creates a new embedded/contained object for object-like properties.\r\n *\r\n * Typically used for `embedded` or `object_array` to instantiate an element.\r\n *\r\n * @param ctor - Constructor to instantiate.\r\n * @param index - Target index where the new object will be inserted.\r\n * @returns The newly created object instance.\r\n */\r\n create?: (this: T, ctor: GenericConstructor, index: number) => Nullable<object>;\r\n /**\r\n * Deletes an element from an array-like property or clears a value.\r\n *\r\n * @param index - Target element index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n delete?: (this: T, index: number) => void | Promise<void>;\r\n /**\r\n * Adds a new element/value to an array-like property.\r\n *\r\n * If `index` is omitted, implementations may append to the end.\r\n *\r\n * @param value - The value to add (read appropriate lane(s) per {@link PropertyType}).\r\n * @param index - Optional insertion index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n add?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Validates the current state of `this` with respect to this property.\r\n *\r\n * Returning `false` may block serialization or UI confirmation.\r\n *\r\n * @returns `true` if valid, otherwise `false`.\r\n */\r\n isValid?: (this: T) => boolean;\r\n /**\r\n * Indicates whether this property is serializable. Default is serializable if not present.\r\n *\r\n * @returns `true` if persistent, otherwise `false`.\r\n */\r\n isPersistent?: (this: T) => boolean;\r\n /**\r\n * Indicates whether a specific element or slot may be `null` or `undefined`.\r\n *\r\n * Applies to array-like or optional properties.\r\n *\r\n * @param index - Target element index.\r\n * @returns `true` if nullable, otherwise `false`.\r\n */\r\n isNullable?: (this: T, index: number) => boolean;\r\n /**\r\n * Controls visibility of a specific element or the property in UI.\r\n *\r\n * @param index - Target element index.\r\n * @param obj - Value at index\r\n * @returns `true` if hidden, otherwise `false`.\r\n */\r\n isHidden?: (this: T, index: number, obj?: unknown) => boolean;\r\n /**\r\n * Executes a command-style property.\r\n *\r\n * Only meaningful for `type: 'command'`. Return value may indicate success or toggle state.\r\n *\r\n * @param index - Optional command index for multi-command groups.\r\n * @returns Command result, commonly a boolean for toggle-like actions.\r\n */\r\n command?: (this: T, index: number) => boolean;\r\n /**\r\n * Supplies a default value dynamically at runtime.\r\n *\r\n * If provided, this takes precedence over the static `default` field.\r\n */\r\n getDefaultValue?: (this: T) => any;\r\n};\r\n\r\n/**\r\n * Descriptor for a serializable class/type.\r\n *\r\n * This defines how a class is identified, constructed, and inspected for properties.\r\n * Editors and serializers can use this metadata to instantiate objects, load initial\r\n * parameters, and enumerate property accessors.\r\n *\r\n * @public\r\n */\r\nexport type SerializableClass = {\r\n /** Concrete constructor for the serializable class. */\r\n ctor: GenericConstructor;\r\n /** Optional parent/superclass constructor to represent inheritance in tooling. */\r\n parent?: GenericConstructor;\r\n /** If true, suppresses title rendering in UI for compact displays. */\r\n noTitle?: boolean;\r\n /** Display name used by tooling and editors. */\r\n name: string;\r\n /**\r\n * Custom factory to create an instance and optionally control property loading.\r\n *\r\n * If `loadProps` is `false`, the caller may skip default property loading\r\n * (useful for lazy or staged initialization).\r\n *\r\n * @param ctx - Optional construction context (editor/runtime-specific).\r\n * @param init - Optional initialization payload.\r\n * @returns The created object and a `loadProps` hint.\r\n */\r\n createFunc?: (\r\n ctx?: any,\r\n init?: any\r\n ) => { obj: any; loadProps?: boolean } | Promise<{ obj: any; loadProps?: boolean }>;\r\n /**\r\n * Extracts initialization parameters from an instance suitable for re-creation.\r\n *\r\n * This is the inverse of `createFunc`'s `init` argument, enabling round-trip\r\n * serialization of constructor/initializer data.\r\n *\r\n * @param obj - The instance to introspect.\r\n * @returns An initialization payload (serializable).\r\n */\r\n getInitParams?: (obj: any, flags: { saveProps: boolean }) => any;\r\n /**\r\n * Enumerates property accessors for this class.\r\n *\r\n * The returned list defines the full set of serializable/editor-visible properties.\r\n *\r\n * @returns Array of property accessors.\r\n */\r\n getProps: () => PropertyAccessor<any>[];\r\n};\r\n"],"names":["defineProps","accessors"],"mappings":"AA2HA;;;;IAKO,SAASA,WAAAA,CAAYC,SAA2C,EAAA;IACrE,OAAOA,SAAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/utility/serialization/types.ts"],"sourcesContent":["import type { GenericConstructor, Nullable, RequireOptionals } from '@zephyr3d/base';\r\n\r\n/**\r\n * Enumerates supported data types for serializable properties.\r\n *\r\n * This type informs serializers/editors how to interpret and encode values.\r\n * 'bool'|'int'|'float'|'vec2'|'vec3'|'vec4'|'int2'|'int3'|'int4'|'string'|'rgb'|'rgba'|'object'|'object_array'|'embedded'|'command';\r\n *\r\n * @public\r\n */\r\nexport type PropertyType = string;\r\n\r\n/**\r\n * Maps a property type discriminator to the corresponding value lane key.\r\n *\r\n * @public\r\n */\r\nexport type PropertyToType<T extends string> = T extends\r\n | 'float'\r\n | 'vec2'\r\n | 'vec3'\r\n | 'vec4'\r\n | 'int'\r\n | 'int2'\r\n | 'int3'\r\n | 'int4'\r\n | 'rgb'\r\n | 'rgba'\r\n ? 'num'\r\n : T extends 'bool'\r\n ? 'bool'\r\n : T extends 'string'\r\n ? 'str'\r\n : T extends 'object' | 'object_array'\r\n ? 'object'\r\n : 'num' | 'bool' | 'str' | 'object';\r\n/**\r\n * Container for a serializable property's value.\r\n *\r\n * Values are carried in typed arrays (even for single values) to support\r\n * both scalar and array-like properties in a unified shape.\r\n *\r\n * Conventions:\r\n * - `num` carries numeric data for types like `int`, `float`, `vec*`, `int*`, `rgb`, `rgba`\r\n * - `str` carries string data for `string`\r\n * - `bool` carries boolean data for `bool`\r\n * - `object` carries references/instances for `object`, `object_array`, `embedded`\r\n *\r\n * Only the relevant field(s) for the property's {@link PropertyType} will be populated.\r\n *\r\n * @public\r\n */\r\nexport type PropertyValue = {\r\n /** Numeric lane(s) for numeric, vector, or color types. */\r\n num?: number[];\r\n /** String lane(s) for text properties. */\r\n str?: string[];\r\n /** Boolean lane(s) for boolean properties. */\r\n bool?: boolean[];\r\n /** Object lane(s) for object references or embedded objects. */\r\n object?: Nullable<object>[];\r\n};\r\n\r\n/**\r\n * Editor-oriented edit types that augment how a property is presented/edited.\r\n *\r\n * This is orthogonal to {@link PropertyType} and is purely an editor hint.\r\n *\r\n * @public\r\n */\r\nexport type PropEdit = 'aabb' | 'quaternion' | 'proptrack' | 'curve1f';\r\n\r\n/**\r\n * Extra scene-node picker hints for a property.\r\n *\r\n * @public\r\n */\r\nexport type PropertySceneNodeOptions = {\r\n kind?: 'node' | 'mesh';\r\n};\r\n\r\n/**\r\n * Additional options controlling how a property is displayed, constrained, and edited.\r\n *\r\n * These options are consumed primarily by an editor/inspector UI, but may\r\n * also influence validation and tooling behavior.\r\n *\r\n * @public\r\n */\r\nexport type PropertyAccessorOptions = {\r\n /** Human-friendly label for UI. Defaults to `name` if omitted. */\r\n label?: string;\r\n /** Element label for object_array type */\r\n elementLabel?: string;\r\n /** Logical grouping/category in UI. */\r\n group?: string;\r\n /** Whether the inspector group should be expanded by default. */\r\n defaultOpen?: boolean;\r\n /** Editor presentation hint (e.g., quaternion gizmo, animation track). */\r\n edit?: PropEdit;\r\n /** Minimum numeric value (for sliders/spinners). */\r\n minValue?: number;\r\n /** Maximum numeric value (for sliders/spinners). */\r\n maxValue?: number;\r\n /** Whether string property is multiline. */\r\n multiline?: boolean;\r\n /** Step/speed for numeric editing UI. */\r\n speed?: number;\r\n /** Whether the property can be animated/keyframed. */\r\n animatable?: boolean;\r\n /** Allowed MIME types for file-picker-like editors. */\r\n mimeTypes?: string[];\r\n /** Accept scene hierarchy node drag-drop in the inspector. */\r\n sceneNode?: PropertySceneNodeOptions;\r\n /** Render object-array entries inline instead of expandable nested groups. */\r\n inlineObjectArray?: boolean;\r\n /** Allowed constructor types when choosing/creating object references. */\r\n objectTypes?: GenericConstructor[];\r\n /**\r\n * Optional enumeration metadata.\r\n * `labels[i]` corresponds to `values[i]`.\r\n */\r\n enum?: { labels: string[]; values: unknown[] };\r\n};\r\n\r\n/**\r\n * Returns the property accessor list unchanged while preserving typing.\r\n *\r\n * @public\r\n */\r\nexport function defineProps(accessors: PropertyAccessor<any, 'DUMMY'>[]): PropertyAccessor[] {\r\n return accessors;\r\n}\r\n\r\n/**\r\n * Descriptor for a serializable property of a class/type.\r\n *\r\n * This binds together:\r\n * - Metadata: `type`, `name`, `default`, `readonly`, `persistent`, `options`\r\n * - Accessors: `get`, `set`, `add`, `delete`, `create` for manipulating the underlying object state\r\n * - Predicates: `isValid`, `isNullable`, `isHidden` to control UI and validation\r\n * - Commands: `command` for action-style properties (`type: 'command'`)\r\n * - Utilities: `getDefaultValue` to compute defaults dynamically\r\n *\r\n * The accessors are invoked with `this` bound to the owning object instance.\r\n *\r\n * @typeParam T - The instance type that owns the property.\r\n * @public\r\n */\r\nexport type PropertyAccessor<T = object, U extends string = ''> = {\r\n /** The storage/serialization data type. */\r\n type: PropertyType;\r\n /** Unique property name (stable identifier for tooling/serialization). */\r\n name: string;\r\n /** Description of this property */\r\n description?: string;\r\n /**\r\n * Optional evaluation phase/order hint (lower runs earlier).\r\n * Useful for staged initialization or batched updates in editors.\r\n */\r\n phase?: number;\r\n /** If true, the property is read-only in UI and programmatic setters may be disallowed. */\r\n readonly?: boolean;\r\n /** Default value used if none is provided. Can be a primitive, array, or object. */\r\n default?: any;\r\n /**\r\n * If true, the property is persisted during save/serialize.\r\n * Non-persistent properties may be computed or session-only.\r\n */\r\n //persistent?: boolean;\r\n /** Editor and validation options for this property. */\r\n options?: PropertyAccessorOptions;\r\n /**\r\n * Reads the current value from `this` into the provided `value` container.\r\n *\r\n * Implementations should fully populate the appropriate lane(s) (e.g., `num`, `str`, etc.)\r\n * according to the property's {@link PropertyType}.\r\n *\r\n * @param value - Output container to be filled by the getter.\r\n */\r\n get: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>\r\n ) => void;\r\n /**\r\n * Writes an incoming value to `this`.\r\n *\r\n * For array-like properties, `index` can target a specific element.\r\n * Implementations should read from the appropriate lane(s) of `value` according to {@link PropertyType}.\r\n *\r\n * @param value - Input container carrying the new value.\r\n * @param index - Optional element index for array-like properties.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n set?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Creates a new embedded/contained object for object-like properties.\r\n *\r\n * Typically used for `embedded` or `object_array` to instantiate an element.\r\n *\r\n * @param ctor - Constructor to instantiate.\r\n * @param index - Target index where the new object will be inserted.\r\n * @returns The newly created object instance.\r\n */\r\n create?: (this: T, ctor: GenericConstructor, index: number) => Nullable<object>;\r\n /**\r\n * Deletes an element from an array-like property or clears a value.\r\n *\r\n * @param index - Target element index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n delete?: (this: T, index: number) => void | Promise<void>;\r\n /**\r\n * Adds a new element/value to an array-like property.\r\n *\r\n * If `index` is omitted, implementations may append to the end.\r\n *\r\n * @param value - The value to add (read appropriate lane(s) per {@link PropertyType}).\r\n * @param index - Optional insertion index.\r\n * @returns Optionally `Promise<void>` if asynchronous work is required.\r\n */\r\n add?: <K extends string>(\r\n this: T,\r\n value: U extends '' ? Required<Pick<PropertyValue, PropertyToType<K>>> : RequireOptionals<PropertyValue>,\r\n index?: number\r\n ) => void | Promise<void>;\r\n /**\r\n * Validates the current state of `this` with respect to this property.\r\n *\r\n * Returning `false` may block serialization or UI confirmation.\r\n *\r\n * @returns `true` if valid, otherwise `false`.\r\n */\r\n isValid?: (this: T) => boolean;\r\n /**\r\n * Indicates whether this property is serializable. Default is serializable if not present.\r\n *\r\n * @returns `true` if persistent, otherwise `false`.\r\n */\r\n isPersistent?: (this: T) => boolean;\r\n /**\r\n * Indicates whether a specific element or slot may be `null` or `undefined`.\r\n *\r\n * Applies to array-like or optional properties.\r\n *\r\n * @param index - Target element index.\r\n * @returns `true` if nullable, otherwise `false`.\r\n */\r\n isNullable?: (this: T, index: number) => boolean;\r\n /**\r\n * Controls visibility of a specific element or the property in UI.\r\n *\r\n * @param index - Target element index.\r\n * @param obj - Value at index\r\n * @returns `true` if hidden, otherwise `false`.\r\n */\r\n isHidden?: (this: T, index: number, obj?: unknown) => boolean;\r\n /**\r\n * Executes a command-style property.\r\n *\r\n * Only meaningful for `type: 'command'`. Return value may indicate success or toggle state.\r\n *\r\n * @param index - Optional command index for multi-command groups.\r\n * @returns Command result, commonly a boolean for toggle-like actions.\r\n */\r\n command?: (this: T, index: number) => boolean;\r\n /**\r\n * Supplies a default value dynamically at runtime.\r\n *\r\n * If provided, this takes precedence over the static `default` field.\r\n */\r\n getDefaultValue?: (this: T) => any;\r\n};\r\n\r\n/**\r\n * Descriptor for a serializable class/type.\r\n *\r\n * This defines how a class is identified, constructed, and inspected for properties.\r\n * Editors and serializers can use this metadata to instantiate objects, load initial\r\n * parameters, and enumerate property accessors.\r\n *\r\n * @public\r\n */\r\nexport type SerializableClass = {\r\n /** Concrete constructor for the serializable class. */\r\n ctor: GenericConstructor;\r\n /** Optional parent/superclass constructor to represent inheritance in tooling. */\r\n parent?: GenericConstructor;\r\n /** If true, suppresses title rendering in UI for compact displays. */\r\n noTitle?: boolean;\r\n /** Display name used by tooling and editors. */\r\n name: string;\r\n /**\r\n * Custom factory to create an instance and optionally control property loading.\r\n *\r\n * If `loadProps` is `false`, the caller may skip default property loading\r\n * (useful for lazy or staged initialization).\r\n *\r\n * @param ctx - Optional construction context (editor/runtime-specific).\r\n * @param init - Optional initialization payload.\r\n * @returns The created object and a `loadProps` hint.\r\n */\r\n createFunc?: (\r\n ctx?: any,\r\n init?: any\r\n ) => { obj: any; loadProps?: boolean } | Promise<{ obj: any; loadProps?: boolean }>;\r\n /**\r\n * Extracts initialization parameters from an instance suitable for re-creation.\r\n *\r\n * This is the inverse of `createFunc`'s `init` argument, enabling round-trip\r\n * serialization of constructor/initializer data.\r\n *\r\n * @param obj - The instance to introspect.\r\n * @returns An initialization payload (serializable).\r\n */\r\n getInitParams?: (obj: any, flags: { saveProps: boolean }) => any;\r\n /**\r\n * Enumerates property accessors for this class.\r\n *\r\n * The returned list defines the full set of serializable/editor-visible properties.\r\n *\r\n * @returns Array of property accessors.\r\n */\r\n getProps: () => PropertyAccessor<any>[];\r\n};\r\n"],"names":["defineProps","accessors"],"mappings":"AA6HA;;;;IAKO,SAASA,WAAAA,CAAYC,SAA2C,EAAA;IACrE,OAAOA,SAAAA;AACT;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Primitive } from '../render/primitive.js';
|
|
2
|
-
import { Disposable, DRef, Vector4 } from '@zephyr3d/base';
|
|
2
|
+
import { Disposable, DRef, Vector4, PRNG } from '@zephyr3d/base';
|
|
3
3
|
import { fetchSampler } from './misc.js';
|
|
4
4
|
import { getDevice } from '../app/api.js';
|
|
5
5
|
|
|
@@ -130,11 +130,15 @@ import { getDevice } from '../app/api.js';
|
|
|
130
130
|
*/ init(device) {
|
|
131
131
|
if (!this._primitive.get()) {
|
|
132
132
|
const samples = new Float32Array(this._numSamples * 4);
|
|
133
|
+
// Seeded so the projection is the same on every run: with Math.random()
|
|
134
|
+
// every page load drew different directions, which made all sky-lit
|
|
135
|
+
// lighting differ slightly from run to run.
|
|
136
|
+
const rand = new PRNG(0x5348);
|
|
133
137
|
for(let i = 0; i < this._numSamples; i++){
|
|
134
138
|
let x1, x2, s;
|
|
135
139
|
do {
|
|
136
|
-
x1 =
|
|
137
|
-
x2 =
|
|
140
|
+
x1 = rand.get() * 2 - 1;
|
|
141
|
+
x2 = rand.get() * 2 - 1;
|
|
138
142
|
s = x1 * x1 + x2 * x2;
|
|
139
143
|
}while (s >= 1)
|
|
140
144
|
const sqrtS = Math.sqrt(1 - s);
|
|
@@ -145,19 +149,6 @@ import { getDevice } from '../app/api.js';
|
|
|
145
149
|
}
|
|
146
150
|
const primitive = new Primitive();
|
|
147
151
|
primitive.createAndSetVertexBuffer('position_f32x4', samples);
|
|
148
|
-
if (device.type === 'webgl') {
|
|
149
|
-
primitive.createAndSetVertexBuffer('tex0_f32', new Float32Array([
|
|
150
|
-
0,
|
|
151
|
-
1,
|
|
152
|
-
2,
|
|
153
|
-
3,
|
|
154
|
-
4,
|
|
155
|
-
5,
|
|
156
|
-
6,
|
|
157
|
-
7,
|
|
158
|
-
8
|
|
159
|
-
]), 'instance');
|
|
160
|
-
}
|
|
161
152
|
primitive.indexCount = this._numSamples;
|
|
162
153
|
primitive.indexStart = 0;
|
|
163
154
|
primitive.primitiveType = 'point-list';
|
|
@@ -191,16 +182,13 @@ import { getDevice } from '../app/api.js';
|
|
|
191
182
|
const program = device.buildRenderProgram({
|
|
192
183
|
vertex (pb) {
|
|
193
184
|
this.$inputs.directionWeight = pb.vec4().attrib('position');
|
|
194
|
-
if (device.type === 'webgl') {
|
|
195
|
-
this.$inputs.instanceId = pb.float().attrib('texCoord0');
|
|
196
|
-
}
|
|
197
185
|
pb.main(function() {
|
|
198
186
|
this.$outputs.direction = this.$inputs.directionWeight.xyz;
|
|
199
187
|
this.$outputs.weight = this.$inputs.directionWeight.w;
|
|
200
188
|
if (pb.getDevice().type !== 'webgpu') {
|
|
201
189
|
this.$builtins.pointSize = 1;
|
|
202
190
|
}
|
|
203
|
-
this.$outputs.shIndex =
|
|
191
|
+
this.$outputs.shIndex = pb.int(this.$builtins.instanceIndex);
|
|
204
192
|
this.$l.x = pb.mod(this.$outputs.shIndex, 3);
|
|
205
193
|
this.$l.y = pb.div(this.$outputs.shIndex, 3);
|
|
206
194
|
this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);
|
|
@@ -299,8 +287,8 @@ import { getDevice } from '../app/api.js';
|
|
|
299
287
|
});
|
|
300
288
|
pb.main(function() {
|
|
301
289
|
this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;
|
|
302
|
-
this.$l.bandFactor = this.cosineLobeBandFactor(
|
|
303
|
-
this.$l.sh = this.evalBasis(this.$inputs.direction,
|
|
290
|
+
this.$l.bandFactor = this.cosineLobeBandFactor(this.$inputs.shIndex);
|
|
291
|
+
this.$l.sh = this.evalBasis(this.$inputs.direction, this.$inputs.shIndex);
|
|
304
292
|
this.$outputs.color = pb.vec4(pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale), 1);
|
|
305
293
|
});
|
|
306
294
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shprojector.js","sources":["../../src/utility/shprojector.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BindGroup,\r\n FrameBuffer,\r\n GPUDataBuffer,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube\r\n} from '@zephyr3d/device';\r\nimport { Primitive } from '../render/primitive';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { Disposable, DRef, Vector4 } from '@zephyr3d/base';\r\nimport { fetchSampler } from './misc';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.\r\n * This is commonly used for efficient environment lighting approximation in real-time rendering.\r\n *\r\n * The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)\r\n * from a cubemap texture, which can then be used for ambient lighting calculations.\r\n *\r\n * @example\r\n * ```typescript\r\n * const projector = new CubemapSHProjector(10000);\r\n * const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });\r\n * projector.projectCubemap(environmentCubemap, shBuffer);\r\n * // shBuffer now contains the 9 SH coefficients as RGB values\r\n * projector.dispose();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class CubemapSHProjector extends Disposable {\r\n private static _programInst: Nullable<GPUProgram> = null;\r\n private static _bindGroupInst: Nullable<BindGroup> = null;\r\n private static _renderStats: Nullable<RenderStateSet> = null;\r\n private readonly _primitive: DRef<Primitive>;\r\n private readonly _renderTarget: DRef<FrameBuffer>;\r\n private readonly _numSamples: number;\r\n /**\r\n * Creates a new CubemapSHProjector instance.\r\n *\r\n * @param numSamples - Number of Monte Carlo samples to use for SH projection.\r\n * Higher values provide better accuracy but slower computation.\r\n * Default is 10000.\r\n */\r\n constructor(numSamples = 10000) {\r\n super();\r\n this._numSamples = numSamples;\r\n this._primitive = new DRef();\r\n this._renderTarget = new DRef();\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outBuffer - GPU data buffer to receive the computed SH coefficients.\r\n * Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).\r\n *\r\n * @example\r\n * ```typescript\r\n * const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes\r\n * projector.projectCubemap(environmentMap, shBuffer);\r\n * ```\r\n */\r\n projectCubemap(cubemap: TextureCube, outBuffer: GPUDataBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n if (!this._renderTarget.get()) {\r\n const texture = device.createTexture2D('rgba32f', 3, 3, {\r\n mipmapping: false\r\n })!;\r\n this._renderTarget.set(device.createFrameBuffer([texture], null));\r\n }\r\n this.projectCubemapToTexture(cubemap, this._renderTarget.get()!, radianceSource);\r\n this._renderTarget.get()!.getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.\r\n *\r\n * @example\r\n * ```typescript\r\n * const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes\r\n * const shFramebuffer = device.createFrameBuffer([shTexture], null);\r\n * projector.projectCubemapToTexture(environmentMap, shFramebuffer);\r\n * ```\r\n */\r\n projectCubemapToTexture(cubemap: TextureCube, framebuffer: FrameBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n const clearColor = new Vector4(0, 0, 0, 1);\r\n this.init(device);\r\n device.pushDeviceStates();\r\n device.setRenderStates(CubemapSHProjector._renderStats);\r\n device.setProgram(CubemapSHProjector._programInst);\r\n device.setFramebuffer(framebuffer);\r\n device.clearFrameBuffer(clearColor, null, null);\r\n const bindGroup = CubemapSHProjector._bindGroupInst!;\r\n bindGroup.setTexture('cubemap', cubemap, fetchSampler('clamp_linear_nomip'));\r\n bindGroup.setValue('scale', radianceSource ? 1.0 : Math.PI);\r\n device.setBindGroup(0, bindGroup);\r\n this._primitive.get()!.drawInstanced(9);\r\n device.popDeviceStates();\r\n }\r\n /**\r\n * Disposes of all resources allocated by this projector instance.\r\n * Should be called when the projector is no longer needed to prevent memory leaks.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._primitive.dispose();\r\n if (this._renderTarget.get()) {\r\n this._renderTarget.get()!.getColorAttachments()[0].dispose();\r\n this._renderTarget.dispose();\r\n }\r\n }\r\n /**\r\n * Initializes the GPU resources needed for SH projection.\r\n * This method is called automatically by projectCubemap() and sets up:\r\n * - Sample directions primitive (Monte Carlo samples on unit sphere)\r\n * - Render target (3x3 RGBA32F texture)\r\n * - Render states (additive blending, no depth test)\r\n * - GPU program for SH evaluation\r\n *\r\n * @param device - The graphics device to create resources with\r\n * @internal\r\n */\r\n private init(device: AbstractDevice) {\r\n if (!this._primitive.get()) {\r\n const samples = new Float32Array(this._numSamples * 4);\r\n for (let i = 0; i < this._numSamples; i++) {\r\n let x1: number, x2: number, s: number;\r\n do {\r\n x1 = Math.random() * 2 - 1;\r\n x2 = Math.random() * 2 - 1;\r\n s = x1 * x1 + x2 * x2;\r\n } while (s >= 1);\r\n const sqrtS = Math.sqrt(1 - s);\r\n samples[i * 4 + 0] = 2 * x1 * sqrtS;\r\n samples[i * 4 + 1] = 2 * x2 * sqrtS;\r\n samples[i * 4 + 2] = 1 - 2 * s;\r\n samples[i * 4 + 3] = (4 * Math.PI) / this._numSamples;\r\n }\r\n const primitive = new Primitive();\r\n primitive.createAndSetVertexBuffer('position_f32x4', samples);\r\n if (device.type === 'webgl') {\r\n primitive.createAndSetVertexBuffer(\r\n 'tex0_f32',\r\n new Float32Array([0, 1, 2, 3, 4, 5, 6, 7, 8]),\r\n 'instance'\r\n );\r\n }\r\n primitive.indexCount = this._numSamples;\r\n primitive.indexStart = 0;\r\n primitive.primitiveType = 'point-list';\r\n this._primitive.set(primitive);\r\n }\r\n\r\n if (!CubemapSHProjector._renderStats) {\r\n CubemapSHProjector._renderStats = device.createRenderStateSet();\r\n CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);\r\n CubemapSHProjector._renderStats\r\n .useBlendingState()\r\n .enable(true)\r\n .setBlendEquation('add', 'add')\r\n .setBlendFuncRGB('one', 'one')\r\n .setBlendFuncAlpha('zero', 'one');\r\n CubemapSHProjector._renderStats.useRasterizerState().setCullMode('none');\r\n }\r\n\r\n if (!CubemapSHProjector._programInst) {\r\n CubemapSHProjector._programInst = CubemapSHProjector._createProgram(device)!;\r\n CubemapSHProjector._bindGroupInst = device.createBindGroup(\r\n CubemapSHProjector._programInst.bindGroupLayouts[0]\r\n );\r\n }\r\n }\r\n /**\r\n * Creates the GPU program for spherical harmonics evaluation.\r\n *\r\n * The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).\r\n * Each instance renders all sample points, but the vertex shader maps them to different\r\n * pixels in the 3x3 output texture based on the instance ID.\r\n *\r\n * The fragment shader evaluates the appropriate SH basis function based on the pixel location,\r\n * samples the cubemap in the sample direction, and multiplies by the integration weight.\r\n *\r\n * @param device - The graphics device to create the program with\r\n * @returns The compiled GPU program\r\n * @internal\r\n */\r\n private static _createProgram(device: AbstractDevice) {\r\n const program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.directionWeight = pb.vec4().attrib('position');\r\n if (device.type === 'webgl') {\r\n this.$inputs.instanceId = pb.float().attrib('texCoord0');\r\n }\r\n pb.main(function () {\r\n this.$outputs.direction = this.$inputs.directionWeight.xyz;\r\n this.$outputs.weight = this.$inputs.directionWeight.w;\r\n if (pb.getDevice().type !== 'webgpu') {\r\n this.$builtins.pointSize = 1;\r\n }\r\n this.$outputs.shIndex =\r\n device.type === 'webgl' ? this.$inputs.instanceId : pb.int(this.$builtins.instanceIndex);\r\n this.$l.x = pb.mod(this.$outputs.shIndex, 3);\r\n this.$l.y = pb.div(this.$outputs.shIndex, 3);\r\n this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);\r\n this.$l.ndcY = pb.sub(pb.div(pb.add(pb.float(this.y), 0.5), 1.5), 1);\r\n this.$l.$builtins.position = pb.vec4(this.ndcX, this.ndcY, 0, 1);\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position = pb.mul(this.$builtins.position, pb.vec4(1, -1, 1, 1));\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n this.cubemap = pb.texCube().uniform(0);\r\n this.scale = pb.float().uniform(0);\r\n pb.func('cosineLobeBandFactor', [pb.int('l')], function () {\r\n this.$if(pb.equal(this.l, 0), function () {\r\n this.$return(pb.float(1));\r\n });\r\n this.$if(pb.lessThanEqual(this.l, 3), function () {\r\n this.$return(2 / 3);\r\n });\r\n this.$return(1 / 4);\r\n });\r\n pb.func('Y0', [pb.vec3('v')], function () {\r\n this.$return(0.282094791773878);\r\n });\r\n pb.func('Y1', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, -0.4886025119));\r\n });\r\n pb.func('Y2', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.z, 0.4886025119));\r\n });\r\n pb.func('Y3', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, -0.4886025119));\r\n });\r\n pb.func('Y4', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.y, 1.0925484306));\r\n });\r\n pb.func('Y5', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y6', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.z, this.v.z, 3), 1), 0.3153915652));\r\n });\r\n pb.func('Y7', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y8', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.x, this.v.x), pb.mul(this.v.y, this.v.y)), 0.5462742153));\r\n });\r\n pb.func('evalBasis', [pb.vec3('dir'), pb.int('c')], function () {\r\n this.$if(pb.equal(this.c, 0), function () {\r\n this.$return(this.Y0(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 1), function () {\r\n this.$return(this.Y1(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 2), function () {\r\n this.$return(this.Y2(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 3), function () {\r\n this.$return(this.Y3(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 4), function () {\r\n this.$return(this.Y4(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 5), function () {\r\n this.$return(this.Y5(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 6), function () {\r\n this.$return(this.Y6(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 7), function () {\r\n this.$return(this.Y7(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 8), function () {\r\n this.$return(this.Y8(this.dir));\r\n })\r\n .$else(function () {\r\n this.$return(0);\r\n });\r\n });\r\n pb.main(function () {\r\n this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;\r\n this.$l.bandFactor = this.cosineLobeBandFactor(\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$l.sh = this.evalBasis(\r\n this.$inputs.direction,\r\n pb.getDevice().type === 'webgl' ? pb.int(this.$inputs.shIndex) : this.$inputs.shIndex\r\n );\r\n this.$outputs.color = pb.vec4(\r\n pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale),\r\n 1\r\n );\r\n });\r\n }\r\n })!;\r\n program.name = '@CubemapSHProjector_SHProject';\r\n return program;\r\n }\r\n}\r\n"],"names":["CubemapSHProjector","Disposable","_programInst","_bindGroupInst","_renderStats","_primitive","_renderTarget","_numSamples","numSamples","DRef","projectCubemap","cubemap","outBuffer","radianceSource","device","getDevice","get","texture","createTexture2D","mipmapping","set","createFrameBuffer","projectCubemapToTexture","getColorAttachments","readPixelsToBuffer","framebuffer","clearColor","Vector4","init","pushDeviceStates","setRenderStates","setProgram","setFramebuffer","clearFrameBuffer","bindGroup","setTexture","fetchSampler","setValue","Math","PI","setBindGroup","drawInstanced","popDeviceStates","onDispose","dispose","samples","Float32Array","i","x1","x2","s","random","sqrtS","sqrt","primitive","Primitive","createAndSetVertexBuffer","type","indexCount","indexStart","primitiveType","createRenderStateSet","useDepthState","enableTest","enableWrite","useBlendingState","enable","setBlendEquation","setBlendFuncRGB","setBlendFuncAlpha","useRasterizerState","setCullMode","_createProgram","createBindGroup","bindGroupLayouts","program","buildRenderProgram","vertex","pb","$inputs","directionWeight","vec4","attrib","instanceId","float","main","$outputs","direction","xyz","weight","w","$builtins","pointSize","shIndex","int","instanceIndex","$l","x","mod","y","div","ndcX","sub","add","ndcY","position","mul","fragment","color","texCube","uniform","scale","func","$if","equal","l","$return","lessThanEqual","vec3","v","z","c","Y0","dir","$elseif","Y1","Y2","Y3","Y4","Y5","Y6","Y7","Y8","$else","radiance","textureSampleLevel","rgb","bandFactor","cosineLobeBandFactor","sh","evalBasis","name"],"mappings":";;;;;AAeA;;;;;;;;;;;;;;;;;IAkBO,MAAMA,kBAA2BC,SAAAA,UAAAA,CAAAA;AACtC,IAAA,OAAeC,eAAqC,IAAK;AACzD,IAAA,OAAeC,iBAAsC,IAAK;AAC1D,IAAA,OAAeC,eAAyC,IAAK;IAC5CC,UAA4B;IAC5BC,aAAiC;IACjCC,WAAoB;AACrC;;;;;;MAOA,WAAA,CAAYC,UAAa,GAAA,KAAK,CAAE;QAC9B,KAAK,EAAA;QACL,IAAI,CAACD,WAAW,GAAGC,UAAAA;QACnB,IAAI,CAACH,UAAU,GAAG,IAAII,IAAAA,EAAAA;QACtB,IAAI,CAACH,aAAa,GAAG,IAAIG,IAAAA,EAAAA;AAC3B;AACA;;;;;;;;;;;;;;;;;;;AAmBC,MACDC,eAAeC,OAAoB,EAAEC,SAAwB,EAAEC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E,IAAI,CAAC1B,KAAK,CAC/E,EAAA,CAAA,CAAA;AAEJ,iBAAA,CAAA;AACF;AACF,SAAA,CAAA;AACApC,QAAAA,OAAAA,CAAQkE,IAAI,GAAG,+BAAA;QACf,OAAOlE,OAAAA;AACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"shprojector.js","sources":["../../src/utility/shprojector.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BindGroup,\r\n FrameBuffer,\r\n GPUDataBuffer,\r\n GPUProgram,\r\n RenderStateSet,\r\n TextureCube\r\n} from '@zephyr3d/device';\r\nimport { Primitive } from '../render/primitive';\r\nimport type { Nullable } from '@zephyr3d/base';\r\nimport { Disposable, DRef, PRNG, Vector4 } from '@zephyr3d/base';\r\nimport { fetchSampler } from './misc';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * CubemapSHProjector is responsible for projecting a cubemap texture into spherical harmonics (SH) coefficients.\r\n * This is commonly used for efficient environment lighting approximation in real-time rendering.\r\n *\r\n * The class uses Monte Carlo sampling to compute the first 9 spherical harmonics coefficients (up to order 2)\r\n * from a cubemap texture, which can then be used for ambient lighting calculations.\r\n *\r\n * @example\r\n * ```typescript\r\n * const projector = new CubemapSHProjector(10000);\r\n * const shBuffer = device.createBuffer(4 * 4 * 9, { usage: 'uniform' });\r\n * projector.projectCubemap(environmentCubemap, shBuffer);\r\n * // shBuffer now contains the 9 SH coefficients as RGB values\r\n * projector.dispose();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class CubemapSHProjector extends Disposable {\r\n private static _programInst: Nullable<GPUProgram> = null;\r\n private static _bindGroupInst: Nullable<BindGroup> = null;\r\n private static _renderStats: Nullable<RenderStateSet> = null;\r\n private readonly _primitive: DRef<Primitive>;\r\n private readonly _renderTarget: DRef<FrameBuffer>;\r\n private readonly _numSamples: number;\r\n /**\r\n * Creates a new CubemapSHProjector instance.\r\n *\r\n * @param numSamples - Number of Monte Carlo samples to use for SH projection.\r\n * Higher values provide better accuracy but slower computation.\r\n * Default is 10000.\r\n */\r\n constructor(numSamples = 10000) {\r\n super();\r\n this._numSamples = numSamples;\r\n this._primitive = new DRef();\r\n this._renderTarget = new DRef();\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a GPUBuffer.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outBuffer - GPU data buffer to receive the computed SH coefficients.\r\n * Must be large enough to hold 9 RGB values (36 floats for RGBA32F format).\r\n *\r\n * @example\r\n * ```typescript\r\n * const shBuffer = device.createDataBuffer(9 * 4 * 4); // 9 coefficients * 4 components * 4 bytes\r\n * projector.projectCubemap(environmentMap, shBuffer);\r\n * ```\r\n */\r\n projectCubemap(cubemap: TextureCube, outBuffer: GPUDataBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n if (!this._renderTarget.get()) {\r\n const texture = device.createTexture2D('rgba32f', 3, 3, {\r\n mipmapping: false\r\n })!;\r\n this._renderTarget.set(device.createFrameBuffer([texture], null));\r\n }\r\n this.projectCubemapToTexture(cubemap, this._renderTarget.get()!, radianceSource);\r\n this._renderTarget.get()!.getColorAttachments()[0].readPixelsToBuffer(0, 0, 3, 3, 0, 0, outBuffer);\r\n }\r\n /**\r\n * Projects a cubemap texture into spherical harmonics coefficients and stores them in a 3x3 texture.\r\n *\r\n * The method performs Monte Carlo integration over the sphere to compute the first 9 SH coefficients.\r\n * The results are written to a 3x3 render target where each pixel contains RGB values for one SH coefficient.\r\n * The layout is:\r\n * - (0,0): Y₀₀ (0,1): Y₁₋₁ (0,2): Y₁₀\r\n * - (1,0): Y₁₁ (1,1): Y₂₋₂ (1,2): Y₂₋₁\r\n * - (2,0): Y₂₀ (2,1): Y₂₁ (2,2): Y₂₂\r\n *\r\n * @param cubemap - The input cubemap texture to project\r\n * @param outFramebuffer - Framebuffer that contains the 3x3 texture to receive the computed SH coefficients in color attachment slot 0.\r\n *\r\n * @example\r\n * ```typescript\r\n * const shTexture = device.createTexture2D('rgba32f', 3, 3); // 9 coefficients * 4 components * 4 bytes\r\n * const shFramebuffer = device.createFrameBuffer([shTexture], null);\r\n * projector.projectCubemapToTexture(environmentMap, shFramebuffer);\r\n * ```\r\n */\r\n projectCubemapToTexture(cubemap: TextureCube, framebuffer: FrameBuffer, radianceSource = true) {\r\n const device = getDevice();\r\n const clearColor = new Vector4(0, 0, 0, 1);\r\n this.init(device);\r\n device.pushDeviceStates();\r\n device.setRenderStates(CubemapSHProjector._renderStats);\r\n device.setProgram(CubemapSHProjector._programInst);\r\n device.setFramebuffer(framebuffer);\r\n device.clearFrameBuffer(clearColor, null, null);\r\n const bindGroup = CubemapSHProjector._bindGroupInst!;\r\n bindGroup.setTexture('cubemap', cubemap, fetchSampler('clamp_linear_nomip'));\r\n bindGroup.setValue('scale', radianceSource ? 1.0 : Math.PI);\r\n device.setBindGroup(0, bindGroup);\r\n this._primitive.get()!.drawInstanced(9);\r\n device.popDeviceStates();\r\n }\r\n /**\r\n * Disposes of all resources allocated by this projector instance.\r\n * Should be called when the projector is no longer needed to prevent memory leaks.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._primitive.dispose();\r\n if (this._renderTarget.get()) {\r\n this._renderTarget.get()!.getColorAttachments()[0].dispose();\r\n this._renderTarget.dispose();\r\n }\r\n }\r\n /**\r\n * Initializes the GPU resources needed for SH projection.\r\n * This method is called automatically by projectCubemap() and sets up:\r\n * - Sample directions primitive (Monte Carlo samples on unit sphere)\r\n * - Render target (3x3 RGBA32F texture)\r\n * - Render states (additive blending, no depth test)\r\n * - GPU program for SH evaluation\r\n *\r\n * @param device - The graphics device to create resources with\r\n * @internal\r\n */\r\n private init(device: AbstractDevice) {\r\n if (!this._primitive.get()) {\r\n const samples = new Float32Array(this._numSamples * 4);\r\n // Seeded so the projection is the same on every run: with Math.random()\r\n // every page load drew different directions, which made all sky-lit\r\n // lighting differ slightly from run to run.\r\n const rand = new PRNG(0x5348);\r\n for (let i = 0; i < this._numSamples; i++) {\r\n let x1: number, x2: number, s: number;\r\n do {\r\n x1 = rand.get() * 2 - 1;\r\n x2 = rand.get() * 2 - 1;\r\n s = x1 * x1 + x2 * x2;\r\n } while (s >= 1);\r\n const sqrtS = Math.sqrt(1 - s);\r\n samples[i * 4 + 0] = 2 * x1 * sqrtS;\r\n samples[i * 4 + 1] = 2 * x2 * sqrtS;\r\n samples[i * 4 + 2] = 1 - 2 * s;\r\n samples[i * 4 + 3] = (4 * Math.PI) / this._numSamples;\r\n }\r\n const primitive = new Primitive();\r\n primitive.createAndSetVertexBuffer('position_f32x4', samples);\r\n primitive.indexCount = this._numSamples;\r\n primitive.indexStart = 0;\r\n primitive.primitiveType = 'point-list';\r\n this._primitive.set(primitive);\r\n }\r\n\r\n if (!CubemapSHProjector._renderStats) {\r\n CubemapSHProjector._renderStats = device.createRenderStateSet();\r\n CubemapSHProjector._renderStats.useDepthState().enableTest(false).enableWrite(false);\r\n CubemapSHProjector._renderStats\r\n .useBlendingState()\r\n .enable(true)\r\n .setBlendEquation('add', 'add')\r\n .setBlendFuncRGB('one', 'one')\r\n .setBlendFuncAlpha('zero', 'one');\r\n CubemapSHProjector._renderStats.useRasterizerState().setCullMode('none');\r\n }\r\n\r\n if (!CubemapSHProjector._programInst) {\r\n CubemapSHProjector._programInst = CubemapSHProjector._createProgram(device)!;\r\n CubemapSHProjector._bindGroupInst = device.createBindGroup(\r\n CubemapSHProjector._programInst.bindGroupLayouts[0]\r\n );\r\n }\r\n }\r\n /**\r\n * Creates the GPU program for spherical harmonics evaluation.\r\n *\r\n * The vertex shader uses instanced rendering to generate 9 instances (one per SH coefficient).\r\n * Each instance renders all sample points, but the vertex shader maps them to different\r\n * pixels in the 3x3 output texture based on the instance ID.\r\n *\r\n * The fragment shader evaluates the appropriate SH basis function based on the pixel location,\r\n * samples the cubemap in the sample direction, and multiplies by the integration weight.\r\n *\r\n * @param device - The graphics device to create the program with\r\n * @returns The compiled GPU program\r\n * @internal\r\n */\r\n private static _createProgram(device: AbstractDevice) {\r\n const program = device.buildRenderProgram({\r\n vertex(pb) {\r\n this.$inputs.directionWeight = pb.vec4().attrib('position');\r\n pb.main(function () {\r\n this.$outputs.direction = this.$inputs.directionWeight.xyz;\r\n this.$outputs.weight = this.$inputs.directionWeight.w;\r\n if (pb.getDevice().type !== 'webgpu') {\r\n this.$builtins.pointSize = 1;\r\n }\r\n this.$outputs.shIndex = pb.int(this.$builtins.instanceIndex);\r\n this.$l.x = pb.mod(this.$outputs.shIndex, 3);\r\n this.$l.y = pb.div(this.$outputs.shIndex, 3);\r\n this.$l.ndcX = pb.sub(pb.div(pb.add(pb.float(this.x), 0.5), 1.5), 1);\r\n this.$l.ndcY = pb.sub(pb.div(pb.add(pb.float(this.y), 0.5), 1.5), 1);\r\n this.$l.$builtins.position = pb.vec4(this.ndcX, this.ndcY, 0, 1);\r\n if (pb.getDevice().type === 'webgpu') {\r\n this.$builtins.position = pb.mul(this.$builtins.position, pb.vec4(1, -1, 1, 1));\r\n }\r\n });\r\n },\r\n fragment(pb) {\r\n this.$outputs.color = pb.vec4();\r\n this.cubemap = pb.texCube().uniform(0);\r\n this.scale = pb.float().uniform(0);\r\n pb.func('cosineLobeBandFactor', [pb.int('l')], function () {\r\n this.$if(pb.equal(this.l, 0), function () {\r\n this.$return(pb.float(1));\r\n });\r\n this.$if(pb.lessThanEqual(this.l, 3), function () {\r\n this.$return(2 / 3);\r\n });\r\n this.$return(1 / 4);\r\n });\r\n pb.func('Y0', [pb.vec3('v')], function () {\r\n this.$return(0.282094791773878);\r\n });\r\n pb.func('Y1', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, -0.4886025119));\r\n });\r\n pb.func('Y2', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.z, 0.4886025119));\r\n });\r\n pb.func('Y3', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, -0.4886025119));\r\n });\r\n pb.func('Y4', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.y, 1.0925484306));\r\n });\r\n pb.func('Y5', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.y, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y6', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.z, this.v.z, 3), 1), 0.3153915652));\r\n });\r\n pb.func('Y7', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(this.v.x, this.v.z, -1.0925484306));\r\n });\r\n pb.func('Y8', [pb.vec3('v')], function () {\r\n this.$return(pb.mul(pb.sub(pb.mul(this.v.x, this.v.x), pb.mul(this.v.y, this.v.y)), 0.5462742153));\r\n });\r\n pb.func('evalBasis', [pb.vec3('dir'), pb.int('c')], function () {\r\n this.$if(pb.equal(this.c, 0), function () {\r\n this.$return(this.Y0(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 1), function () {\r\n this.$return(this.Y1(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 2), function () {\r\n this.$return(this.Y2(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 3), function () {\r\n this.$return(this.Y3(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 4), function () {\r\n this.$return(this.Y4(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 5), function () {\r\n this.$return(this.Y5(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 6), function () {\r\n this.$return(this.Y6(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 7), function () {\r\n this.$return(this.Y7(this.dir));\r\n })\r\n .$elseif(pb.equal(this.c, 8), function () {\r\n this.$return(this.Y8(this.dir));\r\n })\r\n .$else(function () {\r\n this.$return(0);\r\n });\r\n });\r\n pb.main(function () {\r\n this.$l.radiance = pb.textureSampleLevel(this.cubemap, this.$inputs.direction, 0).rgb;\r\n this.$l.bandFactor = this.cosineLobeBandFactor(this.$inputs.shIndex);\r\n this.$l.sh = this.evalBasis(this.$inputs.direction, this.$inputs.shIndex);\r\n this.$outputs.color = pb.vec4(\r\n pb.mul(this.radiance, this.sh, this.$inputs.weight, this.bandFactor, this.scale),\r\n 1\r\n );\r\n });\r\n }\r\n })!;\r\n program.name = '@CubemapSHProjector_SHProject';\r\n return program;\r\n }\r\n}\r\n"],"names":["CubemapSHProjector","Disposable","_programInst","_bindGroupInst","_renderStats","_primitive","_renderTarget","_numSamples","numSamples","DRef","projectCubemap","cubemap","outBuffer","radianceSource","device","getDevice","get","texture","createTexture2D","mipmapping","set","createFrameBuffer","projectCubemapToTexture","getColorAttachments","readPixelsToBuffer","framebuffer","clearColor","Vector4","init","pushDeviceStates","setRenderStates","setProgram","setFramebuffer","clearFrameBuffer","bindGroup","setTexture","fetchSampler","setValue","Math","PI","setBindGroup","drawInstanced","popDeviceStates","onDispose","dispose","samples","Float32Array","rand","PRNG","i","x1","x2","s","sqrtS","sqrt","primitive","Primitive","createAndSetVertexBuffer","indexCount","indexStart","primitiveType","createRenderStateSet","useDepthState","enableTest","enableWrite","useBlendingState","enable","setBlendEquation","setBlendFuncRGB","setBlendFuncAlpha","useRasterizerState","setCullMode","_createProgram","createBindGroup","bindGroupLayouts","program","buildRenderProgram","vertex","pb","$inputs","directionWeight","vec4","attrib","main","$outputs","direction","xyz","weight","w","type","$builtins","pointSize","shIndex","int","instanceIndex","$l","x","mod","y","div","ndcX","sub","add","float","ndcY","position","mul","fragment","color","texCube","uniform","scale","func","$if","equal","l","$return","lessThanEqual","vec3","v","z","c","Y0","dir","$elseif","Y1","Y2","Y3","Y4","Y5","Y6","Y7","Y8","$else","radiance","textureSampleLevel","rgb","bandFactor","cosineLobeBandF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|
|
2
|
+
|
|
3
|
+
let foamTexture = null;
|
|
4
|
+
/** Texels along each side of the default foam texture. */ const FOAM_TEXTURE_SIZE = 256;
|
|
5
|
+
/**
|
|
6
|
+
* Bubbles of the default foam texture: cells of a Worley basis across the
|
|
7
|
+
* tile at two scales, the larger the stronger, and the width of their rims
|
|
8
|
+
* in cell spacings.
|
|
9
|
+
*/ const FOAM_BUBBLES_COARSE = 12;
|
|
10
|
+
const FOAM_BUBBLES_FINE = 27;
|
|
11
|
+
const FOAM_RIM_WIDTH = 0.18;
|
|
12
|
+
/** Clumps of the default foam texture: value noise cells across the tile, and their share of the value. */ const FOAM_CLUMPS = 4;
|
|
13
|
+
const FOAM_CLUMP_WEIGHT = 0.5;
|
|
14
|
+
/**
|
|
15
|
+
* Grey levels of Crest's default foam texture (Foam2.png, Wave Harmonic, MIT)
|
|
16
|
+
* at every sixteenth of its texels in order, darkest to brightest. The
|
|
17
|
+
* default texture is remapped to them rank for rank, so a foam density
|
|
18
|
+
* uncovers as much of it as of Crest's.
|
|
19
|
+
*/ const FOAM_LEVELS = [
|
|
20
|
+
0.0,
|
|
21
|
+
0.455,
|
|
22
|
+
0.51,
|
|
23
|
+
0.557,
|
|
24
|
+
0.596,
|
|
25
|
+
0.631,
|
|
26
|
+
0.655,
|
|
27
|
+
0.675,
|
|
28
|
+
0.694,
|
|
29
|
+
0.71,
|
|
30
|
+
0.722,
|
|
31
|
+
0.737,
|
|
32
|
+
0.753,
|
|
33
|
+
0.769,
|
|
34
|
+
0.796,
|
|
35
|
+
0.839,
|
|
36
|
+
0.98
|
|
37
|
+
];
|
|
38
|
+
/** Deterministic hash of integer lattice coordinates to [0, 1). */ function hash2(x, y, seed) {
|
|
39
|
+
let h = Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1) ^ Math.imul(seed, 0x9e3779b9);
|
|
40
|
+
h = Math.imul(h ^ h >>> 15, 0x85ebca6b);
|
|
41
|
+
h = Math.imul(h ^ h >>> 13, 0xc2b2ae35);
|
|
42
|
+
return ((h ^ h >>> 16) >>> 0) / 4294967296;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Worley's cellular basis (Worley, "A Cellular Texture Basis Function",
|
|
46
|
+
* SIGGRAPH 1996) on a lattice of `cells` across a unit tile, wrapping so the
|
|
47
|
+
* tile repeats: the distances F1 and F2 from (u, v) to the nearest and second
|
|
48
|
+
* nearest feature point, one per cell, in cell spacings.
|
|
49
|
+
*/ function worley(u, v, cells, seed) {
|
|
50
|
+
const x = u * cells;
|
|
51
|
+
const y = v * cells;
|
|
52
|
+
const cx = Math.floor(x);
|
|
53
|
+
const cy = Math.floor(y);
|
|
54
|
+
let f1 = 1e9;
|
|
55
|
+
let f2 = 1e9;
|
|
56
|
+
for(let j = -1; j <= 1; j++){
|
|
57
|
+
for(let i = -1; i <= 1; i++){
|
|
58
|
+
const gx = cx + i;
|
|
59
|
+
const gy = cy + j;
|
|
60
|
+
const wx = (gx % cells + cells) % cells;
|
|
61
|
+
const wy = (gy % cells + cells) % cells;
|
|
62
|
+
const dx = gx + hash2(wx, wy, seed) - x;
|
|
63
|
+
const dy = gy + hash2(wx, wy, seed + 1) - y;
|
|
64
|
+
const d = Math.sqrt(dx * dx + dy * dy);
|
|
65
|
+
if (d < f1) {
|
|
66
|
+
f2 = f1;
|
|
67
|
+
f1 = d;
|
|
68
|
+
} else if (d < f2) {
|
|
69
|
+
f2 = d;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return [
|
|
74
|
+
f1,
|
|
75
|
+
f2
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
/** Smoothly interpolated value noise on a lattice of `cells` across a unit tile, wrapping. */ function tiledValueNoise(u, v, cells, seed) {
|
|
79
|
+
const x = u * cells;
|
|
80
|
+
const y = v * cells;
|
|
81
|
+
const cx = Math.floor(x);
|
|
82
|
+
const cy = Math.floor(y);
|
|
83
|
+
const fx = x - cx;
|
|
84
|
+
const fy = y - cy;
|
|
85
|
+
const sx = fx * fx * (3 - 2 * fx);
|
|
86
|
+
const sy = fy * fy * (3 - 2 * fy);
|
|
87
|
+
const at = (i, j)=>hash2(((cx + i) % cells + cells) % cells, ((cy + j) % cells + cells) % cells, seed);
|
|
88
|
+
const a = at(0, 0) + (at(1, 0) - at(0, 0)) * sx;
|
|
89
|
+
const b = at(0, 1) + (at(1, 1) - at(0, 1)) * sx;
|
|
90
|
+
return a + (b - a) * sy;
|
|
91
|
+
}
|
|
92
|
+
/** Smoothstep falloff of a value: 1 at 0, 0 from `width` on. */ function rim(d, width) {
|
|
93
|
+
const t = Math.min(Math.max(d / width, 0), 1);
|
|
94
|
+
return 1 - t * t * (3 - 2 * t);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Default foam texture: a tile of bubbles, cells of Worley's basis at two
|
|
98
|
+
* scales whose walls (where F2 - F1, the distance to the edge between two
|
|
99
|
+
* cells, is small) are bright and whose middles dark, over clumps of value
|
|
100
|
+
* noise, its grey levels those of Crest's default foam texture (see
|
|
101
|
+
* FOAM_LEVELS). Value in the red channel.
|
|
102
|
+
*
|
|
103
|
+
* @internal
|
|
104
|
+
*/ function getDefaultFoamTexture() {
|
|
105
|
+
if (!foamTexture) {
|
|
106
|
+
const n = FOAM_TEXTURE_SIZE;
|
|
107
|
+
const values = new Float32Array(n * n);
|
|
108
|
+
for(let y = 0; y < n; y++){
|
|
109
|
+
for(let x = 0; x < n; x++){
|
|
110
|
+
const u = (x + 0.5) / n;
|
|
111
|
+
const v = (y + 0.5) / n;
|
|
112
|
+
const [c1, c2] = worley(u, v, FOAM_BUBBLES_COARSE, 11);
|
|
113
|
+
const [f1, f2] = worley(u, v, FOAM_BUBBLES_FINE, 23);
|
|
114
|
+
const bubbles = 0.65 * rim(c2 - c1, FOAM_RIM_WIDTH) + 0.35 * rim(f2 - f1, FOAM_RIM_WIDTH);
|
|
115
|
+
const clumps = 0.65 * tiledValueNoise(u, v, FOAM_CLUMPS, 37) + 0.35 * tiledValueNoise(u, v, FOAM_CLUMPS * 2, 41);
|
|
116
|
+
values[y * n + x] = FOAM_CLUMP_WEIGHT * clumps + (1 - FOAM_CLUMP_WEIGHT) * bubbles;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Rank for rank onto Crest's grey levels
|
|
120
|
+
const order = Array.from(values.keys()).sort((a, b)=>values[a] - values[b]);
|
|
121
|
+
const data = new Uint8Array(n * n * 4);
|
|
122
|
+
const last = FOAM_LEVELS.length - 1;
|
|
123
|
+
order.forEach((texel, rank)=>{
|
|
124
|
+
const t = rank / (order.length - 1) * last;
|
|
125
|
+
const k = Math.min(Math.floor(t), last - 1);
|
|
126
|
+
const level = FOAM_LEVELS[k] + (FOAM_LEVELS[k + 1] - FOAM_LEVELS[k]) * (t - k);
|
|
127
|
+
const o = texel * 4;
|
|
128
|
+
data[o] = data[o + 1] = data[o + 2] = Math.round(level * 255);
|
|
129
|
+
data[o + 3] = 255;
|
|
130
|
+
});
|
|
131
|
+
foamTexture = getDevice().createTexture2D('rgba8unorm', n, n);
|
|
132
|
+
foamTexture.name = '@WaterFoam';
|
|
133
|
+
foamTexture.update(data, 0, 0, n, n);
|
|
134
|
+
foamTexture.generateMipmaps();
|
|
135
|
+
}
|
|
136
|
+
return foamTexture;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Samples a foam texture at `uv`, filtered with the screen gradients of the
|
|
140
|
+
* world XZ it was taken from; its value is the red channel.
|
|
141
|
+
* @param uvScale - uv per metre of world XZ.
|
|
142
|
+
* @param mipScale - Factor on the filter footprint, above 1 to blur.
|
|
143
|
+
* @param withSlope - Also take the slope of the value, by differencing a texel
|
|
144
|
+
* along u and v.
|
|
145
|
+
* @returns (value, its slope along world x, along world z), slopes per metre,
|
|
146
|
+
* 0 without `withSlope`
|
|
147
|
+
* @internal
|
|
148
|
+
*/ function sampleFoamTexture(scope, tex, uv, xzGrad, uvScale, mipScale = 1, withSlope = true) {
|
|
149
|
+
const pb = scope.$builder;
|
|
150
|
+
const dx = pb.mul(xzGrad.xy, uvScale, mipScale);
|
|
151
|
+
const dy = pb.mul(xzGrad.zw, uvScale, mipScale);
|
|
152
|
+
const s0 = pb.textureSampleGrad(tex, uv, dx, dy).r;
|
|
153
|
+
if (!withSlope) {
|
|
154
|
+
return pb.vec3(s0, 0, 0);
|
|
155
|
+
}
|
|
156
|
+
const texel = pb.div(pb.vec2(1), pb.vec2(pb.textureDimensions(tex, 0)));
|
|
157
|
+
const su = pb.textureSampleGrad(tex, pb.add(uv, pb.vec2(texel.x, 0)), dx, dy).r;
|
|
158
|
+
const sv = pb.textureSampleGrad(tex, pb.add(uv, pb.vec2(0, texel.y)), dx, dy).r;
|
|
159
|
+
return pb.vec3(s0, pb.mul(pb.div(pb.vec2(pb.sub(su, s0), pb.sub(sv, s0)), texel), uvScale));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Metres of world XZ per texel of a foam texture, at `uvScale` uv per metre.
|
|
163
|
+
* @internal
|
|
164
|
+
*/ function foamTexelSize(scope, tex, uvScale) {
|
|
165
|
+
const pb = scope.$builder;
|
|
166
|
+
return pb.div(1, pb.mul(uvScale, pb.float(pb.textureDimensions(tex, 0).x)));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export { foamTexelSize, getDefaultFoamTexture, sampleFoamTexture };
|
|
170
|
+
//# sourceMappingURL=foam.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foam.js","sources":["../../../src/utility/textures/foam.ts"],"sourcesContent":["import type { PBInsideFunctionScope, PBShaderExp, Texture2D } from '@zephyr3d/device';\r\nimport { getDevice } from '../../app/api';\r\n\r\nlet foamTexture: Texture2D | null = null;\r\n\r\n/** Texels along each side of the default foam texture. */\r\nconst FOAM_TEXTURE_SIZE = 256;\r\n/**\r\n * Bubbles of the default foam texture: cells of a Worley basis across the\r\n * tile at two scales, the larger the stronger, and the width of their rims\r\n * in cell spacings.\r\n */\r\nconst FOAM_BUBBLES_COARSE = 12;\r\nconst FOAM_BUBBLES_FINE = 27;\r\nconst FOAM_RIM_WIDTH = 0.18;\r\n/** Clumps of the default foam texture: value noise cells across the tile, and their share of the value. */\r\nconst FOAM_CLUMPS = 4;\r\nconst FOAM_CLUMP_WEIGHT = 0.5;\r\n/**\r\n * Grey levels of Crest's default foam texture (Foam2.png, Wave Harmonic, MIT)\r\n * at every sixteenth of its texels in order, darkest to brightest. The\r\n * default texture is remapped to them rank for rank, so a foam density\r\n * uncovers as much of it as of Crest's.\r\n */\r\nconst FOAM_LEVELS = [\r\n 0.0, 0.455, 0.51, 0.557, 0.596, 0.631, 0.655, 0.675, 0.694, 0.71, 0.722, 0.737, 0.753, 0.769, 0.796, 0.839,\r\n 0.98\r\n];\r\n\r\n/** Deterministic hash of integer lattice coordinates to [0, 1). */\r\nfunction hash2(x: number, y: number, seed: number) {\r\n let h = Math.imul(x, 0x27d4eb2d) ^ Math.imul(y, 0x165667b1) ^ Math.imul(seed, 0x9e3779b9);\r\n h = Math.imul(h ^ (h >>> 15), 0x85ebca6b);\r\n h = Math.imul(h ^ (h >>> 13), 0xc2b2ae35);\r\n return ((h ^ (h >>> 16)) >>> 0) / 4294967296;\r\n}\r\n\r\n/**\r\n * Worley's cellular basis (Worley, \"A Cellular Texture Basis Function\",\r\n * SIGGRAPH 1996) on a lattice of `cells` across a unit tile, wrapping so the\r\n * tile repeats: the distances F1 and F2 from (u, v) to the nearest and second\r\n * nearest feature point, one per cell, in cell spacings.\r\n */\r\nfunction worley(u: number, v: number, cells: number, seed: number): [number, number] {\r\n const x = u * cells;\r\n const y = v * cells;\r\n const cx = Math.floor(x);\r\n const cy = Math.floor(y);\r\n let f1 = 1e9;\r\n let f2 = 1e9;\r\n for (let j = -1; j <= 1; j++) {\r\n for (let i = -1; i <= 1; i++) {\r\n const gx = cx + i;\r\n const gy = cy + j;\r\n const wx = ((gx % cells) + cells) % cells;\r\n const wy = ((gy % cells) + cells) % cells;\r\n const dx = gx + hash2(wx, wy, seed) - x;\r\n const dy = gy + hash2(wx, wy, seed + 1) - y;\r\n const d = Math.sqrt(dx * dx + dy * dy);\r\n if (d < f1) {\r\n f2 = f1;\r\n f1 = d;\r\n } else if (d < f2) {\r\n f2 = d;\r\n }\r\n }\r\n }\r\n return [f1, f2];\r\n}\r\n\r\n/** Smoothly interpolated value noise on a lattice of `cells` across a unit tile, wrapping. */\r\nfunction tiledValueNoise(u: number, v: number, cells: number, seed: number) {\r\n const x = u * cells;\r\n const y = v * cells;\r\n const cx = Math.floor(x);\r\n const cy = Math.floor(y);\r\n const fx = x - cx;\r\n const fy = y - cy;\r\n const sx = fx * fx * (3 - 2 * fx);\r\n const sy = fy * fy * (3 - 2 * fy);\r\n const at = (i: number, j: number) =>\r\n hash2((((cx + i) % cells) + cells) % cells, (((cy + j) % cells) + cells) % cells, seed);\r\n const a = at(0, 0) + (at(1, 0) - at(0, 0)) * sx;\r\n const b = at(0, 1) + (at(1, 1) - at(0, 1)) * sx;\r\n return a + (b - a) * sy;\r\n}\r\n\r\n/** Smoothstep falloff of a value: 1 at 0, 0 from `width` on. */\r\nfunction rim(d: number, width: number) {\r\n const t = Math.min(Math.max(d / width, 0), 1);\r\n return 1 - t * t * (3 - 2 * t);\r\n}\r\n\r\n/**\r\n * Default foam texture: a tile of bubbles, cells of Worley's basis at two\r\n * scales whose walls (where F2 - F1, the distance to the edge between two\r\n * cells, is small) are bright and whose middles dark, over clumps of value\r\n * noise, its grey levels those of Crest's default foam texture (see\r\n * FOAM_LEVELS). Value in the red channel.\r\n *\r\n * @internal\r\n */\r\nexport function getDefaultFoamTexture() {\r\n if (!foamTexture) {\r\n const n = FOAM_TEXTURE_SIZE;\r\n const values = new Float32Array(n * n);\r\n for (let y = 0; y < n; y++) {\r\n for (let x = 0; x < n; x++) {\r\n const u = (x + 0.5) / n;\r\n const v = (y + 0.5) / n;\r\n const [c1, c2] = worley(u, v, FOAM_BUBBLES_COARSE, 11);\r\n const [f1, f2] = worley(u, v, FOAM_BUBBLES_FINE, 23);\r\n const bubbles = 0.65 * rim(c2 - c1, FOAM_RIM_WIDTH) + 0.35 * rim(f2 - f1, FOAM_RIM_WIDTH);\r\n const clumps =\r\n 0.65 * tiledValueNoise(u, v, FOAM_CLUMPS, 37) + 0.35 * tiledValueNoise(u, v, FOAM_CLUMPS * 2, 41);\r\n values[y * n + x] = FOAM_CLUMP_WEIGHT * clumps + (1 - FOAM_CLUMP_WEIGHT) * bubbles;\r\n }\r\n }\r\n // Rank for rank onto Crest's grey levels\r\n const order = Array.from(values.keys()).sort((a, b) => values[a] - values[b]);\r\n const data = new Uint8Array(n * n * 4);\r\n const last = FOAM_LEVELS.length - 1;\r\n order.forEach((texel, rank) => {\r\n const t = (rank / (order.length - 1)) * last;\r\n const k = Math.min(Math.floor(t), last - 1);\r\n const level = FOAM_LEVELS[k] + (FOAM_LEVELS[k + 1] - FOAM_LEVELS[k]) * (t - k);\r\n const o = texel * 4;\r\n data[o] = data[o + 1] = data[o + 2] = Math.round(level * 255);\r\n data[o + 3] = 255;\r\n });\r\n foamTexture = getDevice().createTexture2D('rgba8unorm', n, n)!;\r\n foamTexture.name = '@WaterFoam';\r\n foamTexture.update(data, 0, 0, n, n);\r\n foamTexture.generateMipmaps();\r\n }\r\n return foamTexture;\r\n}\r\n\r\n/**\r\n * Samples a foam texture at `uv`, filtered with the screen gradients of the\r\n * world XZ it was taken from; its value is the red channel.\r\n * @param uvScale - uv per metre of world XZ.\r\n * @param mipScale - Factor on the filter footprint, above 1 to blur.\r\n * @param withSlope - Also take the slope of the value, by differencing a texel\r\n * along u and v.\r\n * @returns (value, its slope along world x, along world z), slopes per metre,\r\n * 0 without `withSlope`\r\n * @internal\r\n */\r\nexport function sampleFoamTexture(\r\n scope: PBInsideFunctionScope,\r\n tex: PBShaderExp,\r\n uv: PBShaderExp,\r\n xzGrad: PBShaderExp,\r\n uvScale: number | PBShaderExp,\r\n mipScale = 1,\r\n withSlope = true\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const dx = pb.mul(xzGrad.xy, uvScale, mipScale);\r\n const dy = pb.mul(xzGrad.zw, uvScale, mipScale);\r\n const s0 = pb.textureSampleGrad(tex, uv, dx, dy).r;\r\n if (!withSlope) {\r\n return pb.vec3(s0, 0, 0);\r\n }\r\n const texel = pb.div(pb.vec2(1), pb.vec2(pb.textureDimensions(tex, 0)));\r\n const su = pb.textureSampleGrad(tex, pb.add(uv, pb.vec2(texel.x, 0)), dx, dy).r;\r\n const sv = pb.textureSampleGrad(tex, pb.add(uv, pb.vec2(0, texel.y)), dx, dy).r;\r\n return pb.vec3(s0, pb.mul(pb.div(pb.vec2(pb.sub(su, s0), pb.sub(sv, s0)), texel), uvScale));\r\n}\r\n\r\n/**\r\n * Metres of world XZ per texel of a foam texture, at `uvScale` uv per metre.\r\n * @internal\r\n */\r\nexport function foamTexelSize(scope: PBInsideFunctionScope, tex: PBShaderExp, uvScale: PBShaderExp) {\r\n const pb = scope.$builder;\r\n return pb.div(1, pb.mul(uvScale, pb.float(pb.textureDimensions(tex, 0).x)));\r\n}\r\n"],"names":["foamTexture","FOAM_TEXTURE_SIZE","FOAM_BUBBLES_COARSE","FOAM_BUBBLES_FINE","FOAM_RIM_WIDTH","FOAM_CLUMPS","FOAM_CLUMP_WEIGHT","FOAM_LEVELS","hash2","x","y","seed","h","Math","imul","worley","u","v","cells","cx","floor","cy","f1","f2","j","i","gx","gy","wx","wy","dx","dy","d","sqrt","tiledValueNoise","fx","fy","sx","sy","at","a","b","rim","width","t","min","max","getDefaultFoamTexture","n","values","Float32Array","c1","c2","bubbles","clumps","order","Array","from","keys","sort","data","Uint8Array","last","length","forEach","texel","rank","k","level","o","round","getDevice","createTexture2D","name","update","generateMipmaps","sampleFoamTexture","scope","tex","uv","xzGrad","uvScale","mipScale","withSlope","pb","$builder","mul","xy","zw","s0","textureSampleGrad","r","vec3","div","vec2","textureDimensions","su","add","sv","sub","foamTexelSize","float"],"mappings":";;AAGA,IAA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;AACzB,IAAA,OAAOD,GAAGS,GAAG,CAAC,CAAGT,EAAAA,EAAAA,CAAGE,GAAG,CAACL,OAAAA,EAASG,EAAGiB,CAAAA,KAAK,CAACjB,EAAGW,CAAAA,iBAAiB,CAACjB,GAAAA,EAAK,GAAGrE,CAAC,CAAA,CAAA,CAAA;AAC1E;;;;"}
|
|
@@ -26,49 +26,23 @@ function createGGXLUT(size) {
|
|
|
26
26
|
fragment (pb) {
|
|
27
27
|
this.$outputs.color = pb.vec4();
|
|
28
28
|
const SAMPLE_COUNT = 1024;
|
|
29
|
-
|
|
30
|
-
pb.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
pb.func('hammersley2d', [
|
|
48
|
-
pb.int('i'),
|
|
49
|
-
pb.int('N')
|
|
50
|
-
], function() {
|
|
51
|
-
this.$return(pb.vec2(pb.div(pb.float(this.i), pb.float(this.N)), this.radicalInverse_VdC(this.i)));
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
pb.func('radicalInverse_VdC', [
|
|
55
|
-
pb.uint('bits')
|
|
56
|
-
], function() {
|
|
57
|
-
this.$l.n = this.bits;
|
|
58
|
-
this.n = pb.compOr(pb.sal(this.n, 16), pb.sar(this.n, 16));
|
|
59
|
-
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xaaaaaaaa), 1));
|
|
60
|
-
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xcccccccc), 2));
|
|
61
|
-
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0f0f0f0f), 4), pb.sar(pb.compAnd(this.n, 0xf0f0f0f0), 4));
|
|
62
|
-
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00ff00ff), 8), pb.sar(pb.compAnd(this.n, 0xff00ff00), 8));
|
|
63
|
-
this.$return(pb.mul(pb.float(this.n), 2.3283064365386963e-10));
|
|
64
|
-
});
|
|
65
|
-
pb.func('hammersley2d', [
|
|
66
|
-
pb.int('i'),
|
|
67
|
-
pb.int('N')
|
|
68
|
-
], function() {
|
|
69
|
-
this.$return(pb.vec2(pb.div(pb.float(this.i), pb.float(this.N)), this.radicalInverse_VdC(pb.uint(this.i))));
|
|
70
|
-
});
|
|
71
|
-
}
|
|
29
|
+
pb.func('radicalInverse_VdC', [
|
|
30
|
+
pb.uint('bits')
|
|
31
|
+
], function() {
|
|
32
|
+
this.$l.n = this.bits;
|
|
33
|
+
this.n = pb.compOr(pb.sal(this.n, 16), pb.sar(this.n, 16));
|
|
34
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x55555555), 1), pb.sar(pb.compAnd(this.n, 0xaaaaaaaa), 1));
|
|
35
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x33333333), 2), pb.sar(pb.compAnd(this.n, 0xcccccccc), 2));
|
|
36
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x0f0f0f0f), 4), pb.sar(pb.compAnd(this.n, 0xf0f0f0f0), 4));
|
|
37
|
+
this.n = pb.compOr(pb.sal(pb.compAnd(this.n, 0x00ff00ff), 8), pb.sar(pb.compAnd(this.n, 0xff00ff00), 8));
|
|
38
|
+
this.$return(pb.mul(pb.float(this.n), 2.3283064365386963e-10));
|
|
39
|
+
});
|
|
40
|
+
pb.func('hammersley2d', [
|
|
41
|
+
pb.int('i'),
|
|
42
|
+
pb.int('N')
|
|
43
|
+
], function() {
|
|
44
|
+
this.$return(pb.vec2(pb.div(pb.float(this.i), pb.float(this.N)), this.radicalInverse_VdC(pb.uint(this.i))));
|
|
45
|
+
});
|
|
72
46
|
pb.func('generateTBN', [
|
|
73
47
|
pb.vec3('normal')
|
|
74
48
|
], function() {
|