@zephyr3d/scene 0.9.26 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +146 -30
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +300 -56
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +177 -3
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +178 -200
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +30475 -19865
- package/dist/index.js +67 -12
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/hairstrand.js +235 -235
- package/dist/material/hairstrand.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +362 -300
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +223 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +733 -190
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +2009 -201
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +668 -63
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +48 -50
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +34 -15
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +40 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +328 -62
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +26 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +53 -53
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +8 -13
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +268 -136
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +113 -28
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/hzb.js +80 -22
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +23 -9
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/oit.js +11 -11
- package/dist/render/oit.js.map +1 -1
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +198 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +14 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +15 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +585 -59
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +524 -0
- package/dist/render/underwater.js.map +1 -0
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +1195 -0
- package/dist/render/water_caustics.js.map +1 -0
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +36 -36
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +997 -96
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +40 -87
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +42 -0
- package/dist/shaders/water_medium.js.map +1 -0
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +87 -49
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +36 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +77 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +140 -279
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +2473 -114
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +97 -109
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
|
@@ -4,100 +4,106 @@ import { RenderBundleWrapper } from '../render/renderbundle_wrapper.js';
|
|
|
4
4
|
import { Disposable } from '@zephyr3d/base';
|
|
5
5
|
import { getEngine } from '../app/api.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Base class for all materials.
|
|
9
|
-
*
|
|
10
|
-
* Responsibilities:
|
|
11
|
-
* - Defines a multi-pass rendering interface (`numPasses`, `apply`, `bind`, `draw`, `drawPrimitive`).
|
|
12
|
-
* - Builds and caches GPU shader programs per pass and per-render-context hash.
|
|
13
|
-
* - Manages a per-material bind group (typically at index 2) for uniforms and resources.
|
|
14
|
-
* - Updates render states per pass (`updateRenderStates`) and uploads uniforms (`_applyUniforms`).
|
|
15
|
-
* - Tracks "option" changes that affect shader variant hashing and render bundles.
|
|
16
|
-
*
|
|
17
|
-
* Caching and hashing:
|
|
18
|
-
* - `createHash(pass)` produces a stable hash representing shader variant options for a pass.
|
|
19
|
-
* Override `_createHash()` in subclasses to encode feature toggles (defines, keywords, macros).
|
|
20
|
-
* - The global hash used to key `MaterialState` also includes `ctx.materialFlags` and
|
|
21
|
-
* `ctx.shaderVariantHash` when provided, allowing context-sensitive variants without
|
|
22
|
-
* coupling shader programs to runtime texture identities.
|
|
23
|
-
* - GPU programs are additionally memoized in a global static `_programCache` across materials
|
|
24
|
-
* by `constructor.name` + hash, to avoid recompilation of identical variants.
|
|
25
|
-
*
|
|
26
|
-
* Bind groups and uniforms:
|
|
27
|
-
* - If a program declares a bind group layout at index 2 (i.e., `bindGroupLayouts.length > 2`),
|
|
28
|
-
* `apply()` will allocate the group and keep it in the state. Subclasses should fill it in
|
|
29
|
-
* `_applyUniforms()`.
|
|
30
|
-
* - `applyUniforms()` only calls `_applyUniforms()` when `needUpdate` is true, based on
|
|
31
|
-
* `_optionTag` changes (see `optionChanged()`).
|
|
32
|
-
*
|
|
33
|
-
* Lifecycle:
|
|
34
|
-
* - Constructed materials register a persistent ID into a global registry for serialization.
|
|
35
|
-
* - `apply(ctx)` prepares all passes: creates/gets state, programs, bind groups, render states,
|
|
36
|
-
* and uploads uniforms as needed.
|
|
37
|
-
* - `bind(device, pass)` binds the program, bind group (index 2), and render states.
|
|
38
|
-
* - `draw(primitive, ctx, numInstances)` runs all passes, calling `bind()` and `drawPrimitive()`.
|
|
39
|
-
* - `onDispose()` releases bind groups and registry entries.
|
|
40
|
-
*
|
|
41
|
-
* Extending:
|
|
42
|
-
* - Override `_createProgram(pb, ctx, pass)` to build a shader.
|
|
43
|
-
* - Override `_applyUniforms(bindGroup, ctx, pass)` to upload uniforms and resources.
|
|
44
|
-
* - Override `updateRenderStates(pass, renderStates, ctx)` to set depth, blend, cull, etc.
|
|
45
|
-
* - Override `_createHash()` to encode options that affect program compilation.
|
|
46
|
-
* - Override `supportLighting`, `supportInstancing`, `isTransparentPass`, `getQueueType`, etc.
|
|
47
|
-
*
|
|
48
|
-
* Thread-safety:
|
|
49
|
-
* - Intended for main-thread use in a renderer driving WebGPU/WebGL-like devices.
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all materials.
|
|
9
|
+
*
|
|
10
|
+
* Responsibilities:
|
|
11
|
+
* - Defines a multi-pass rendering interface (`numPasses`, `apply`, `bind`, `draw`, `drawPrimitive`).
|
|
12
|
+
* - Builds and caches GPU shader programs per pass and per-render-context hash.
|
|
13
|
+
* - Manages a per-material bind group (typically at index 2) for uniforms and resources.
|
|
14
|
+
* - Updates render states per pass (`updateRenderStates`) and uploads uniforms (`_applyUniforms`).
|
|
15
|
+
* - Tracks "option" changes that affect shader variant hashing and render bundles.
|
|
16
|
+
*
|
|
17
|
+
* Caching and hashing:
|
|
18
|
+
* - `createHash(pass)` produces a stable hash representing shader variant options for a pass.
|
|
19
|
+
* Override `_createHash()` in subclasses to encode feature toggles (defines, keywords, macros).
|
|
20
|
+
* - The global hash used to key `MaterialState` also includes `ctx.materialFlags` and
|
|
21
|
+
* `ctx.shaderVariantHash` when provided, allowing context-sensitive variants without
|
|
22
|
+
* coupling shader programs to runtime texture identities.
|
|
23
|
+
* - GPU programs are additionally memoized in a global static `_programCache` across materials
|
|
24
|
+
* by `constructor.name` + hash, to avoid recompilation of identical variants.
|
|
25
|
+
*
|
|
26
|
+
* Bind groups and uniforms:
|
|
27
|
+
* - If a program declares a bind group layout at index 2 (i.e., `bindGroupLayouts.length > 2`),
|
|
28
|
+
* `apply()` will allocate the group and keep it in the state. Subclasses should fill it in
|
|
29
|
+
* `_applyUniforms()`.
|
|
30
|
+
* - `applyUniforms()` only calls `_applyUniforms()` when `needUpdate` is true, based on
|
|
31
|
+
* `_optionTag` changes (see `optionChanged()`).
|
|
32
|
+
*
|
|
33
|
+
* Lifecycle:
|
|
34
|
+
* - Constructed materials register a persistent ID into a global registry for serialization.
|
|
35
|
+
* - `apply(ctx)` prepares all passes: creates/gets state, programs, bind groups, render states,
|
|
36
|
+
* and uploads uniforms as needed.
|
|
37
|
+
* - `bind(device, pass)` binds the program, bind group (index 2), and render states.
|
|
38
|
+
* - `draw(primitive, ctx, numInstances)` runs all passes, calling `bind()` and `drawPrimitive()`.
|
|
39
|
+
* - `onDispose()` releases bind groups and registry entries.
|
|
40
|
+
*
|
|
41
|
+
* Extending:
|
|
42
|
+
* - Override `_createProgram(pb, ctx, pass)` to build a shader.
|
|
43
|
+
* - Override `_applyUniforms(bindGroup, ctx, pass)` to upload uniforms and resources.
|
|
44
|
+
* - Override `updateRenderStates(pass, renderStates, ctx)` to set depth, blend, cull, etc.
|
|
45
|
+
* - Override `_createHash()` to encode options that affect program compilation.
|
|
46
|
+
* - Override `supportLighting`, `supportInstancing`, `isTransparentPass`, `getQueueType`, etc.
|
|
47
|
+
*
|
|
48
|
+
* Thread-safety:
|
|
49
|
+
* - Intended for main-thread use in a renderer driving WebGPU/WebGL-like devices.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
52
|
*/ class Material extends Disposable {
|
|
53
|
-
/**
|
|
54
|
-
* Monotonic instance ID counter.
|
|
55
|
-
* @internal
|
|
53
|
+
/**
|
|
54
|
+
* Monotonic instance ID counter.
|
|
55
|
+
* @internal
|
|
56
56
|
*/ static _nextId = 0;
|
|
57
|
-
/**
|
|
58
|
-
* Global program cache keyed by global hash
|
|
57
|
+
/**
|
|
58
|
+
* Global program cache keyed by global hash
|
|
59
59
|
*/ static _programCache = {};
|
|
60
|
-
/**
|
|
61
|
-
* Per-material state cache keyed by global hash (material + context + pass).
|
|
62
|
-
* @internal
|
|
60
|
+
/**
|
|
61
|
+
* Per-material state cache keyed by global hash (material + context + pass).
|
|
62
|
+
* @internal
|
|
63
63
|
*/ _states;
|
|
64
|
-
/**
|
|
65
|
-
* Number of rendering passes.
|
|
66
|
-
* Subclasses can increase this to implement multi-pass rendering.
|
|
67
|
-
* @internal
|
|
64
|
+
/**
|
|
65
|
+
* Number of rendering passes.
|
|
66
|
+
* Subclasses can increase this to implement multi-pass rendering.
|
|
67
|
+
* @internal
|
|
68
68
|
*/ _numPasses;
|
|
69
|
-
/**
|
|
70
|
-
* Per-pass hash cached results. Length scales with `numPasses`.
|
|
71
|
-
* @internal
|
|
69
|
+
/**
|
|
70
|
+
* Per-pass hash cached results. Length scales with `numPasses`.
|
|
71
|
+
* @internal
|
|
72
72
|
*/ _hash;
|
|
73
|
-
/**
|
|
74
|
-
* Incremented each time options change (via `optionChanged`), used to decide whether
|
|
75
|
-
* uniforms need update on next `apply()`.
|
|
76
|
-
* @internal
|
|
73
|
+
/**
|
|
74
|
+
* Incremented each time options change (via `optionChanged`), used to decide whether
|
|
75
|
+
* uniforms need update on next `apply()`.
|
|
76
|
+
* @internal
|
|
77
77
|
*/ _optionTag;
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
78
|
+
/**
|
|
79
|
+
* Incremented by every option change that can alter how the material looks,
|
|
80
|
+
* which leaves out per-object values of utility passes (the object color of
|
|
81
|
+
* GPU picking).
|
|
82
|
+
* @internal
|
|
83
|
+
*/ _appearanceTag;
|
|
84
|
+
/**
|
|
85
|
+
* Unique runtime instance ID.
|
|
86
|
+
* @internal
|
|
81
87
|
*/ _id;
|
|
82
|
-
/**
|
|
83
|
-
* Latest computed global hash per pass, set during `apply()`, read in `bind()`.
|
|
84
|
-
* @internal
|
|
88
|
+
/**
|
|
89
|
+
* Latest computed global hash per pass, set during `apply()`, read in `bind()`.
|
|
90
|
+
* @internal
|
|
85
91
|
*/ _currentHash;
|
|
86
|
-
/**
|
|
87
|
-
* Incremented when material states affecting render bundles change (e.g., bind group id changes
|
|
88
|
-
* or `optionChanged(true)`), used to trigger re-recording of render bundles.
|
|
89
|
-
* @internal
|
|
92
|
+
/**
|
|
93
|
+
* Incremented when material states affecting render bundles change (e.g., bind group id changes
|
|
94
|
+
* or `optionChanged(true)`), used to trigger re-recording of render bundles.
|
|
95
|
+
* @internal
|
|
90
96
|
*/ _changeTag;
|
|
91
|
-
/**
|
|
92
|
-
* Unique program id counter for naming compiled programs.
|
|
93
|
-
* @internal
|
|
97
|
+
/**
|
|
98
|
+
* Unique program id counter for naming compiled programs.
|
|
99
|
+
* @internal
|
|
94
100
|
*/ _nextProgramId = 0;
|
|
95
|
-
/**
|
|
96
|
-
* Create a new material instance.
|
|
97
|
-
*
|
|
98
|
-
* - Initializes one pass by default.
|
|
99
|
-
* - Prepares per-pass hash storage and change tracking.
|
|
100
|
-
* - Registers a persistent ID in the global registry.
|
|
101
|
+
/**
|
|
102
|
+
* Create a new material instance.
|
|
103
|
+
*
|
|
104
|
+
* - Initializes one pass by default.
|
|
105
|
+
* - Prepares per-pass hash storage and change tracking.
|
|
106
|
+
* - Registers a persistent ID in the global registry.
|
|
101
107
|
*/ constructor(){
|
|
102
108
|
super();
|
|
103
109
|
this._id = ++Material._nextId;
|
|
@@ -108,49 +114,65 @@ import { getEngine } from '../app/api.js';
|
|
|
108
114
|
null
|
|
109
115
|
];
|
|
110
116
|
this._optionTag = 0;
|
|
117
|
+
this._appearanceTag = 0;
|
|
111
118
|
this._changeTag = 0;
|
|
112
119
|
this._currentHash = [];
|
|
113
120
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Create a shallow clone of this material.
|
|
116
|
-
*
|
|
117
|
-
* Note: The base implementation returns a base `Material`. Subclasses should
|
|
118
|
-
* override to return their own type and copy custom fields.
|
|
121
|
+
/**
|
|
122
|
+
* Create a shallow clone of this material.
|
|
123
|
+
*
|
|
124
|
+
* Note: The base implementation returns a base `Material`. Subclasses should
|
|
125
|
+
* override to return their own type and copy custom fields.
|
|
119
126
|
*/ clone() {
|
|
120
127
|
const other = new Material();
|
|
121
128
|
other.copyFrom(this);
|
|
122
129
|
return other;
|
|
123
130
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Copy basic properties from another material.
|
|
126
|
-
*
|
|
127
|
-
* Disposes existing bind groups/states, copies `numPasses`. Subclasses should
|
|
128
|
-
* extend this to copy their own fields and call `optionChanged(true)` if
|
|
129
|
-
* shader-affecting options differ.
|
|
130
|
-
*
|
|
131
|
-
* @param other - Source material.
|
|
131
|
+
/**
|
|
132
|
+
* Copy basic properties from another material.
|
|
133
|
+
*
|
|
134
|
+
* Disposes existing bind groups/states, copies `numPasses`. Subclasses should
|
|
135
|
+
* extend this to copy their own fields and call `optionChanged(true)` if
|
|
136
|
+
* shader-affecting options differ.
|
|
137
|
+
*
|
|
138
|
+
* @param other - Source material.
|
|
132
139
|
*/ copyFrom(other) {
|
|
133
140
|
this.clearCache();
|
|
134
141
|
this._numPasses = other._numPasses;
|
|
135
142
|
getEngine().resourceManager.setAssetId(this, getEngine().resourceManager.getAssetId(other.coreMaterial));
|
|
136
143
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Incremented when the material’s GPU-relevant state changes and render bundles
|
|
139
|
-
* may need to be rebuilt.
|
|
144
|
+
/**
|
|
145
|
+
* Incremented when the material’s GPU-relevant state changes and render bundles
|
|
146
|
+
* may need to be rebuilt.
|
|
140
147
|
*/ get changeTag() {
|
|
141
148
|
return this._changeTag;
|
|
142
149
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Runtime-unique numeric identifier for the material instance.
|
|
150
|
+
/**
|
|
151
|
+
* Runtime-unique numeric identifier for the material instance.
|
|
145
152
|
*/ get instanceId() {
|
|
146
153
|
return this._id;
|
|
147
154
|
}
|
|
148
|
-
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Incremented on every option or uniform change (see `optionChanged()`),
|
|
157
|
+
* including value edits that leave the programs alone, which
|
|
158
|
+
* {@link Material.changeTag} does not count.
|
|
159
|
+
*/ get optionTag() {
|
|
160
|
+
return this._optionTag;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Like {@link Material.optionTag}, but not advanced by values that do not
|
|
164
|
+
* change how the material looks, such as the object color GPU picking sets
|
|
165
|
+
* every frame it picks. For caches of the material's appearance, like the
|
|
166
|
+
* voxelized materials of the global illumination.
|
|
167
|
+
*/ get appearanceTag() {
|
|
168
|
+
return this._appearanceTag;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Number of rendering passes this material uses.
|
|
172
|
+
*
|
|
173
|
+
* Increasing this will expand the per-pass hash cache; make sure to implement
|
|
174
|
+
* `createHash(pass)`, `_createProgram(pb, ctx, pass)`, and `updateRenderStates(pass, ...)`
|
|
175
|
+
* accordingly for each pass.
|
|
154
176
|
*/ get numPasses() {
|
|
155
177
|
return this._numPasses;
|
|
156
178
|
}
|
|
@@ -160,95 +182,95 @@ import { getEngine } from '../app/api.js';
|
|
|
160
182
|
}
|
|
161
183
|
this._numPasses = val;
|
|
162
184
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Get the number of passes this material will render for the given draw context.
|
|
165
|
-
*
|
|
166
|
-
* Default returns `numPasses`. Subclasses may override to skip passes based on context flags.
|
|
167
|
-
* @param _ctx - Draw context (device, flags, pass hash, instance data, etc.).
|
|
168
|
-
* @returns Number of passes to render for this context.
|
|
185
|
+
/**
|
|
186
|
+
* Get the number of passes this material will render for the given draw context.
|
|
187
|
+
*
|
|
188
|
+
* Default returns `numPasses`. Subclasses may override to skip passes based on context flags.
|
|
189
|
+
* @param _ctx - Draw context (device, flags, pass hash, instance data, etc.).
|
|
190
|
+
* @returns Number of passes to render for this context.
|
|
169
191
|
*/ getNumPassesForRender(_ctx) {
|
|
170
192
|
return this._numPasses;
|
|
171
193
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Get or compute the per-pass shader hash used for program caching.
|
|
174
|
-
*
|
|
175
|
-
* Calls `createHash(pass)` lazily and caches the result.
|
|
176
|
-
* @internal
|
|
194
|
+
/**
|
|
195
|
+
* Get or compute the per-pass shader hash used for program caching.
|
|
196
|
+
*
|
|
197
|
+
* Calls `createHash(pass)` lazily and caches the result.
|
|
198
|
+
* @internal
|
|
177
199
|
*/ getHash(pass) {
|
|
178
200
|
if (this._hash[pass] === null) {
|
|
179
201
|
this._hash[pass] = this.createHash(pass);
|
|
180
202
|
}
|
|
181
203
|
return this._hash[pass];
|
|
182
204
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Return the queue type to which this material belongs.
|
|
185
|
-
*
|
|
186
|
-
* Override this in transparent or special materials (e.g., post-process).
|
|
205
|
+
/**
|
|
206
|
+
* Return the queue type to which this material belongs.
|
|
207
|
+
*
|
|
208
|
+
* Override this in transparent or special materials (e.g., post-process).
|
|
187
209
|
*/ getQueueType() {
|
|
188
210
|
return QUEUE_OPAQUE;
|
|
189
211
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Whether the given pass is transparent.
|
|
192
|
-
*
|
|
193
|
-
* Used to place draw calls into appropriate render queues and set blending states.
|
|
212
|
+
/**
|
|
213
|
+
* Whether the given pass is transparent.
|
|
214
|
+
*
|
|
215
|
+
* Used to place draw calls into appropriate render queues and set blending states.
|
|
194
216
|
*/ isTransparentPass(_pass) {
|
|
195
217
|
return false;
|
|
196
218
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Whether this material's shading is affected by scene lights.
|
|
199
|
-
*
|
|
200
|
-
* Override and return `false` for unlit materials.
|
|
219
|
+
/**
|
|
220
|
+
* Whether this material's shading is affected by scene lights.
|
|
221
|
+
*
|
|
222
|
+
* Override and return `false` for unlit materials.
|
|
201
223
|
*/ supportLighting() {
|
|
202
224
|
return true;
|
|
203
225
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Whether this material supports hardware instancing.
|
|
206
|
-
*
|
|
207
|
-
* Override and return `false` if per-instance data is not supported in the shader.
|
|
226
|
+
/**
|
|
227
|
+
* Whether this material supports hardware instancing.
|
|
228
|
+
*
|
|
229
|
+
* Override and return `false` if per-instance data is not supported in the shader.
|
|
208
230
|
*/ supportInstancing() {
|
|
209
231
|
return true;
|
|
210
232
|
}
|
|
211
233
|
/** Returns true if this is a instance of material */ isBatchable() {
|
|
212
234
|
return false;
|
|
213
235
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Whether this material requires the scene color texture (e.g., for refraction).
|
|
236
|
+
/**
|
|
237
|
+
* Whether this material requires the scene color texture (e.g., for refraction).
|
|
216
238
|
*/ needSceneColor() {
|
|
217
239
|
return false;
|
|
218
240
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).
|
|
241
|
+
/**
|
|
242
|
+
* Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).
|
|
221
243
|
*/ needSceneDepth() {
|
|
222
244
|
return false;
|
|
223
245
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Create a material instance (instance-uniform-driven variant).
|
|
226
|
-
*
|
|
227
|
-
* Base returns `null`. Subclasses that support instancing can return a lightweight instance.
|
|
246
|
+
/**
|
|
247
|
+
* Create a material instance (instance-uniform-driven variant).
|
|
248
|
+
*
|
|
249
|
+
* Base returns `null`. Subclasses that support instancing can return a lightweight instance.
|
|
228
250
|
*/ createInstance() {
|
|
229
251
|
throw new Error('Abstract function call');
|
|
230
252
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Returns the core material that owns GPU state.
|
|
233
|
-
*
|
|
234
|
-
* Instances may delegate to a shared core to reuse compiled programs and caches.
|
|
235
|
-
* @public
|
|
253
|
+
/**
|
|
254
|
+
* Returns the core material that owns GPU state.
|
|
255
|
+
*
|
|
256
|
+
* Instances may delegate to a shared core to reuse compiled programs and caches.
|
|
257
|
+
* @public
|
|
236
258
|
*/ get coreMaterial() {
|
|
237
259
|
return this;
|
|
238
260
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Prepare the material for drawing across all passes for the given draw context.
|
|
241
|
-
*
|
|
242
|
-
* Steps per pass:
|
|
243
|
-
* - Compute global hash (material variant + context).
|
|
244
|
-
* - Retrieve or build the GPU program, cache in `_programCache`.
|
|
245
|
-
* - Create per-material bind group (index 2) if the program exposes it.
|
|
246
|
-
* - Update uniforms if `_optionTag` indicates changes since last apply.
|
|
247
|
-
* - Update and cache render states for the pass.
|
|
248
|
-
* - Detect bind group GPU ID changes to bump `changeTag` and notify `RenderBundleWrapper`.
|
|
249
|
-
*
|
|
250
|
-
* @param ctx - Draw context (device, flags, pass hash, instance data, etc.).
|
|
251
|
-
* @returns `true` if successful; `false` if any pass lacks a valid program.
|
|
261
|
+
/**
|
|
262
|
+
* Prepare the material for drawing across all passes for the given draw context.
|
|
263
|
+
*
|
|
264
|
+
* Steps per pass:
|
|
265
|
+
* - Compute global hash (material variant + context).
|
|
266
|
+
* - Retrieve or build the GPU program, cache in `_programCache`.
|
|
267
|
+
* - Create per-material bind group (index 2) if the program exposes it.
|
|
268
|
+
* - Update uniforms if `_optionTag` indicates changes since last apply.
|
|
269
|
+
* - Update and cache render states for the pass.
|
|
270
|
+
* - Detect bind group GPU ID changes to bump `changeTag` and notify `RenderBundleWrapper`.
|
|
271
|
+
*
|
|
272
|
+
* @param ctx - Draw context (device, flags, pass hash, instance data, etc.).
|
|
273
|
+
* @returns `true` if successful; `false` if any pass lacks a valid program.
|
|
252
274
|
*/ apply(ctx) {
|
|
253
275
|
const numPasses = this.getNumPassesForRender(ctx);
|
|
254
276
|
for(let pass = 0; pass < numPasses; pass++){
|
|
@@ -328,15 +350,15 @@ import { getEngine } from '../app/api.js';
|
|
|
328
350
|
}
|
|
329
351
|
return true;
|
|
330
352
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Bind the program, bind group, and render states for the specified pass.
|
|
333
|
-
*
|
|
334
|
-
* Must be called after `apply(ctx)` for the same pass.
|
|
335
|
-
*
|
|
336
|
-
* @param device - Rendering device.
|
|
337
|
-
* @param pass - Pass index to bind.
|
|
338
|
-
* @returns `true` on success; `false` if state or program missing.
|
|
339
|
-
* @internal
|
|
353
|
+
/**
|
|
354
|
+
* Bind the program, bind group, and render states for the specified pass.
|
|
355
|
+
*
|
|
356
|
+
* Must be called after `apply(ctx)` for the same pass.
|
|
357
|
+
*
|
|
358
|
+
* @param device - Rendering device.
|
|
359
|
+
* @param pass - Pass index to bind.
|
|
360
|
+
* @returns `true` on success; `false` if state or program missing.
|
|
361
|
+
* @internal
|
|
340
362
|
*/ bind(device, pass) {
|
|
341
363
|
const hash = this._currentHash[pass];
|
|
342
364
|
const state = this._states[hash];
|
|
@@ -354,29 +376,29 @@ import { getEngine } from '../app/api.js';
|
|
|
354
376
|
device.setRenderStates(state.renderStateSet);
|
|
355
377
|
return true;
|
|
356
378
|
}
|
|
357
|
-
/**
|
|
358
|
-
* Compute the global hash for the given pass and draw context.
|
|
359
|
-
*
|
|
360
|
-
* Includes:
|
|
361
|
-
* - Per-pass material hash from `getHash(pass)`.
|
|
362
|
-
* - `ctx.materialFlags` for context-dependent toggles.
|
|
363
|
-
* - `ctx.shaderVariantHash` for shader layout/feature variants, falling back
|
|
364
|
-
* to `ctx.renderPassHash` for passes without a shader-only hash.
|
|
365
|
-
* @internal
|
|
379
|
+
/**
|
|
380
|
+
* Compute the global hash for the given pass and draw context.
|
|
381
|
+
*
|
|
382
|
+
* Includes:
|
|
383
|
+
* - Per-pass material hash from `getHash(pass)`.
|
|
384
|
+
* - `ctx.materialFlags` for context-dependent toggles.
|
|
385
|
+
* - `ctx.shaderVariantHash` for shader layout/feature variants, falling back
|
|
386
|
+
* to `ctx.renderPassHash` for passes without a shader-only hash.
|
|
387
|
+
* @internal
|
|
366
388
|
*/ calcGlobalHash(ctx, pass) {
|
|
367
389
|
const shaderVariantHash = ctx.shaderVariantHash ?? ctx.renderPassHash;
|
|
368
390
|
return `${this.getHash(pass)}:${ctx.materialFlags}:${shaderVariantHash}:${ctx.drawEnvLight ? 1 : 0}:${ctx.currentShadowLight ? 1 : 0}:${ctx.lightBlending ? 1 : 0}`;
|
|
369
391
|
}
|
|
370
|
-
/**
|
|
371
|
-
* Draw a primitive for all passes using this material.
|
|
372
|
-
*
|
|
373
|
-
* Calls `bind()` then `drawPrimitive()` per pass. If `numInstances` is zero,
|
|
374
|
-
* and `ctx.instanceData` exists, uses `ctx.instanceData.numInstances`.
|
|
375
|
-
*
|
|
376
|
-
* @param primitive - Geometry to draw.
|
|
377
|
-
* @param ctx - Draw context.
|
|
378
|
-
* @param numInstances - Instance count; 0 means auto-detect from context.
|
|
379
|
-
* @internal
|
|
392
|
+
/**
|
|
393
|
+
* Draw a primitive for all passes using this material.
|
|
394
|
+
*
|
|
395
|
+
* Calls `bind()` then `drawPrimitive()` per pass. If `numInstances` is zero,
|
|
396
|
+
* and `ctx.instanceData` exists, uses `ctx.instanceData.numInstances`.
|
|
397
|
+
*
|
|
398
|
+
* @param primitive - Geometry to draw.
|
|
399
|
+
* @param ctx - Draw context.
|
|
400
|
+
* @param numInstances - Instance count; 0 means auto-detect from context.
|
|
401
|
+
* @internal
|
|
380
402
|
*/ draw(primitive, ctx, numInstances = 0) {
|
|
381
403
|
const numPasses = this.getNumPassesForRender(ctx);
|
|
382
404
|
for(let pass = 0; pass < numPasses; pass++){
|
|
@@ -384,31 +406,56 @@ import { getEngine } from '../app/api.js';
|
|
|
384
406
|
this.drawPrimitive(pass, primitive, ctx, numInstances);
|
|
385
407
|
}
|
|
386
408
|
}
|
|
387
|
-
/**
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
* @param
|
|
409
|
+
/**
|
|
410
|
+
* Draw a primitive in all passes with arguments read from a GPU buffer (WebGPU only).
|
|
411
|
+
*
|
|
412
|
+
* The indirect counterpart of {@link Material.draw}, see {@link Primitive.drawIndirect} for the
|
|
413
|
+
* buffer layout. The instance count comes from the buffer, so instanced shaders fed by
|
|
414
|
+
* `ctx.instanceData` do not apply; the vertex shader reads per-instance data from instance
|
|
415
|
+
* vertex buffers instead.
|
|
416
|
+
*
|
|
417
|
+
* @param primitive - Geometry to draw.
|
|
418
|
+
* @param ctx - Draw context.
|
|
419
|
+
* @param indirectBuffer - Buffer holding the draw arguments.
|
|
420
|
+
* @param indirectOffset - Byte offset of the arguments, a multiple of 4.
|
|
421
|
+
* @internal
|
|
422
|
+
*/ drawIndirect(primitive, ctx, indirectBuffer, indirectOffset = 0) {
|
|
423
|
+
const numPasses = this.getNumPassesForRender(ctx);
|
|
424
|
+
for(let pass = 0; pass < numPasses; pass++){
|
|
425
|
+
this.bind(ctx.device, pass);
|
|
426
|
+
primitive.drawIndirect(indirectBuffer, indirectOffset);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Conditionally update uniforms/resources into the material bind group.
|
|
431
|
+
*
|
|
432
|
+
* Delegates to `_applyUniforms()` when `needUpdate` is true (based on `_optionTag` check).
|
|
433
|
+
*
|
|
434
|
+
* @param bindGroup - Material bind group at index 2 (may be `null` if program has no layout).
|
|
435
|
+
* @param ctx - Draw context.
|
|
436
|
+
* @param needUpdate - Whether uniforms need to be refreshed.
|
|
437
|
+
* @param pass - Pass index.
|
|
396
438
|
*/ applyUniforms(bindGroup, ctx, needUpdate, pass) {
|
|
397
439
|
if (needUpdate) {
|
|
398
440
|
this._applyUniforms(bindGroup, ctx, pass);
|
|
399
441
|
}
|
|
400
442
|
}
|
|
401
|
-
/**
|
|
402
|
-
* Notify the material that some option changed.
|
|
403
|
-
*
|
|
404
|
-
* - Always increments `_optionTag`. This will trigger uniforms update on next `apply()`.
|
|
405
|
-
* - If `changeHash` is true, clears per-pass hashes so programs/states will be rebuilt,
|
|
406
|
-
* increments `_changeTag`, and notifies `RenderBundleWrapper` to regenerate recorded bundles.
|
|
407
|
-
*
|
|
408
|
-
* @param changeHash - Set true if the change affects shader compilation or render states.
|
|
409
|
-
* @
|
|
410
|
-
|
|
443
|
+
/**
|
|
444
|
+
* Notify the material that some option changed.
|
|
445
|
+
*
|
|
446
|
+
* - Always increments `_optionTag`. This will trigger uniforms update on next `apply()`.
|
|
447
|
+
* - If `changeHash` is true, clears per-pass hashes so programs/states will be rebuilt,
|
|
448
|
+
* increments `_changeTag`, and notifies `RenderBundleWrapper` to regenerate recorded bundles.
|
|
449
|
+
*
|
|
450
|
+
* @param changeHash - Set true if the change affects shader compilation or render states.
|
|
451
|
+
* @param appearance - Set false for a value that does not change how the material looks
|
|
452
|
+
* (see {@link Material.appearanceTag}); defaults to true.
|
|
453
|
+
* @internal
|
|
454
|
+
*/ optionChanged(changeHash, appearance = true) {
|
|
411
455
|
this._optionTag++;
|
|
456
|
+
if (appearance || changeHash) {
|
|
457
|
+
this._appearanceTag++;
|
|
458
|
+
}
|
|
412
459
|
if (changeHash) {
|
|
413
460
|
for(let i = 0; i < this._numPasses; i++){
|
|
414
461
|
this._hash[i] = null;
|
|
@@ -437,130 +484,145 @@ import { getEngine } from '../app/api.js';
|
|
|
437
484
|
}
|
|
438
485
|
this._states = {};
|
|
439
486
|
}
|
|
440
|
-
/**
|
|
441
|
-
* Convert a pass index to a hash seed string.
|
|
442
|
-
*
|
|
443
|
-
* Subclasses may override to encode per-pass role (e.g., "depth", "forward", "shadow").
|
|
444
|
-
*
|
|
445
|
-
* @param pass - Pass number.
|
|
446
|
-
* @returns String used when building full hash.
|
|
487
|
+
/**
|
|
488
|
+
* Convert a pass index to a hash seed string.
|
|
489
|
+
*
|
|
490
|
+
* Subclasses may override to encode per-pass role (e.g., "depth", "forward", "shadow").
|
|
491
|
+
*
|
|
492
|
+
* @param pass - Pass number.
|
|
493
|
+
* @returns String used when building full hash.
|
|
447
494
|
*/ passToHash(pass) {
|
|
448
495
|
return String(pass);
|
|
449
496
|
}
|
|
450
|
-
/**
|
|
451
|
-
* Build the material hash for a pass (excluding context-dependent parts).
|
|
452
|
-
*
|
|
453
|
-
* Default formula: `${constructor.name}|${pass}|${_createHash()}`
|
|
454
|
-
*
|
|
455
|
-
* @param pass - Pass number.
|
|
456
|
-
* @returns Hash string used in program caching.
|
|
457
|
-
* @internal
|
|
497
|
+
/**
|
|
498
|
+
* Build the material hash for a pass (excluding context-dependent parts).
|
|
499
|
+
*
|
|
500
|
+
* Default formula: `${constructor.name}|${pass}|${_createHash()}`
|
|
501
|
+
*
|
|
502
|
+
* @param pass - Pass number.
|
|
503
|
+
* @returns Hash string used in program caching.
|
|
504
|
+
* @internal
|
|
458
505
|
*/ createHash(pass) {
|
|
459
506
|
return `${this.constructor.name}|${this.passToHash(pass)}|${this._createHash()}`;
|
|
460
507
|
}
|
|
461
|
-
/**
|
|
462
|
-
* Issue the actual draw call for a pass.
|
|
463
|
-
*
|
|
464
|
-
* Override for custom per-pass draw behavior if necessary. The default implementation:
|
|
465
|
-
* - Draws instanced if `numInstances > 0`.
|
|
466
|
-
* - Else uses `ctx.instanceData.numInstances` if available.
|
|
467
|
-
* - Else issues a non-instanced draw.
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* @param
|
|
472
|
-
* @param
|
|
508
|
+
/**
|
|
509
|
+
* Issue the actual draw call for a pass.
|
|
510
|
+
*
|
|
511
|
+
* Override for custom per-pass draw behavior if necessary. The default implementation:
|
|
512
|
+
* - Draws instanced if `numInstances > 0`.
|
|
513
|
+
* - Else uses `ctx.instanceData.numInstances` if available.
|
|
514
|
+
* - Else issues a non-instanced draw.
|
|
515
|
+
*
|
|
516
|
+
* The primitive is drawn at the level of detail in `ctx.primitiveLod`.
|
|
517
|
+
*
|
|
518
|
+
* @param pass - Pass number.
|
|
519
|
+
* @param primitive - Primitive to draw.
|
|
520
|
+
* @param ctx - Draw context.
|
|
521
|
+
* @param numInstances - Explicit instance count (0 = auto).
|
|
473
522
|
*/ drawPrimitive(pass, primitive, ctx, numInstances) {
|
|
523
|
+
const lod = ctx.primitiveLod ?? 0;
|
|
474
524
|
if (numInstances > 0) {
|
|
475
|
-
primitive.drawInstanced(numInstances);
|
|
525
|
+
primitive.drawInstanced(numInstances, lod);
|
|
476
526
|
} else if (ctx.instanceData) {
|
|
477
|
-
|
|
527
|
+
const culled = ctx.instanceData.culled;
|
|
528
|
+
if (culled && culled.primitive === primitive) {
|
|
529
|
+
// One draw per level of detail culling spread the instances over, empty ones included
|
|
530
|
+
for(let i = 0; i < culled.lodCount; i++){
|
|
531
|
+
primitive.drawIndirect(culled.argsBuffer, culled.argsOffset + i * 20, culled.edgeArgsOffset >= 0 ? culled.edgeArgsOffset + i * 20 : -1);
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
534
|
+
if (culled) {
|
|
535
|
+
// Culled for another primitive: draw all instances
|
|
536
|
+
ctx.device.setBindGroup(3, ctx.instanceData.bindGroup.bindGroup);
|
|
537
|
+
}
|
|
538
|
+
primitive.drawInstanced(ctx.instanceData.numInstances, lod);
|
|
539
|
+
}
|
|
478
540
|
} else {
|
|
479
|
-
primitive.draw();
|
|
541
|
+
primitive.draw(lod);
|
|
480
542
|
}
|
|
481
543
|
}
|
|
482
|
-
/**
|
|
483
|
-
* Dispose the material and release GPU-side resource references.
|
|
484
|
-
*
|
|
485
|
-
* - Unregisters from the global registry.
|
|
486
|
-
* - Disposes the per-material bind groups kept in `_states`.
|
|
544
|
+
/**
|
|
545
|
+
* Dispose the material and release GPU-side resource references.
|
|
546
|
+
*
|
|
547
|
+
* - Unregisters from the global registry.
|
|
548
|
+
* - Disposes the per-material bind groups kept in `_states`.
|
|
487
549
|
*/ onDispose() {
|
|
488
550
|
super.onDispose();
|
|
489
551
|
this.clearCache();
|
|
490
552
|
}
|
|
491
|
-
/**
|
|
492
|
-
* Build the GPU program for a pass.
|
|
493
|
-
*
|
|
494
|
-
* Default creates a `ProgramBuilder` and calls `_createProgram(pb, ctx, pass)`.
|
|
495
|
-
* Subclasses should override `_createProgram` instead of this method unless
|
|
496
|
-
* they need to replace builder instantiation.
|
|
497
|
-
*
|
|
498
|
-
* @param ctx - Draw context.
|
|
499
|
-
* @param pass - Pass number.
|
|
500
|
-
* @returns The compiled `GPUProgram`, or `null` on failure.
|
|
501
|
-
* @internal
|
|
553
|
+
/**
|
|
554
|
+
* Build the GPU program for a pass.
|
|
555
|
+
*
|
|
556
|
+
* Default creates a `ProgramBuilder` and calls `_createProgram(pb, ctx, pass)`.
|
|
557
|
+
* Subclasses should override `_createProgram` instead of this method unless
|
|
558
|
+
* they need to replace builder instantiation.
|
|
559
|
+
*
|
|
560
|
+
* @param ctx - Draw context.
|
|
561
|
+
* @param pass - Pass number.
|
|
562
|
+
* @returns The compiled `GPUProgram`, or `null` on failure.
|
|
563
|
+
* @internal
|
|
502
564
|
*/ createProgram(ctx, pass) {
|
|
503
565
|
const pb = new ProgramBuilder(ctx.device);
|
|
504
566
|
return this._createProgram(pb, ctx, pass);
|
|
505
567
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Create and compile the shader program for this material/pass.
|
|
508
|
-
*
|
|
509
|
-
* Implement in subclasses:
|
|
510
|
-
* - Define shader stages, entry points, macros/defines, and resource layouts.
|
|
511
|
-
* - Return a compiled `GPUProgram`.
|
|
512
|
-
*
|
|
513
|
-
* @param pb - Program builder.
|
|
514
|
-
* @param ctx - Draw context.
|
|
515
|
-
* @param _pass - Pass number.
|
|
516
|
-
* @returns The created program, or `null` on failure.
|
|
568
|
+
/**
|
|
569
|
+
* Create and compile the shader program for this material/pass.
|
|
570
|
+
*
|
|
571
|
+
* Implement in subclasses:
|
|
572
|
+
* - Define shader stages, entry points, macros/defines, and resource layouts.
|
|
573
|
+
* - Return a compiled `GPUProgram`.
|
|
574
|
+
*
|
|
575
|
+
* @param pb - Program builder.
|
|
576
|
+
* @param ctx - Draw context.
|
|
577
|
+
* @param _pass - Pass number.
|
|
578
|
+
* @returns The created program, or `null` on failure.
|
|
517
579
|
*/ _createProgram(_pb, _ctx, _pass) {
|
|
518
580
|
throw new Error('Abstract function call');
|
|
519
581
|
}
|
|
520
|
-
/**
|
|
521
|
-
* Upload uniforms and bind resources to the per-material bind group (index 2).
|
|
522
|
-
*
|
|
523
|
-
* Implement in subclasses to:
|
|
524
|
-
* - Write uniform buffers/textures/samplers to the `bindGroup`.
|
|
525
|
-
* - Respect the current `pass` and `ctx`.
|
|
526
|
-
*
|
|
527
|
-
* @param _bindGroup - The bind group to populate.
|
|
528
|
-
* @param _ctx - Draw context.
|
|
529
|
-
* @param _pass - Pass number.
|
|
582
|
+
/**
|
|
583
|
+
* Upload uniforms and bind resources to the per-material bind group (index 2).
|
|
584
|
+
*
|
|
585
|
+
* Implement in subclasses to:
|
|
586
|
+
* - Write uniform buffers/textures/samplers to the `bindGroup`.
|
|
587
|
+
* - Respect the current `pass` and `ctx`.
|
|
588
|
+
*
|
|
589
|
+
* @param _bindGroup - The bind group to populate.
|
|
590
|
+
* @param _ctx - Draw context.
|
|
591
|
+
* @param _pass - Pass number.
|
|
530
592
|
*/ _applyUniforms(_bindGroup, _ctx, _pass) {}
|
|
531
|
-
/**
|
|
532
|
-
* Update render states (depth/stencil, blending, rasterization) for the pass.
|
|
533
|
-
*
|
|
534
|
-
* Implement in subclasses based on transparency, double-sidedness, depth writes/tests,
|
|
535
|
-
* color mask, stencil ops, etc., and any context flags in `ctx`.
|
|
536
|
-
*
|
|
537
|
-
* @param _pass - Current pass index.
|
|
538
|
-
* @param _renderStates - Render state set to mutate.
|
|
539
|
-
* @param _ctx - Draw context.
|
|
593
|
+
/**
|
|
594
|
+
* Update render states (depth/stencil, blending, rasterization) for the pass.
|
|
595
|
+
*
|
|
596
|
+
* Implement in subclasses based on transparency, double-sidedness, depth writes/tests,
|
|
597
|
+
* color mask, stencil ops, etc., and any context flags in `ctx`.
|
|
598
|
+
*
|
|
599
|
+
* @param _pass - Current pass index.
|
|
600
|
+
* @param _renderStates - Render state set to mutate.
|
|
601
|
+
* @param _ctx - Draw context.
|
|
540
602
|
*/ updateRenderStates(_pass, _renderStates, _ctx) {}
|
|
541
|
-
/**
|
|
542
|
-
* Compute the material-specific portion of the shader hash for the current options.
|
|
543
|
-
*
|
|
544
|
-
* Subclasses should override to include macro/define sets that influence program compilation.
|
|
545
|
-
* Example return: `"USE_NORMALMAP=1;ALPHA_MODE=BLEND;RECEIVE_SHADOWS=1"`.
|
|
546
|
-
*
|
|
547
|
-
* @returns Hash fragment string (no context/pass info).
|
|
603
|
+
/**
|
|
604
|
+
* Compute the material-specific portion of the shader hash for the current options.
|
|
605
|
+
*
|
|
606
|
+
* Subclasses should override to include macro/define sets that influence program compilation.
|
|
607
|
+
* Example return: `"USE_NORMALMAP=1;ALPHA_MODE=BLEND;RECEIVE_SHADOWS=1"`.
|
|
608
|
+
*
|
|
609
|
+
* @returns Hash fragment string (no context/pass info).
|
|
548
610
|
*/ _createHash() {
|
|
549
611
|
return '';
|
|
550
612
|
}
|
|
551
|
-
/**
|
|
552
|
-
* Whether this is a lightweight instance of a core material.
|
|
553
|
-
*
|
|
554
|
-
* Instances typically share GPU programs with a core and only override instance uniforms.
|
|
555
|
-
* @internal
|
|
613
|
+
/**
|
|
614
|
+
* Whether this is a lightweight instance of a core material.
|
|
615
|
+
*
|
|
616
|
+
* Instances typically share GPU programs with a core and only override instance uniforms.
|
|
617
|
+
* @internal
|
|
556
618
|
*/ get $isInstance() {
|
|
557
619
|
return false;
|
|
558
620
|
}
|
|
559
|
-
/**
|
|
560
|
-
* Instance-uniform buffer for material instances, if supported.
|
|
561
|
-
*
|
|
562
|
-
* Returned as a typed Float32 view over a backing ArrayBuffer.
|
|
563
|
-
* @internal
|
|
621
|
+
/**
|
|
622
|
+
* Instance-uniform buffer for material instances, if supported.
|
|
623
|
+
*
|
|
624
|
+
* Returned as a typed Float32 view over a backing ArrayBuffer.
|
|
625
|
+
* @internal
|
|
564
626
|
*/ get $instanceUniforms() {
|
|
565
627
|
throw new Error('Abstract function call');
|
|
566
628
|
}
|