@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,489 @@
|
|
|
1
|
+
import { AbstractPostEffect, PostEffectLayer } from './posteffect.js';
|
|
2
|
+
import { linearToGamma } from '../shaders/misc.js';
|
|
3
|
+
import { SSR_calcJitter, screenSpaceRayTracing_HiZ, screenSpaceRayTracing_Linear2D } from '../shaders/ssr.js';
|
|
4
|
+
import { Vector2, Vector4, Matrix4x4 } from '@zephyr3d/base';
|
|
5
|
+
import { fetchSampler, copyTexture } from '../utility/misc.js';
|
|
6
|
+
import { BilateralBlurBlitter } from '../blitter/bilateralblur.js';
|
|
7
|
+
import { ShaderHelper } from '../material/shader/helper.js';
|
|
8
|
+
import '../material/lambert.js';
|
|
9
|
+
import '../material/blinn.js';
|
|
10
|
+
import '../material/unlit.js';
|
|
11
|
+
import '../material/particle.js';
|
|
12
|
+
import '@zephyr3d/device';
|
|
13
|
+
import '../values.js';
|
|
14
|
+
import '../material/meshmaterial.js';
|
|
15
|
+
import '../material/grassmaterial.js';
|
|
16
|
+
import '../material/terrainmaterial.js';
|
|
17
|
+
import '../material/terrain-cm.js';
|
|
18
|
+
import '../material/pbrmr.js';
|
|
19
|
+
import '../material/pbrsg.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* SSR post effect
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Internal used in light pass
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/ class SSR extends AbstractPostEffect {
|
|
29
|
+
static _programs = {};
|
|
30
|
+
static _resolveProgram = {};
|
|
31
|
+
static _combineProgram = undefined;
|
|
32
|
+
static _blurBlitterH = null;
|
|
33
|
+
static _blurBlitterV = null;
|
|
34
|
+
_bindgroups;
|
|
35
|
+
_resolveBindGroup;
|
|
36
|
+
_combineBindGroup;
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of SSR post effect
|
|
39
|
+
*/ constructor(){
|
|
40
|
+
super();
|
|
41
|
+
this._layer = PostEffectLayer.opaque;
|
|
42
|
+
this._bindgroups = {};
|
|
43
|
+
this._resolveBindGroup = {};
|
|
44
|
+
this._combineBindGroup = null;
|
|
45
|
+
}
|
|
46
|
+
/** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */ requireLinearDepthTexture() {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/** {@inheritDoc AbstractPostEffect.requireDepthAttachment} */ requireDepthAttachment() {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/** @internal */ blurPass(ctx, blitter, blurSizeTex, blurSizeIndex, blurSizeScale, kernelRadius, stdDev, depthCutoff, fbFrom, fbTo) {
|
|
53
|
+
const size = new Vector2(fbFrom.getWidth(), fbFrom.getHeight());
|
|
54
|
+
blitter.kernelRadius = kernelRadius;
|
|
55
|
+
blitter.stdDev = stdDev;
|
|
56
|
+
blitter.size = size;
|
|
57
|
+
blitter.depthTex = ctx.linearDepthTexture;
|
|
58
|
+
blitter.depthCutoff = depthCutoff;
|
|
59
|
+
blitter.blurSizeTex = blurSizeTex;
|
|
60
|
+
blitter.blurSizeIndex = blurSizeIndex;
|
|
61
|
+
blitter.blurSizeScale = blurSizeScale;
|
|
62
|
+
blitter.sampler = fetchSampler('clamp_nearest_nomip');
|
|
63
|
+
blitter.cameraNearFar.setXY(ctx.camera.getNearPlane(), ctx.camera.getFarPlane());
|
|
64
|
+
blitter.srgbOut = false;
|
|
65
|
+
blitter.blit(fbFrom.getColorAttachments()[0], fbTo, fetchSampler('clamp_linear_nomip'));
|
|
66
|
+
}
|
|
67
|
+
/** @internal */ combine(ctx, inputColorTexture, reflectanceTex, srgbOut) {
|
|
68
|
+
const device = ctx.device;
|
|
69
|
+
let program = SSR._combineProgram;
|
|
70
|
+
if (program === undefined) {
|
|
71
|
+
program = this._createCombineProgrm(ctx);
|
|
72
|
+
SSR._combineProgram = program;
|
|
73
|
+
}
|
|
74
|
+
if (!this._combineBindGroup) {
|
|
75
|
+
this._combineBindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
|
|
76
|
+
}
|
|
77
|
+
const linearSampler = fetchSampler('clamp_linear');
|
|
78
|
+
this._combineBindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
|
|
79
|
+
this._combineBindGroup.setTexture('reflectanceTex', reflectanceTex, linearSampler);
|
|
80
|
+
this._combineBindGroup.setTexture('roughnessTex', ctx.SSRRoughnessTexture, linearSampler);
|
|
81
|
+
this._combineBindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
|
|
82
|
+
this._combineBindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), device.getDrawingBufferWidth(), device.getDrawingBufferHeight()));
|
|
83
|
+
this._combineBindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
84
|
+
this._combineBindGroup.setValue('srgbOut', srgbOut ? 1 : 0);
|
|
85
|
+
device.setProgram(program);
|
|
86
|
+
device.setBindGroup(0, this._combineBindGroup);
|
|
87
|
+
this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
|
|
88
|
+
}
|
|
89
|
+
/** @internal */ resolve(ctx, inputColorTexture, sceneDepthTexture, intersectTexture) {
|
|
90
|
+
const device = ctx.device;
|
|
91
|
+
const hash = ctx.env.light.envLight ? ctx.env.light.getHash() : '';
|
|
92
|
+
let program = SSR._resolveProgram[hash];
|
|
93
|
+
if (program === undefined) {
|
|
94
|
+
program = this._createResolveProgram(ctx);
|
|
95
|
+
SSR._resolveProgram[hash] = program;
|
|
96
|
+
}
|
|
97
|
+
let bindGroup = this._resolveBindGroup[hash];
|
|
98
|
+
if (!bindGroup) {
|
|
99
|
+
bindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
|
|
100
|
+
this._resolveBindGroup[hash] = bindGroup;
|
|
101
|
+
}
|
|
102
|
+
const nearestSampler = fetchSampler('clamp_nearest');
|
|
103
|
+
const linearSampler = fetchSampler('clamp_linear');
|
|
104
|
+
bindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
|
|
105
|
+
bindGroup.setTexture('intersectTex', intersectTexture, nearestSampler);
|
|
106
|
+
bindGroup.setTexture('roughnessTex', ctx.SSRRoughnessTexture, nearestSampler);
|
|
107
|
+
bindGroup.setTexture('normalTex', ctx.SSRNormalTexture, nearestSampler);
|
|
108
|
+
bindGroup.setTexture('depthTex', sceneDepthTexture, nearestSampler);
|
|
109
|
+
bindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
|
|
110
|
+
bindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
|
|
111
|
+
bindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), sceneDepthTexture.width, sceneDepthTexture.height));
|
|
112
|
+
bindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
|
|
113
|
+
bindGroup.setValue('viewMatrix', ctx.camera.viewMatrix);
|
|
114
|
+
bindGroup.setValue('invViewMatrix', ctx.camera.worldMatrix);
|
|
115
|
+
if (ctx.env.light.envLight) {
|
|
116
|
+
bindGroup.setValue('envLightStrength', ctx.env.light.strength);
|
|
117
|
+
ctx.env.light.envLight.updateBindGroup(bindGroup);
|
|
118
|
+
}
|
|
119
|
+
bindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
120
|
+
device.setProgram(program);
|
|
121
|
+
device.setBindGroup(0, bindGroup);
|
|
122
|
+
this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
|
|
123
|
+
}
|
|
124
|
+
/** @internal */ intersect(ctx, inputColorTexture, sceneDepthTexture, blur, srgbOut) {
|
|
125
|
+
const device = ctx.device;
|
|
126
|
+
const hash = `${Number(blur)}:${ctx.env.light.envLight ? ctx.env.light.getHash() : ''}:${!!ctx.HiZTexture}:${!!ctx.primaryCamera.ssrCalcThickness}`;
|
|
127
|
+
let program = SSR._programs[hash];
|
|
128
|
+
if (program === undefined) {
|
|
129
|
+
program = this._createIntersectProgram(ctx, blur);
|
|
130
|
+
SSR._programs[hash] = program;
|
|
131
|
+
}
|
|
132
|
+
let bindGroup = this._bindgroups[hash];
|
|
133
|
+
if (!bindGroup) {
|
|
134
|
+
bindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
|
|
135
|
+
this._bindgroups[hash] = bindGroup;
|
|
136
|
+
}
|
|
137
|
+
const nearestSampler = fetchSampler('clamp_nearest');
|
|
138
|
+
const linearSampler = fetchSampler('clamp_linear');
|
|
139
|
+
if (!blur) {
|
|
140
|
+
bindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
|
|
141
|
+
if (ctx.env.light.envLight) {
|
|
142
|
+
bindGroup.setValue('envLightStrength', ctx.env.light.strength);
|
|
143
|
+
ctx.env.light.envLight.updateBindGroup(bindGroup);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
bindGroup.setTexture('roughnessTex', ctx.SSRRoughnessTexture, nearestSampler);
|
|
147
|
+
bindGroup.setTexture('normalTex', ctx.SSRNormalTexture, nearestSampler);
|
|
148
|
+
bindGroup.setTexture('depthTex', sceneDepthTexture, nearestSampler);
|
|
149
|
+
bindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
|
|
150
|
+
bindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
|
|
151
|
+
bindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
|
|
152
|
+
bindGroup.setValue('projMatrix', ctx.camera.getProjectionMatrix());
|
|
153
|
+
bindGroup.setValue('viewMatrix', ctx.camera.viewMatrix);
|
|
154
|
+
bindGroup.setValue('invViewMatrix', ctx.camera.worldMatrix);
|
|
155
|
+
bindGroup.setValue('ssrParams', ctx.camera.ssrParams);
|
|
156
|
+
bindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
|
|
157
|
+
if (ctx.HiZTexture) {
|
|
158
|
+
bindGroup.setTexture('hizTex', ctx.HiZTexture, nearestSampler);
|
|
159
|
+
bindGroup.setValue('depthMipLevels', ctx.HiZTexture.mipLevelCount);
|
|
160
|
+
bindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), ctx.HiZTexture.width, ctx.HiZTexture.height));
|
|
161
|
+
} else {
|
|
162
|
+
bindGroup.setValue('ssrStride', ctx.camera.ssrStride);
|
|
163
|
+
bindGroup.setValue('targetSize', new Vector4(device.getDrawingBufferWidth(), device.getDrawingBufferHeight(), sceneDepthTexture.width, sceneDepthTexture.height));
|
|
164
|
+
}
|
|
165
|
+
bindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
166
|
+
bindGroup.setValue('srgbOut', srgbOut ? 1 : 0);
|
|
167
|
+
device.setProgram(program);
|
|
168
|
+
device.setBindGroup(0, bindGroup);
|
|
169
|
+
this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
|
|
170
|
+
}
|
|
171
|
+
/** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
|
|
172
|
+
const device = ctx.device;
|
|
173
|
+
device.pushDeviceStates();
|
|
174
|
+
copyTexture(inputColorTexture, device.getFramebuffer(), fetchSampler('clamp_nearest_nomip'), AbstractPostEffect.getDefaultRenderState(ctx, 'eq'));
|
|
175
|
+
const intersectFramebuffer = device.pool.fetchTemporalFramebuffer(false, inputColorTexture.width, inputColorTexture.height, 'rgba16f', ctx.depthTexture, false);
|
|
176
|
+
const pingpongFramebuffer = [
|
|
177
|
+
device.pool.fetchTemporalFramebuffer(false, inputColorTexture.width, inputColorTexture.height, 'rgba16f', ctx.depthTexture, false),
|
|
178
|
+
device.pool.fetchTemporalFramebuffer(false, inputColorTexture.width, inputColorTexture.height, 'rgba16f', ctx.depthTexture, false)
|
|
179
|
+
];
|
|
180
|
+
device.setFramebuffer(intersectFramebuffer);
|
|
181
|
+
this.intersect(ctx, inputColorTexture, sceneDepthTexture, true, false);
|
|
182
|
+
const intersectTex = intersectFramebuffer.getColorAttachments()[0];
|
|
183
|
+
device.setFramebuffer(pingpongFramebuffer[0]);
|
|
184
|
+
this.resolve(ctx, inputColorTexture, sceneDepthTexture, intersectTex);
|
|
185
|
+
if (ctx.camera.ssrBlurScale > 0 && ctx.camera.ssrBlurKernelSize > 0) {
|
|
186
|
+
const blurSizeScale = 255 * ctx.camera.ssrBlurScale;
|
|
187
|
+
const kernelRadius = Math.max(1, ctx.camera.ssrBlurKernelSize >> 0) - 1 >> 1;
|
|
188
|
+
const stdDev = ctx.camera.ssrBlurStdDev;
|
|
189
|
+
const depthCutoff = ctx.camera.ssrBlurDepthCutoff;
|
|
190
|
+
const blitterH = SSR._blurBlitterH = SSR._blurBlitterH ?? new BilateralBlurBlitter(false);
|
|
191
|
+
blitterH.renderStates = AbstractPostEffect.getDefaultRenderState(ctx, 'gt');
|
|
192
|
+
this.blurPass(ctx, blitterH, intersectTex, 2, blurSizeScale, kernelRadius, stdDev, depthCutoff, pingpongFramebuffer[0], pingpongFramebuffer[1]);
|
|
193
|
+
const blitterV = SSR._blurBlitterV = SSR._blurBlitterV ?? new BilateralBlurBlitter(true);
|
|
194
|
+
blitterV.renderStates = AbstractPostEffect.getDefaultRenderState(ctx, 'gt');
|
|
195
|
+
this.blurPass(ctx, blitterV, intersectTex, 2, blurSizeScale, kernelRadius, stdDev, depthCutoff, pingpongFramebuffer[1], pingpongFramebuffer[0]);
|
|
196
|
+
}
|
|
197
|
+
device.popDeviceStates();
|
|
198
|
+
this.combine(ctx, inputColorTexture, pingpongFramebuffer[0].getColorAttachments()[0], srgbOutput);
|
|
199
|
+
device.pool.releaseFrameBuffer(intersectFramebuffer);
|
|
200
|
+
device.pool.releaseFrameBuffer(pingpongFramebuffer[0]);
|
|
201
|
+
device.pool.releaseFrameBuffer(pingpongFramebuffer[1]);
|
|
202
|
+
}
|
|
203
|
+
/** @internal */ _createCombineProgrm(ctx) {
|
|
204
|
+
return ctx.device.buildRenderProgram({
|
|
205
|
+
vertex (pb) {
|
|
206
|
+
this.flip = pb.int().uniform(0);
|
|
207
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
208
|
+
this.$outputs.uv = pb.vec2();
|
|
209
|
+
pb.main(function() {
|
|
210
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 1, 1);
|
|
211
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
212
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
213
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
fragment (pb) {
|
|
218
|
+
this.colorTex = pb.tex2D().uniform(0);
|
|
219
|
+
this.reflectanceTex = pb.tex2D().uniform(0);
|
|
220
|
+
this.roughnessTex = pb.tex2D().uniform(0);
|
|
221
|
+
this.targetSize = pb.vec4().uniform(0);
|
|
222
|
+
this.ssrMaxRoughness = pb.float().uniform(0);
|
|
223
|
+
this.srgbOut = pb.int().uniform(0);
|
|
224
|
+
this.$outputs.outColor = pb.vec4();
|
|
225
|
+
pb.func('resolveSample', [
|
|
226
|
+
pb.vec3('sceneColor'),
|
|
227
|
+
pb.vec3('reflectance'),
|
|
228
|
+
pb.vec4('roughnessValue')
|
|
229
|
+
], function() {
|
|
230
|
+
this.$l.r = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
|
|
231
|
+
this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
232
|
+
this.color = pb.add(pb.mul(this.r, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
233
|
+
this.$return(this.color);
|
|
234
|
+
});
|
|
235
|
+
pb.main(function() {
|
|
236
|
+
this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
|
|
237
|
+
this.$l.sceneColor = pb.textureSampleLevel(this.colorTex, this.screenUV, 0).rgb;
|
|
238
|
+
this.$l.roughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
|
|
239
|
+
this.$l.combined = pb.vec3();
|
|
240
|
+
this.$if(pb.greaterThanEqual(this.roughnessInfo.a, this.ssrMaxRoughness), function() {
|
|
241
|
+
this.combined = this.sceneColor;
|
|
242
|
+
}).$else(function() {
|
|
243
|
+
this.$l.reflectance = pb.textureSampleLevel(this.reflectanceTex, this.screenUV, 0).rgb;
|
|
244
|
+
this.combined = this.resolveSample(this.sceneColor, this.reflectance, this.roughnessInfo);
|
|
245
|
+
});
|
|
246
|
+
this.$if(pb.equal(this.srgbOut, 0), function() {
|
|
247
|
+
this.$outputs.outColor = pb.vec4(this.combined, 1);
|
|
248
|
+
}).$else(function() {
|
|
249
|
+
this.$outputs.outColor = pb.vec4(linearToGamma(this, this.combined), 1);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
/** @internal */ _createResolveProgram(ctx) {
|
|
256
|
+
return ctx.device.buildRenderProgram({
|
|
257
|
+
vertex (pb) {
|
|
258
|
+
this.flip = pb.int().uniform(0);
|
|
259
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
260
|
+
this.$outputs.uv = pb.vec2();
|
|
261
|
+
if (ctx.env.light.envLight) {
|
|
262
|
+
ctx.env.light.envLight.initShaderBindings(pb);
|
|
263
|
+
}
|
|
264
|
+
pb.main(function() {
|
|
265
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 1, 1);
|
|
266
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
267
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
268
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
fragment (pb) {
|
|
273
|
+
this.colorTex = pb.tex2D().uniform(0);
|
|
274
|
+
this.intersectTex = pb.tex2D().uniform(0);
|
|
275
|
+
this.roughnessTex = pb.tex2D().uniform(0);
|
|
276
|
+
this.normalTex = pb.tex2D().uniform(0);
|
|
277
|
+
this.depthTex = pb.tex2D().uniform(0);
|
|
278
|
+
this.cameraNearFar = pb.vec2().uniform(0);
|
|
279
|
+
this.targetSize = pb.vec4().uniform(0);
|
|
280
|
+
this.viewMatrix = pb.mat4().uniform(0);
|
|
281
|
+
this.invViewMatrix = pb.mat4().uniform(0);
|
|
282
|
+
this.invProjMatrix = pb.mat4().uniform(0);
|
|
283
|
+
this.ssrMaxRoughness = pb.float().uniform(0);
|
|
284
|
+
if (ctx.env.light.envLight) {
|
|
285
|
+
this.envLightStrength = pb.float().uniform(0);
|
|
286
|
+
ctx.env.light.envLight.initShaderBindings(pb);
|
|
287
|
+
}
|
|
288
|
+
this.$outputs.outColor = pb.vec4();
|
|
289
|
+
pb.func('getPosition', [
|
|
290
|
+
pb.vec2('uv'),
|
|
291
|
+
pb.mat4('mat')
|
|
292
|
+
], function() {
|
|
293
|
+
this.$l.linearDepth = ShaderHelper.sampleLinearDepth(this, this.depthTex, this.uv, 0);
|
|
294
|
+
this.$l.nonLinearDepth = pb.div(pb.sub(pb.div(this.cameraNearFar.x, this.linearDepth), this.cameraNearFar.y), pb.sub(this.cameraNearFar.x, this.cameraNearFar.y));
|
|
295
|
+
this.$l.clipSpacePos = pb.vec4(pb.sub(pb.mul(this.uv, 2), pb.vec2(1)), pb.sub(pb.mul(pb.clamp(this.nonLinearDepth, 0, 1), 2), 1), 1);
|
|
296
|
+
this.$l.wPos = pb.mul(this.mat, this.clipSpacePos);
|
|
297
|
+
this.$return(pb.vec4(pb.div(this.wPos.xyz, this.wPos.w), this.linearDepth));
|
|
298
|
+
});
|
|
299
|
+
pb.func('resolveSample', [
|
|
300
|
+
pb.vec3('sceneColor'),
|
|
301
|
+
pb.vec3('reflectance'),
|
|
302
|
+
pb.vec4('roughnessValue')
|
|
303
|
+
], function() {
|
|
304
|
+
this.$l.r = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
|
|
305
|
+
this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
306
|
+
this.color = pb.add(pb.mul(this.r, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
307
|
+
this.$return(this.color);
|
|
308
|
+
});
|
|
309
|
+
pb.func('resolveEnvRadiance', [
|
|
310
|
+
pb.vec2('uv'),
|
|
311
|
+
pb.vec4('roughnessInfo')
|
|
312
|
+
], function() {
|
|
313
|
+
if (!ctx.env.light.envLight) {
|
|
314
|
+
this.$return(pb.vec3(0));
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
this.$l.pos = this.getPosition(this.uv, this.invProjMatrix);
|
|
318
|
+
this.$if(pb.greaterThanEqual(this.pos.w, 1), function() {
|
|
319
|
+
this.$return(pb.vec3(0));
|
|
320
|
+
});
|
|
321
|
+
this.$l.roughness = this.roughnessInfo.a;
|
|
322
|
+
this.$l.viewPos = this.pos.xyz;
|
|
323
|
+
this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
|
|
324
|
+
this.$l.viewVec = pb.normalize(this.viewPos);
|
|
325
|
+
this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
|
|
326
|
+
this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
|
|
327
|
+
this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
|
|
328
|
+
this.$l.roughness2 = pb.float(0);
|
|
329
|
+
this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness2), this.envLightStrength);
|
|
330
|
+
this.$return(pb.min(this.env, pb.vec3(1)));
|
|
331
|
+
});
|
|
332
|
+
pb.func('resolveReflectance', [
|
|
333
|
+
pb.vec2('uv'),
|
|
334
|
+
pb.vec3('reflectSceneColor'),
|
|
335
|
+
pb.vec4('roughnessInfo'),
|
|
336
|
+
pb.float('alpha')
|
|
337
|
+
], function() {
|
|
338
|
+
this.$l.env = this.resolveEnvRadiance(this.uv, this.roughnessInfo);
|
|
339
|
+
this.$l.reflectance = pb.mix(this.env, this.reflectSceneColor, this.alpha);
|
|
340
|
+
this.$return(this.reflectance);
|
|
341
|
+
});
|
|
342
|
+
pb.main(function() {
|
|
343
|
+
this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
|
|
344
|
+
this.$l.roughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
|
|
345
|
+
this.$if(pb.greaterThanEqual(this.roughnessInfo.a, this.ssrMaxRoughness), function() {
|
|
346
|
+
pb.discard();
|
|
347
|
+
});
|
|
348
|
+
this.$l.intersectSample = pb.textureSampleLevel(this.intersectTex, this.screenUV, 0);
|
|
349
|
+
this.$l.reflectance = pb.vec3();
|
|
350
|
+
this.$if(pb.greaterThan(this.intersectSample.w, 0), function() {
|
|
351
|
+
this.$l.indirectIntersectSample = pb.textureSampleLevel(this.intersectTex, this.intersectSample.xy, 0);
|
|
352
|
+
this.$l.indirectRoughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.intersectSample.xy, 0);
|
|
353
|
+
this.$l.indirectReflectance = pb.vec3();
|
|
354
|
+
this.$if(pb.greaterThan(this.indirectIntersectSample.w, 0), function() {
|
|
355
|
+
this.$l.indirectReflectSceneColor = pb.textureSampleLevel(this.colorTex, this.indirectIntersectSample.xy, 0).rgb;
|
|
356
|
+
this.indirectReflectance = this.resolveReflectance(this.intersectSample.xy, this.indirectReflectSceneColor, this.indirectRoughnessInfo, this.indirectIntersectSample.w);
|
|
357
|
+
}).$else(function() {
|
|
358
|
+
this.indirectReflectance = this.resolveEnvRadiance(this.intersectSample.xy, this.indirectRoughnessInfo);
|
|
359
|
+
});
|
|
360
|
+
this.$l.reflectSceneColor = pb.textureSampleLevel(this.colorTex, this.intersectSample.xy, 0).rgb;
|
|
361
|
+
this.$l.reflectSceneColor = this.resolveSample(this.reflectSceneColor, this.indirectReflectance, this.indirectRoughnessInfo);
|
|
362
|
+
this.reflectance = this.resolveReflectance(this.screenUV, this.reflectSceneColor, this.roughnessInfo, this.intersectSample.w);
|
|
363
|
+
}).$else(function() {
|
|
364
|
+
this.reflectance = this.resolveEnvRadiance(this.screenUV, this.roughnessInfo);
|
|
365
|
+
});
|
|
366
|
+
this.$outputs.outColor = pb.vec4(this.reflectance, this.intersectSample.z);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
/** @internal */ _createIntersectProgram(ctx, blur) {
|
|
372
|
+
return ctx.device.buildRenderProgram({
|
|
373
|
+
vertex (pb) {
|
|
374
|
+
this.flip = pb.int().uniform(0);
|
|
375
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
376
|
+
this.$outputs.uv = pb.vec2();
|
|
377
|
+
if (!blur && ctx.env.light.envLight) {
|
|
378
|
+
ctx.env.light.envLight.initShaderBindings(pb);
|
|
379
|
+
}
|
|
380
|
+
pb.main(function() {
|
|
381
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 1, 1);
|
|
382
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
383
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
384
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
fragment (pb) {
|
|
389
|
+
if (!blur) {
|
|
390
|
+
this.colorTex = pb.tex2D().uniform(0);
|
|
391
|
+
if (ctx.env.light.envLight) {
|
|
392
|
+
this.envLightStrength = pb.float().uniform(0);
|
|
393
|
+
ctx.env.light.envLight.initShaderBindings(pb);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
this.roughnessTex = pb.tex2D().uniform(0);
|
|
397
|
+
this.normalTex = pb.tex2D().uniform(0);
|
|
398
|
+
this.depthTex = pb.tex2D().uniform(0);
|
|
399
|
+
this.cameraNearFar = pb.vec2().uniform(0);
|
|
400
|
+
this.cameraPos = pb.vec3().uniform(0);
|
|
401
|
+
this.invProjMatrix = pb.mat4().uniform(0);
|
|
402
|
+
this.projMatrix = pb.mat4().uniform(0);
|
|
403
|
+
this.viewMatrix = pb.mat4().uniform(0);
|
|
404
|
+
this.invViewMatrix = pb.mat4().uniform(0);
|
|
405
|
+
this.ssrParams = pb.vec4().uniform(0);
|
|
406
|
+
this.ssrMaxRoughness = pb.float().uniform(0);
|
|
407
|
+
this.targetSize = pb.vec4().uniform(0);
|
|
408
|
+
if (ctx.HiZTexture) {
|
|
409
|
+
this.hizTex = pb.tex2D().uniform(0);
|
|
410
|
+
this.depthMipLevels = pb.int().uniform(0);
|
|
411
|
+
} else {
|
|
412
|
+
this.ssrStride = pb.float().uniform(0);
|
|
413
|
+
}
|
|
414
|
+
this.srgbOut = pb.int().uniform(0);
|
|
415
|
+
this.$outputs.outColor = pb.vec4();
|
|
416
|
+
pb.func('getPosition', [
|
|
417
|
+
pb.vec2('uv'),
|
|
418
|
+
pb.mat4('mat')
|
|
419
|
+
], function() {
|
|
420
|
+
this.$l.linearDepth = ShaderHelper.sampleLinearDepth(this, this.depthTex, this.uv, 0);
|
|
421
|
+
this.$l.nonLinearDepth = pb.div(pb.sub(pb.div(this.cameraNearFar.x, this.linearDepth), this.cameraNearFar.y), pb.sub(this.cameraNearFar.x, this.cameraNearFar.y));
|
|
422
|
+
this.$l.clipSpacePos = pb.vec4(pb.sub(pb.mul(this.uv, 2), pb.vec2(1)), pb.sub(pb.mul(pb.clamp(this.nonLinearDepth, 0, 1), 2), 1), 1);
|
|
423
|
+
this.$l.wPos = pb.mul(this.mat, this.clipSpacePos);
|
|
424
|
+
this.$return(pb.vec4(pb.div(this.wPos.xyz, this.wPos.w), this.linearDepth));
|
|
425
|
+
});
|
|
426
|
+
pb.main(function() {
|
|
427
|
+
this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
|
|
428
|
+
this.$l.roughnessValue = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
|
|
429
|
+
this.$l.roughness = this.roughnessValue.a;
|
|
430
|
+
this.$if(pb.greaterThanEqual(this.roughness, this.ssrMaxRoughness), function() {
|
|
431
|
+
pb.discard();
|
|
432
|
+
});
|
|
433
|
+
if (!blur) {
|
|
434
|
+
this.$l.sceneColor = pb.textureSampleLevel(this.colorTex, this.screenUV, 0).rgb;
|
|
435
|
+
}
|
|
436
|
+
this.$l.pos = this.getPosition(this.screenUV, this.invProjMatrix);
|
|
437
|
+
this.$l.linearDepth = this.pos.w;
|
|
438
|
+
this.$l.color = pb.vec3(0);
|
|
439
|
+
this.$l.a = pb.float();
|
|
440
|
+
this.$if(pb.greaterThanEqual(this.linearDepth, 1), function() {
|
|
441
|
+
if (!blur) {
|
|
442
|
+
this.color = this.sceneColor;
|
|
443
|
+
this.a = 1;
|
|
444
|
+
}
|
|
445
|
+
}).$else(function() {
|
|
446
|
+
this.$l.viewPos = this.pos.xyz;
|
|
447
|
+
this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.screenUV, 0).rgb, 2), pb.vec3(1));
|
|
448
|
+
this.$l.viewVec = pb.normalize(this.viewPos);
|
|
449
|
+
this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
|
|
450
|
+
this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
|
|
451
|
+
this.$l.hitInfo = ctx.HiZTexture ? screenSpaceRayTracing_HiZ(this, this.viewPos, this.reflectVec, this.viewMatrix, this.projMatrix, this.invProjMatrix, this.cameraNearFar, this.depthMipLevels, this.ssrParams.y, this.ssrParams.z, this.targetSize, this.hizTex, this.normalTex) : screenSpaceRayTracing_Linear2D(this, this.viewPos, this.reflectVec, this.viewMatrix, this.projMatrix, this.invProjMatrix, this.cameraNearFar, this.ssrParams.x, this.ssrParams.y, this.ssrParams.z, this.ssrStride, this.targetSize, this.depthTex, this.normalTex, !!ctx.primaryCamera.ssrCalcThickness);
|
|
452
|
+
if (blur) {
|
|
453
|
+
this.blurRadius = pb.float(0);
|
|
454
|
+
this.$if(pb.greaterThan(this.roughness, 0.001), function() {
|
|
455
|
+
this.$l.coneAngle = pb.mul(pb.min(this.roughness, 0.999), Math.PI * 0.5);
|
|
456
|
+
this.$l.coneLen = this.$choice(pb.greaterThan(this.hitInfo.w, 0), this.hitInfo.z, pb.min(this.targetSize.z, this.targetSize.w));
|
|
457
|
+
this.$l.opLen = pb.mul(pb.tan(this.coneAngle), this.coneLen, 2);
|
|
458
|
+
this.$l.a2 = pb.mul(this.opLen, this.opLen);
|
|
459
|
+
this.$l.fh2 = pb.mul(this.coneLen, this.coneLen, 4);
|
|
460
|
+
this.blurRadius = pb.div(pb.mul(this.opLen, pb.sub(pb.sqrt(pb.add(this.a2, this.fh2)), this.opLen)), pb.mul(this.coneLen, 4));
|
|
461
|
+
});
|
|
462
|
+
this.a = this.hitInfo.w;
|
|
463
|
+
this.color = pb.vec3(this.hitInfo.xy, pb.clamp(pb.div(this.blurRadius, 255), 0, 1));
|
|
464
|
+
} else {
|
|
465
|
+
if (ctx.env.light.envLight) {
|
|
466
|
+
this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
|
|
467
|
+
this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness), this.envLightStrength);
|
|
468
|
+
} else {
|
|
469
|
+
this.$l.env = pb.vec3(0);
|
|
470
|
+
}
|
|
471
|
+
this.$l.reflectance = pb.mix(this.env, pb.textureSampleLevel(this.colorTex, this.hitInfo.xy, 0).rgb, this.hitInfo.w);
|
|
472
|
+
this.reflectance = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
|
|
473
|
+
this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
474
|
+
this.color = pb.add(pb.mul(this.reflectance, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
this.$if(pb.equal(this.srgbOut, 0), function() {
|
|
478
|
+
this.$outputs.outColor = pb.vec4(this.color, this.a);
|
|
479
|
+
}).$else(function() {
|
|
480
|
+
this.$outputs.outColor = pb.vec4(linearToGamma(this, this.color), this.a);
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export { SSR };
|
|
489
|
+
//# sourceMappingURL=ssr.js.map
|