@zephyr3d/scene 0.9.1 → 0.9.3
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/dist/animation/animationset.js +2 -0
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_system.js +9 -1
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +5 -1
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/geometry_cache_utils.js +20 -4
- package/dist/animation/geometry_cache_utils.js.map +1 -1
- package/dist/animation/ik/ik_angle_constraint.js +2 -6
- package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
- package/dist/animation/ik/ik_chain_builder.js +68 -0
- package/dist/animation/ik/ik_chain_builder.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +2 -7
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +2 -6
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +60 -12
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/constraints.js +20 -4
- package/dist/animation/joint_dynamics/constraints.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +94 -46
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/math.js +16 -0
- package/dist/animation/joint_dynamics/math.js.map +1 -0
- package/dist/animation/joint_dynamics/solver.js +21 -11
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js +15 -3
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +5 -1
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/skeleton.js +2 -2
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +2 -6
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +4 -4
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +13 -40
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring2/constraints.js.map +1 -1
- package/dist/animation/spring2/controller.js +64 -64
- package/dist/animation/spring2/controller.js.map +1 -1
- package/dist/animation/spring2/math.js.map +1 -1
- package/dist/animation/spring2/spring_system.js +8 -8
- package/dist/animation/spring2/spring_system.js.map +1 -1
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +1 -1
- package/dist/app/engine.js.map +1 -1
- package/dist/app/screen.js +4 -4
- package/dist/app/screen.js.map +1 -1
- package/dist/app/scriptingsystem.js +24 -1
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +22 -1
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +60 -60
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +1 -1
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +795 -266
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +3 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/shader/helper.js +281 -278
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite.js +6 -6
- package/dist/material/sprite.js.map +1 -1
- package/dist/material/terrain-cm.js +2 -2
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
- package/dist/posteffect/taa.js +31 -39
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/cluster_light.js +3 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +5 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +29 -3
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +283 -33
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +338 -108
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +195 -115
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +10 -0
- package/dist/render/rendergraph/history_resources.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +162 -35
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js +25 -5
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/rendertarget.js +5 -1
- package/dist/render/rendertarget.js.map +1 -1
- package/dist/render/screenrendertarget.js +5 -1
- package/dist/render/screenrendertarget.js.map +1 -1
- package/dist/render/sky.js +4 -4
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +2 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/graph_node.js +1 -1
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/mesh.js +81 -97
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/particlesys.js +1 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene_node.js +228 -228
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/script_attachment.js +15 -3
- package/dist/scene/script_attachment.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +3 -3
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/box.js +1 -1
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/capsule.js +0 -3
- package/dist/shapes/capsule.js.map +1 -1
- package/dist/shapes/cylinder.js +0 -3
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +0 -3
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/tetrahedron.js +3 -9
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +94 -66
- package/dist/shapes/torus.js.map +1 -1
- package/dist/src/animation/animation.js +127 -0
- package/dist/src/animation/animation.js.map +1 -0
- package/dist/src/animation/animationset.js +255 -0
- package/dist/src/animation/animationset.js.map +1 -0
- package/dist/src/animation/animationtrack.js +34 -0
- package/dist/src/animation/animationtrack.js.map +1 -0
- package/dist/src/animation/eulerrotationtrack.js +52 -0
- package/dist/src/animation/eulerrotationtrack.js.map +1 -0
- package/dist/src/animation/morphtarget.js +93 -0
- package/dist/src/animation/morphtarget.js.map +1 -0
- package/dist/src/animation/morphtrack.js +70 -0
- package/dist/src/animation/morphtrack.js.map +1 -0
- package/dist/src/animation/proptrack.js +161 -0
- package/dist/src/animation/proptrack.js.map +1 -0
- package/dist/src/animation/rotationtrack.js +51 -0
- package/dist/src/animation/rotationtrack.js.map +1 -0
- package/dist/src/animation/scaletrack.js +50 -0
- package/dist/src/animation/scaletrack.js.map +1 -0
- package/dist/src/animation/skeleton.js +204 -0
- package/dist/src/animation/skeleton.js.map +1 -0
- package/dist/src/animation/translationtrack.js +50 -0
- package/dist/src/animation/translationtrack.js.map +1 -0
- package/dist/src/app/app.js +129 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/inputmgr.js +267 -0
- package/dist/src/app/inputmgr.js.map +1 -0
- package/dist/src/asset/assetmanager.js +404 -0
- package/dist/src/asset/assetmanager.js.map +1 -0
- package/dist/src/asset/builtin.js +337 -0
- package/dist/src/asset/builtin.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds.js +470 -0
- package/dist/src/asset/loaders/dds/dds.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
- package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/helpers.js +327 -0
- package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/src/asset/loaders/hdr/hdr.js +180 -0
- package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
- package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
- package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/src/asset/loaders/loader.js +45 -0
- package/dist/src/asset/loaders/loader.js.map +1 -0
- package/dist/src/asset/model.js +414 -0
- package/dist/src/asset/model.js.map +1 -0
- package/dist/src/blitter/bilateralblur.js +221 -0
- package/dist/src/blitter/bilateralblur.js.map +1 -0
- package/dist/src/blitter/blitter.js +390 -0
- package/dist/src/blitter/blitter.js.map +1 -0
- package/dist/src/blitter/box.js +118 -0
- package/dist/src/blitter/box.js.map +1 -0
- package/dist/src/blitter/copy.js +22 -0
- package/dist/src/blitter/copy.js.map +1 -0
- package/dist/src/blitter/gaussianblur.js +228 -0
- package/dist/src/blitter/gaussianblur.js.map +1 -0
- package/dist/src/camera/base.js +92 -0
- package/dist/src/camera/base.js.map +1 -0
- package/dist/src/camera/camera.js +1005 -0
- package/dist/src/camera/camera.js.map +1 -0
- package/dist/src/camera/fps.js +238 -0
- package/dist/src/camera/fps.js.map +1 -0
- package/dist/src/camera/orbit.js +245 -0
- package/dist/src/camera/orbit.js.map +1 -0
- package/dist/src/camera/orthocamera.js +167 -0
- package/dist/src/camera/orthocamera.js.map +1 -0
- package/dist/src/camera/perspectivecamera.js +141 -0
- package/dist/src/camera/perspectivecamera.js.map +1 -0
- package/dist/src/index.js +120 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/material/blinn.js +81 -0
- package/dist/src/material/blinn.js.map +1 -0
- package/dist/src/material/grassmaterial.js +113 -0
- package/dist/src/material/grassmaterial.js.map +1 -0
- package/dist/src/material/lambert.js +92 -0
- package/dist/src/material/lambert.js.map +1 -0
- package/dist/src/material/material.js +301 -0
- package/dist/src/material/material.js.map +1 -0
- package/dist/src/material/meshmaterial.js +704 -0
- package/dist/src/material/meshmaterial.js.map +1 -0
- package/dist/src/material/mixins/albedocolor.js +76 -0
- package/dist/src/material/mixins/albedocolor.js.map +1 -0
- package/dist/src/material/mixins/foliage.js +47 -0
- package/dist/src/material/mixins/foliage.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
- package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
- package/dist/src/material/mixins/lit.js +476 -0
- package/dist/src/material/mixins/lit.js.map +1 -0
- package/dist/src/material/mixins/pbr/common.js +918 -0
- package/dist/src/material/mixins/pbr/common.js.map +1 -0
- package/dist/src/material/mixins/texture.js +172 -0
- package/dist/src/material/mixins/texture.js.map +1 -0
- package/dist/src/material/mixins/vertexcolor.js +56 -0
- package/dist/src/material/mixins/vertexcolor.js.map +1 -0
- package/dist/src/material/particle.js +178 -0
- package/dist/src/material/particle.js.map +1 -0
- package/dist/src/material/pbrmr.js +97 -0
- package/dist/src/material/pbrmr.js.map +1 -0
- package/dist/src/material/pbrsg.js +97 -0
- package/dist/src/material/pbrsg.js.map +1 -0
- package/dist/src/material/shader/helper.js +1209 -0
- package/dist/src/material/shader/helper.js.map +1 -0
- package/dist/src/material/terrain-cm.js +606 -0
- package/dist/src/material/terrain-cm.js.map +1 -0
- package/dist/src/material/terrainmaterial.js +375 -0
- package/dist/src/material/terrainmaterial.js.map +1 -0
- package/dist/src/material/unlit.js +41 -0
- package/dist/src/material/unlit.js.map +1 -0
- package/dist/src/material/water.js +417 -0
- package/dist/src/material/water.js.map +1 -0
- package/dist/src/posteffect/bloom.js +361 -0
- package/dist/src/posteffect/bloom.js.map +1 -0
- package/dist/src/posteffect/compositor.js +226 -0
- package/dist/src/posteffect/compositor.js.map +1 -0
- package/dist/src/posteffect/fxaa.js +273 -0
- package/dist/src/posteffect/fxaa.js.map +1 -0
- package/dist/src/posteffect/grayscale.js +69 -0
- package/dist/src/posteffect/grayscale.js.map +1 -0
- package/dist/src/posteffect/motionblur.js +96 -0
- package/dist/src/posteffect/motionblur.js.map +1 -0
- package/dist/src/posteffect/posteffect.js +126 -0
- package/dist/src/posteffect/posteffect.js.map +1 -0
- package/dist/src/posteffect/sao.js +324 -0
- package/dist/src/posteffect/sao.js.map +1 -0
- package/dist/src/posteffect/ssr.js +489 -0
- package/dist/src/posteffect/ssr.js.map +1 -0
- package/dist/src/posteffect/taa.js +172 -0
- package/dist/src/posteffect/taa.js.map +1 -0
- package/dist/src/posteffect/tonemap.js +94 -0
- package/dist/src/posteffect/tonemap.js.map +1 -0
- package/dist/src/render/abuffer_oit.js +361 -0
- package/dist/src/render/abuffer_oit.js.map +1 -0
- package/dist/src/render/clipmap.js +851 -0
- package/dist/src/render/clipmap.js.map +1 -0
- package/dist/src/render/cluster_light.js +333 -0
- package/dist/src/render/cluster_light.js.map +1 -0
- package/dist/src/render/cull_visitor.js +187 -0
- package/dist/src/render/cull_visitor.js.map +1 -0
- package/dist/src/render/depthpass.js +68 -0
- package/dist/src/render/depthpass.js.map +1 -0
- package/dist/src/render/drawable_mixin.js +227 -0
- package/dist/src/render/drawable_mixin.js.map +1 -0
- package/dist/src/render/envlight.js +463 -0
- package/dist/src/render/envlight.js.map +1 -0
- package/dist/src/render/fbm_wavegenerator.js +251 -0
- package/dist/src/render/fbm_wavegenerator.js.map +1 -0
- package/dist/src/render/fft_wavegenerator.js +1006 -0
- package/dist/src/render/fft_wavegenerator.js.map +1 -0
- package/dist/src/render/fullscreenquad.js +38 -0
- package/dist/src/render/fullscreenquad.js.map +1 -0
- package/dist/src/render/gerstner_wavegenerator.js +314 -0
- package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
- package/dist/src/render/globalbindgroup_allocator.js +60 -0
- package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
- package/dist/src/render/hzb.js +273 -0
- package/dist/src/render/hzb.js.map +1 -0
- package/dist/src/render/lightpass.js +172 -0
- package/dist/src/render/lightpass.js.map +1 -0
- package/dist/src/render/objectcolorpass.js +51 -0
- package/dist/src/render/objectcolorpass.js.map +1 -0
- package/dist/src/render/primitive.js +364 -0
- package/dist/src/render/primitive.js.map +1 -0
- package/dist/src/render/render_queue.js +467 -0
- package/dist/src/render/render_queue.js.map +1 -0
- package/dist/src/render/renderbundle_wrapper.js +152 -0
- package/dist/src/render/renderbundle_wrapper.js.map +1 -0
- package/dist/src/render/renderer.js +455 -0
- package/dist/src/render/renderer.js.map +1 -0
- package/dist/src/render/renderpass.js +200 -0
- package/dist/src/render/renderpass.js.map +1 -0
- package/dist/src/render/shadowmap_pass.js +56 -0
- package/dist/src/render/shadowmap_pass.js.map +1 -0
- package/dist/src/render/sky.js +1103 -0
- package/dist/src/render/sky.js.map +1 -0
- package/dist/src/render/weightedblended_oit.js +168 -0
- package/dist/src/render/weightedblended_oit.js.map +1 -0
- package/dist/src/scene/batchgroup.js +162 -0
- package/dist/src/scene/batchgroup.js.map +1 -0
- package/dist/src/scene/environment.js +209 -0
- package/dist/src/scene/environment.js.map +1 -0
- package/dist/src/scene/graph_node.js +72 -0
- package/dist/src/scene/graph_node.js.map +1 -0
- package/dist/src/scene/light.js +416 -0
- package/dist/src/scene/light.js.map +1 -0
- package/dist/src/scene/mesh.js +341 -0
- package/dist/src/scene/mesh.js.map +1 -0
- package/dist/src/scene/octree.js +649 -0
- package/dist/src/scene/octree.js.map +1 -0
- package/dist/src/scene/particlesys.js +738 -0
- package/dist/src/scene/particlesys.js.map +1 -0
- package/dist/src/scene/raycast_visitor.js +103 -0
- package/dist/src/scene/raycast_visitor.js.map +1 -0
- package/dist/src/scene/scene.js +284 -0
- package/dist/src/scene/scene.js.map +1 -0
- package/dist/src/scene/scene_node.js +732 -0
- package/dist/src/scene/scene_node.js.map +1 -0
- package/dist/src/scene/terrain/grass.js +278 -0
- package/dist/src/scene/terrain/grass.js.map +1 -0
- package/dist/src/scene/terrain/heightfield.js +475 -0
- package/dist/src/scene/terrain/heightfield.js.map +1 -0
- package/dist/src/scene/terrain/patch.js +530 -0
- package/dist/src/scene/terrain/patch.js.map +1 -0
- package/dist/src/scene/terrain/quadtree.js +461 -0
- package/dist/src/scene/terrain/quadtree.js.map +1 -0
- package/dist/src/scene/terrain/terrain.js +246 -0
- package/dist/src/scene/terrain/terrain.js.map +1 -0
- package/dist/src/scene/terrain-cm/grass.js +594 -0
- package/dist/src/scene/terrain-cm/grass.js.map +1 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/src/scene/water.js +374 -0
- package/dist/src/scene/water.js.map +1 -0
- package/dist/src/shaders/atmosphere.js +957 -0
- package/dist/src/shaders/atmosphere.js.map +1 -0
- package/dist/src/shaders/fog.js +112 -0
- package/dist/src/shaders/fog.js.map +1 -0
- package/dist/src/shaders/misc.js +266 -0
- package/dist/src/shaders/misc.js.map +1 -0
- package/dist/src/shaders/noise.js +222 -0
- package/dist/src/shaders/noise.js.map +1 -0
- package/dist/src/shaders/pbr.js +51 -0
- package/dist/src/shaders/pbr.js.map +1 -0
- package/dist/src/shaders/shadow.js +636 -0
- package/dist/src/shaders/shadow.js.map +1 -0
- package/dist/src/shaders/ssr.js +490 -0
- package/dist/src/shaders/ssr.js.map +1 -0
- package/dist/src/shaders/temporal.js +215 -0
- package/dist/src/shaders/temporal.js.map +1 -0
- package/dist/src/shaders/water.js +756 -0
- package/dist/src/shaders/water.js.map +1 -0
- package/dist/src/shadow/esm.js +237 -0
- package/dist/src/shadow/esm.js.map +1 -0
- package/dist/src/shadow/pcf_opt.js +181 -0
- package/dist/src/shadow/pcf_opt.js.map +1 -0
- package/dist/src/shadow/pcf_pd.js +189 -0
- package/dist/src/shadow/pcf_pd.js.map +1 -0
- package/dist/src/shadow/shader.js +37 -0
- package/dist/src/shadow/shader.js.map +1 -0
- package/dist/src/shadow/shadow_impl.js +15 -0
- package/dist/src/shadow/shadow_impl.js.map +1 -0
- package/dist/src/shadow/shadowmapper.js +790 -0
- package/dist/src/shadow/shadowmapper.js.map +1 -0
- package/dist/src/shadow/ssm.js +159 -0
- package/dist/src/shadow/ssm.js.map +1 -0
- package/dist/src/shadow/vsm.js +297 -0
- package/dist/src/shadow/vsm.js.map +1 -0
- package/dist/src/shapes/box.js +386 -0
- package/dist/src/shapes/box.js.map +1 -0
- package/dist/src/shapes/cylinder.js +125 -0
- package/dist/src/shapes/cylinder.js.map +1 -0
- package/dist/src/shapes/plane.js +88 -0
- package/dist/src/shapes/plane.js.map +1 -0
- package/dist/src/shapes/shape.js +87 -0
- package/dist/src/shapes/shape.js.map +1 -0
- package/dist/src/shapes/sphere.js +114 -0
- package/dist/src/shapes/sphere.js.map +1 -0
- package/dist/src/shapes/tetrahedron.js +188 -0
- package/dist/src/shapes/tetrahedron.js.map +1 -0
- package/dist/src/shapes/torus.js +111 -0
- package/dist/src/shapes/torus.js.map +1 -0
- package/dist/src/utility/aabbtree.js +400 -0
- package/dist/src/utility/aabbtree.js.map +1 -0
- package/dist/src/utility/bounding_volume.js +29 -0
- package/dist/src/utility/bounding_volume.js.map +1 -0
- package/dist/src/utility/debug.js +28 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/draco/decoder.js +116 -0
- package/dist/src/utility/draco/decoder.js.map +1 -0
- package/dist/src/utility/misc.js +105 -0
- package/dist/src/utility/misc.js.map +1 -0
- package/dist/src/utility/panorama.js +163 -0
- package/dist/src/utility/panorama.js.map +1 -0
- package/dist/src/utility/pmrem.js +354 -0
- package/dist/src/utility/pmrem.js.map +1 -0
- package/dist/src/utility/rendermipmap.js +115 -0
- package/dist/src/utility/rendermipmap.js.map +1 -0
- package/dist/src/utility/serialization/json.js +402 -0
- package/dist/src/utility/serialization/json.js.map +1 -0
- package/dist/src/utility/serialization/manager.js +623 -0
- package/dist/src/utility/serialization/manager.js.map +1 -0
- package/dist/src/utility/serialization/scene/animation.js +248 -0
- package/dist/src/utility/serialization/scene/animation.js.map +1 -0
- package/dist/src/utility/serialization/scene/batch.js +59 -0
- package/dist/src/utility/serialization/scene/batch.js.map +1 -0
- package/dist/src/utility/serialization/scene/camera.js +790 -0
- package/dist/src/utility/serialization/scene/camera.js.map +1 -0
- package/dist/src/utility/serialization/scene/common.js +222 -0
- package/dist/src/utility/serialization/scene/common.js.map +1 -0
- package/dist/src/utility/serialization/scene/light.js +575 -0
- package/dist/src/utility/serialization/scene/light.js.map +1 -0
- package/dist/src/utility/serialization/scene/material.js +1111 -0
- package/dist/src/utility/serialization/scene/material.js.map +1 -0
- package/dist/src/utility/serialization/scene/mesh.js +148 -0
- package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/src/utility/serialization/scene/misc.js +39 -0
- package/dist/src/utility/serialization/scene/misc.js.map +1 -0
- package/dist/src/utility/serialization/scene/node.js +451 -0
- package/dist/src/utility/serialization/scene/node.js.map +1 -0
- package/dist/src/utility/serialization/scene/particle.js +425 -0
- package/dist/src/utility/serialization/scene/particle.js.map +1 -0
- package/dist/src/utility/serialization/scene/primitive.js +692 -0
- package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/src/utility/serialization/scene/scene.js +704 -0
- package/dist/src/utility/serialization/scene/scene.js.map +1 -0
- package/dist/src/utility/serialization/scene/terrain.js +488 -0
- package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/src/utility/serialization/scene/water.js +465 -0
- package/dist/src/utility/serialization/scene/water.js.map +1 -0
- package/dist/src/utility/shprojector.js +297 -0
- package/dist/src/utility/shprojector.js.map +1 -0
- package/dist/src/utility/textures/ggxlut.js +213 -0
- package/dist/src/utility/textures/ggxlut.js.map +1 -0
- package/dist/src/utility/textures/gradientnoise.js +62 -0
- package/dist/src/utility/textures/gradientnoise.js.map +1 -0
- package/dist/src/utility/textures/randomnoise.js +41 -0
- package/dist/src/utility/textures/randomnoise.js.map +1 -0
- package/dist/src/values.js +162 -0
- package/dist/src/values.js.map +1 -0
- package/dist/utility/blueprint/material/common.js +7 -0
- package/dist/utility/blueprint/material/common.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +3 -3
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +4 -4
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/serialization/blueprint/constants.js +255 -0
- package/dist/utility/serialization/blueprint/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/constants.js +203 -0
- package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/texture.js +165 -0
- package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
- package/dist/utility/serialization/manager.js +299 -268
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +45 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +53 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +10 -0
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +30 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +63 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +11 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/misc.js +2 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +19 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +22 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +33 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +39 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/script.js +2 -0
- package/dist/utility/serialization/scene/script.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +9 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +21 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +5 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +49 -53
- package/dist/values.js.map +1 -1
- package/package.json +2 -2
- package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
- package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone.js +0 -240
- package/dist/animation/spring/spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone_collider.js +0 -198
- package/dist/animation/spring/spring_bone_collider.js.map +0 -1
- package/dist/animation/spring/spring_bone_constraint.js +0 -170
- package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
- package/dist/animation/spring/spring_bone_system.js +0 -328
- package/dist/animation/spring/spring_bone_system.js.map +0 -1
- package/dist/render/sky_motion_vector.js +0 -85
- package/dist/render/sky_motion_vector.js.map +0 -1
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
import { ProgramBuilder } from '@zephyr3d/device';
|
|
2
|
+
import { RENDER_PASS_TYPE_OBJECT_COLOR, QUEUE_OPAQUE, RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_LIGHT, MaterialVaryingFlags, RENDER_PASS_TYPE_DEPTH, QUEUE_TRANSPARENT } from '../values.js';
|
|
3
|
+
import { Material } from './material.js';
|
|
4
|
+
import { encodeNormalizedFloatToRGBA } from '../shaders/misc.js';
|
|
5
|
+
import { Application } from '../app/app.js';
|
|
6
|
+
import { ShaderHelper } from './shader/helper.js';
|
|
7
|
+
import { Vector4, DRef, DWeakRef, Vector3, Vector2, applyMixins } from '@zephyr3d/base';
|
|
8
|
+
import { RenderBundleWrapper } from '../render/renderbundle_wrapper.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Apply material mixins to specific material class
|
|
12
|
+
* @param target - Material class
|
|
13
|
+
* @param mixins - mixins
|
|
14
|
+
* @returns Mixed mesh material class
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/ function applyMaterialMixins(target, ...mixins) {
|
|
18
|
+
return applyMixins(target, ...mixins);
|
|
19
|
+
}
|
|
20
|
+
let FEATURE_ALPHATEST = 0;
|
|
21
|
+
let FEATURE_ALPHABLEND = 0;
|
|
22
|
+
let FEATURE_ALPHATOCOVERAGE = 0;
|
|
23
|
+
let FEATURE_DISABLE_TAA = 0;
|
|
24
|
+
/**
|
|
25
|
+
* Base class for any kind of mesh materials
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/ class MeshMaterial extends Material {
|
|
29
|
+
/** @internal */ static INSTANCE_UNIFORMS = [];
|
|
30
|
+
/** @internal */ static NEXT_FEATURE_INDEX = 3;
|
|
31
|
+
/** @internal */ static OBJECT_COLOR_UNIFORM = this.defineInstanceUniform('objectColor', 'rgba');
|
|
32
|
+
/** @internal */ static OPACITY_UNIFORM = this.defineInstanceUniform('opacity', 'float');
|
|
33
|
+
/** @internal */ _featureStates;
|
|
34
|
+
/** @internal */ _alphaCutoff;
|
|
35
|
+
/** @internal */ _blendMode;
|
|
36
|
+
/** @internal */ _cullMode;
|
|
37
|
+
/** @internal */ _opacity;
|
|
38
|
+
/** @internal */ _taaStrength;
|
|
39
|
+
/** @internal */ _objectColor;
|
|
40
|
+
/** @internal */ _ctx;
|
|
41
|
+
/** @internal */ _materialPass;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an instance of MeshMaterial class
|
|
44
|
+
* @param args - constructor arguments
|
|
45
|
+
*/ constructor(){
|
|
46
|
+
super();
|
|
47
|
+
this._featureStates = [];
|
|
48
|
+
this._alphaCutoff = 0;
|
|
49
|
+
this._blendMode = 'none';
|
|
50
|
+
this._cullMode = 'back';
|
|
51
|
+
this._opacity = 1;
|
|
52
|
+
this._taaStrength = 1 - 1 / 16;
|
|
53
|
+
this._objectColor = Vector4.one();
|
|
54
|
+
this._ctx = null;
|
|
55
|
+
this._materialPass = -1;
|
|
56
|
+
this.useFeature(FEATURE_ALPHABLEND, this._blendMode);
|
|
57
|
+
}
|
|
58
|
+
clone() {
|
|
59
|
+
const other = new MeshMaterial();
|
|
60
|
+
other.copyFrom(this);
|
|
61
|
+
return other;
|
|
62
|
+
}
|
|
63
|
+
copyFrom(other) {
|
|
64
|
+
super.copyFrom(other);
|
|
65
|
+
this.alphaCutoff = other.alphaCutoff;
|
|
66
|
+
this.blendMode = other.blendMode;
|
|
67
|
+
this.cullMode = other.cullMode;
|
|
68
|
+
this.opacity = other.opacity;
|
|
69
|
+
this.objectColor = other.objectColor;
|
|
70
|
+
}
|
|
71
|
+
/** Indicate that the uniform has changed and needs to be resubmitted. */ uniformChanged() {
|
|
72
|
+
this.optionChanged(false);
|
|
73
|
+
}
|
|
74
|
+
/** Define feature index */ static defineFeature() {
|
|
75
|
+
const val = this.NEXT_FEATURE_INDEX;
|
|
76
|
+
this.NEXT_FEATURE_INDEX++;
|
|
77
|
+
return val;
|
|
78
|
+
}
|
|
79
|
+
/** @internal */ static getNumComponents(type) {
|
|
80
|
+
if (type === 'float') {
|
|
81
|
+
return 1;
|
|
82
|
+
}
|
|
83
|
+
if (type === 'vec2') {
|
|
84
|
+
return 2;
|
|
85
|
+
}
|
|
86
|
+
if (type === 'rgb' || type === 'vec3') {
|
|
87
|
+
return 3;
|
|
88
|
+
}
|
|
89
|
+
if (type === 'rgba' || type === 'vec4') {
|
|
90
|
+
return 4;
|
|
91
|
+
}
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
/** Define instance uniform index */ static defineInstanceUniform(prop, type) {
|
|
95
|
+
if (this.INSTANCE_UNIFORMS.findIndex((val)=>val.prop === prop) >= 0) {
|
|
96
|
+
throw new Error(`${this.name}.defineInstanceUniform(): ${prop} was already defined`);
|
|
97
|
+
}
|
|
98
|
+
const numComponents = this.getNumComponents(type);
|
|
99
|
+
if (numComponents === 0) {
|
|
100
|
+
throw new Error(`${this.name}.defineInstanceUniform(): invalid uniform type ${type}`);
|
|
101
|
+
}
|
|
102
|
+
let index = this.INSTANCE_UNIFORMS.length;
|
|
103
|
+
let offset = 0;
|
|
104
|
+
if (this.INSTANCE_UNIFORMS.length > 0) {
|
|
105
|
+
const lastUniform = this.INSTANCE_UNIFORMS[this.INSTANCE_UNIFORMS.length - 1];
|
|
106
|
+
const finalOffset = lastUniform.offset + 4 & -4;
|
|
107
|
+
offset = finalOffset;
|
|
108
|
+
for(let i = 0; i < this.INSTANCE_UNIFORMS.length; i++){
|
|
109
|
+
const offset1 = this.INSTANCE_UNIFORMS[i].offset;
|
|
110
|
+
const numComps1 = this.getNumComponents(this.INSTANCE_UNIFORMS[i].type);
|
|
111
|
+
const offset2 = i === this.INSTANCE_UNIFORMS.length - 1 ? finalOffset : this.INSTANCE_UNIFORMS[i + 1].offset;
|
|
112
|
+
if (offset1 + numComps1 + numComponents <= offset2) {
|
|
113
|
+
index = i + 1;
|
|
114
|
+
offset = offset1 + numComps1;
|
|
115
|
+
if (offset + numComponents === offset2) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.INSTANCE_UNIFORMS = this.INSTANCE_UNIFORMS.slice();
|
|
122
|
+
this.INSTANCE_UNIFORMS.splice(index, 0, {
|
|
123
|
+
prop,
|
|
124
|
+
offset,
|
|
125
|
+
type
|
|
126
|
+
});
|
|
127
|
+
return offset << 2 | numComponents - 1;
|
|
128
|
+
}
|
|
129
|
+
getInstancedUniform(scope, uniformIndex) {
|
|
130
|
+
const pb = scope.$builder;
|
|
131
|
+
const instanceID = scope.$builtins.instanceIndex;
|
|
132
|
+
const uniformName = ShaderHelper.getInstanceDataUniformName();
|
|
133
|
+
const strideName = ShaderHelper.getInstanceDataStrideUniformName();
|
|
134
|
+
const offsetName = ShaderHelper.getInstanceDataOffsetUniformName();
|
|
135
|
+
const numComponents = (uniformIndex & 3) + 1;
|
|
136
|
+
const vecIndex = uniformIndex >> 4;
|
|
137
|
+
const vecOffset = uniformIndex >> 2 & 3;
|
|
138
|
+
const u = scope[uniformName].at(pb.add(pb.mul(scope[strideName], instanceID), ShaderHelper.MATERIAL_INSTANCE_DATA_OFFSET + vecIndex, scope[offsetName]));
|
|
139
|
+
const m = [
|
|
140
|
+
'x',
|
|
141
|
+
'y',
|
|
142
|
+
'z',
|
|
143
|
+
'w'
|
|
144
|
+
].slice(vecOffset, vecOffset + numComponents).join('');
|
|
145
|
+
return u[m];
|
|
146
|
+
}
|
|
147
|
+
/** Get instanced material property list */ getInstancedUniforms() {
|
|
148
|
+
return this.constructor.INSTANCE_UNIFORMS;
|
|
149
|
+
}
|
|
150
|
+
/** Create material instance */ createInstance() {
|
|
151
|
+
if (this.$isInstance) {
|
|
152
|
+
return this.coreMaterial.createInstance();
|
|
153
|
+
}
|
|
154
|
+
const isWebGL1 = Application.instance.device.type === 'webgl';
|
|
155
|
+
if (isWebGL1 || !this.supportInstancing) {
|
|
156
|
+
return this.clone();
|
|
157
|
+
}
|
|
158
|
+
const instanceUniforms = this.getInstancedUniforms();
|
|
159
|
+
const uniformsHolder = instanceUniforms.length > 0 ? new Float32Array(instanceUniforms[instanceUniforms.length - 1].offset + 4 & -4) : null;
|
|
160
|
+
const instance = {};
|
|
161
|
+
const that = this;
|
|
162
|
+
const coreMaterial = new DRef(that);
|
|
163
|
+
let disposed = false;
|
|
164
|
+
instance.isBatchable = ()=>true; //!isWebGL1 && that.supportInstancing();
|
|
165
|
+
instance.dispose = ()=>{
|
|
166
|
+
if (!disposed) {
|
|
167
|
+
disposed = true;
|
|
168
|
+
coreMaterial.dispose();
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
instance.$instanceUniforms = uniformsHolder;
|
|
172
|
+
instance.$isInstance = true;
|
|
173
|
+
let persistentId = crypto.randomUUID();
|
|
174
|
+
Material._registry.set(persistentId, new DWeakRef(instance));
|
|
175
|
+
Object.defineProperty(instance, 'coreMaterial', {
|
|
176
|
+
get: function() {
|
|
177
|
+
return coreMaterial.get();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(instance, 'persistentId', {
|
|
181
|
+
get: function() {
|
|
182
|
+
return persistentId;
|
|
183
|
+
},
|
|
184
|
+
set: function(val) {
|
|
185
|
+
if (val !== persistentId) {
|
|
186
|
+
const m = Material._registry.get(persistentId);
|
|
187
|
+
if (!m || m.get() !== instance) {
|
|
188
|
+
throw new Error('Registry material mismatch');
|
|
189
|
+
}
|
|
190
|
+
Material._registry.delete(persistentId);
|
|
191
|
+
persistentId = val;
|
|
192
|
+
Material._registry.set(persistentId, m);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
// Copy original uniform values
|
|
197
|
+
for(let i = 0; i < instanceUniforms.length; i++){
|
|
198
|
+
const { prop, offset, type } = instanceUniforms[i];
|
|
199
|
+
const value = that[prop];
|
|
200
|
+
switch(type){
|
|
201
|
+
case 'float':
|
|
202
|
+
{
|
|
203
|
+
uniformsHolder[offset] = Number(value);
|
|
204
|
+
Object.defineProperty(instance, prop, {
|
|
205
|
+
get () {
|
|
206
|
+
return uniformsHolder[offset];
|
|
207
|
+
},
|
|
208
|
+
set (value) {
|
|
209
|
+
uniformsHolder[offset] = value;
|
|
210
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case 'vec2':
|
|
216
|
+
{
|
|
217
|
+
if (!(value instanceof Vector2)) {
|
|
218
|
+
throw new Error(`Instance uniform property ${prop} must be of type Vector2`);
|
|
219
|
+
}
|
|
220
|
+
uniformsHolder[offset] = value.x;
|
|
221
|
+
uniformsHolder[offset + 1] = value.y;
|
|
222
|
+
Object.defineProperty(instance, prop, {
|
|
223
|
+
get () {
|
|
224
|
+
return new Vector2(uniformsHolder[offset], uniformsHolder[offset + 1]);
|
|
225
|
+
},
|
|
226
|
+
set (value) {
|
|
227
|
+
if (!(value instanceof Vector2)) {
|
|
228
|
+
throw new Error(`Instance uniform property ${prop} must be of type Vector2`);
|
|
229
|
+
}
|
|
230
|
+
uniformsHolder[offset] = value.x;
|
|
231
|
+
uniformsHolder[offset + 1] = value.y;
|
|
232
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
case 'vec3':
|
|
238
|
+
case 'rgb':
|
|
239
|
+
{
|
|
240
|
+
if (!(value instanceof Vector3)) {
|
|
241
|
+
throw new Error(`Instance uniform property ${prop} must be of type Vector3`);
|
|
242
|
+
}
|
|
243
|
+
uniformsHolder[offset] = value.x;
|
|
244
|
+
uniformsHolder[offset + 1] = value.y;
|
|
245
|
+
uniformsHolder[offset + 2] = value.z;
|
|
246
|
+
Object.defineProperty(instance, prop, {
|
|
247
|
+
get () {
|
|
248
|
+
return new Vector3(uniformsHolder[offset], uniformsHolder[offset + 1], uniformsHolder[offset + 2]);
|
|
249
|
+
},
|
|
250
|
+
set (value) {
|
|
251
|
+
if (!(value instanceof Vector3)) {
|
|
252
|
+
throw new Error(`Instance uniform property ${prop} must be of type Vector3`);
|
|
253
|
+
}
|
|
254
|
+
uniformsHolder[offset] = value.x;
|
|
255
|
+
uniformsHolder[offset + 1] = value.y;
|
|
256
|
+
uniformsHolder[offset + 2] = value.z;
|
|
257
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case 'vec4':
|
|
263
|
+
case 'rgba':
|
|
264
|
+
{
|
|
265
|
+
if (!(value instanceof Vector4)) {
|
|
266
|
+
throw new Error(`Instance uniform property ${prop} must be of type Vector4`);
|
|
267
|
+
}
|
|
268
|
+
uniformsHolder[offset] = value.x;
|
|
269
|
+
uniformsHolder[offset + 1] = value.y;
|
|
270
|
+
uniformsHolder[offset + 2] = value.z;
|
|
271
|
+
uniformsHolder[offset + 3] = value.w;
|
|
272
|
+
Object.defineProperty(instance, prop, {
|
|
273
|
+
get () {
|
|
274
|
+
return new Vector4(uniformsHolder[offset], uniformsHolder[offset + 1], uniformsHolder[offset + 2], uniformsHolder[offset + 3]);
|
|
275
|
+
},
|
|
276
|
+
set (value) {
|
|
277
|
+
if (!(value instanceof Vector4)) {
|
|
278
|
+
throw new Error(`Instance uniform property ${prop} must be of type Vector4`);
|
|
279
|
+
}
|
|
280
|
+
uniformsHolder[offset] = value.x;
|
|
281
|
+
uniformsHolder[offset + 1] = value.y;
|
|
282
|
+
uniformsHolder[offset + 2] = value.z;
|
|
283
|
+
uniformsHolder[offset + 3] = value.w;
|
|
284
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
Object.setPrototypeOf(instance, that);
|
|
292
|
+
return instance;
|
|
293
|
+
}
|
|
294
|
+
/** Draw context for shader creation */ get drawContext() {
|
|
295
|
+
return this._ctx;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Current material pass
|
|
299
|
+
* @internal
|
|
300
|
+
**/ get pass() {
|
|
301
|
+
return this._materialPass;
|
|
302
|
+
}
|
|
303
|
+
/** A value between 0 and 1, presents the cutoff for alpha testing */ get alphaCutoff() {
|
|
304
|
+
return this._alphaCutoff;
|
|
305
|
+
}
|
|
306
|
+
set alphaCutoff(val) {
|
|
307
|
+
if (this._alphaCutoff !== val) {
|
|
308
|
+
this.useFeature(FEATURE_ALPHATEST, val > 0);
|
|
309
|
+
this._alphaCutoff = val;
|
|
310
|
+
this.uniformChanged();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** Whether TAA should be disabled on this material */ get TAADisabled() {
|
|
314
|
+
return !!this.featureUsed(FEATURE_DISABLE_TAA);
|
|
315
|
+
}
|
|
316
|
+
set TAADisabled(val) {
|
|
317
|
+
this.useFeature(FEATURE_DISABLE_TAA, !!val);
|
|
318
|
+
}
|
|
319
|
+
/** TAA strength */ get TAAStrength() {
|
|
320
|
+
return this._taaStrength;
|
|
321
|
+
}
|
|
322
|
+
set TAAStrength(val) {
|
|
323
|
+
val = val > 1 ? 1 : val < 0 ? 0 : val;
|
|
324
|
+
if (this._taaStrength !== val) {
|
|
325
|
+
this._taaStrength = val;
|
|
326
|
+
this.uniformChanged();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
get alphaToCoverage() {
|
|
330
|
+
return this.featureUsed(FEATURE_ALPHATOCOVERAGE);
|
|
331
|
+
}
|
|
332
|
+
set alphaToCoverage(val) {
|
|
333
|
+
this.useFeature(FEATURE_ALPHATOCOVERAGE, !!val);
|
|
334
|
+
}
|
|
335
|
+
/** Blending mode */ get blendMode() {
|
|
336
|
+
return this._blendMode;
|
|
337
|
+
}
|
|
338
|
+
set blendMode(val) {
|
|
339
|
+
if (this._blendMode !== val) {
|
|
340
|
+
this._blendMode = val;
|
|
341
|
+
this.useFeature(FEATURE_ALPHABLEND, this._blendMode);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/** Cull mode */ get cullMode() {
|
|
345
|
+
return this._cullMode;
|
|
346
|
+
}
|
|
347
|
+
set cullMode(val) {
|
|
348
|
+
this._cullMode = val;
|
|
349
|
+
}
|
|
350
|
+
/** A value between 0 and 1, presents the opacity */ get opacity() {
|
|
351
|
+
return this._opacity;
|
|
352
|
+
}
|
|
353
|
+
set opacity(val) {
|
|
354
|
+
val = val < 0 ? 0 : val > 1 ? 1 : val;
|
|
355
|
+
if (this._opacity !== val) {
|
|
356
|
+
this._opacity = val;
|
|
357
|
+
this.uniformChanged();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/** Object color used for GPU picking */ get objectColor() {
|
|
361
|
+
return this._objectColor;
|
|
362
|
+
}
|
|
363
|
+
set objectColor(val) {
|
|
364
|
+
if (val !== this._objectColor) {
|
|
365
|
+
this._objectColor.set(val ?? Vector4.one());
|
|
366
|
+
this.uniformChanged();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/** Returns true if shading of the material will be affected by lights */ supportLighting() {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* {@inheritDoc Material.updateRenderStates}
|
|
374
|
+
*/ updateRenderStates(pass, stateSet, ctx) {
|
|
375
|
+
const isObjectColorPass = ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR;
|
|
376
|
+
const blending = !isObjectColorPass && (this.featureUsed(FEATURE_ALPHABLEND) !== 'none' || ctx.lightBlending);
|
|
377
|
+
const a2c = !isObjectColorPass && this.featureUsed(FEATURE_ALPHATOCOVERAGE);
|
|
378
|
+
const ztestEq = ctx.queue === QUEUE_OPAQUE && !!ctx.depthTexture && !ctx.sceneColorTexture;
|
|
379
|
+
if (blending || a2c) {
|
|
380
|
+
const blendingState = stateSet.useBlendingState();
|
|
381
|
+
if (blending) {
|
|
382
|
+
blendingState.enable(true);
|
|
383
|
+
blendingState.setBlendFuncAlpha('zero', 'one');
|
|
384
|
+
blendingState.setBlendEquation('add', 'add');
|
|
385
|
+
if (this._blendMode === 'additive' || ctx.lightBlending) {
|
|
386
|
+
blendingState.setBlendFuncRGB('one', 'one');
|
|
387
|
+
} else {
|
|
388
|
+
blendingState.setBlendFuncRGB('one', 'inv-src-alpha');
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
blendingState.enable(false);
|
|
392
|
+
}
|
|
393
|
+
blendingState.enableAlphaToCoverage(a2c);
|
|
394
|
+
if (ztestEq) {
|
|
395
|
+
stateSet.useDepthState().setCompareFunc('eq').enableTest(true).enableWrite(false);
|
|
396
|
+
} else if (blendingState.enabled) {
|
|
397
|
+
stateSet.useDepthState().enableTest(true).enableWrite(false);
|
|
398
|
+
} else {
|
|
399
|
+
stateSet.defaultDepthState();
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
stateSet.defaultBlendingState();
|
|
403
|
+
if (ztestEq) {
|
|
404
|
+
stateSet.useDepthState().setCompareFunc('eq').enableTest(true).enableWrite(false);
|
|
405
|
+
} else {
|
|
406
|
+
stateSet.defaultDepthState();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (ctx.forceCullMode || this._cullMode !== 'back') {
|
|
410
|
+
stateSet.useRasterizerState().cullMode = ctx.forceCullMode || this._cullMode;
|
|
411
|
+
} else if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
412
|
+
stateSet.useRasterizerState().cullMode = 'none';
|
|
413
|
+
} else {
|
|
414
|
+
stateSet.defaultRasterizerState();
|
|
415
|
+
}
|
|
416
|
+
if (ctx.forceColorState) {
|
|
417
|
+
stateSet.useColorState(ctx.forceColorState);
|
|
418
|
+
} else {
|
|
419
|
+
stateSet.defaultColorState();
|
|
420
|
+
}
|
|
421
|
+
stateSet.defaultStencilState();
|
|
422
|
+
if (ctx.oit) {
|
|
423
|
+
ctx.oit.setRenderStates(stateSet);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Submit Uniform values before rendering with this material.
|
|
428
|
+
*
|
|
429
|
+
* @param bindGroup - Bind group for this material
|
|
430
|
+
* @param ctx - Draw context
|
|
431
|
+
* @param pass - Current pass of the material
|
|
432
|
+
*/ applyUniformValues(bindGroup, ctx, pass) {
|
|
433
|
+
if (this.featureUsed(FEATURE_ALPHATEST)) {
|
|
434
|
+
bindGroup.setValue('zAlphaCutoff', this._alphaCutoff);
|
|
435
|
+
}
|
|
436
|
+
if (this.isTransparentPass(pass) && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT && !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
437
|
+
bindGroup.setValue('zOpacity', this._opacity);
|
|
438
|
+
}
|
|
439
|
+
if (ctx.oit) {
|
|
440
|
+
ctx.oit.applyUniforms(ctx, bindGroup);
|
|
441
|
+
}
|
|
442
|
+
if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING) && ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
443
|
+
bindGroup.setValue('zObjectColor', this._objectColor);
|
|
444
|
+
}
|
|
445
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH && ctx.motionVectors) {
|
|
446
|
+
bindGroup.setValue('zTAAStrength', (1 - this._taaStrength) * 50000);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Determine which queue should be used to render this material.
|
|
451
|
+
* @returns QUEUE_TRANSPARENT or QUEUE_OPAQUE
|
|
452
|
+
*/ getQueueType() {
|
|
453
|
+
return this.isTransparentPass(0) ? QUEUE_TRANSPARENT : QUEUE_OPAQUE;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Determine if a certain pass of this material is translucent.
|
|
457
|
+
* @param pass - Pass of the material
|
|
458
|
+
* @returns True if it is translucent, otherwise false.
|
|
459
|
+
*/ isTransparentPass(_pass) {
|
|
460
|
+
return this.featureUsed(FEATURE_ALPHABLEND) !== 'none';
|
|
461
|
+
}
|
|
462
|
+
/** @internal */ createProgram(ctx, pass) {
|
|
463
|
+
const pb = new ProgramBuilder(ctx.device);
|
|
464
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
465
|
+
const shadowMapParams = ctx.shadowMapInfo.get(ctx.renderPass.light);
|
|
466
|
+
pb.emulateDepthClamp = !!shadowMapParams.depthClampEnabled;
|
|
467
|
+
}
|
|
468
|
+
return this._createProgram(pb, ctx, pass);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Check if a feature is in use for given render pass type.
|
|
472
|
+
*
|
|
473
|
+
* @param feature - The feature index
|
|
474
|
+
* @returns true if the feature is in use, otherwise false.
|
|
475
|
+
*/ featureUsed(feature) {
|
|
476
|
+
return this._featureStates[feature];
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Use or unuse a feature of the material, this will cause the shader to be rebuild.
|
|
480
|
+
*
|
|
481
|
+
* @param feature - Which feature will be used or unused
|
|
482
|
+
* @param use - true if use the feature, otherwise false
|
|
483
|
+
*/ useFeature(feature, use) {
|
|
484
|
+
if (this._featureStates[feature] !== use) {
|
|
485
|
+
this._featureStates[feature] = use;
|
|
486
|
+
this.optionChanged(true);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* {@inheritDoc Material._createHash}
|
|
491
|
+
* @override
|
|
492
|
+
*
|
|
493
|
+
* @internal
|
|
494
|
+
*/ _createHash() {
|
|
495
|
+
return this._featureStates.map((val)=>val === undefined ? '' : val).join('|');
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* {@inheritDoc Material._applyUniforms}
|
|
499
|
+
* @override
|
|
500
|
+
*
|
|
501
|
+
* @internal
|
|
502
|
+
*/ _applyUniforms(bindGroup, ctx, pass) {
|
|
503
|
+
this.applyUniformValues(bindGroup, ctx, pass);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Check if the color should be computed in fragment shader, this is required for forward render pass or alpha test is in use or alpha to coverage is in use.
|
|
507
|
+
*
|
|
508
|
+
* @returns - true if the color should be computed in fragment shader, otherwise false.
|
|
509
|
+
*/ needFragmentColor(ctx) {
|
|
510
|
+
return (ctx ?? this.drawContext).renderPass.type === RENDER_PASS_TYPE_LIGHT || this._alphaCutoff > 0 || this.alphaToCoverage;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Vertex shader implementation of this material
|
|
514
|
+
* @param scope - Shader scope
|
|
515
|
+
*/ vertexShader(scope) {
|
|
516
|
+
const pb = scope.$builder;
|
|
517
|
+
ShaderHelper.prepareVertexShader(pb, this.drawContext);
|
|
518
|
+
if (this.drawContext.materialFlags & MaterialVaryingFlags.SKIN_ANIMATION) {
|
|
519
|
+
scope.$inputs.zBlendIndices = pb.vec4().attrib('blendIndices');
|
|
520
|
+
scope.$inputs.zBlendWeights = pb.vec4().attrib('blendWeights');
|
|
521
|
+
ShaderHelper.prepareSkinAnimation(scope);
|
|
522
|
+
}
|
|
523
|
+
if (this.drawContext.materialFlags & MaterialVaryingFlags.MORPH_ANIMATION && this.drawContext.device.type === 'webgl') {
|
|
524
|
+
scope.$inputs.zFakeVertexID = pb.float().attrib('texCoord7');
|
|
525
|
+
}
|
|
526
|
+
if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
|
|
527
|
+
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
528
|
+
scope.$outputs.zObjectColor = this.getInstancedUniform(scope, MeshMaterial.OBJECT_COLOR_UNIFORM);
|
|
529
|
+
}
|
|
530
|
+
if (this.isTransparentPass(this.pass)) {
|
|
531
|
+
scope.$outputs.zOpacity = this.getInstancedUniform(scope, MeshMaterial.OPACITY_UNIFORM);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Fragment shader implementation of this material
|
|
537
|
+
* @param scope - Shader scope
|
|
538
|
+
*/ fragmentShader(scope) {
|
|
539
|
+
const pb = scope.$builder;
|
|
540
|
+
ShaderHelper.prepareFragmentShader(pb, this.drawContext);
|
|
541
|
+
if (this._alphaCutoff > 0) {
|
|
542
|
+
scope.zAlphaCutoff = pb.float().uniform(2);
|
|
543
|
+
}
|
|
544
|
+
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
545
|
+
if (this.isTransparentPass(this.pass) && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
546
|
+
scope.zOpacity = pb.float().uniform(2);
|
|
547
|
+
}
|
|
548
|
+
} else if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
549
|
+
scope.zObjectColor = pb.vec4().uniform(2);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* {@inheritDoc Material._createProgram}
|
|
554
|
+
* @override
|
|
555
|
+
*
|
|
556
|
+
* @internal
|
|
557
|
+
*/ _createProgram(pb, ctx, pass) {
|
|
558
|
+
const that = this;
|
|
559
|
+
this._ctx = ctx;
|
|
560
|
+
this._materialPass = pass;
|
|
561
|
+
const program = pb.buildRenderProgram({
|
|
562
|
+
vertex (pb) {
|
|
563
|
+
pb.main(function() {
|
|
564
|
+
that.vertexShader(this);
|
|
565
|
+
});
|
|
566
|
+
},
|
|
567
|
+
fragment (pb) {
|
|
568
|
+
if (that.drawContext.oit) {
|
|
569
|
+
that.drawContext.oit.setupFragmentOutput(this);
|
|
570
|
+
} else {
|
|
571
|
+
this.$outputs.zFragmentOutput = pb.vec4();
|
|
572
|
+
if (ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
573
|
+
this.$outputs.zSSRRoughness = pb.vec4();
|
|
574
|
+
this.$outputs.zSSRNormal = pb.vec4();
|
|
575
|
+
}
|
|
576
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH && ctx.motionVectors) {
|
|
577
|
+
this.$outputs.zMotionVector = pb.vec4();
|
|
578
|
+
this.zTAAStrength = pb.float().uniform(2);
|
|
579
|
+
}
|
|
580
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
581
|
+
this.$outputs.zDistance = pb.vec4();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
pb.main(function() {
|
|
585
|
+
that.fragmentShader(this);
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
return program;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Calculate final fragment color for output.
|
|
593
|
+
*
|
|
594
|
+
* @param scope - Shader scope
|
|
595
|
+
* @param color - Lit fragment color
|
|
596
|
+
*
|
|
597
|
+
* @returns The final fragment color
|
|
598
|
+
*/ outputFragmentColor(scope, worldPos, color, ssrRoughness, ssrNormal) {
|
|
599
|
+
const pb = scope.$builder;
|
|
600
|
+
const that = this;
|
|
601
|
+
const funcName = 'Z_outputFragmentColor';
|
|
602
|
+
pb.func(funcName, color ? [
|
|
603
|
+
pb.vec3('worldPos'),
|
|
604
|
+
pb.vec4('color')
|
|
605
|
+
] : [
|
|
606
|
+
pb.vec3('worldPos')
|
|
607
|
+
], function() {
|
|
608
|
+
this.$l.outColor = color ? this.color : pb.vec4();
|
|
609
|
+
if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
610
|
+
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
611
|
+
let output = true;
|
|
612
|
+
if (!that.isTransparentPass(that.pass) && !that.alphaToCoverage) {
|
|
613
|
+
this.outColor.a = 1;
|
|
614
|
+
} else if (that.isTransparentPass(that.pass)) {
|
|
615
|
+
const opacity = that.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING ? this.$inputs.zOpacity : this.zOpacity;
|
|
616
|
+
this.outColor.a = pb.mul(this.outColor.a, opacity);
|
|
617
|
+
}
|
|
618
|
+
if (that.isTransparentPass(that.pass)) {
|
|
619
|
+
if (this.zAlphaCutoff) {
|
|
620
|
+
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
621
|
+
pb.discard();
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
if (!that.drawContext.oit || that.drawContext.oit.wantsPremultipliedAlpha()) {
|
|
625
|
+
this.outColor = pb.vec4(pb.mul(this.outColor.rgb, this.outColor.a), that.featureUsed(FEATURE_ALPHABLEND) === 'additive' ? 0 : this.outColor.a);
|
|
626
|
+
}
|
|
627
|
+
output = !that.drawContext.oit || !that.drawContext.oit.outputFragmentColor(this, this.outColor);
|
|
628
|
+
}
|
|
629
|
+
if (output) {
|
|
630
|
+
ShaderHelper.applyFog(this, this.worldPos, this.outColor, that.drawContext);
|
|
631
|
+
this.$outputs.zFragmentOutput = ShaderHelper.encodeColorOutput(this, this.outColor);
|
|
632
|
+
}
|
|
633
|
+
} else if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_DEPTH) {
|
|
634
|
+
if (color) {
|
|
635
|
+
if (this.zAlphaCutoff) {
|
|
636
|
+
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
637
|
+
pb.discard();
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
642
|
+
const depthPass = that.drawContext.renderPass;
|
|
643
|
+
this.$l.depth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.$builtins.fragCoord.z);
|
|
644
|
+
if (depthPass.encodeDepth) {
|
|
645
|
+
this.$outputs.zFragmentOutput = encodeNormalizedFloatToRGBA(this, this.depth);
|
|
646
|
+
} else if (depthPass.renderBackface) {
|
|
647
|
+
this.$outputs.zFragmentOutput = pb.vec4(0, this.depth, 0, 1);
|
|
648
|
+
} else {
|
|
649
|
+
this.$outputs.zFragmentOutput = pb.vec4(this.depth, 0, 0, 1);
|
|
650
|
+
}
|
|
651
|
+
if (that.drawContext.motionVectors) {
|
|
652
|
+
if (that.featureUsed(FEATURE_DISABLE_TAA)) {
|
|
653
|
+
this.$outputs.zMotionVector = pb.vec4(6e4, 6e4, 1, 1);
|
|
654
|
+
} else {
|
|
655
|
+
if (this.$inputs.zMotionVectorPosCurrent && this.$inputs.zMotionVectorPosPrev) {
|
|
656
|
+
this.$outputs.zMotionVector = pb.vec4(pb.mul(pb.sub(pb.div(this.$inputs.zMotionVectorPosCurrent.xy, this.$inputs.zMotionVectorPosCurrent.w), pb.div(this.$inputs.zMotionVectorPosPrev.xy, this.$inputs.zMotionVectorPosPrev.w)), 0.5), this.zTAAStrength, 1);
|
|
657
|
+
} else {
|
|
658
|
+
this.$outputs.zMotionVector = pb.vec4(0, 0, 1, 1);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
} else if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
663
|
+
if (color) {
|
|
664
|
+
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
665
|
+
pb.discard();
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
669
|
+
this.$outputs.zFragmentOutput = that.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING ? scope.$inputs.zObjectColor : scope.zObjectColor;
|
|
670
|
+
if (that.drawContext.device.type === 'webgl') {
|
|
671
|
+
this.$l.linearDepth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.$builtins.fragCoord.z);
|
|
672
|
+
this.$outputs.zDistance = encodeNormalizedFloatToRGBA(this, this.linearDepth);
|
|
673
|
+
} else {
|
|
674
|
+
this.$outputs.zDistance = pb.vec4(this.worldPos, pb.distance(ShaderHelper.getCameraPosition(this), this.worldPos));
|
|
675
|
+
}
|
|
676
|
+
} else {
|
|
677
|
+
if (color) {
|
|
678
|
+
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
679
|
+
pb.discard();
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
683
|
+
const shadowMapParams = that.drawContext.shadowMapInfo.get(that.drawContext.renderPass.light);
|
|
684
|
+
this.$outputs.zFragmentOutput = shadowMapParams.impl.computeShadowMapDepth(shadowMapParams, this, this.worldPos);
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
if (color) {
|
|
688
|
+
pb.getGlobalScope()[funcName](worldPos, color);
|
|
689
|
+
} else {
|
|
690
|
+
pb.getGlobalScope()[funcName](worldPos);
|
|
691
|
+
}
|
|
692
|
+
if (that.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
693
|
+
scope.$outputs.zSSRRoughness = ssrRoughness ?? pb.vec4(1, 0, 0, 1);
|
|
694
|
+
scope.$outputs.zSSRNormal = ssrNormal ?? pb.vec4(0);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
FEATURE_ALPHATEST = MeshMaterial.defineFeature();
|
|
699
|
+
FEATURE_ALPHABLEND = MeshMaterial.defineFeature();
|
|
700
|
+
FEATURE_ALPHATOCOVERAGE = MeshMaterial.defineFeature();
|
|
701
|
+
FEATURE_DISABLE_TAA = MeshMaterial.defineFeature();
|
|
702
|
+
|
|
703
|
+
export { MeshMaterial, applyMaterialMixins };
|
|
704
|
+
//# sourceMappingURL=meshmaterial.js.map
|