@zephyr3d/scene 0.9.27 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +54 -0
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +279 -55
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +171 -1
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +104 -178
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +25436 -15990
- package/dist/index.js +65 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +66 -4
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +191 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +333 -191
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +1261 -1438
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +106 -106
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +2 -6
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +4 -13
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +3 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +179 -64
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +25 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +5 -5
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +5 -10
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +247 -157
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +16 -38
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +19 -8
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +162 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +10 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +14 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +272 -55
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +41 -0
- package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +58 -158
- package/dist/render/underwater.js.map +1 -1
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +134 -319
- package/dist/render/water_caustics.js.map +1 -1
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +3 -3
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +633 -268
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssgi.js +63 -0
- package/dist/shaders/ssgi.js.map +1 -0
- package/dist/shaders/ssgi_reprojection.js +118 -0
- package/dist/shaders/ssgi_reprojection.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +32 -82
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +7 -21
- package/dist/shaders/water_medium.js.map +1 -1
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +40 -2
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +34 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +46 -5
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +87 -254
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1543 -264
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +10 -22
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
- package/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
2
|
+
|
|
3
|
+
/** Number of scalar parameter columns stored per profile row. */ const SKIN_PROFILE_PARAM_COLUMNS = 6;
|
|
4
|
+
/** Number of texels the baked transmission profile occupies. */ const SKIN_TRANSMISSION_LUT_SIZE = 32;
|
|
5
|
+
/** Total columns per profile row: the scalar parameters followed by the baked transmission profile. */ const SKIN_PROFILE_COLUMNS = SKIN_PROFILE_PARAM_COLUMNS + SKIN_TRANSMISSION_LUT_SIZE;
|
|
6
|
+
/** Maximum number of live skin profiles, matching the 8-bit profile id channel. */ const SKIN_PROFILE_CAPACITY = 256;
|
|
7
|
+
/**
|
|
8
|
+
* Gate on {@link SSSProfile}'s constructor.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Module-private, so only {@link SSSProfile.createOwned} can pass it. See the
|
|
12
|
+
* constructor for why a `private` modifier alone is not enough.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/ const CREATE_TOKEN = Symbol('SSSProfile.create');
|
|
16
|
+
/**
|
|
17
|
+
* Largest optical depth the transmission profile is defined over.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
**/ const SKIN_MAX_TRANSMISSION_OPTICAL_DEPTH = 5;
|
|
21
|
+
/**
|
|
22
|
+
* Floor the averaged optical depth is clamped to before encoding.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
**/ const SKIN_TRANSMISSION_OPTICAL_DEPTH_FLOOR = 0.15;
|
|
26
|
+
/**
|
|
27
|
+
* Constant added to the optical depth after clamping.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
**/ const SKIN_TRANSMISSION_OPTICAL_DEPTH_BIAS = 0.25;
|
|
31
|
+
/**
|
|
32
|
+
* Largest value the thickness pass can write, and with it the sentinel that
|
|
33
|
+
* separates a real measurement from "no light wrote this".
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/ const SKIN_TRANSMISSION_NO_DATA_ENCODING = 1 - (SKIN_TRANSMISSION_OPTICAL_DEPTH_FLOOR + SKIN_TRANSMISSION_OPTICAL_DEPTH_BIAS) / SKIN_MAX_TRANSMISSION_OPTICAL_DEPTH;
|
|
37
|
+
/**
|
|
38
|
+
* Distance, in profile millimetres, the baked transmission profile spans.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/ const TRANSMISSION_LUT_MAX_DISTANCE_MM = 50;
|
|
42
|
+
/**
|
|
43
|
+
* Radius the baked transmission profile is offset by, in profile millimetres.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/ const TRANSMISSION_LUT_RADIUS_OFFSET_MM = 0.6;
|
|
47
|
+
/**
|
|
48
|
+
* Profile-space millimetres per world unit, before the profile's own world unit
|
|
49
|
+
* scale is applied.
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
*/ const WORLD_UNITS_TO_PROFILE_MM = 1000;
|
|
53
|
+
/**
|
|
54
|
+
* Optical depth accumulated per world unit of light path, before the profile's
|
|
55
|
+
* `extinctionScale`.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/ const SKIN_OPTICAL_DEPTH_PER_WORLD_UNIT = WORLD_UNITS_TO_PROFILE_MM * SKIN_MAX_TRANSMISSION_OPTICAL_DEPTH / (TRANSMISSION_LUT_MAX_DISTANCE_MM * ((SKIN_TRANSMISSION_LUT_SIZE - 1) / SKIN_TRANSMISSION_LUT_SIZE));
|
|
59
|
+
/**
|
|
60
|
+
* `GetSearchLightDiffuseScalingFactor`, the default variant.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* `s = 3.5 + 100 (A - 0.33)^4`. The same curve the diffusion evaluates on the
|
|
64
|
+
* GPU (`posteffect/postsss.ts`, `scalingFactor`); the transmission profile is
|
|
65
|
+
* baked on the CPU and needs its own copy.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/ function searchLightDiffuseScalingFactor(albedo) {
|
|
69
|
+
const v = albedo - 0.33;
|
|
70
|
+
return 3.5 + 100 * v * v * v * v;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Preset parameters.
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
*/ const SKIN_PROFILE_TEMPLATES = {
|
|
77
|
+
skin: {
|
|
78
|
+
surfaceAlbedo: [
|
|
79
|
+
0.91058,
|
|
80
|
+
0.338275,
|
|
81
|
+
0.2718
|
|
82
|
+
],
|
|
83
|
+
meanFreePath: [
|
|
84
|
+
1.0,
|
|
85
|
+
0.0889636,
|
|
86
|
+
0.0720951
|
|
87
|
+
],
|
|
88
|
+
meanFreePathDistance: 0.026748,
|
|
89
|
+
worldUnitScale: 1,
|
|
90
|
+
scatterScale: 1,
|
|
91
|
+
boundaryColorBleed: [
|
|
92
|
+
1,
|
|
93
|
+
1,
|
|
94
|
+
1
|
|
95
|
+
],
|
|
96
|
+
transmissionTint: [
|
|
97
|
+
1.0,
|
|
98
|
+
0.42,
|
|
99
|
+
0.3
|
|
100
|
+
],
|
|
101
|
+
extinctionScale: 1,
|
|
102
|
+
normalScale: 0.08,
|
|
103
|
+
scatteringDistribution: 0.93,
|
|
104
|
+
ior: 1.55,
|
|
105
|
+
roughness0: 0.75,
|
|
106
|
+
roughness1: 1.3,
|
|
107
|
+
lobeMix: 0.85
|
|
108
|
+
},
|
|
109
|
+
skin_pale: {
|
|
110
|
+
surfaceAlbedo: [
|
|
111
|
+
0.93,
|
|
112
|
+
0.4,
|
|
113
|
+
0.33
|
|
114
|
+
],
|
|
115
|
+
meanFreePath: [
|
|
116
|
+
1.0,
|
|
117
|
+
0.1,
|
|
118
|
+
0.083
|
|
119
|
+
],
|
|
120
|
+
meanFreePathDistance: 0.0294,
|
|
121
|
+
worldUnitScale: 1,
|
|
122
|
+
scatterScale: 1,
|
|
123
|
+
boundaryColorBleed: [
|
|
124
|
+
1,
|
|
125
|
+
1,
|
|
126
|
+
1
|
|
127
|
+
],
|
|
128
|
+
transmissionTint: [
|
|
129
|
+
1.0,
|
|
130
|
+
0.48,
|
|
131
|
+
0.38
|
|
132
|
+
],
|
|
133
|
+
extinctionScale: 1,
|
|
134
|
+
normalScale: 0.08,
|
|
135
|
+
scatteringDistribution: 0.93,
|
|
136
|
+
ior: 1.55,
|
|
137
|
+
roughness0: 0.72,
|
|
138
|
+
roughness1: 1.25,
|
|
139
|
+
lobeMix: 0.85
|
|
140
|
+
},
|
|
141
|
+
skin_tan: {
|
|
142
|
+
surfaceAlbedo: [
|
|
143
|
+
0.88,
|
|
144
|
+
0.3,
|
|
145
|
+
0.235
|
|
146
|
+
],
|
|
147
|
+
meanFreePath: [
|
|
148
|
+
1.0,
|
|
149
|
+
0.082,
|
|
150
|
+
0.066
|
|
151
|
+
],
|
|
152
|
+
meanFreePathDistance: 0.0254,
|
|
153
|
+
worldUnitScale: 1,
|
|
154
|
+
scatterScale: 1,
|
|
155
|
+
boundaryColorBleed: [
|
|
156
|
+
1,
|
|
157
|
+
1,
|
|
158
|
+
1
|
|
159
|
+
],
|
|
160
|
+
transmissionTint: [
|
|
161
|
+
1.0,
|
|
162
|
+
0.38,
|
|
163
|
+
0.26
|
|
164
|
+
],
|
|
165
|
+
extinctionScale: 1,
|
|
166
|
+
normalScale: 0.08,
|
|
167
|
+
scatteringDistribution: 0.93,
|
|
168
|
+
ior: 1.55,
|
|
169
|
+
roughness0: 0.76,
|
|
170
|
+
roughness1: 1.32,
|
|
171
|
+
lobeMix: 0.85
|
|
172
|
+
},
|
|
173
|
+
skin_dark: {
|
|
174
|
+
surfaceAlbedo: [
|
|
175
|
+
0.8,
|
|
176
|
+
0.24,
|
|
177
|
+
0.185
|
|
178
|
+
],
|
|
179
|
+
meanFreePath: [
|
|
180
|
+
1.0,
|
|
181
|
+
0.072,
|
|
182
|
+
0.057
|
|
183
|
+
],
|
|
184
|
+
meanFreePathDistance: 0.0227,
|
|
185
|
+
worldUnitScale: 1,
|
|
186
|
+
scatterScale: 1,
|
|
187
|
+
boundaryColorBleed: [
|
|
188
|
+
1,
|
|
189
|
+
1,
|
|
190
|
+
1
|
|
191
|
+
],
|
|
192
|
+
transmissionTint: [
|
|
193
|
+
1.0,
|
|
194
|
+
0.3,
|
|
195
|
+
0.2
|
|
196
|
+
],
|
|
197
|
+
extinctionScale: 1,
|
|
198
|
+
normalScale: 0.08,
|
|
199
|
+
scatteringDistribution: 0.93,
|
|
200
|
+
ior: 1.55,
|
|
201
|
+
roughness0: 0.78,
|
|
202
|
+
roughness1: 1.35,
|
|
203
|
+
lobeMix: 0.85
|
|
204
|
+
},
|
|
205
|
+
wax: {
|
|
206
|
+
surfaceAlbedo: [
|
|
207
|
+
0.95,
|
|
208
|
+
0.9,
|
|
209
|
+
0.8
|
|
210
|
+
],
|
|
211
|
+
meanFreePath: [
|
|
212
|
+
1.0,
|
|
213
|
+
0.85,
|
|
214
|
+
0.68
|
|
215
|
+
],
|
|
216
|
+
meanFreePathDistance: 0.05,
|
|
217
|
+
worldUnitScale: 1,
|
|
218
|
+
scatterScale: 1,
|
|
219
|
+
boundaryColorBleed: [
|
|
220
|
+
1,
|
|
221
|
+
1,
|
|
222
|
+
1
|
|
223
|
+
],
|
|
224
|
+
transmissionTint: [
|
|
225
|
+
1.0,
|
|
226
|
+
0.88,
|
|
227
|
+
0.74
|
|
228
|
+
],
|
|
229
|
+
extinctionScale: 1,
|
|
230
|
+
normalScale: 0.05,
|
|
231
|
+
scatteringDistribution: 0.85,
|
|
232
|
+
ior: 1.45,
|
|
233
|
+
roughness0: 0.85,
|
|
234
|
+
roughness1: 1.4,
|
|
235
|
+
lobeMix: 0.8
|
|
236
|
+
},
|
|
237
|
+
jade: {
|
|
238
|
+
surfaceAlbedo: [
|
|
239
|
+
0.75,
|
|
240
|
+
0.93,
|
|
241
|
+
0.86
|
|
242
|
+
],
|
|
243
|
+
meanFreePath: [
|
|
244
|
+
0.6,
|
|
245
|
+
1.0,
|
|
246
|
+
0.85
|
|
247
|
+
],
|
|
248
|
+
meanFreePathDistance: 0.045,
|
|
249
|
+
worldUnitScale: 1,
|
|
250
|
+
scatterScale: 1,
|
|
251
|
+
boundaryColorBleed: [
|
|
252
|
+
1,
|
|
253
|
+
1,
|
|
254
|
+
1
|
|
255
|
+
],
|
|
256
|
+
transmissionTint: [
|
|
257
|
+
0.68,
|
|
258
|
+
0.95,
|
|
259
|
+
0.88
|
|
260
|
+
],
|
|
261
|
+
extinctionScale: 1,
|
|
262
|
+
normalScale: 0.05,
|
|
263
|
+
scatteringDistribution: 0.7,
|
|
264
|
+
ior: 1.6,
|
|
265
|
+
roughness0: 0.6,
|
|
266
|
+
roughness1: 1.1,
|
|
267
|
+
lobeMix: 0.75
|
|
268
|
+
},
|
|
269
|
+
marble: {
|
|
270
|
+
surfaceAlbedo: [
|
|
271
|
+
0.95,
|
|
272
|
+
0.94,
|
|
273
|
+
0.92
|
|
274
|
+
],
|
|
275
|
+
meanFreePath: [
|
|
276
|
+
1.0,
|
|
277
|
+
0.96,
|
|
278
|
+
0.92
|
|
279
|
+
],
|
|
280
|
+
meanFreePathDistance: 0.035,
|
|
281
|
+
worldUnitScale: 1,
|
|
282
|
+
scatterScale: 1,
|
|
283
|
+
boundaryColorBleed: [
|
|
284
|
+
1,
|
|
285
|
+
1,
|
|
286
|
+
1
|
|
287
|
+
],
|
|
288
|
+
transmissionTint: [
|
|
289
|
+
0.96,
|
|
290
|
+
0.95,
|
|
291
|
+
0.94
|
|
292
|
+
],
|
|
293
|
+
extinctionScale: 1,
|
|
294
|
+
normalScale: 0.04,
|
|
295
|
+
scatteringDistribution: 0.6,
|
|
296
|
+
ior: 1.55,
|
|
297
|
+
roughness0: 0.55,
|
|
298
|
+
roughness1: 1.05,
|
|
299
|
+
lobeMix: 0.7
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Subsurface profile for {@link SSSMaterial}.
|
|
304
|
+
*
|
|
305
|
+
* @public
|
|
306
|
+
*/ class SSSProfile {
|
|
307
|
+
static _profiles = new Array(SKIN_PROFILE_CAPACITY).fill(null);
|
|
308
|
+
static _table = null;
|
|
309
|
+
/** Device {@link SSSProfile._table} belongs to, so a device swap can be spotted. */ static _tableDevice = null;
|
|
310
|
+
static _tableData = null;
|
|
311
|
+
static _tableDirty = true;
|
|
312
|
+
static _defaultProfile = null;
|
|
313
|
+
_id;
|
|
314
|
+
_surfaceAlbedo;
|
|
315
|
+
_meanFreePath;
|
|
316
|
+
_boundaryColorBleed;
|
|
317
|
+
_transmissionTint;
|
|
318
|
+
_preset;
|
|
319
|
+
_meanFreePathDistance;
|
|
320
|
+
_worldUnitScale;
|
|
321
|
+
_scatterScale;
|
|
322
|
+
_extinctionScale;
|
|
323
|
+
_normalScale;
|
|
324
|
+
_scatteringDistribution;
|
|
325
|
+
_ior;
|
|
326
|
+
_roughness0;
|
|
327
|
+
_roughness1;
|
|
328
|
+
_lobeMix;
|
|
329
|
+
_disposed;
|
|
330
|
+
_changeListeners;
|
|
331
|
+
/**
|
|
332
|
+
* Not constructible from outside. Use {@link SSSMaterial.subsurfaceProfile},
|
|
333
|
+
* which owns one for the material's lifetime.
|
|
334
|
+
*
|
|
335
|
+
* @remarks
|
|
336
|
+
* The token check is not redundant with `private`: profiles hold a row of a
|
|
337
|
+
* 256-entry GPU table that only {@link SSSProfile.dispose} returns, and the
|
|
338
|
+
* editor ships as prebuilt JavaScript that drives this class through
|
|
339
|
+
* serialization metadata, where TypeScript's visibility rules do not apply.
|
|
340
|
+
*
|
|
341
|
+
* @internal
|
|
342
|
+
*/ constructor(token, preset = 'skin'){
|
|
343
|
+
if (token !== CREATE_TOKEN) {
|
|
344
|
+
throw new Error('SSSProfile is not constructible directly; it is owned by the SSSMaterial that created it.');
|
|
345
|
+
}
|
|
346
|
+
this._surfaceAlbedo = new Vector3();
|
|
347
|
+
this._meanFreePath = new Vector3();
|
|
348
|
+
this._boundaryColorBleed = new Vector3();
|
|
349
|
+
this._transmissionTint = new Vector3();
|
|
350
|
+
this._preset = preset;
|
|
351
|
+
this._meanFreePathDistance = 0;
|
|
352
|
+
this._worldUnitScale = 1;
|
|
353
|
+
this._scatterScale = 1;
|
|
354
|
+
this._extinctionScale = 1;
|
|
355
|
+
this._normalScale = 0.08;
|
|
356
|
+
this._scatteringDistribution = 0.93;
|
|
357
|
+
this._ior = 1.55;
|
|
358
|
+
this._roughness0 = 0.75;
|
|
359
|
+
this._roughness1 = 1.3;
|
|
360
|
+
this._lobeMix = 0.85;
|
|
361
|
+
this._disposed = false;
|
|
362
|
+
this._changeListeners = new Set();
|
|
363
|
+
this._id = SSSProfile.allocateId(this);
|
|
364
|
+
this.applyPreset(preset);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Registers a callback invoked whenever this profile's parameters change.
|
|
368
|
+
*
|
|
369
|
+
* @param listener - The callback to add.
|
|
370
|
+
*
|
|
371
|
+
* @public
|
|
372
|
+
*/ addChangeListener(listener) {
|
|
373
|
+
this._changeListeners.add(listener);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Removes a previously registered change listener.
|
|
377
|
+
*
|
|
378
|
+
* @param listener - The callback to remove.
|
|
379
|
+
*
|
|
380
|
+
* @public
|
|
381
|
+
*/ removeChangeListener(listener) {
|
|
382
|
+
this._changeListeners.delete(listener);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Creates a profile for a material to own.
|
|
386
|
+
*
|
|
387
|
+
* @remarks
|
|
388
|
+
* The only way to obtain one. The caller takes on releasing its table row — in
|
|
389
|
+
* practice {@link SSSMaterial}, which disposes the profile with itself.
|
|
390
|
+
*
|
|
391
|
+
* @param preset - Preset to start from. Defaults to `'skin'`.
|
|
392
|
+
* @returns The new profile.
|
|
393
|
+
*
|
|
394
|
+
* @internal
|
|
395
|
+
*/ static createOwned(preset = 'skin') {
|
|
396
|
+
return new SSSProfile(CREATE_TOKEN, preset);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* The shared default skin profile.
|
|
400
|
+
*
|
|
401
|
+
* @remarks
|
|
402
|
+
* A fallback for consumers with no material to ask — the diffusion uses it for
|
|
403
|
+
* pixels whose id is not in the table. Created lazily, since it holds a table
|
|
404
|
+
* row for the lifetime of the process.
|
|
405
|
+
*
|
|
406
|
+
* @public
|
|
407
|
+
*/ static getDefault() {
|
|
408
|
+
if (!this._defaultProfile) {
|
|
409
|
+
this._defaultProfile = new SSSProfile(CREATE_TOKEN, 'skin');
|
|
410
|
+
}
|
|
411
|
+
return this._defaultProfile;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Looks up a profile by its packed id.
|
|
415
|
+
*
|
|
416
|
+
* @param id - The profile id, as written to the per-pixel profile channel.
|
|
417
|
+
* @returns The profile, or `null` when the id is unused.
|
|
418
|
+
*
|
|
419
|
+
* @public
|
|
420
|
+
*/ static getById(id) {
|
|
421
|
+
return id > 0 && id < SKIN_PROFILE_CAPACITY ? this._profiles[id] : null;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* The packed parameter table, rebuilt when any profile has changed.
|
|
425
|
+
*
|
|
426
|
+
* @remarks
|
|
427
|
+
* Rows are indexed by profile id, columns by parameter group. The skin
|
|
428
|
+
* diffusion passes sample this to recover per-pixel scattering parameters.
|
|
429
|
+
*
|
|
430
|
+
* @param device - Device used to create and upload the table.
|
|
431
|
+
* @returns The table texture, or `null` when it could not be created.
|
|
432
|
+
*
|
|
433
|
+
* @public
|
|
434
|
+
*/ static getTable(device) {
|
|
435
|
+
// The table is static and outlives any one device. A texture belonging to a
|
|
436
|
+
// dead device silently swallows every `update`, which strands the last values
|
|
437
|
+
// uploaded before the swap on screen until the page is reloaded.
|
|
438
|
+
if (this._table && (this._tableDevice !== device || this._table.disposed)) {
|
|
439
|
+
this._table = null;
|
|
440
|
+
this._tableData = null;
|
|
441
|
+
}
|
|
442
|
+
if (!this._table) {
|
|
443
|
+
this._table = device.createTexture2D('rgba32f', SKIN_PROFILE_COLUMNS, SKIN_PROFILE_CAPACITY, {
|
|
444
|
+
mipmapping: false,
|
|
445
|
+
samplerOptions: {
|
|
446
|
+
minFilter: 'nearest',
|
|
447
|
+
magFilter: 'nearest',
|
|
448
|
+
mipFilter: 'none'
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
this._tableDevice = device;
|
|
452
|
+
this._tableData = new Float32Array(SKIN_PROFILE_COLUMNS * SKIN_PROFILE_CAPACITY * 4);
|
|
453
|
+
this._tableDirty = true;
|
|
454
|
+
}
|
|
455
|
+
if (this._tableDirty && this._table && this._tableData) {
|
|
456
|
+
this.packTable(this._tableData);
|
|
457
|
+
this._table.update(this._tableData, 0, 0, SKIN_PROFILE_COLUMNS, SKIN_PROFILE_CAPACITY);
|
|
458
|
+
this._tableDirty = false;
|
|
459
|
+
}
|
|
460
|
+
return this._table;
|
|
461
|
+
}
|
|
462
|
+
/** Number of parameter columns in the packed table. @public */ static get tableColumns() {
|
|
463
|
+
return SKIN_PROFILE_COLUMNS;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Column the baked transmission profile starts at.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
*/ static get transmissionLutOffset() {
|
|
470
|
+
return SKIN_PROFILE_PARAM_COLUMNS;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Column holding `(worldUnitScale, scatterScale, 0, 0)`.
|
|
474
|
+
*
|
|
475
|
+
* @remarks
|
|
476
|
+
* Read by the transmission thickness pass, which needs the world unit scale to
|
|
477
|
+
* size its normal shrink against the asset.
|
|
478
|
+
*
|
|
479
|
+
* @public
|
|
480
|
+
*/ static get scalingParamColumn() {
|
|
481
|
+
return 0;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Column holding `(extinctionScale, normalScale, scatteringDistribution,
|
|
485
|
+
* 1 / ior)`.
|
|
486
|
+
*
|
|
487
|
+
* @public
|
|
488
|
+
*/ static get transmissionParamColumn() {
|
|
489
|
+
return 4;
|
|
490
|
+
}
|
|
491
|
+
/** Number of entries in the baked transmission profile. @public */ static get transmissionLutSize() {
|
|
492
|
+
return SKIN_TRANSMISSION_LUT_SIZE;
|
|
493
|
+
}
|
|
494
|
+
/** Number of rows in the packed table. @public */ static get tableRows() {
|
|
495
|
+
return SKIN_PROFILE_CAPACITY;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* The id this profile occupies in the packed table.
|
|
499
|
+
*
|
|
500
|
+
* @remarks
|
|
501
|
+
* Ids start at 1; 0 means "not skin" in the per-pixel profile channel. The
|
|
502
|
+
* material encodes this as `id / 255`.
|
|
503
|
+
*
|
|
504
|
+
* @public
|
|
505
|
+
*/ get id() {
|
|
506
|
+
return this._id;
|
|
507
|
+
}
|
|
508
|
+
/** Normalized id as written to an 8-bit per-pixel channel. @public */ get encodedId() {
|
|
509
|
+
return this._id / 255;
|
|
510
|
+
}
|
|
511
|
+
/** The preset this profile was last initialized from. @public */ get preset() {
|
|
512
|
+
return this._preset;
|
|
513
|
+
}
|
|
514
|
+
set preset(val) {
|
|
515
|
+
if (val !== this._preset) {
|
|
516
|
+
this.applyPreset(val);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Per-channel scattering albedo.
|
|
521
|
+
*
|
|
522
|
+
* @remarks
|
|
523
|
+
* Drives Burley's shaping term `s = (albedo - 0.33)^4 * 100 + 3.5`, so values
|
|
524
|
+
* near 0.33 give the widest diffusion and values at either extreme tighten it.
|
|
525
|
+
*
|
|
526
|
+
* @public
|
|
527
|
+
*/ get surfaceAlbedo() {
|
|
528
|
+
return this._surfaceAlbedo;
|
|
529
|
+
}
|
|
530
|
+
set surfaceAlbedo(val) {
|
|
531
|
+
if (!val.equalsTo(this._surfaceAlbedo)) {
|
|
532
|
+
this._surfaceAlbedo.set(val);
|
|
533
|
+
this.notifyChanged();
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Per-channel diffuse mean free path, as a ratio.
|
|
538
|
+
*
|
|
539
|
+
* @remarks
|
|
540
|
+
* Scaled by {@link SSSProfile.meanFreePathDistance} to reach world units. The
|
|
541
|
+
* red channel is normally much longer than blue, which is what makes thin
|
|
542
|
+
* geometry such as an ear rim glow red.
|
|
543
|
+
*
|
|
544
|
+
* @public
|
|
545
|
+
*/ get meanFreePath() {
|
|
546
|
+
return this._meanFreePath;
|
|
547
|
+
}
|
|
548
|
+
set meanFreePath(val) {
|
|
549
|
+
if (!val.equalsTo(this._meanFreePath)) {
|
|
550
|
+
this._meanFreePath.set(val);
|
|
551
|
+
this.notifyChanged();
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/** Mean free path of the widest channel, in profile space. @public */ get meanFreePathDistance() {
|
|
555
|
+
return this._meanFreePathDistance;
|
|
556
|
+
}
|
|
557
|
+
set meanFreePathDistance(val) {
|
|
558
|
+
const next = Math.max(0, val ?? 0);
|
|
559
|
+
if (next !== this._meanFreePathDistance) {
|
|
560
|
+
this._meanFreePathDistance = next;
|
|
561
|
+
this.notifyChanged();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Profile-space to world-unit conversion, for scenes not authored in metres.
|
|
566
|
+
*
|
|
567
|
+
* @public
|
|
568
|
+
*/ get worldUnitScale() {
|
|
569
|
+
return this._worldUnitScale;
|
|
570
|
+
}
|
|
571
|
+
set worldUnitScale(val) {
|
|
572
|
+
const next = Math.max(0.01, val ?? 1);
|
|
573
|
+
if (next !== this._worldUnitScale) {
|
|
574
|
+
this._worldUnitScale = next;
|
|
575
|
+
this.notifyChanged();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
/** Overall multiplier on the diffusion width. @public */ get scatterScale() {
|
|
579
|
+
return this._scatterScale;
|
|
580
|
+
}
|
|
581
|
+
set scatterScale(val) {
|
|
582
|
+
const next = Math.max(0, val ?? 1);
|
|
583
|
+
if (next !== this._scatterScale) {
|
|
584
|
+
this._scatterScale = next;
|
|
585
|
+
this.notifyChanged();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Per-channel tint applied where two different profiles meet.
|
|
590
|
+
*
|
|
591
|
+
* @remarks
|
|
592
|
+
* Taps that belong to another profile are attenuated by this instead of being
|
|
593
|
+
* rejected outright, so a face/lip boundary softens rather than forming a seam.
|
|
594
|
+
*
|
|
595
|
+
* @public
|
|
596
|
+
*/ get boundaryColorBleed() {
|
|
597
|
+
return this._boundaryColorBleed;
|
|
598
|
+
}
|
|
599
|
+
set boundaryColorBleed(val) {
|
|
600
|
+
if (!val.equalsTo(this._boundaryColorBleed)) {
|
|
601
|
+
this._boundaryColorBleed.set(val);
|
|
602
|
+
this.notifyChanged();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
/** Tint applied to light transmitted through thin geometry. @public */ get transmissionTint() {
|
|
606
|
+
return this._transmissionTint;
|
|
607
|
+
}
|
|
608
|
+
set transmissionTint(val) {
|
|
609
|
+
if (!val.equalsTo(this._transmissionTint)) {
|
|
610
|
+
this._transmissionTint.set(val);
|
|
611
|
+
this.notifyChanged();
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/** Extinction multiplier for transmission attenuation. @public */ get extinctionScale() {
|
|
615
|
+
return this._extinctionScale;
|
|
616
|
+
}
|
|
617
|
+
set extinctionScale(val) {
|
|
618
|
+
const next = Math.max(0, val ?? 1);
|
|
619
|
+
if (next !== this._extinctionScale) {
|
|
620
|
+
this._extinctionScale = next;
|
|
621
|
+
this.notifyChanged();
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/** How much surface normal detail survives the diffusion. @public */ get normalScale() {
|
|
625
|
+
return this._normalScale;
|
|
626
|
+
}
|
|
627
|
+
set normalScale(val) {
|
|
628
|
+
const next = Math.max(0, val ?? 0);
|
|
629
|
+
if (next !== this._normalScale) {
|
|
630
|
+
this._normalScale = next;
|
|
631
|
+
this.notifyChanged();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Henyey-Greenstein asymmetry of the transmitted light, in `[-1, 1]`.
|
|
636
|
+
*
|
|
637
|
+
* @public
|
|
638
|
+
*/ get scatteringDistribution() {
|
|
639
|
+
return this._scatteringDistribution;
|
|
640
|
+
}
|
|
641
|
+
set scatteringDistribution(val) {
|
|
642
|
+
const next = Math.min(1, Math.max(-1, val ?? 0));
|
|
643
|
+
if (next !== this._scatteringDistribution) {
|
|
644
|
+
this._scatteringDistribution = next;
|
|
645
|
+
this.notifyChanged();
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Index of refraction used to bend the view ray before the phase function.
|
|
650
|
+
*
|
|
651
|
+
* @public
|
|
652
|
+
*/ get ior() {
|
|
653
|
+
return this._ior;
|
|
654
|
+
}
|
|
655
|
+
set ior(val) {
|
|
656
|
+
const next = Math.min(3, Math.max(1, val ?? 1.55));
|
|
657
|
+
if (next !== this._ior) {
|
|
658
|
+
this._ior = next;
|
|
659
|
+
this.notifyChanged();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Multiplier on the material roughness for the narrow specular lobe.
|
|
664
|
+
*
|
|
665
|
+
* @public
|
|
666
|
+
*/ get roughness0() {
|
|
667
|
+
return this._roughness0;
|
|
668
|
+
}
|
|
669
|
+
set roughness0(val) {
|
|
670
|
+
const next = Math.min(2, Math.max(0.5, val ?? 0.75));
|
|
671
|
+
if (next !== this._roughness0) {
|
|
672
|
+
this._roughness0 = next;
|
|
673
|
+
this.notifyChanged();
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Multiplier on the material roughness for the wide specular lobe.
|
|
678
|
+
*
|
|
679
|
+
* @remarks
|
|
680
|
+
* Same scaling as {@link SSSProfile.roughness0}; skin's default 1.3 broadens
|
|
681
|
+
* the second lobe, giving it a soft sheen alongside the tighter highlight.
|
|
682
|
+
*
|
|
683
|
+
* @public
|
|
684
|
+
*/ get roughness1() {
|
|
685
|
+
return this._roughness1;
|
|
686
|
+
}
|
|
687
|
+
set roughness1(val) {
|
|
688
|
+
const next = Math.min(2, Math.max(0.5, val ?? 1.3));
|
|
689
|
+
if (next !== this._roughness1) {
|
|
690
|
+
this._roughness1 = next;
|
|
691
|
+
this.notifyChanged();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/** Blend between the narrow and wide specular lobes. @public */ get lobeMix() {
|
|
695
|
+
return this._lobeMix;
|
|
696
|
+
}
|
|
697
|
+
set lobeMix(val) {
|
|
698
|
+
const next = Math.min(0.9, Math.max(0.1, val ?? 0.85));
|
|
699
|
+
if (next !== this._lobeMix) {
|
|
700
|
+
this._lobeMix = next;
|
|
701
|
+
this.notifyChanged();
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Per-channel diffusion distance, in profile space.
|
|
706
|
+
*
|
|
707
|
+
* @returns Mean free path scaled by the profile's distance and scatter scale.
|
|
708
|
+
*
|
|
709
|
+
* @public
|
|
710
|
+
*/ getScatterDistance() {
|
|
711
|
+
const s = this._meanFreePathDistance * this._scatterScale;
|
|
712
|
+
return new Vector3(this._meanFreePath.x * s, this._meanFreePath.y * s, this._meanFreePath.z * s);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Overwrites every parameter from another profile.
|
|
716
|
+
*
|
|
717
|
+
* @remarks
|
|
718
|
+
* The only way to transfer a look, since profiles cannot be shared or cloned.
|
|
719
|
+
* The table row is untouched: it identifies the profile, not its contents.
|
|
720
|
+
*
|
|
721
|
+
* @param other - Profile to copy the parameters from.
|
|
722
|
+
*
|
|
723
|
+
* @public
|
|
724
|
+
*/ copyFrom(other) {
|
|
725
|
+
this._preset = other._preset;
|
|
726
|
+
this._surfaceAlbedo.set(other._surfaceAlbedo);
|
|
727
|
+
this._meanFreePath.set(other._meanFreePath);
|
|
728
|
+
this._boundaryColorBleed.set(other._boundaryColorBleed);
|
|
729
|
+
this._transmissionTint.set(other._transmissionTint);
|
|
730
|
+
this._meanFreePathDistance = other._meanFreePathDistance;
|
|
731
|
+
this._worldUnitScale = other._worldUnitScale;
|
|
732
|
+
this._scatterScale = other._scatterScale;
|
|
733
|
+
this._extinctionScale = other._extinctionScale;
|
|
734
|
+
this._normalScale = other._normalScale;
|
|
735
|
+
this._scatteringDistribution = other._scatteringDistribution;
|
|
736
|
+
this._ior = other._ior;
|
|
737
|
+
this._roughness0 = other._roughness0;
|
|
738
|
+
this._roughness1 = other._roughness1;
|
|
739
|
+
this._lobeMix = other._lobeMix;
|
|
740
|
+
this.notifyChanged();
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Releases this profile's table slot.
|
|
744
|
+
*
|
|
745
|
+
* @public
|
|
746
|
+
*/ dispose() {
|
|
747
|
+
if (this._disposed) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
this._disposed = true;
|
|
751
|
+
if (SSSProfile._profiles[this._id] === this) {
|
|
752
|
+
SSSProfile._profiles[this._id] = null;
|
|
753
|
+
SSSProfile.markDirty();
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
applyPreset(preset) {
|
|
757
|
+
const t = SKIN_PROFILE_TEMPLATES[preset] ?? SKIN_PROFILE_TEMPLATES.skin;
|
|
758
|
+
this._preset = preset;
|
|
759
|
+
this._surfaceAlbedo.setXYZ(t.surfaceAlbedo[0], t.surfaceAlbedo[1], t.surfaceAlbedo[2]);
|
|
760
|
+
this._meanFreePath.setXYZ(t.meanFreePath[0], t.meanFreePath[1], t.meanFreePath[2]);
|
|
761
|
+
this._boundaryColorBleed.setXYZ(t.boundaryColorBleed[0], t.boundaryColorBleed[1], t.boundaryColorBleed[2]);
|
|
762
|
+
this._transmissionTint.setXYZ(t.transmissionTint[0], t.transmissionTint[1], t.transmissionTint[2]);
|
|
763
|
+
this._meanFreePathDistance = t.meanFreePathDistance;
|
|
764
|
+
this._worldUnitScale = t.worldUnitScale;
|
|
765
|
+
this._scatterScale = t.scatterScale;
|
|
766
|
+
this._extinctionScale = t.extinctionScale;
|
|
767
|
+
this._normalScale = t.normalScale;
|
|
768
|
+
this._scatteringDistribution = t.scatteringDistribution;
|
|
769
|
+
this._ior = t.ior;
|
|
770
|
+
this._roughness0 = t.roughness0;
|
|
771
|
+
this._roughness1 = t.roughness1;
|
|
772
|
+
this._lobeMix = t.lobeMix;
|
|
773
|
+
this.notifyChanged();
|
|
774
|
+
}
|
|
775
|
+
static allocateId(profile) {
|
|
776
|
+
for(let i = 1; i < SKIN_PROFILE_CAPACITY; i++){
|
|
777
|
+
if (!this._profiles[i]) {
|
|
778
|
+
this._profiles[i] = profile;
|
|
779
|
+
this.markDirty();
|
|
780
|
+
return i;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
throw new Error('SSSProfile limit exceeded');
|
|
784
|
+
}
|
|
785
|
+
static markDirty() {
|
|
786
|
+
this._tableDirty = true;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Flags the packed table for a rebuild and notifies materials using this
|
|
790
|
+
* profile so they can refresh their uniforms.
|
|
791
|
+
*/ notifyChanged() {
|
|
792
|
+
SSSProfile.markDirty();
|
|
793
|
+
this._changeListeners.forEach((listener)=>listener());
|
|
794
|
+
}
|
|
795
|
+
static packTable(out) {
|
|
796
|
+
out.fill(0);
|
|
797
|
+
const stride = SKIN_PROFILE_COLUMNS * 4;
|
|
798
|
+
for(let id = 1; id < SKIN_PROFILE_CAPACITY; id++){
|
|
799
|
+
const p = this._profiles[id];
|
|
800
|
+
if (!p) {
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
const row = id * stride;
|
|
804
|
+
const write = (column, x, y, z, w)=>{
|
|
805
|
+
const o = row + column * 4;
|
|
806
|
+
out[o] = x;
|
|
807
|
+
out[o + 1] = y;
|
|
808
|
+
out[o + 2] = z;
|
|
809
|
+
out[o + 3] = w;
|
|
810
|
+
};
|
|
811
|
+
const d = p.getScatterDistance();
|
|
812
|
+
const widest = Math.max(d.x, d.y, d.z);
|
|
813
|
+
const albedoForSampling = widest > 0 ? [
|
|
814
|
+
p._surfaceAlbedo.x,
|
|
815
|
+
p._surfaceAlbedo.y,
|
|
816
|
+
p._surfaceAlbedo.z
|
|
817
|
+
][[
|
|
818
|
+
d.x,
|
|
819
|
+
d.y,
|
|
820
|
+
d.z
|
|
821
|
+
].indexOf(widest)] : p._surfaceAlbedo.x;
|
|
822
|
+
write(0, p._worldUnitScale, p._scatterScale, 0, 0);
|
|
823
|
+
write(1, p._surfaceAlbedo.x, p._surfaceAlbedo.y, p._surfaceAlbedo.z, albedoForSampling);
|
|
824
|
+
write(2, d.x, d.y, d.z, widest);
|
|
825
|
+
write(3, p._boundaryColorBleed.x, p._boundaryColorBleed.y, p._boundaryColorBleed.z, 0);
|
|
826
|
+
write(4, p._extinctionScale, p._normalScale, p._scatteringDistribution, 1 / Math.max(p._ior, 1e-4));
|
|
827
|
+
write(5, p._roughness0, p._roughness1, p._lobeMix, 0);
|
|
828
|
+
// The LUT columns are consecutive within the row, so the baked profile
|
|
829
|
+
// drops straight in after the scalar parameters.
|
|
830
|
+
p.writeTransmissionProfile(out, row + SKIN_PROFILE_PARAM_COLUMNS * 4);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Bakes this profile's transmission table.
|
|
835
|
+
*
|
|
836
|
+
* @param out - Destination, `4 x transmissionLutSize` floats from `offset`.
|
|
837
|
+
* @param offset - Index of the first float to write.
|
|
838
|
+
*
|
|
839
|
+
* @public
|
|
840
|
+
*/ writeTransmissionProfile(out, offset = 0) {
|
|
841
|
+
const invUnitScale = 1 / Math.max(this._worldUnitScale, 1e-4);
|
|
842
|
+
const d = this.getScatterDistance();
|
|
843
|
+
const l = [
|
|
844
|
+
d.x * WORLD_UNITS_TO_PROFILE_MM,
|
|
845
|
+
d.y * WORLD_UNITS_TO_PROFILE_MM,
|
|
846
|
+
d.z * WORLD_UNITS_TO_PROFILE_MM
|
|
847
|
+
];
|
|
848
|
+
const s = [
|
|
849
|
+
searchLightDiffuseScalingFactor(this._surfaceAlbedo.x),
|
|
850
|
+
searchLightDiffuseScalingFactor(this._surfaceAlbedo.y),
|
|
851
|
+
searchLightDiffuseScalingFactor(this._surfaceAlbedo.z)
|
|
852
|
+
];
|
|
853
|
+
const tint = [
|
|
854
|
+
this._transmissionTint.x,
|
|
855
|
+
this._transmissionTint.y,
|
|
856
|
+
this._transmissionTint.z
|
|
857
|
+
];
|
|
858
|
+
const offsetMM = TRANSMISSION_LUT_RADIUS_OFFSET_MM * invUnitScale;
|
|
859
|
+
for(let i = 0; i < SKIN_TRANSMISSION_LUT_SIZE; i++){
|
|
860
|
+
const o = offset + i * 4;
|
|
861
|
+
if (i === SKIN_TRANSMISSION_LUT_SIZE - 1) {
|
|
862
|
+
out[o] = 0;
|
|
863
|
+
out[o + 1] = 0;
|
|
864
|
+
out[o + 2] = 0;
|
|
865
|
+
out[o + 3] = 0;
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
const distanceMM = i / SKIN_TRANSMISSION_LUT_SIZE * TRANSMISSION_LUT_MAX_DISTANCE_MM * invUnitScale;
|
|
869
|
+
const r = distanceMM + offsetMM;
|
|
870
|
+
for(let c = 0; c < 3; c++){
|
|
871
|
+
out[o + c] = l[c] > 0 ? 0.25 * (Math.exp(-s[c] * r / l[c]) + 3 * Math.exp(-s[c] * r / (3 * l[c]))) * tint[c] : 0;
|
|
872
|
+
}
|
|
873
|
+
out[o + 3] = Math.exp(-distanceMM * this._extinctionScale);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
export { SKIN_MAX_TRANSMISSION_OPTICAL_DEPTH, SKIN_OPTICAL_DEPTH_PER_WORLD_UNIT, SKIN_TRANSMISSION_NO_DATA_ENCODING, SKIN_TRANSMISSION_OPTICAL_DEPTH_BIAS, SKIN_TRANSMISSION_OPTICAL_DEPTH_FLOOR, SSSProfile };
|
|
879
|
+
//# sourceMappingURL=sssprofile.js.map
|