@zephyr3d/scene 0.9.2 → 0.9.4
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 +135 -135
- package/dist/animation/animationset.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/joint_dynamics/controller.js +146 -146
- 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/spring/spring_system.js +75 -75
- 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/engine.js +119 -71
- package/dist/app/engine.js.map +1 -1
- package/dist/asset/assetmanager.js +296 -244
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/camera/camera.js +184 -184
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +685 -38
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +290 -290
- package/dist/material/material.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +123 -108
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +6 -3
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- 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/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +3 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +93 -93
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -3
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js +22 -22
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +29 -17
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +1 -0
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +8 -9
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -0
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shapes/torus.js +90 -59
- 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/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +143 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +47 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.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 +1275 -1091
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +505 -490
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.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 +55 -11
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +2 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +2 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +2 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +4 -4
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +1 -5
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"pbr.js","sources":["../../../src/shaders/pbr.ts"],"sourcesContent":["import type { PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\n\r\n/** @internal */\r\nexport function fresnelSchlick(\r\n scope: PBInsideFunctionScope,\r\n VdotH: PBShaderExp,\r\n f0: PBShaderExp,\r\n f90: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'fresnelSchlick';\r\n pb.func(funcName, [pb.float('VdotH'), pb.vec3('F0'), pb.vec3('F90')], function () {\r\n this.$return(\r\n pb.add(this.F0, pb.mul(pb.sub(this.F90, this.F0), pb.pow(pb.clamp(pb.sub(1, this.VdotH), 0, 1), 5)))\r\n );\r\n });\r\n return pb.getGlobalScope()[funcName](VdotH, f0, f90);\r\n}\r\n\r\n/** @internal */\r\nexport function distributionGGX(\r\n scope: PBInsideFunctionScope,\r\n NdotH: PBShaderExp,\r\n alphaRoughness: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'distributionGGX';\r\n pb.func(funcName, [pb.float('NdotH'), pb.float('roughness')], function () {\r\n this.$l.a2 = pb.mul(this.roughness, this.roughness);\r\n this.$l.NdotH2 = pb.mul(this.NdotH, this.NdotH);\r\n this.$l.num = this.a2;\r\n this.$l.denom = pb.add(pb.mul(this.NdotH2, pb.sub(this.a2, 1)), 1);\r\n this.denom = pb.mul(pb.mul(3.14159265, this.denom), this.denom);\r\n this.$return(pb.div(this.num, this.denom));\r\n });\r\n return pb.getGlobalScope()[funcName](NdotH, alphaRoughness);\r\n}\r\n\r\n/** @internal */\r\nexport function visGGX(\r\n scope: PBInsideFunctionScope,\r\n NdotV: PBShaderExp,\r\n NdotL: PBShaderExp,\r\n alphaRoughness: PBShaderExp\r\n): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'visGGX';\r\n pb.func(funcName, [pb.float('NdotV'), pb.float('NdotL'), pb.float('roughness')], function () {\r\n this.$l.a2 = pb.mul(this.roughness, this.roughness);\r\n this.$l.ggxV = pb.mul(\r\n this.NdotL,\r\n pb.sqrt(pb.add(pb.mul(this.NdotV, this.NdotV, pb.sub(1, this.a2)), this.a2))\r\n );\r\n this.$l.ggxL = pb.mul(\r\n this.NdotV,\r\n pb.sqrt(pb.add(pb.mul(this.NdotL, this.NdotL, pb.sub(1, this.a2)), this.a2))\r\n );\r\n this.$l.ggx = pb.add(this.ggxV, this.ggxL);\r\n this.$if(pb.greaterThan(this.ggx, 0), function () {\r\n this.$return(pb.div(0.5, this.ggx));\r\n }).$else(function () {\r\n this.$return(pb.float(0));\r\n });\r\n });\r\n return pb.getGlobalScope()[funcName](NdotV, NdotL, alphaRoughness);\r\n}\r\n"],"names":["fresnelSchlick","scope","VdotH","f0","f90","pb","$builder","funcName","func","float","vec3","$return","add","F0","mul","sub","F90","pow","clamp","getGlobalScope","distributionGGX","NdotH","alphaRoughness","$l","a2","roughness","NdotH2","num","denom","div","visGGX","NdotV","NdotL","ggxV","sqrt","ggxL","ggx","$if","greaterThan","$else"],"mappings":"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"}
|
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
import { hasDepthChannel } from '@zephyr3d/device';
|
|
2
|
+
import { Application } from '../app/app.js';
|
|
3
|
+
import { LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_POINT, LIGHT_TYPE_SPOT } from '../values.js';
|
|
4
|
+
import { encodeNormalizedFloatToRGBA, decode2HalfFromRGBA, decodeNormalizedFloatFromRGBA } from './misc.js';
|
|
5
|
+
import { ShaderHelper } from '../material/shader/helper.js';
|
|
6
|
+
import { interleavedGradientNoise } from './noise.js';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
const PCF_KERNEL_3x3 = [
|
|
10
|
+
[0.5, 1.0, 0.5],
|
|
11
|
+
[1.0, 1.0, 1.0],
|
|
12
|
+
[0.5, 1.0, 0.5]
|
|
13
|
+
];
|
|
14
|
+
const PCF_KERNEL_SUM_3x3 = 7;
|
|
15
|
+
|
|
16
|
+
const PCF_KERNEL_5x5 = [
|
|
17
|
+
[0.0, 0.5, 1.0, 0.5, 0.0],
|
|
18
|
+
[0.5, 1.0, 1.0, 1.0, 0.5],
|
|
19
|
+
[1.0, 1.0, 1.0, 1.0, 1.0],
|
|
20
|
+
[0.5, 1.0, 1.0, 1.0, 0.5],
|
|
21
|
+
[0.0, 0.5, 1.0, 0.5, 0.0]
|
|
22
|
+
];
|
|
23
|
+
const PCF_KERNEL_SUM_5x5 = 17;
|
|
24
|
+
|
|
25
|
+
const PCF_KERNEL_7x7 = [
|
|
26
|
+
[0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0],
|
|
27
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
28
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
29
|
+
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
|
|
30
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
31
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
32
|
+
[0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0]
|
|
33
|
+
];
|
|
34
|
+
const PCF_KERNEL_SUM_7x7 = 33;
|
|
35
|
+
|
|
36
|
+
const PCF_KERNEL_9x9 = [
|
|
37
|
+
[0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0],
|
|
38
|
+
[0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
|
|
39
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
40
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
41
|
+
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
|
|
42
|
+
[0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5],
|
|
43
|
+
[0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
|
|
44
|
+
[0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
|
|
45
|
+
[0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0]
|
|
46
|
+
];
|
|
47
|
+
const PCF_KERNEL_SUM_9x9 = 53;
|
|
48
|
+
*/ const PCF_POISSON_DISC = [
|
|
49
|
+
[
|
|
50
|
+
0.511749,
|
|
51
|
+
0.547686
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
0.58929,
|
|
55
|
+
0.257224
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
0.165018,
|
|
59
|
+
0.57663
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
0.407692,
|
|
63
|
+
0.742285
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
0.707012,
|
|
67
|
+
0.646523
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
0.31463,
|
|
71
|
+
0.466825
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
0.801257,
|
|
75
|
+
0.485186
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
0.418136,
|
|
79
|
+
0.146517
|
|
80
|
+
],
|
|
81
|
+
[
|
|
82
|
+
0.579889,
|
|
83
|
+
0.0368284
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
0.79801,
|
|
87
|
+
0.140114
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
-0.0413185,
|
|
91
|
+
0.371455
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
-0.0529108,
|
|
95
|
+
0.627352
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
0.0821375,
|
|
99
|
+
0.882071
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
0.17308,
|
|
103
|
+
0.301207
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
-0.120452,
|
|
107
|
+
0.867216
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
0.371096,
|
|
111
|
+
0.916454
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
-0.178381,
|
|
115
|
+
0.146101
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
-0.276489,
|
|
119
|
+
0.550525
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
0.12542,
|
|
123
|
+
0.126643
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
-0.296654,
|
|
127
|
+
0.286879
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
0.261744,
|
|
131
|
+
-604975e-8
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
-0.213417,
|
|
135
|
+
0.715776
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
0.425684,
|
|
139
|
+
-0.153211
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
-0.480054,
|
|
143
|
+
0.321357
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
-0.0717878,
|
|
147
|
+
-0.0250567
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
-0.328775,
|
|
151
|
+
-0.169666
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
-0.394923,
|
|
155
|
+
0.130802
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
-0.553681,
|
|
159
|
+
-0.176777
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
-0.722615,
|
|
163
|
+
0.120616
|
|
164
|
+
],
|
|
165
|
+
[
|
|
166
|
+
-0.693065,
|
|
167
|
+
0.309017
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
0.603193,
|
|
171
|
+
0.791471
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
-0.0754941,
|
|
175
|
+
-0.297988
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
0.109303,
|
|
179
|
+
-0.156472
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
0.260605,
|
|
183
|
+
-0.280111
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
0.129731,
|
|
187
|
+
-0.487954
|
|
188
|
+
],
|
|
189
|
+
[
|
|
190
|
+
-0.537315,
|
|
191
|
+
0.520494
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
-0.42758,
|
|
195
|
+
0.800607
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
0.77309,
|
|
199
|
+
-0.0728102
|
|
200
|
+
],
|
|
201
|
+
[
|
|
202
|
+
0.908777,
|
|
203
|
+
0.328356
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
0.985341,
|
|
207
|
+
0.0759158
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
0.947536,
|
|
211
|
+
-0.11837
|
|
212
|
+
],
|
|
213
|
+
[
|
|
214
|
+
-0.103315,
|
|
215
|
+
-0.610747
|
|
216
|
+
],
|
|
217
|
+
[
|
|
218
|
+
0.337171,
|
|
219
|
+
-0.584
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
0.210919,
|
|
223
|
+
-0.720055
|
|
224
|
+
],
|
|
225
|
+
[
|
|
226
|
+
0.41894,
|
|
227
|
+
-0.36769
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
-0.254228,
|
|
231
|
+
-0.49368
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
-0.428562,
|
|
235
|
+
-0.404037
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
-0.831732,
|
|
239
|
+
-0.189615
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
-0.922642,
|
|
243
|
+
0.0888026
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
-0.865914,
|
|
247
|
+
0.427795
|
|
248
|
+
],
|
|
249
|
+
[
|
|
250
|
+
0.706117,
|
|
251
|
+
-0.311662
|
|
252
|
+
],
|
|
253
|
+
[
|
|
254
|
+
0.545465,
|
|
255
|
+
-0.520942
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
-0.695738,
|
|
259
|
+
0.664492
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
0.389421,
|
|
263
|
+
-0.899007
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
0.48842,
|
|
267
|
+
-0.708054
|
|
268
|
+
],
|
|
269
|
+
[
|
|
270
|
+
0.760298,
|
|
271
|
+
-0.62735
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
-0.390788,
|
|
275
|
+
-0.707388
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
-0.591046,
|
|
279
|
+
-0.686721
|
|
280
|
+
],
|
|
281
|
+
[
|
|
282
|
+
-0.769903,
|
|
283
|
+
-0.413775
|
|
284
|
+
],
|
|
285
|
+
[
|
|
286
|
+
-0.604457,
|
|
287
|
+
-0.502571
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
-0.557234,
|
|
291
|
+
0.00451362
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
0.147572,
|
|
295
|
+
-0.924353
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
-0.0662488,
|
|
299
|
+
-0.892081
|
|
300
|
+
],
|
|
301
|
+
[
|
|
302
|
+
0.863832,
|
|
303
|
+
-0.4072
|
|
304
|
+
]
|
|
305
|
+
];
|
|
306
|
+
function getShadowMapTexelSize(scope) {
|
|
307
|
+
return scope.$builder.div(1, ShaderHelper.getShadowCameraParams(scope).z);
|
|
308
|
+
}
|
|
309
|
+
function getShadowMapSize(scope) {
|
|
310
|
+
return ShaderHelper.getShadowCameraParams(scope).z;
|
|
311
|
+
}
|
|
312
|
+
/** @internal */ function computeShadowMapDepth(scope, worldPos, targetFormat) {
|
|
313
|
+
const funcNameComputeShadowMapDepth = 'Z_computeShadowMapDepth';
|
|
314
|
+
const pb = scope.$builder;
|
|
315
|
+
pb.func(funcNameComputeShadowMapDepth, [
|
|
316
|
+
pb.vec3('worldPos')
|
|
317
|
+
], function() {
|
|
318
|
+
if (hasDepthChannel(targetFormat)) {
|
|
319
|
+
// use native shadowmap
|
|
320
|
+
this.$return(pb.vec4(pb.emulateDepthClamp ? pb.clamp(scope.$inputs.clamppedDepth, 0, 1) : scope.$builtins.fragCoord.z, 0, 0, 1));
|
|
321
|
+
} else {
|
|
322
|
+
this.$l.depth = pb.float();
|
|
323
|
+
this.$l.lightType = ShaderHelper.getLightTypeForShadow(this);
|
|
324
|
+
this.$if(pb.equal(this.lightType, LIGHT_TYPE_DIRECTIONAL), function() {
|
|
325
|
+
this.depth = pb.emulateDepthClamp ? pb.clamp(this.$inputs.clamppedDepth, 0, 1) : this.$builtins.fragCoord.z;
|
|
326
|
+
}).$elseif(pb.equal(this.lightType, LIGHT_TYPE_POINT), function() {
|
|
327
|
+
this.$l.lightSpacePos = pb.mul(ShaderHelper.getLightViewMatrixForShadow(this), pb.vec4(this.worldPos, 1));
|
|
328
|
+
this.depth = pb.clamp(pb.div(pb.length(this.lightSpacePos.xyz), ShaderHelper.getLightPositionAndRangeForShadow(this).w), 0, 1);
|
|
329
|
+
}).$else(function() {
|
|
330
|
+
this.$l.lightSpacePos = pb.mul(ShaderHelper.getLightViewMatrixForShadow(this), pb.vec4(this.worldPos, 1));
|
|
331
|
+
this.depth = pb.clamp(pb.div(pb.neg(this.lightSpacePos.z), ShaderHelper.getLightPositionAndRangeForShadow(this).w), 0, 1);
|
|
332
|
+
});
|
|
333
|
+
this.$return(targetFormat === 'rgba8unorm' ? encodeNormalizedFloatToRGBA(this, this.depth) : pb.vec4(this.depth, 0, 0, 1));
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
return pb.getGlobalScope()[funcNameComputeShadowMapDepth](worldPos);
|
|
337
|
+
}
|
|
338
|
+
/** @internal */ function computeReceiverPlaneDepthBias(scope, texCoord) {
|
|
339
|
+
const funcNameComputeReceiverPlaneDepthBias = 'lib_computeReceiverPlaneDepthBias';
|
|
340
|
+
const pb = scope.$builder;
|
|
341
|
+
pb.func(funcNameComputeReceiverPlaneDepthBias, [
|
|
342
|
+
pb.vec4('coords')
|
|
343
|
+
], function() {
|
|
344
|
+
this.$l.dx = pb.dpdx(this.coords);
|
|
345
|
+
this.$l.dy = pb.dpdy(this.coords);
|
|
346
|
+
this.$l.biasMultiply = pb.float(1);
|
|
347
|
+
this.$l.uv = pb.vec2(pb.sub(pb.mul(this.dy.y, this.dx.z), pb.mul(this.dx.y, this.dy.z)), pb.sub(pb.mul(this.dx.x, this.dy.z), pb.mul(this.dy.x, this.dx.z)));
|
|
348
|
+
this.$l.uv = pb.mul(this.$l.uv, pb.div(this.biasMultiply, pb.sub(pb.mul(this.dx.x, this.dy.y), pb.mul(this.dx.y, this.dy.x))));
|
|
349
|
+
// from unity shader
|
|
350
|
+
this.$l.minFractionalError = pb.float(0.01);
|
|
351
|
+
this.$l.fractionalSamplingError = pb.dot(pb.vec2(getShadowMapTexelSize(this)), pb.abs(this.$l.uv));
|
|
352
|
+
this.$l.staticBias = pb.min(this.$l.fractionalSamplingError, this.$l.minFractionalError);
|
|
353
|
+
// return
|
|
354
|
+
this.$return(pb.vec3(this.$l.uv, this.$l.staticBias));
|
|
355
|
+
});
|
|
356
|
+
return pb.getGlobalScope()[funcNameComputeReceiverPlaneDepthBias](texCoord);
|
|
357
|
+
}
|
|
358
|
+
function getRandomRotationMatrix(scope, fragCoord) {
|
|
359
|
+
const funcNameGetRandomRotationMatrix = 'lib_getRandomRotationMatrix';
|
|
360
|
+
const pb = scope.$builder;
|
|
361
|
+
pb.func(funcNameGetRandomRotationMatrix, [
|
|
362
|
+
pb.vec2('fragCoord')
|
|
363
|
+
], function() {
|
|
364
|
+
this.$l.randomAngle = pb.mul(interleavedGradientNoise(this, fragCoord), 2 * Math.PI);
|
|
365
|
+
this.$l.randomBase = pb.vec2(pb.cos(this.randomAngle), pb.sin(this.randomAngle));
|
|
366
|
+
this.$return(pb.mat2(this.randomBase.x, this.randomBase.y, pb.neg(this.randomBase.y), this.randomBase.x));
|
|
367
|
+
});
|
|
368
|
+
return pb.getGlobalScope()[funcNameGetRandomRotationMatrix](fragCoord);
|
|
369
|
+
}
|
|
370
|
+
function getPoissonDiscSampleRadius(scope) {
|
|
371
|
+
return ShaderHelper.getDepthBiasValues(scope).z;
|
|
372
|
+
}
|
|
373
|
+
function sampleShadowMapPCF(scope, shadowMapFormat, pos, offset, depth, cascade) {
|
|
374
|
+
const funcName = cascade ? 'lib_sampleShadowMapCascadePCF' : 'lib_sampleShadowMapPCF';
|
|
375
|
+
const pb = scope.$builder;
|
|
376
|
+
const nativeShadowMap = hasDepthChannel(shadowMapFormat);
|
|
377
|
+
pb.func(funcName, [
|
|
378
|
+
pb.vec2('coords'),
|
|
379
|
+
pb.float('z'),
|
|
380
|
+
pb.vec2('offset'),
|
|
381
|
+
...cascade ? [
|
|
382
|
+
pb.int('cascade')
|
|
383
|
+
] : []
|
|
384
|
+
], function() {
|
|
385
|
+
const sampleDepth = this.z;
|
|
386
|
+
const uv = pb.add(this.coords, this.offset);
|
|
387
|
+
if (nativeShadowMap) {
|
|
388
|
+
this.$return(cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), uv, this.cascade, sampleDepth) : pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), uv, sampleDepth));
|
|
389
|
+
} else {
|
|
390
|
+
this.$l.shadowTex = cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), uv, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), uv, 0);
|
|
391
|
+
if (shadowMapFormat === 'rgba8unorm') {
|
|
392
|
+
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
393
|
+
}
|
|
394
|
+
this.$return(pb.step(sampleDepth, this.shadowTex.x));
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
return pb.getGlobalScope()[funcName](pos, depth, offset, ...cascade ? [
|
|
398
|
+
cascade
|
|
399
|
+
] : []);
|
|
400
|
+
}
|
|
401
|
+
function sampleShadowMap(scope, lightType, shadowMapFormat, pos, depth, cascade) {
|
|
402
|
+
const funcNameSampleShadowMap = 'lib_sampleShadowMap';
|
|
403
|
+
const pb = scope.$builder;
|
|
404
|
+
const nativeShadowMap = hasDepthChannel(shadowMapFormat);
|
|
405
|
+
pb.func(funcNameSampleShadowMap, [
|
|
406
|
+
lightType === LIGHT_TYPE_POINT ? pb.vec3('coords') : pb.vec2('coords'),
|
|
407
|
+
pb.float('z'),
|
|
408
|
+
...cascade ? [
|
|
409
|
+
pb.int('cascade')
|
|
410
|
+
] : []
|
|
411
|
+
], function() {
|
|
412
|
+
if (lightType === LIGHT_TYPE_POINT) {
|
|
413
|
+
if (nativeShadowMap) {
|
|
414
|
+
this.$return(pb.clamp(pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, this.z), 0, 1));
|
|
415
|
+
} else {
|
|
416
|
+
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords, 0);
|
|
417
|
+
if (shadowMapFormat === 'rgba8unorm') {
|
|
418
|
+
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
419
|
+
}
|
|
420
|
+
this.$return(pb.step(this.z, this.shadowTex.x));
|
|
421
|
+
}
|
|
422
|
+
} else {
|
|
423
|
+
if (nativeShadowMap) {
|
|
424
|
+
this.$return(cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, this.cascade, this.z) : pb.textureSampleCompareLevel(ShaderHelper.getShadowMap(this), this.coords, this.z));
|
|
425
|
+
} else {
|
|
426
|
+
this.$l.shadowTex = cascade && Application.instance.device.type !== 'webgl' ? pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.coords, this.cascade, 0) : pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.coords, 0);
|
|
427
|
+
if (shadowMapFormat === 'rgba8unorm') {
|
|
428
|
+
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
429
|
+
}
|
|
430
|
+
this.$return(pb.step(this.z, this.shadowTex.x));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
return cascade ? pb.getGlobalScope()[funcNameSampleShadowMap](pos, depth, cascade) : pb.getGlobalScope()[funcNameSampleShadowMap](pos, depth);
|
|
435
|
+
}
|
|
436
|
+
function chebyshevUpperBound(scope, distance, occluder) {
|
|
437
|
+
const funcNameChebyshevUpperBound = 'lib_chebyshevUpperBound';
|
|
438
|
+
const pb = scope.$builder;
|
|
439
|
+
pb.func(funcNameChebyshevUpperBound, [
|
|
440
|
+
pb.float('distance'),
|
|
441
|
+
pb.vec2('occluder')
|
|
442
|
+
], function() {
|
|
443
|
+
this.$l.shadow = pb.float(1);
|
|
444
|
+
this.$l.test = pb.step(this.distance, this.occluder.x);
|
|
445
|
+
this.$if(pb.notEqual(this.test, 1), function() {
|
|
446
|
+
this.$l.d = pb.sub(this.distance, this.occluder.x);
|
|
447
|
+
this.$l.variance = pb.max(pb.mul(this.occluder.y, this.occluder.y), 0);
|
|
448
|
+
const darkness = ShaderHelper.getDepthBiasValues(this).z;
|
|
449
|
+
this.shadow = pb.div(this.variance, pb.add(this.variance, pb.mul(this.d, this.d)));
|
|
450
|
+
this.shadow = pb.clamp(pb.div(pb.sub(this.shadow, darkness), pb.sub(1, darkness)), 0, 1);
|
|
451
|
+
});
|
|
452
|
+
this.$return(this.shadow);
|
|
453
|
+
});
|
|
454
|
+
return pb.getGlobalScope()[funcNameChebyshevUpperBound](distance, occluder);
|
|
455
|
+
}
|
|
456
|
+
/** @internal */ function filterShadowVSM(scope, lightType, shadowMapFormat, texCoord, cascade) {
|
|
457
|
+
const funcNameFilterShadowVSM = 'lib_filterShadowVSM';
|
|
458
|
+
const pb = scope.$builder;
|
|
459
|
+
pb.func(funcNameFilterShadowVSM, [
|
|
460
|
+
pb.vec4('texCoord'),
|
|
461
|
+
...cascade ? [
|
|
462
|
+
pb.int('cascade')
|
|
463
|
+
] : []
|
|
464
|
+
], function() {
|
|
465
|
+
if (lightType === LIGHT_TYPE_POINT) {
|
|
466
|
+
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xyz, 0);
|
|
467
|
+
this.$return(chebyshevUpperBound(this, this.texCoord.w, shadowMapFormat === 'rgba8unorm' ? decode2HalfFromRGBA(this, this.shadowTex) : this.shadowTex.rg));
|
|
468
|
+
} else {
|
|
469
|
+
if (Application.instance.device.type !== 'webgl' && cascade) {
|
|
470
|
+
this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xy, this.cascade, 0);
|
|
471
|
+
} else {
|
|
472
|
+
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.texCoord.xy, 0);
|
|
473
|
+
}
|
|
474
|
+
this.$return(chebyshevUpperBound(this, this.texCoord.z, shadowMapFormat === 'rgba8unorm' ? decode2HalfFromRGBA(this, this.shadowTex) : this.shadowTex.rg));
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
return pb.getGlobalScope()[funcNameFilterShadowVSM](texCoord, ...cascade ? [
|
|
478
|
+
cascade
|
|
479
|
+
] : []);
|
|
480
|
+
}
|
|
481
|
+
/** @internal */ function filterShadowESM(scope, lightType, shadowMapFormat, shadowVertex, cascade) {
|
|
482
|
+
const funcNameFilterShadowESM = 'lib_filterShadowESM';
|
|
483
|
+
const pb = scope.$builder;
|
|
484
|
+
pb.func(funcNameFilterShadowESM, [
|
|
485
|
+
lightType === LIGHT_TYPE_POINT ? pb.vec3('shadowVertex') : pb.vec4('shadowVertex'),
|
|
486
|
+
...cascade ? [
|
|
487
|
+
pb.int('cascade')
|
|
488
|
+
] : []
|
|
489
|
+
], function() {
|
|
490
|
+
if (lightType === LIGHT_TYPE_POINT) {
|
|
491
|
+
this.$l.depth = pb.div(pb.length(this.shadowVertex.xyz), ShaderHelper.getLightPositionAndRangeForShadow(this).w);
|
|
492
|
+
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xyz, 0);
|
|
493
|
+
if (shadowMapFormat === 'rgba8unorm') {
|
|
494
|
+
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
495
|
+
}
|
|
496
|
+
} else {
|
|
497
|
+
if (cascade && Application.instance.device.type !== 'webgl') {
|
|
498
|
+
this.$l.shadowTex = pb.textureArraySampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xy, this.cascade, 0);
|
|
499
|
+
} else {
|
|
500
|
+
this.$l.shadowTex = pb.textureSampleLevel(ShaderHelper.getShadowMap(this), this.shadowVertex.xy, 0);
|
|
501
|
+
}
|
|
502
|
+
if (shadowMapFormat === 'rgba8unorm') {
|
|
503
|
+
this.shadowTex.x = decodeNormalizedFloatFromRGBA(this, this.shadowTex);
|
|
504
|
+
}
|
|
505
|
+
if (lightType === LIGHT_TYPE_SPOT) {
|
|
506
|
+
this.$l.nearFar = ShaderHelper.getShadowCameraParams(this).xy;
|
|
507
|
+
this.$l.depth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.shadowVertex.z, this.nearFar);
|
|
508
|
+
} else {
|
|
509
|
+
this.$l.depth = this.shadowVertex.z;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const depthScale = ShaderHelper.getDepthBiasValues(this).z;
|
|
513
|
+
this.$return(pb.clamp(pb.exp(pb.min(87, pb.mul(depthScale, pb.sub(this.shadowTex.x, this.depth)))), 0, 1));
|
|
514
|
+
});
|
|
515
|
+
return pb.getGlobalScope()[funcNameFilterShadowESM](shadowVertex, ...cascade ? [
|
|
516
|
+
cascade
|
|
517
|
+
] : []);
|
|
518
|
+
}
|
|
519
|
+
/** @internal */ function filterShadowPCF(scope, lightType, shadowMapFormat, kernelSize, texCoord, receiverPlaneDepthBias, cascade) {
|
|
520
|
+
const funcNameFilterShadowPCF = `lib_filterShadowPCF${kernelSize}x${kernelSize}`;
|
|
521
|
+
const pb = scope.$builder;
|
|
522
|
+
pb.func(funcNameFilterShadowPCF, [
|
|
523
|
+
pb.vec4('texCoord'),
|
|
524
|
+
...receiverPlaneDepthBias ? [
|
|
525
|
+
pb.vec3('receiverPlaneDepthBias')
|
|
526
|
+
] : [],
|
|
527
|
+
...cascade ? [
|
|
528
|
+
pb.int('cascade')
|
|
529
|
+
] : []
|
|
530
|
+
], function() {
|
|
531
|
+
this.$l.lightDepth = this.texCoord.z;
|
|
532
|
+
if (receiverPlaneDepthBias) {
|
|
533
|
+
this.lightDepth = pb.sub(this.lightDepth, this.receiverPlaneDepthBias.z);
|
|
534
|
+
}
|
|
535
|
+
const shadowMapTexelSize = getShadowMapTexelSize(this);
|
|
536
|
+
this.$l.uv = pb.add(pb.mul(this.texCoord.xy, pb.vec2(getShadowMapSize(this))), pb.vec2(0));
|
|
537
|
+
this.$l.st = pb.fract(this.uv);
|
|
538
|
+
this.$l.baseUV = pb.sub(pb.floor(this.uv), pb.vec2(0.5));
|
|
539
|
+
this.baseUV = pb.mul(this.baseUV, shadowMapTexelSize);
|
|
540
|
+
this.$l.shadow = pb.float(0);
|
|
541
|
+
if (kernelSize === 3) {
|
|
542
|
+
this.$l.uvw0 = pb.sub(pb.vec2(3), pb.mul(2, this.st));
|
|
543
|
+
this.$l.uvw1 = pb.add(pb.vec2(1), pb.mul(2, this.st));
|
|
544
|
+
this.$l.u = pb.mul(pb.vec2(pb.sub(pb.div(pb.sub(2, this.st.x), this.uvw0.x), 1), pb.add(pb.div(this.st.x, this.uvw1.x), 1)), shadowMapTexelSize);
|
|
545
|
+
this.$l.v = pb.mul(pb.vec2(pb.sub(pb.div(pb.sub(2, this.st.y), this.uvw0.y), 1), pb.add(pb.div(this.st.y, this.uvw1.y), 1)), shadowMapTexelSize);
|
|
546
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.x), this.lightDepth, this.cascade), this.uvw0.x, this.uvw0.y));
|
|
547
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.x), this.lightDepth, this.cascade), this.uvw1.x, this.uvw0.y));
|
|
548
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.y), this.lightDepth, this.cascade), this.uvw0.x, this.uvw1.y));
|
|
549
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.y), this.lightDepth, this.cascade), this.uvw1.x, this.uvw1.y));
|
|
550
|
+
this.shadow = pb.div(this.shadow, 16);
|
|
551
|
+
} else if (kernelSize === 5) {
|
|
552
|
+
this.$l.uvw0 = pb.sub(pb.vec2(4), pb.mul(this.st, 3));
|
|
553
|
+
this.$l.uvw1 = pb.vec2(7);
|
|
554
|
+
this.$l.uvw2 = pb.add(pb.vec2(1), pb.mul(this.st, 3));
|
|
555
|
+
this.$l.u = pb.mul(pb.vec3(pb.sub(pb.div(pb.sub(3, pb.mul(this.st.x, 2)), this.uvw0.x), 2), pb.div(pb.add(this.st.x, 3), this.uvw1.x), pb.add(pb.div(this.st.x, this.uvw2.x), 2)), shadowMapTexelSize);
|
|
556
|
+
this.$l.v = pb.mul(pb.vec3(pb.sub(pb.div(pb.sub(3, pb.mul(this.st.y, 2)), this.uvw0.y), 2), pb.div(pb.add(this.st.y, 3), this.uvw1.y), pb.add(pb.div(this.st.y, this.uvw2.y), 2)), shadowMapTexelSize);
|
|
557
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.x), this.lightDepth, this.cascade), this.uvw0.x, this.uvw0.y));
|
|
558
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.x), this.lightDepth, this.cascade), this.uvw1.x, this.uvw0.y));
|
|
559
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.z, this.v.x), this.lightDepth, this.cascade), this.uvw2.x, this.uvw0.y));
|
|
560
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.y), this.lightDepth, this.cascade), this.uvw0.x, this.uvw1.y));
|
|
561
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.y), this.lightDepth, this.cascade), this.uvw1.x, this.uvw1.y));
|
|
562
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.z, this.v.y), this.lightDepth, this.cascade), this.uvw2.x, this.uvw1.y));
|
|
563
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.x, this.v.z), this.lightDepth, this.cascade), this.uvw0.x, this.uvw2.y));
|
|
564
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.y, this.v.z), this.lightDepth, this.cascade), this.uvw1.x, this.uvw2.y));
|
|
565
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.vec2(this.u.z, this.v.z), this.lightDepth, this.cascade), this.uvw2.x, this.uvw2.y));
|
|
566
|
+
this.shadow = pb.div(this.shadow, 144);
|
|
567
|
+
} else if (kernelSize === 7) {
|
|
568
|
+
this.$l.uvw0 = pb.sub(pb.mul(this.st, 5), pb.vec2(6));
|
|
569
|
+
this.$l.uvw1 = pb.sub(pb.mul(this.st, 11), pb.vec2(28));
|
|
570
|
+
this.$l.uvw2 = pb.sub(pb.mul(this.st, -11), pb.vec2(17));
|
|
571
|
+
this.$l.uvw3 = pb.sub(pb.mul(this.st, -5), 1);
|
|
572
|
+
this.$l.u = pb.vec4(pb.sub(pb.div(pb.sub(pb.mul(this.st.x, 4), 5), this.uvw0.x), 3), pb.sub(pb.div(pb.sub(pb.mul(this.st.x, 4), 16), this.uvw1.x), 1), pb.add(pb.div(pb.sub(pb.mul(this.st.x, -7), 5), this.uvw2.x), 1), pb.add(pb.div(pb.neg(this.st.x), this.uvw3.x), 3));
|
|
573
|
+
this.$l.v = pb.vec4(pb.sub(pb.div(pb.sub(pb.mul(this.st.y, 4), 5), this.uvw0.y), 3), pb.sub(pb.div(pb.sub(pb.mul(this.st.y, 4), 16), this.uvw1.y), 1), pb.add(pb.div(pb.sub(pb.mul(this.st.y, -7), 5), this.uvw2.y), 1), pb.add(pb.div(pb.neg(this.st.y), this.uvw3.y), 3));
|
|
574
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw0.y));
|
|
575
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw0.y));
|
|
576
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw0.y));
|
|
577
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.x), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw0.y));
|
|
578
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw1.y));
|
|
579
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw1.y));
|
|
580
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw1.y));
|
|
581
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.y), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw1.y));
|
|
582
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw2.y));
|
|
583
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw2.y));
|
|
584
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw2.y));
|
|
585
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.z), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw2.y));
|
|
586
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.x, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw0.x, this.uvw3.y));
|
|
587
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.y, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw1.x, this.uvw3.y));
|
|
588
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.z, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw2.x, this.uvw3.y));
|
|
589
|
+
this.shadow = pb.add(this.shadow, pb.mul(sampleShadowMapPCF(this, shadowMapFormat, this.baseUV, pb.mul(pb.vec2(this.u.w, this.v.w), shadowMapTexelSize), this.lightDepth, this.cascade), this.uvw3.x, this.uvw3.y));
|
|
590
|
+
this.shadow = pb.div(this.shadow, 2704);
|
|
591
|
+
}
|
|
592
|
+
this.$return(this.shadow);
|
|
593
|
+
});
|
|
594
|
+
return pb.getGlobalScope()[funcNameFilterShadowPCF](texCoord, ...receiverPlaneDepthBias ? [
|
|
595
|
+
receiverPlaneDepthBias
|
|
596
|
+
] : [], ...cascade ? [
|
|
597
|
+
cascade
|
|
598
|
+
] : []);
|
|
599
|
+
}
|
|
600
|
+
/** @internal */ function filterShadowPoissonDisc(scope, lightType, shadowMapFormat, tapCount, texCoord, receiverPlaneDepthBias, cascade) {
|
|
601
|
+
const funcNameFilterShadowPoissonDisc = 'lib_filterShadowPoissonDisc';
|
|
602
|
+
const pb = scope.$builder;
|
|
603
|
+
pb.func(funcNameFilterShadowPoissonDisc, [
|
|
604
|
+
pb.vec4('texCoord'),
|
|
605
|
+
...receiverPlaneDepthBias ? [
|
|
606
|
+
pb.vec3('receiverPlaneDepthBias')
|
|
607
|
+
] : [],
|
|
608
|
+
...cascade ? [
|
|
609
|
+
pb.int('cascade')
|
|
610
|
+
] : []
|
|
611
|
+
], function() {
|
|
612
|
+
this.$l.lightDepth = this.texCoord.z;
|
|
613
|
+
if (receiverPlaneDepthBias) {
|
|
614
|
+
this.lightDepth = pb.sub(this.lightDepth, this.receiverPlaneDepthBias.z);
|
|
615
|
+
}
|
|
616
|
+
this.$l.duv = pb.vec2();
|
|
617
|
+
this.$l.filterRadius = pb.mul(getShadowMapTexelSize(this), getPoissonDiscSampleRadius(this));
|
|
618
|
+
this.$l.matrix = getRandomRotationMatrix(this, this.$builtins.fragCoord.xy);
|
|
619
|
+
this.$l.shadow = pb.float(0);
|
|
620
|
+
for(let i = 0; i < tapCount; i++){
|
|
621
|
+
this.duv = pb.mul(this.matrix, pb.mul(pb.vec2(PCF_POISSON_DISC[i][0], PCF_POISSON_DISC[i][1]), this.filterRadius));
|
|
622
|
+
const sampleDepth = receiverPlaneDepthBias ? pb.add(this.lightDepth, pb.dot(this.duv, this.receiverPlaneDepthBias.xy)) : this.lightDepth;
|
|
623
|
+
this.shadow = pb.add(this.shadow, sampleShadowMap(this, lightType, shadowMapFormat, pb.add(this.texCoord.xy, this.duv), sampleDepth, this.cascade));
|
|
624
|
+
}
|
|
625
|
+
this.shadow = pb.div(this.shadow, tapCount);
|
|
626
|
+
this.$return(this.shadow);
|
|
627
|
+
});
|
|
628
|
+
return pb.getGlobalScope()[funcNameFilterShadowPoissonDisc](texCoord, ...receiverPlaneDepthBias ? [
|
|
629
|
+
receiverPlaneDepthBias
|
|
630
|
+
] : [], ...cascade ? [
|
|
631
|
+
cascade
|
|
632
|
+
] : []);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export { computeReceiverPlaneDepthBias, computeShadowMapDepth, filterShadowESM, filterShadowPCF, filterShadowPoissonDisc, filterShadowVSM };
|
|
636
|
+
//# sourceMappingURL=shadow.js.map
|