@zephyr3d/scene 0.7.1 → 0.8.1
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/animation.js +0 -18
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +200 -3
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +371 -0
- package/dist/animation/ik/ccd_solver.js.map +1 -0
- package/dist/animation/ik/fabrik_solver.js +398 -0
- package/dist/animation/ik/fabrik_solver.js.map +1 -0
- package/dist/animation/ik/ik_angle_constraint.js +181 -0
- package/dist/animation/ik/ik_angle_constraint.js.map +1 -0
- package/dist/animation/ik/ik_chain.js +163 -0
- package/dist/animation/ik/ik_chain.js.map +1 -0
- package/dist/animation/ik/ik_constraint.js +25 -0
- package/dist/animation/ik/ik_constraint.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +128 -0
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -0
- package/dist/animation/ik/ik_solver.js +48 -0
- package/dist/animation/ik/ik_solver.js.map +1 -0
- package/dist/animation/ik/ik_track.js +96 -0
- package/dist/animation/ik/ik_track.js.map +1 -0
- package/dist/animation/ik/ik_utils.js +191 -0
- package/dist/animation/ik/ik_utils.js.map +1 -0
- package/dist/animation/ik/two_bone_ik_solver.js +331 -0
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -0
- package/dist/animation/ik_modifier.js +61 -0
- package/dist/animation/ik_modifier.js.map +1 -0
- package/dist/animation/ik_postprocessor.js +71 -0
- package/dist/animation/ik_postprocessor.js.map +1 -0
- package/dist/animation/manual_transform_processor.js +156 -0
- package/dist/animation/manual_transform_processor.js.map +1 -0
- package/dist/animation/skeleton.js +55 -51
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +38 -0
- package/dist/animation/skeleton_modifier.js.map +1 -0
- package/dist/animation/skeleton_postprocessor.js +50 -0
- package/dist/animation/skeleton_postprocessor.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +503 -0
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -0
- package/dist/animation/spring/spring_bone.js +240 -0
- package/dist/animation/spring/spring_bone.js.map +1 -0
- package/dist/animation/spring/spring_bone_collider.js +198 -0
- package/dist/animation/spring/spring_bone_collider.js.map +1 -0
- package/dist/animation/spring/spring_bone_constraint.js +170 -0
- package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
- package/dist/animation/spring/spring_bone_system.js +328 -0
- package/dist/animation/spring/spring_bone_system.js.map +1 -0
- package/dist/animation/spring/spring_chain.js +103 -0
- package/dist/animation/spring/spring_chain.js.map +1 -0
- package/dist/animation/spring/spring_collider.js +247 -0
- package/dist/animation/spring/spring_collider.js.map +1 -0
- package/dist/animation/spring/spring_constraint.js +21 -0
- package/dist/animation/spring/spring_constraint.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +20 -0
- package/dist/animation/spring/spring_particle.js.map +1 -0
- package/dist/animation/spring/spring_system.js +526 -0
- package/dist/animation/spring/spring_system.js.map +1 -0
- package/dist/animation/spring_modifier.js +45 -0
- package/dist/animation/spring_modifier.js.map +1 -0
- package/dist/animation/spring_postprocessor.js +54 -0
- package/dist/animation/spring_postprocessor.js.map +1 -0
- package/dist/app/screen.js +1 -1
- package/dist/app/screen.js.map +1 -1
- package/dist/asset/model.js +10 -6
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -3
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +1400 -4
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +66 -4
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +20 -17
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/shader/helper.js +5 -3
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/render/gpu_picking.js +100 -0
- package/dist/render/gpu_picking.js.map +1 -0
- package/dist/render/rendergraph/device_pool_allocator.js +41 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
- package/dist/render/rendergraph/executor.js +146 -0
- package/dist/render/rendergraph/executor.js.map +1 -0
- package/dist/render/rendergraph/forward_plus_builder.js +414 -0
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +306 -0
- package/dist/render/rendergraph/rendergraph.js.map +1 -0
- package/dist/render/rendergraph/types.js +57 -0
- package/dist/render/rendergraph/types.js.map +1 -0
- package/dist/render/sky_motion_vector.js +85 -0
- package/dist/render/sky_motion_vector.js.map +1 -0
- package/dist/scene/mesh.js +15 -23
- package/dist/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +24 -23
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +62 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +1 -1
- package/package.json +3 -3
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
|
@@ -1,489 +0,0 @@
|
|
|
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
|