@zephyr3d/scene 0.9.5 → 0.9.7
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/joint_dynamics/controller.js +92 -32
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +71 -27
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +21 -20
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/skeleton.js +7 -10
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/app/engine.js +134 -140
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +47 -16
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +3 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +346 -7
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +20 -16
- package/dist/avatar/wardrobe.js.map +1 -1
- package/dist/camera/camera.js +416 -210
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1350 -621
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +1 -1
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +23 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +178 -23
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +4 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +2 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +1 -1
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +276 -65
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +3 -3
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +2 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/msdf_text.js +3 -3
- package/dist/material/msdf_text.js.map +1 -1
- package/dist/material/mtoon.js +574 -0
- package/dist/material/mtoon.js.map +1 -0
- package/dist/material/pbrblueprint.js +499 -336
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +118 -100
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +1 -1
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +324 -294
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +812 -0
- package/dist/material/subsurfaceprofile.js.map +1 -0
- package/dist/material/unlit.js +1 -1
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/compositor.js +46 -11
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/ssr.js +422 -96
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +1053 -0
- package/dist/posteffect/sss.js.map +1 -0
- package/dist/posteffect/taa.js +61 -60
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +63 -12
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +6 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +1 -5
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +2 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +2 -1
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +2 -1
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/lightpass.js +110 -23
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/render_queue.js +51 -8
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +80 -66
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +8 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +481 -95
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +55 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +10 -4
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sky.js +31 -1
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +23 -5
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +4 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -1
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +11 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +21 -3
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +29 -14
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +5 -2
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +5 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +3 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +6 -5
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +4 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +2 -1
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -2
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +4 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +26 -393
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/esm.js +112 -12
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +2 -2
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +19 -10
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +58 -7
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +6 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +229 -0
- package/dist/shadow/shadow_region.js.map +1 -0
- package/dist/shadow/shadowmapper.js +67 -59
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +45 -19
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/text/font/cff_font.js +890 -0
- package/dist/text/font/cff_font.js.map +1 -0
- package/dist/text/font/font_asset.js +17 -3
- package/dist/text/font/font_asset.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +8 -8
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +31 -4
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +1 -17
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +327 -359
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +5 -2
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -1
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +249 -54
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +37 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +42 -3
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1112 -646
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +7 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +31 -12
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -1
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +3 -1
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +18 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +5 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +3 -1
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -1
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +6 -0
- package/dist/utility/textures/ltcdata.js.map +1 -0
- package/dist/utility/textures/ltclut.js +61 -0
- package/dist/utility/textures/ltclut.js.map +1 -0
- package/dist/values.js +9 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/animation/ik/ik_pole_constraint.js +0 -123
- package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
- package/dist/animation/ik/ik_track.js +0 -96
- package/dist/animation/ik/ik_track.js.map +0 -1
- package/dist/animation/ik_postprocessor.js +0 -71
- package/dist/animation/ik_postprocessor.js.map +0 -1
- package/dist/animation/joint_dynamics/math.js +0 -16
- package/dist/animation/joint_dynamics/math.js.map +0 -1
- package/dist/animation/manual_transform_processor.js +0 -156
- package/dist/animation/manual_transform_processor.js.map +0 -1
- package/dist/animation/skeleton_postprocessor.js +0 -50
- package/dist/animation/skeleton_postprocessor.js.map +0 -1
- package/dist/animation/spring2/collision.js +0 -469
- package/dist/animation/spring2/collision.js.map +0 -1
- package/dist/animation/spring2/constraints.js +0 -329
- package/dist/animation/spring2/constraints.js.map +0 -1
- package/dist/animation/spring2/controller.js +0 -434
- package/dist/animation/spring2/controller.js.map +0 -1
- package/dist/animation/spring2/math.js +0 -16
- package/dist/animation/spring2/math.js.map +0 -1
- package/dist/animation/spring2/solver.js +0 -624
- package/dist/animation/spring2/solver.js.map +0 -1
- package/dist/animation/spring2/spring_system.js +0 -118
- package/dist/animation/spring2/spring_system.js.map +0 -1
- package/dist/animation/spring2/types.js +0 -19
- package/dist/animation/spring2/types.js.map +0 -1
- package/dist/animation/spring_postprocessor.js +0 -54
- package/dist/animation/spring_postprocessor.js.map +0 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +0 -1276
- package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/asset/loaders/gltf/helpers.js +0 -331
- package/dist/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/material/sprite3d.js +0 -301
- package/dist/material/sprite3d.js.map +0 -1
- package/dist/material/sprite3d_std.js +0 -116
- package/dist/material/sprite3d_std.js.map +0 -1
- package/dist/material/sprite3dblueprint.js +0 -235
- package/dist/material/sprite3dblueprint.js.map +0 -1
- package/dist/material/sprite_sdf.js +0 -106
- package/dist/material/sprite_sdf.js.map +0 -1
- package/dist/material/terrainmaterial.js +0 -368
- package/dist/material/terrainmaterial.js.map +0 -1
- 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/render/deferredlightpass.js +0 -510
- package/dist/render/deferredlightpass.js.map +0 -1
- package/dist/render/deferredshadowlightpass.js +0 -428
- package/dist/render/deferredshadowlightpass.js.map +0 -1
- package/dist/render/gbufferpass.js +0 -50
- package/dist/render/gbufferpass.js.map +0 -1
- package/dist/scene/sdftextsprite.js +0 -322
- package/dist/scene/sdftextsprite.js.map +0 -1
- package/dist/scene/sprite3d.js +0 -18
- package/dist/scene/sprite3d.js.map +0 -1
- package/dist/scene/terrain/grass.js +0 -280
- package/dist/scene/terrain/grass.js.map +0 -1
- package/dist/scene/terrain/heightfield.js +0 -475
- package/dist/scene/terrain/heightfield.js.map +0 -1
- package/dist/scene/terrain/patch.js +0 -532
- package/dist/scene/terrain/patch.js.map +0 -1
- package/dist/scene/terrain/quadtree.js +0 -461
- package/dist/scene/terrain/quadtree.js.map +0 -1
- package/dist/scene/terrain/terrain.js +0 -231
- package/dist/scene/terrain/terrain.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
- package/dist/utility/serialization/scene/cloth_script.js +0 -834
- package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
- package/dist/utility/serialization/scene/spring_script.js +0 -596
- package/dist/utility/serialization/scene/spring_script.js.map +0 -1
package/dist/posteffect/ssr.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { AbstractPostEffect, PostEffectLayer } from './posteffect.js';
|
|
2
2
|
import { linearToGamma } from '../shaders/misc.js';
|
|
3
3
|
import { SSR_calcJitter, screenSpaceRayTracing_HiZ, screenSpaceRayTracing_Linear2D } from '../shaders/ssr.js';
|
|
4
|
-
import {
|
|
4
|
+
import { temporalResolve } from '../shaders/temporal.js';
|
|
5
|
+
import { Vector2, Matrix4x4, Vector4 } from '@zephyr3d/base';
|
|
5
6
|
import { fetchSampler, copyTexture } from '../utility/misc.js';
|
|
7
|
+
import { getGGXLUT } from '../utility/textures/ggxlut.js';
|
|
6
8
|
import { BilateralBlurBlitter } from '../blitter/bilateralblur.js';
|
|
7
9
|
import { ShaderHelper } from '../material/shader/helper.js';
|
|
8
10
|
import '../material/lambert.js';
|
|
9
11
|
import '../material/blinn.js';
|
|
10
12
|
import '../material/unlit.js';
|
|
11
13
|
import '../material/particle.js';
|
|
14
|
+
import '../material/subsurfaceprofile.js';
|
|
12
15
|
import '@zephyr3d/device';
|
|
13
16
|
import '../values.js';
|
|
14
17
|
import '../material/meshmaterial.js';
|
|
@@ -16,36 +19,40 @@ import '../material/grassmaterial.js';
|
|
|
16
19
|
import '../material/terrain-cm.js';
|
|
17
20
|
import '../material/pbrmr.js';
|
|
18
21
|
import '../material/pbrsg.js';
|
|
22
|
+
import '../material/mtoon.js';
|
|
19
23
|
import '../material/pbrblueprint.js';
|
|
20
24
|
import '../material/sprite.js';
|
|
21
25
|
import '../material/sprite_std.js';
|
|
22
|
-
import '../material/msdf_text.js';
|
|
23
26
|
import '../utility/blueprint/material/texture.js';
|
|
27
|
+
import { RGHistoryResources } from '../render/rendergraph/history_resources.js';
|
|
24
28
|
|
|
25
|
-
/**
|
|
26
|
-
* SSR post effect
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* Internal used in light pass
|
|
30
|
-
*
|
|
31
|
-
* @internal
|
|
29
|
+
/**
|
|
30
|
+
* SSR post effect
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Internal used in light pass
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
32
36
|
*/ class SSR extends AbstractPostEffect {
|
|
33
37
|
static _programs = {};
|
|
34
38
|
static _resolveProgram = {};
|
|
35
39
|
static _combineProgram;
|
|
40
|
+
static _temporalProgram;
|
|
36
41
|
static _blurBlitterH = null;
|
|
37
42
|
static _blurBlitterV = null;
|
|
38
43
|
_bindgroups;
|
|
39
44
|
_resolveBindGroup;
|
|
40
45
|
_combineBindGroup;
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
_temporalBindGroup;
|
|
47
|
+
/**
|
|
48
|
+
* Creates an instance of SSR post effect
|
|
43
49
|
*/ constructor(){
|
|
44
50
|
super();
|
|
45
51
|
this._layer = PostEffectLayer.opaque;
|
|
46
52
|
this._bindgroups = {};
|
|
47
53
|
this._resolveBindGroup = {};
|
|
48
54
|
this._combineBindGroup = null;
|
|
55
|
+
this._temporalBindGroup = null;
|
|
49
56
|
}
|
|
50
57
|
/** {@inheritDoc AbstractPostEffect.requireLinearDepthTexture} */ requireLinearDepthTexture() {
|
|
51
58
|
return true;
|
|
@@ -75,15 +82,26 @@ import '../utility/blueprint/material/texture.js';
|
|
|
75
82
|
program = this._createCombineProgrm(ctx);
|
|
76
83
|
SSR._combineProgram = program;
|
|
77
84
|
}
|
|
85
|
+
const roughnessTexture = ctx.SSRRoughnessTexture;
|
|
78
86
|
if (!this._combineBindGroup) {
|
|
79
87
|
this._combineBindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
|
|
80
88
|
}
|
|
81
89
|
const linearSampler = fetchSampler('clamp_linear');
|
|
90
|
+
const nearestSampler = fetchSampler('clamp_nearest');
|
|
82
91
|
this._combineBindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
|
|
83
92
|
this._combineBindGroup.setTexture('reflectanceTex', reflectanceTex, linearSampler);
|
|
84
|
-
this._combineBindGroup.setTexture('roughnessTex',
|
|
93
|
+
this._combineBindGroup.setTexture('roughnessTex', roughnessTexture, linearSampler);
|
|
94
|
+
this._combineBindGroup.setTexture('albedoTex', inputColorTexture, linearSampler);
|
|
95
|
+
this._combineBindGroup.setTexture('extraTex', inputColorTexture, nearestSampler);
|
|
96
|
+
this._combineBindGroup.setTexture('normalTex', ctx.SSRNormalTexture, nearestSampler);
|
|
97
|
+
this._combineBindGroup.setTexture('depthTex', ctx.linearDepthTexture, nearestSampler);
|
|
98
|
+
this._combineBindGroup.setTexture('zGGXLut', getGGXLUT(1024), fetchSampler('clamp_nearest_nomip'));
|
|
85
99
|
this._combineBindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
|
|
86
|
-
this._combineBindGroup.setValue('
|
|
100
|
+
this._combineBindGroup.setValue('ssrStrengthMode', 0);
|
|
101
|
+
this._combineBindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
|
|
102
|
+
this._combineBindGroup.setValue('viewMatrix', ctx.camera.viewMatrix);
|
|
103
|
+
this._combineBindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
|
|
104
|
+
this._combineBindGroup.setValue('targetSize', new Vector4(inputColorTexture.width, inputColorTexture.height, inputColorTexture.width, inputColorTexture.height));
|
|
87
105
|
this._combineBindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
88
106
|
this._combineBindGroup.setValue('srgbOut', srgbOut ? 1 : 0);
|
|
89
107
|
device.setProgram(program);
|
|
@@ -92,7 +110,8 @@ import '../utility/blueprint/material/texture.js';
|
|
|
92
110
|
}
|
|
93
111
|
/** @internal */ resolve(ctx, inputColorTexture, sceneDepthTexture, intersectTexture) {
|
|
94
112
|
const device = ctx.device;
|
|
95
|
-
const
|
|
113
|
+
const hasEnvRadiance = !!ctx.env.light.envLight?.hasRadiance();
|
|
114
|
+
const hash = hasEnvRadiance ? ctx.env.light.getHash() : '';
|
|
96
115
|
let program = SSR._resolveProgram[hash];
|
|
97
116
|
if (program === undefined) {
|
|
98
117
|
program = this._createResolveProgram(ctx);
|
|
@@ -105,19 +124,26 @@ import '../utility/blueprint/material/texture.js';
|
|
|
105
124
|
}
|
|
106
125
|
const nearestSampler = fetchSampler('clamp_nearest');
|
|
107
126
|
const linearSampler = fetchSampler('clamp_linear');
|
|
127
|
+
const roughnessTexture = ctx.SSRRoughnessTexture;
|
|
128
|
+
const normalTexture = ctx.SSRNormalTexture;
|
|
108
129
|
bindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
|
|
109
130
|
bindGroup.setTexture('intersectTex', intersectTexture, nearestSampler);
|
|
110
|
-
bindGroup.setTexture('roughnessTex',
|
|
111
|
-
bindGroup.setTexture('normalTex',
|
|
131
|
+
bindGroup.setTexture('roughnessTex', roughnessTexture, nearestSampler);
|
|
132
|
+
bindGroup.setTexture('normalTex', normalTexture, nearestSampler);
|
|
133
|
+
bindGroup.setTexture('albedoTex', inputColorTexture, linearSampler);
|
|
134
|
+
bindGroup.setTexture('extraTex', inputColorTexture, nearestSampler);
|
|
112
135
|
bindGroup.setTexture('depthTex', sceneDepthTexture, nearestSampler);
|
|
136
|
+
bindGroup.setTexture('zGGXLut', getGGXLUT(1024), fetchSampler('clamp_nearest_nomip'));
|
|
113
137
|
bindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
|
|
138
|
+
bindGroup.setValue('ssrStrengthMode', 0);
|
|
114
139
|
bindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
|
|
115
|
-
bindGroup.setValue('targetSize', new Vector4(
|
|
140
|
+
bindGroup.setValue('targetSize', new Vector4(inputColorTexture.width, inputColorTexture.height, sceneDepthTexture.width, sceneDepthTexture.height));
|
|
116
141
|
bindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
|
|
117
142
|
bindGroup.setValue('viewMatrix', ctx.camera.viewMatrix);
|
|
118
143
|
bindGroup.setValue('invViewMatrix', ctx.camera.worldMatrix);
|
|
119
|
-
if (
|
|
144
|
+
if (hasEnvRadiance) {
|
|
120
145
|
bindGroup.setValue('envLightStrength', ctx.env.light.strength);
|
|
146
|
+
bindGroup.setValue('envLightSpecularStrength', ctx.env.light.specularStrength ?? 1);
|
|
121
147
|
ctx.env.light.envLight.updateBindGroup(bindGroup);
|
|
122
148
|
}
|
|
123
149
|
bindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
@@ -127,10 +153,15 @@ import '../utility/blueprint/material/texture.js';
|
|
|
127
153
|
}
|
|
128
154
|
/** @internal */ intersect(ctx, inputColorTexture, sceneDepthTexture, blur, srgbOut) {
|
|
129
155
|
const device = ctx.device;
|
|
130
|
-
const
|
|
156
|
+
const hasEnvRadiance = !!ctx.env.light.envLight?.hasRadiance();
|
|
157
|
+
const hash = `${Number(blur)}:${hasEnvRadiance ? ctx.env.light.getHash() : ''}:${!!ctx.HiZTexture}:${!!ctx.camera.ssrCalcThickness}`;
|
|
131
158
|
let program = SSR._programs[hash];
|
|
132
159
|
if (program === undefined) {
|
|
133
|
-
|
|
160
|
+
const created = this._createIntersectProgram(ctx, blur);
|
|
161
|
+
if (!created) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
program = created;
|
|
134
165
|
SSR._programs[hash] = program;
|
|
135
166
|
}
|
|
136
167
|
let bindGroup = this._bindgroups[hash];
|
|
@@ -140,16 +171,22 @@ import '../utility/blueprint/material/texture.js';
|
|
|
140
171
|
}
|
|
141
172
|
const nearestSampler = fetchSampler('clamp_nearest');
|
|
142
173
|
const linearSampler = fetchSampler('clamp_linear');
|
|
174
|
+
const roughnessTexture = ctx.SSRRoughnessTexture;
|
|
175
|
+
const normalTexture = ctx.SSRNormalTexture;
|
|
143
176
|
if (!blur) {
|
|
144
177
|
bindGroup.setTexture('colorTex', inputColorTexture, linearSampler);
|
|
145
|
-
if (
|
|
178
|
+
if (hasEnvRadiance) {
|
|
146
179
|
bindGroup.setValue('envLightStrength', ctx.env.light.strength);
|
|
180
|
+
bindGroup.setValue('envLightSpecularStrength', ctx.env.light.specularStrength ?? 1);
|
|
147
181
|
ctx.env.light.envLight.updateBindGroup(bindGroup);
|
|
148
182
|
}
|
|
149
183
|
}
|
|
150
|
-
bindGroup.setTexture('
|
|
151
|
-
bindGroup.setTexture('
|
|
184
|
+
bindGroup.setTexture('albedoTex', inputColorTexture, linearSampler);
|
|
185
|
+
bindGroup.setTexture('roughnessTex', roughnessTexture, nearestSampler);
|
|
186
|
+
bindGroup.setTexture('normalTex', normalTexture, nearestSampler);
|
|
187
|
+
bindGroup.setTexture('extraTex', inputColorTexture, nearestSampler);
|
|
152
188
|
bindGroup.setTexture('depthTex', sceneDepthTexture, nearestSampler);
|
|
189
|
+
bindGroup.setTexture('zGGXLut', getGGXLUT(1024), fetchSampler('clamp_nearest_nomip'));
|
|
153
190
|
bindGroup.setValue('cameraNearFar', new Vector2(ctx.camera.getNearPlane(), ctx.camera.getFarPlane()));
|
|
154
191
|
bindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
|
|
155
192
|
bindGroup.setValue('invProjMatrix', Matrix4x4.invert(ctx.camera.getProjectionMatrix()));
|
|
@@ -158,13 +195,14 @@ import '../utility/blueprint/material/texture.js';
|
|
|
158
195
|
bindGroup.setValue('invViewMatrix', ctx.camera.worldMatrix);
|
|
159
196
|
bindGroup.setValue('ssrParams', ctx.camera.ssrParams);
|
|
160
197
|
bindGroup.setValue('ssrMaxRoughness', ctx.camera.ssrMaxRoughness);
|
|
198
|
+
bindGroup.setValue('ssrStrengthMode', 0);
|
|
161
199
|
if (ctx.HiZTexture) {
|
|
162
200
|
bindGroup.setTexture('hizTex', ctx.HiZTexture, nearestSampler);
|
|
163
201
|
bindGroup.setValue('depthMipLevels', ctx.HiZTexture.mipLevelCount);
|
|
164
|
-
bindGroup.setValue('targetSize', new Vector4(
|
|
202
|
+
bindGroup.setValue('targetSize', new Vector4(sceneDepthTexture.width, sceneDepthTexture.height, ctx.HiZTexture.width, ctx.HiZTexture.height));
|
|
165
203
|
} else {
|
|
166
204
|
bindGroup.setValue('ssrStride', ctx.camera.ssrStride);
|
|
167
|
-
bindGroup.setValue('targetSize', new Vector4(
|
|
205
|
+
bindGroup.setValue('targetSize', new Vector4(sceneDepthTexture.width, sceneDepthTexture.height, sceneDepthTexture.width, sceneDepthTexture.height));
|
|
168
206
|
}
|
|
169
207
|
bindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
170
208
|
bindGroup.setValue('srgbOut', srgbOut ? 1 : 0);
|
|
@@ -172,6 +210,29 @@ import '../utility/blueprint/material/texture.js';
|
|
|
172
210
|
device.setBindGroup(0, bindGroup);
|
|
173
211
|
this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
|
|
174
212
|
}
|
|
213
|
+
/** @internal */ temporal(ctx, currentReflectTex, sceneDepthTexture, prevReflectTex, prevMotionVectorTex, outFramebuffer) {
|
|
214
|
+
const device = ctx.device;
|
|
215
|
+
let program = SSR._temporalProgram;
|
|
216
|
+
if (!program) {
|
|
217
|
+
program = this._createTemporalProgram(ctx);
|
|
218
|
+
SSR._temporalProgram = program;
|
|
219
|
+
}
|
|
220
|
+
if (!this._temporalBindGroup) {
|
|
221
|
+
this._temporalBindGroup = device.createBindGroup(program.bindGroupLayouts[0]);
|
|
222
|
+
}
|
|
223
|
+
this._temporalBindGroup.setTexture('historyColorTex', prevReflectTex, fetchSampler('clamp_linear_nomip'));
|
|
224
|
+
this._temporalBindGroup.setTexture('currentColorTex', currentReflectTex, fetchSampler('clamp_nearest_nomip'));
|
|
225
|
+
this._temporalBindGroup.setTexture('currentDepthTex', sceneDepthTexture, fetchSampler('clamp_nearest_nomip'));
|
|
226
|
+
this._temporalBindGroup.setTexture('motionVector', ctx.motionVectorTexture, fetchSampler('clamp_nearest_nomip'));
|
|
227
|
+
this._temporalBindGroup.setTexture('prevMotionVector', prevMotionVectorTex, fetchSampler('clamp_nearest_nomip'));
|
|
228
|
+
this._temporalBindGroup.setValue('flip', this.needFlip(device) ? 1 : 0);
|
|
229
|
+
this._temporalBindGroup.setValue('texSize', new Vector2(sceneDepthTexture.width, sceneDepthTexture.height));
|
|
230
|
+
this._temporalBindGroup.setValue('temporalWeight', ctx.camera.ssrTemporalWeight);
|
|
231
|
+
device.setFramebuffer(outFramebuffer);
|
|
232
|
+
device.setProgram(program);
|
|
233
|
+
device.setBindGroup(0, this._temporalBindGroup);
|
|
234
|
+
this.drawFullscreenQuad(AbstractPostEffect.getDefaultRenderState(ctx, 'gt'));
|
|
235
|
+
}
|
|
175
236
|
/** {@inheritDoc AbstractPostEffect.apply} */ apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
|
|
176
237
|
const device = ctx.device;
|
|
177
238
|
device.pushDeviceStates();
|
|
@@ -185,7 +246,8 @@ import '../utility/blueprint/material/texture.js';
|
|
|
185
246
|
this.intersect(ctx, inputColorTexture, sceneDepthTexture, true, false);
|
|
186
247
|
const intersectTex = intersectFramebuffer.getColorAttachments()[0];
|
|
187
248
|
device.setFramebuffer(pingpongFramebuffer[0]);
|
|
188
|
-
|
|
249
|
+
const ssrSceneColorTexture = ctx.sceneColorTexture ?? inputColorTexture;
|
|
250
|
+
this.resolve(ctx, ssrSceneColorTexture, sceneDepthTexture, intersectTex);
|
|
189
251
|
if (ctx.camera.ssrBlurScale > 0 && ctx.camera.ssrBlurKernelSize > 0) {
|
|
190
252
|
const blurSizeScale = 255 * ctx.camera.ssrBlurScale;
|
|
191
253
|
const kernelRadius = Math.max(1, ctx.camera.ssrBlurKernelSize >> 0) - 1 >> 1;
|
|
@@ -198,8 +260,65 @@ import '../utility/blueprint/material/texture.js';
|
|
|
198
260
|
blitterV.renderStates = AbstractPostEffect.getDefaultRenderState(ctx, 'gt');
|
|
199
261
|
this.blurPass(ctx, blitterV, intersectTex, 2, blurSizeScale, kernelRadius, stdDev, depthCutoff, pingpongFramebuffer[1], pingpongFramebuffer[0]);
|
|
200
262
|
}
|
|
263
|
+
const historyManager = ctx.camera.getHistoryResourceManager();
|
|
264
|
+
const useGraphHistory = !!historyManager?.frameActive;
|
|
265
|
+
const history = useGraphHistory ? null : ctx.camera.getHistoryData();
|
|
266
|
+
let reflectanceTex = pingpongFramebuffer[0].getColorAttachments()[0];
|
|
267
|
+
const prevSSRReflectTex = useGraphHistory ? historyManager.tryGetPrevious(RGHistoryResources.SSR_REFLECT) : history.prevSSRReflectTex;
|
|
268
|
+
const prevSSRMotionVectorTex = useGraphHistory ? historyManager.tryGetPrevious(RGHistoryResources.SSR_MOTION_VECTOR) : history.prevSSRMotionVectorTex;
|
|
269
|
+
const canTemporal = ctx.camera.ssrTemporal && !!ctx.motionVectorTexture && !!prevSSRReflectTex && !!prevSSRMotionVectorTex && prevSSRReflectTex.width === reflectanceTex.width && prevSSRReflectTex.height === reflectanceTex.height;
|
|
270
|
+
if (canTemporal) {
|
|
271
|
+
this.temporal(ctx, reflectanceTex, sceneDepthTexture, prevSSRReflectTex, prevSSRMotionVectorTex, pingpongFramebuffer[1]);
|
|
272
|
+
reflectanceTex = pingpongFramebuffer[1].getColorAttachments()[0];
|
|
273
|
+
}
|
|
201
274
|
device.popDeviceStates();
|
|
202
|
-
this.combine(ctx, inputColorTexture,
|
|
275
|
+
this.combine(ctx, inputColorTexture, reflectanceTex, srgbOutput);
|
|
276
|
+
if (useGraphHistory) {
|
|
277
|
+
if (ctx.camera.ssrTemporal) {
|
|
278
|
+
const reflectanceSize = {
|
|
279
|
+
width: reflectanceTex.width,
|
|
280
|
+
height: reflectanceTex.height
|
|
281
|
+
};
|
|
282
|
+
historyManager.queueRetainedCommit(RGHistoryResources.SSR_REFLECT, {
|
|
283
|
+
format: reflectanceTex.format,
|
|
284
|
+
sizeMode: 'absolute',
|
|
285
|
+
width: reflectanceTex.width,
|
|
286
|
+
height: reflectanceTex.height
|
|
287
|
+
}, reflectanceSize, reflectanceTex);
|
|
288
|
+
}
|
|
289
|
+
if (ctx.camera.ssrTemporal && ctx.motionVectorTexture) {
|
|
290
|
+
const motionVectorSize = {
|
|
291
|
+
width: ctx.motionVectorTexture.width,
|
|
292
|
+
height: ctx.motionVectorTexture.height
|
|
293
|
+
};
|
|
294
|
+
historyManager.queueRetainedCommit(RGHistoryResources.SSR_MOTION_VECTOR, {
|
|
295
|
+
format: ctx.motionVectorTexture.format,
|
|
296
|
+
sizeMode: 'absolute',
|
|
297
|
+
width: ctx.motionVectorTexture.width,
|
|
298
|
+
height: ctx.motionVectorTexture.height
|
|
299
|
+
}, motionVectorSize, ctx.motionVectorTexture);
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
if (history.prevSSRReflectTex) {
|
|
303
|
+
device.pool.releaseTexture(history.prevSSRReflectTex);
|
|
304
|
+
history.prevSSRReflectTex = null;
|
|
305
|
+
}
|
|
306
|
+
if (history.prevSSRMotionVectorTex) {
|
|
307
|
+
device.pool.releaseTexture(history.prevSSRMotionVectorTex);
|
|
308
|
+
history.prevSSRMotionVectorTex = null;
|
|
309
|
+
}
|
|
310
|
+
if (ctx.camera.ssrTemporal) {
|
|
311
|
+
device.pool.retainTexture(reflectanceTex);
|
|
312
|
+
history.prevSSRReflectTex = reflectanceTex;
|
|
313
|
+
}
|
|
314
|
+
if (ctx.camera.ssrTemporal && ctx.motionVectorTexture) {
|
|
315
|
+
if (history.prevSSRMotionVectorTex) {
|
|
316
|
+
device.pool.releaseTexture(history.prevSSRMotionVectorTex);
|
|
317
|
+
}
|
|
318
|
+
device.pool.retainTexture(ctx.motionVectorTexture);
|
|
319
|
+
history.prevSSRMotionVectorTex = ctx.motionVectorTexture;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
203
322
|
device.pool.releaseFrameBuffer(intersectFramebuffer);
|
|
204
323
|
device.pool.releaseFrameBuffer(pingpongFramebuffer[0]);
|
|
205
324
|
device.pool.releaseFrameBuffer(pingpongFramebuffer[1]);
|
|
@@ -222,17 +341,82 @@ import '../utility/blueprint/material/texture.js';
|
|
|
222
341
|
this.colorTex = pb.tex2D().uniform(0);
|
|
223
342
|
this.reflectanceTex = pb.tex2D().uniform(0);
|
|
224
343
|
this.roughnessTex = pb.tex2D().uniform(0);
|
|
344
|
+
this.albedoTex = pb.tex2D().uniform(0);
|
|
345
|
+
this.extraTex = pb.tex2D().uniform(0);
|
|
346
|
+
this.normalTex = pb.tex2D().uniform(0);
|
|
347
|
+
this.depthTex = pb.tex2D().uniform(0);
|
|
348
|
+
this.zGGXLut = pb.tex2D().uniform(0);
|
|
225
349
|
this.targetSize = pb.vec4().uniform(0);
|
|
350
|
+
this.cameraNearFar = pb.vec2().uniform(0);
|
|
351
|
+
this.viewMatrix = pb.mat4().uniform(0);
|
|
352
|
+
this.invProjMatrix = pb.mat4().uniform(0);
|
|
226
353
|
this.ssrMaxRoughness = pb.float().uniform(0);
|
|
354
|
+
this.ssrStrengthMode = pb.int().uniform(0);
|
|
227
355
|
this.srgbOut = pb.int().uniform(0);
|
|
228
356
|
this.$outputs.outColor = pb.vec4();
|
|
357
|
+
pb.func('getPosition', [
|
|
358
|
+
pb.vec2('uv')
|
|
359
|
+
], function() {
|
|
360
|
+
this.$l.linearDepth = ShaderHelper.sampleLinearDepth(this, this.depthTex, this.uv, 0);
|
|
361
|
+
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));
|
|
362
|
+
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);
|
|
363
|
+
this.$l.viewPos4 = pb.mul(this.invProjMatrix, this.clipSpacePos);
|
|
364
|
+
this.$return(pb.vec4(pb.div(this.viewPos4.xyz, this.viewPos4.w), this.linearDepth));
|
|
365
|
+
});
|
|
366
|
+
pb.func('resolveDeferredStrength', [
|
|
367
|
+
pb.vec2('uv'),
|
|
368
|
+
pb.vec4('roughnessValue')
|
|
369
|
+
], function() {
|
|
370
|
+
this.$l.roughness = pb.clamp(this.roughnessValue.a, 0.045, 1);
|
|
371
|
+
this.$l.base = pb.textureSampleLevel(this.albedoTex, this.uv, 0);
|
|
372
|
+
// Hybrid may merge forward-only SSR surface data into the roughness MRT while the
|
|
373
|
+
// deferred GBuffer remains empty at those pixels. Fall back to forward SSR semantics
|
|
374
|
+
// there instead of decoding the mixed texture as deferred metallic/occlusion/F0 data.
|
|
375
|
+
this.$if(pb.lessThanEqual(this.base.a, 1e-5), function() {
|
|
376
|
+
this.$return(pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1)));
|
|
377
|
+
});
|
|
378
|
+
this.$l.pos = this.getPosition(this.uv);
|
|
379
|
+
this.$if(pb.greaterThanEqual(this.pos.w, 1), function() {
|
|
380
|
+
this.$return(pb.vec3(0));
|
|
381
|
+
});
|
|
382
|
+
this.$l.viewPos = this.pos.xyz;
|
|
383
|
+
this.$l.viewVec = pb.neg(pb.normalize(this.viewPos));
|
|
384
|
+
this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
|
|
385
|
+
this.$l.viewNormal = pb.normalize(pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz);
|
|
386
|
+
this.$l.NoV = pb.clamp(pb.dot(this.viewNormal, this.viewVec), 0.0001, 1);
|
|
387
|
+
this.$l.baseColor = this.base.rgb;
|
|
388
|
+
this.$l.extra = pb.textureSampleLevel(this.extraTex, this.uv, 0);
|
|
389
|
+
this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
|
|
390
|
+
this.$l.occlusion = pb.clamp(this.roughnessValue.g, 0, 1);
|
|
391
|
+
this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
|
|
392
|
+
this.$l.specularWeight = pb.clamp(this.extra.a, 0, 1);
|
|
393
|
+
this.$l.f0 = pb.mix(pb.mul(pb.vec3(0.04), this.specStrength), this.baseColor, this.metallic);
|
|
394
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.roughness)), this.f0), this.f0);
|
|
395
|
+
this.$l.kS = pb.add(this.f0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
396
|
+
this.$l.fab = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.roughness), pb.vec2(0), pb.vec2(1)), 0).rg, pb.vec2(0), pb.vec2(1));
|
|
397
|
+
this.$l.FssEss = pb.add(pb.mul(this.kS, this.fab.x), pb.vec3(this.fab.y));
|
|
398
|
+
this.$return(pb.clamp(pb.mul(this.FssEss, this.occlusion, this.specularWeight), pb.vec3(0), pb.vec3(1)));
|
|
399
|
+
});
|
|
229
400
|
pb.func('resolveSample', [
|
|
401
|
+
pb.vec2('uv'),
|
|
230
402
|
pb.vec3('sceneColor'),
|
|
231
403
|
pb.vec3('reflectance'),
|
|
232
404
|
pb.vec4('roughnessValue')
|
|
233
405
|
], function() {
|
|
234
406
|
this.$l.r = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
|
|
235
|
-
this.$l.strength = pb.
|
|
407
|
+
this.$l.strength = pb.vec3();
|
|
408
|
+
this.$if(pb.equal(this.ssrStrengthMode, 0), function() {
|
|
409
|
+
this.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
410
|
+
}).$elseif(pb.equal(this.ssrStrengthMode, 1), function() {
|
|
411
|
+
this.$l.roughAtten = pb.clamp(pb.sub(1, pb.div(this.roughnessValue.a, pb.max(this.ssrMaxRoughness, 1e-4))), 0, 1);
|
|
412
|
+
this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
|
|
413
|
+
this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
|
|
414
|
+
this.$l.f0 = pb.mix(pb.mul(0.04, this.specStrength), 1, this.metallic);
|
|
415
|
+
this.$l.s = pb.mul(this.roughAtten, this.roughAtten, this.f0);
|
|
416
|
+
this.strength = pb.vec3(this.s);
|
|
417
|
+
}).$else(function() {
|
|
418
|
+
this.strength = this.resolveDeferredStrength(this.uv, this.roughnessValue);
|
|
419
|
+
});
|
|
236
420
|
this.color = pb.add(pb.mul(this.r, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
237
421
|
this.$return(this.color);
|
|
238
422
|
});
|
|
@@ -245,7 +429,7 @@ import '../utility/blueprint/material/texture.js';
|
|
|
245
429
|
this.combined = this.sceneColor;
|
|
246
430
|
}).$else(function() {
|
|
247
431
|
this.$l.reflectance = pb.textureSampleLevel(this.reflectanceTex, this.screenUV, 0).rgb;
|
|
248
|
-
this.combined = this.resolveSample(this.sceneColor, this.reflectance, this.roughnessInfo);
|
|
432
|
+
this.combined = this.resolveSample(this.screenUV, this.sceneColor, this.reflectance, this.roughnessInfo);
|
|
249
433
|
});
|
|
250
434
|
this.$if(pb.equal(this.srgbOut, 0), function() {
|
|
251
435
|
this.$outputs.outColor = pb.vec4(this.combined, 1);
|
|
@@ -264,7 +448,7 @@ import '../utility/blueprint/material/texture.js';
|
|
|
264
448
|
this.flip = pb.int().uniform(0);
|
|
265
449
|
this.$inputs.pos = pb.vec2().attrib('position');
|
|
266
450
|
this.$outputs.uv = pb.vec2();
|
|
267
|
-
if (ctx.env.light.envLight) {
|
|
451
|
+
if (ctx.env.light.envLight?.hasRadiance()) {
|
|
268
452
|
ctx.env.light.envLight.initShaderBindings(pb);
|
|
269
453
|
}
|
|
270
454
|
pb.main(function() {
|
|
@@ -280,15 +464,20 @@ import '../utility/blueprint/material/texture.js';
|
|
|
280
464
|
this.intersectTex = pb.tex2D().uniform(0);
|
|
281
465
|
this.roughnessTex = pb.tex2D().uniform(0);
|
|
282
466
|
this.normalTex = pb.tex2D().uniform(0);
|
|
467
|
+
this.albedoTex = pb.tex2D().uniform(0);
|
|
468
|
+
this.extraTex = pb.tex2D().uniform(0);
|
|
283
469
|
this.depthTex = pb.tex2D().uniform(0);
|
|
470
|
+
this.zGGXLut = pb.tex2D().uniform(0);
|
|
284
471
|
this.cameraNearFar = pb.vec2().uniform(0);
|
|
285
472
|
this.targetSize = pb.vec4().uniform(0);
|
|
286
473
|
this.viewMatrix = pb.mat4().uniform(0);
|
|
287
474
|
this.invViewMatrix = pb.mat4().uniform(0);
|
|
288
475
|
this.invProjMatrix = pb.mat4().uniform(0);
|
|
289
476
|
this.ssrMaxRoughness = pb.float().uniform(0);
|
|
290
|
-
|
|
477
|
+
this.ssrStrengthMode = pb.int().uniform(0);
|
|
478
|
+
if (ctx.env.light.envLight?.hasRadiance()) {
|
|
291
479
|
this.envLightStrength = pb.float().uniform(0);
|
|
480
|
+
this.envLightSpecularStrength = pb.float().uniform(0);
|
|
292
481
|
ctx.env.light.envLight.initShaderBindings(pb);
|
|
293
482
|
}
|
|
294
483
|
this.$outputs.outColor = pb.vec4();
|
|
@@ -302,13 +491,57 @@ import '../utility/blueprint/material/texture.js';
|
|
|
302
491
|
this.$l.wPos = pb.mul(this.mat, this.clipSpacePos);
|
|
303
492
|
this.$return(pb.vec4(pb.div(this.wPos.xyz, this.wPos.w), this.linearDepth));
|
|
304
493
|
});
|
|
494
|
+
pb.func('resolveDeferredStrength', [
|
|
495
|
+
pb.vec2('uv'),
|
|
496
|
+
pb.vec4('roughnessValue')
|
|
497
|
+
], function() {
|
|
498
|
+
this.$l.roughness = pb.clamp(this.roughnessValue.a, 0.045, 1);
|
|
499
|
+
this.$l.base = pb.textureSampleLevel(this.albedoTex, this.uv, 0);
|
|
500
|
+
this.$if(pb.lessThanEqual(this.base.a, 1e-5), function() {
|
|
501
|
+
this.$return(pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1)));
|
|
502
|
+
});
|
|
503
|
+
this.$l.pos = this.getPosition(this.uv, this.invProjMatrix);
|
|
504
|
+
this.$if(pb.greaterThanEqual(this.pos.w, 1), function() {
|
|
505
|
+
this.$return(pb.vec3(0));
|
|
506
|
+
});
|
|
507
|
+
this.$l.viewPos = this.pos.xyz;
|
|
508
|
+
this.$l.viewVec = pb.neg(pb.normalize(this.viewPos));
|
|
509
|
+
this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
|
|
510
|
+
this.$l.viewNormal = pb.normalize(pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz);
|
|
511
|
+
this.$l.NoV = pb.clamp(pb.dot(this.viewNormal, this.viewVec), 0.0001, 1);
|
|
512
|
+
this.$l.baseColor = this.base.rgb;
|
|
513
|
+
this.$l.extra = pb.textureSampleLevel(this.extraTex, this.uv, 0);
|
|
514
|
+
this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
|
|
515
|
+
this.$l.occlusion = pb.clamp(this.roughnessValue.g, 0, 1);
|
|
516
|
+
this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
|
|
517
|
+
this.$l.specularWeight = pb.clamp(this.extra.a, 0, 1);
|
|
518
|
+
this.$l.f0 = pb.mix(pb.mul(pb.vec3(0.04), this.specStrength), this.baseColor, this.metallic);
|
|
519
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.roughness)), this.f0), this.f0);
|
|
520
|
+
this.$l.kS = pb.add(this.f0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
521
|
+
this.$l.fab = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.roughness), pb.vec2(0), pb.vec2(1)), 0).rg, pb.vec2(0), pb.vec2(1));
|
|
522
|
+
this.$l.FssEss = pb.add(pb.mul(this.kS, this.fab.x), pb.vec3(this.fab.y));
|
|
523
|
+
this.$return(pb.clamp(pb.mul(this.FssEss, this.occlusion, this.specularWeight), pb.vec3(0), pb.vec3(1)));
|
|
524
|
+
});
|
|
305
525
|
pb.func('resolveSample', [
|
|
526
|
+
pb.vec2('uv'),
|
|
306
527
|
pb.vec3('sceneColor'),
|
|
307
528
|
pb.vec3('reflectance'),
|
|
308
529
|
pb.vec4('roughnessValue')
|
|
309
530
|
], function() {
|
|
310
531
|
this.$l.r = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
|
|
311
|
-
this.$l.strength = pb.
|
|
532
|
+
this.$l.strength = pb.vec3();
|
|
533
|
+
this.$if(pb.equal(this.ssrStrengthMode, 0), function() {
|
|
534
|
+
this.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
535
|
+
}).$elseif(pb.equal(this.ssrStrengthMode, 1), function() {
|
|
536
|
+
this.$l.roughAtten = pb.clamp(pb.sub(1, pb.div(this.roughnessValue.a, pb.max(this.ssrMaxRoughness, 1e-4))), 0, 1);
|
|
537
|
+
this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
|
|
538
|
+
this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
|
|
539
|
+
this.$l.f0 = pb.mix(pb.mul(0.04, this.specStrength), 1, this.metallic);
|
|
540
|
+
this.$l.s = pb.mul(this.roughAtten, this.roughAtten, this.f0);
|
|
541
|
+
this.strength = pb.vec3(this.s);
|
|
542
|
+
}).$else(function() {
|
|
543
|
+
this.strength = this.resolveDeferredStrength(this.uv, this.roughnessValue);
|
|
544
|
+
});
|
|
312
545
|
this.color = pb.add(pb.mul(this.r, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
313
546
|
this.$return(this.color);
|
|
314
547
|
});
|
|
@@ -316,7 +549,7 @@ import '../utility/blueprint/material/texture.js';
|
|
|
316
549
|
pb.vec2('uv'),
|
|
317
550
|
pb.vec4('roughnessInfo')
|
|
318
551
|
], function() {
|
|
319
|
-
if (!ctx.env.light.envLight) {
|
|
552
|
+
if (!ctx.env.light.envLight?.hasRadiance()) {
|
|
320
553
|
this.$return(pb.vec3(0));
|
|
321
554
|
return;
|
|
322
555
|
}
|
|
@@ -331,8 +564,8 @@ import '../utility/blueprint/material/texture.js';
|
|
|
331
564
|
this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
|
|
332
565
|
this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
|
|
333
566
|
this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
|
|
334
|
-
this.$l.roughness2 = pb.
|
|
335
|
-
this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness2), this.envLightStrength);
|
|
567
|
+
this.$l.roughness2 = pb.clamp(this.roughness, 0, 1);
|
|
568
|
+
this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness2), this.envLightStrength, this.envLightSpecularStrength);
|
|
336
569
|
this.$return(pb.min(this.env, pb.vec3(1)));
|
|
337
570
|
});
|
|
338
571
|
pb.func('resolveReflectance', [
|
|
@@ -342,32 +575,36 @@ import '../utility/blueprint/material/texture.js';
|
|
|
342
575
|
pb.float('alpha')
|
|
343
576
|
], function() {
|
|
344
577
|
this.$l.env = this.resolveEnvRadiance(this.uv, this.roughnessInfo);
|
|
345
|
-
this.$l.reflectance = pb.mix(this.env, this.reflectSceneColor, this.alpha);
|
|
578
|
+
this.$l.reflectance = pb.mix(this.env, this.reflectSceneColor, pb.clamp(this.alpha, 0, 1));
|
|
346
579
|
this.$return(this.reflectance);
|
|
347
580
|
});
|
|
348
581
|
pb.main(function() {
|
|
349
582
|
this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
|
|
350
583
|
this.$l.roughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
|
|
351
|
-
this.$
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
this.$
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
this.$l.
|
|
362
|
-
this.indirectReflectance =
|
|
584
|
+
this.$l.intersectSample = pb.vec4(0);
|
|
585
|
+
this.$l.reflectance = pb.vec3(0);
|
|
586
|
+
this.$if(pb.lessThan(this.roughnessInfo.a, this.ssrMaxRoughness), function() {
|
|
587
|
+
this.intersectSample = pb.textureSampleLevel(this.intersectTex, this.screenUV, 0);
|
|
588
|
+
this.$l.hitAlpha = pb.clamp(this.intersectSample.w, 0, 1);
|
|
589
|
+
this.$l.hitUV = pb.clamp(this.intersectSample.xy, pb.vec2(0), pb.vec2(1));
|
|
590
|
+
this.$if(pb.greaterThan(this.hitAlpha, 0), function() {
|
|
591
|
+
this.$l.indirectIntersectSample = pb.textureSampleLevel(this.intersectTex, this.hitUV, 0);
|
|
592
|
+
this.$l.indirectAlpha = pb.clamp(this.indirectIntersectSample.w, 0, 1);
|
|
593
|
+
this.$l.indirectUV = pb.clamp(this.indirectIntersectSample.xy, pb.vec2(0), pb.vec2(1));
|
|
594
|
+
this.$l.indirectRoughnessInfo = pb.textureSampleLevel(this.roughnessTex, this.hitUV, 0);
|
|
595
|
+
this.$l.indirectReflectance = pb.vec3();
|
|
596
|
+
this.$if(pb.greaterThan(this.indirectAlpha, 0), function() {
|
|
597
|
+
this.$l.indirectReflectSceneColor = pb.textureSampleLevel(this.colorTex, this.indirectUV, 0).rgb;
|
|
598
|
+
this.indirectReflectance = this.resolveReflectance(this.hitUV, this.indirectReflectSceneColor, this.indirectRoughnessInfo, this.indirectAlpha);
|
|
599
|
+
}).$else(function() {
|
|
600
|
+
this.indirectReflectance = this.resolveEnvRadiance(this.hitUV, this.indirectRoughnessInfo);
|
|
601
|
+
});
|
|
602
|
+
this.$l.reflectSceneColor = pb.textureSampleLevel(this.colorTex, this.hitUV, 0).rgb;
|
|
603
|
+
this.$l.reflectSceneColor = this.resolveSample(this.hitUV, this.reflectSceneColor, this.indirectReflectance, this.indirectRoughnessInfo);
|
|
604
|
+
this.reflectance = this.resolveReflectance(this.screenUV, this.reflectSceneColor, this.roughnessInfo, this.hitAlpha);
|
|
363
605
|
}).$else(function() {
|
|
364
|
-
this.
|
|
606
|
+
this.reflectance = this.resolveEnvRadiance(this.screenUV, this.roughnessInfo);
|
|
365
607
|
});
|
|
366
|
-
this.$l.reflectSceneColor = pb.textureSampleLevel(this.colorTex, this.intersectSample.xy, 0).rgb;
|
|
367
|
-
this.$l.reflectSceneColor = this.resolveSample(this.reflectSceneColor, this.indirectReflectance, this.indirectRoughnessInfo);
|
|
368
|
-
this.reflectance = this.resolveReflectance(this.screenUV, this.reflectSceneColor, this.roughnessInfo, this.intersectSample.w);
|
|
369
|
-
}).$else(function() {
|
|
370
|
-
this.reflectance = this.resolveEnvRadiance(this.screenUV, this.roughnessInfo);
|
|
371
608
|
});
|
|
372
609
|
this.$outputs.outColor = pb.vec4(this.reflectance, this.intersectSample.z);
|
|
373
610
|
});
|
|
@@ -376,13 +613,48 @@ import '../utility/blueprint/material/texture.js';
|
|
|
376
613
|
program.name = '@SSR_Resolve';
|
|
377
614
|
return program;
|
|
378
615
|
}
|
|
616
|
+
/** @internal */ _createTemporalProgram(ctx) {
|
|
617
|
+
const program = ctx.device.buildRenderProgram({
|
|
618
|
+
vertex (pb) {
|
|
619
|
+
this.flip = pb.int().uniform(0);
|
|
620
|
+
this.$inputs.pos = pb.vec2().attrib('position');
|
|
621
|
+
this.$outputs.uv = pb.vec2();
|
|
622
|
+
pb.main(function() {
|
|
623
|
+
this.$builtins.position = pb.vec4(this.$inputs.pos, 1, 1);
|
|
624
|
+
this.$outputs.uv = pb.add(pb.mul(this.$inputs.pos.xy, 0.5), pb.vec2(0.5));
|
|
625
|
+
this.$if(pb.notEqual(this.flip, 0), function() {
|
|
626
|
+
this.$builtins.position.y = pb.neg(this.$builtins.position.y);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
},
|
|
630
|
+
fragment (pb) {
|
|
631
|
+
this.historyColorTex = pb.tex2D().uniform(0);
|
|
632
|
+
this.currentColorTex = pb.tex2D().uniform(0);
|
|
633
|
+
this.currentDepthTex = pb.tex2D().uniform(0);
|
|
634
|
+
this.motionVector = pb.tex2D().uniform(0);
|
|
635
|
+
this.prevMotionVector = pb.tex2D().uniform(0);
|
|
636
|
+
this.texSize = pb.vec2().uniform(0);
|
|
637
|
+
this.temporalWeight = pb.float().uniform(0);
|
|
638
|
+
this.$outputs.outColor = pb.vec4();
|
|
639
|
+
pb.main(function() {
|
|
640
|
+
this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.texSize);
|
|
641
|
+
this.$l.currentColor = pb.textureSampleLevel(this.currentColorTex, this.screenUV, 0).rgb;
|
|
642
|
+
this.$l.resolvedColor = temporalResolve(this, this.currentColorTex, this.historyColorTex, this.currentDepthTex, this.motionVector, this.prevMotionVector, this.screenUV, this.texSize, 0);
|
|
643
|
+
this.$l.w = pb.clamp(this.temporalWeight, 0, 1);
|
|
644
|
+
this.$outputs.outColor = pb.vec4(pb.mix(this.currentColor, this.resolvedColor, this.w), 1);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
program.name = '@SSR_Temporal';
|
|
649
|
+
return program;
|
|
650
|
+
}
|
|
379
651
|
/** @internal */ _createIntersectProgram(ctx, blur) {
|
|
380
652
|
const program = ctx.device.buildRenderProgram({
|
|
381
653
|
vertex (pb) {
|
|
382
654
|
this.flip = pb.int().uniform(0);
|
|
383
655
|
this.$inputs.pos = pb.vec2().attrib('position');
|
|
384
656
|
this.$outputs.uv = pb.vec2();
|
|
385
|
-
if (!blur && ctx.env.light.envLight) {
|
|
657
|
+
if (!blur && ctx.env.light.envLight?.hasRadiance()) {
|
|
386
658
|
ctx.env.light.envLight.initShaderBindings(pb);
|
|
387
659
|
}
|
|
388
660
|
pb.main(function() {
|
|
@@ -396,14 +668,18 @@ import '../utility/blueprint/material/texture.js';
|
|
|
396
668
|
fragment (pb) {
|
|
397
669
|
if (!blur) {
|
|
398
670
|
this.colorTex = pb.tex2D().uniform(0);
|
|
399
|
-
if (ctx.env.light.envLight) {
|
|
671
|
+
if (ctx.env.light.envLight?.hasRadiance()) {
|
|
400
672
|
this.envLightStrength = pb.float().uniform(0);
|
|
673
|
+
this.envLightSpecularStrength = pb.float().uniform(0);
|
|
401
674
|
ctx.env.light.envLight.initShaderBindings(pb);
|
|
402
675
|
}
|
|
403
676
|
}
|
|
677
|
+
this.albedoTex = pb.tex2D().uniform(0);
|
|
404
678
|
this.roughnessTex = pb.tex2D().uniform(0);
|
|
405
679
|
this.normalTex = pb.tex2D().uniform(0);
|
|
680
|
+
this.extraTex = pb.tex2D().uniform(0);
|
|
406
681
|
this.depthTex = pb.tex2D().uniform(0);
|
|
682
|
+
this.zGGXLut = pb.tex2D().uniform(0);
|
|
407
683
|
this.cameraNearFar = pb.vec2().uniform(0);
|
|
408
684
|
this.cameraPos = pb.vec3().uniform(0);
|
|
409
685
|
this.invProjMatrix = pb.mat4().uniform(0);
|
|
@@ -412,6 +688,7 @@ import '../utility/blueprint/material/texture.js';
|
|
|
412
688
|
this.invViewMatrix = pb.mat4().uniform(0);
|
|
413
689
|
this.ssrParams = pb.vec4().uniform(0);
|
|
414
690
|
this.ssrMaxRoughness = pb.float().uniform(0);
|
|
691
|
+
this.ssrStrengthMode = pb.int().uniform(0);
|
|
415
692
|
this.targetSize = pb.vec4().uniform(0);
|
|
416
693
|
if (ctx.HiZTexture) {
|
|
417
694
|
this.hizTex = pb.tex2D().uniform(0);
|
|
@@ -431,56 +708,102 @@ import '../utility/blueprint/material/texture.js';
|
|
|
431
708
|
this.$l.wPos = pb.mul(this.mat, this.clipSpacePos);
|
|
432
709
|
this.$return(pb.vec4(pb.div(this.wPos.xyz, this.wPos.w), this.linearDepth));
|
|
433
710
|
});
|
|
711
|
+
pb.func('resolveDeferredStrength', [
|
|
712
|
+
pb.vec2('uv'),
|
|
713
|
+
pb.vec4('roughnessValue'),
|
|
714
|
+
pb.vec4('viewPosInfo')
|
|
715
|
+
], function() {
|
|
716
|
+
this.$l.roughness = pb.clamp(this.roughnessValue.a, 0.045, 1);
|
|
717
|
+
this.$l.base = pb.textureSampleLevel(this.albedoTex, this.uv, 0);
|
|
718
|
+
this.$if(pb.lessThanEqual(this.base.a, 1e-5), function() {
|
|
719
|
+
this.$return(pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1)));
|
|
720
|
+
});
|
|
721
|
+
this.$l.viewPos = this.viewPosInfo.xyz;
|
|
722
|
+
this.$l.viewVec = pb.neg(pb.normalize(this.viewPos));
|
|
723
|
+
this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.uv, 0).rgb, 2), pb.vec3(1));
|
|
724
|
+
this.$l.viewNormal = pb.normalize(pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz);
|
|
725
|
+
this.$l.NoV = pb.clamp(pb.dot(this.viewNormal, this.viewVec), 0.0001, 1);
|
|
726
|
+
this.$l.baseColor = this.base.rgb;
|
|
727
|
+
this.$l.extra = pb.textureSampleLevel(this.extraTex, this.uv, 0);
|
|
728
|
+
this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
|
|
729
|
+
this.$l.occlusion = pb.clamp(this.roughnessValue.g, 0, 1);
|
|
730
|
+
this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
|
|
731
|
+
this.$l.specularWeight = pb.clamp(this.extra.a, 0, 1);
|
|
732
|
+
this.$l.f0 = pb.mix(pb.mul(pb.vec3(0.04), this.specStrength), this.baseColor, this.metallic);
|
|
733
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.roughness)), this.f0), this.f0);
|
|
734
|
+
this.$l.kS = pb.add(this.f0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
735
|
+
this.$l.fab = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.roughness), pb.vec2(0), pb.vec2(1)), 0).rg, pb.vec2(0), pb.vec2(1));
|
|
736
|
+
this.$l.FssEss = pb.add(pb.mul(this.kS, this.fab.x), pb.vec3(this.fab.y));
|
|
737
|
+
this.$return(pb.clamp(pb.mul(this.FssEss, this.occlusion, this.specularWeight), pb.vec3(0), pb.vec3(1)));
|
|
738
|
+
});
|
|
434
739
|
pb.main(function() {
|
|
435
740
|
this.$l.screenUV = pb.div(pb.vec2(this.$builtins.fragCoord.xy), this.targetSize.xy);
|
|
436
741
|
this.$l.roughnessValue = pb.textureSampleLevel(this.roughnessTex, this.screenUV, 0);
|
|
437
742
|
this.$l.roughness = this.roughnessValue.a;
|
|
438
|
-
this.$if(pb.greaterThanEqual(this.roughness, this.ssrMaxRoughness), function() {
|
|
439
|
-
pb.discard();
|
|
440
|
-
});
|
|
441
743
|
if (!blur) {
|
|
442
744
|
this.$l.sceneColor = pb.textureSampleLevel(this.colorTex, this.screenUV, 0).rgb;
|
|
443
745
|
}
|
|
444
|
-
this.$l.pos = this.getPosition(this.screenUV, this.invProjMatrix);
|
|
445
|
-
this.$l.linearDepth = this.pos.w;
|
|
446
746
|
this.$l.color = pb.vec3(0);
|
|
447
|
-
this.$l.a = pb.float();
|
|
448
|
-
this.$if(pb.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
this.
|
|
462
|
-
this.$
|
|
463
|
-
|
|
464
|
-
this
|
|
465
|
-
|
|
466
|
-
this
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
747
|
+
this.$l.a = pb.float(0);
|
|
748
|
+
this.$if(pb.lessThan(this.roughness, this.ssrMaxRoughness), function() {
|
|
749
|
+
this.$l.pos = this.getPosition(this.screenUV, this.invProjMatrix);
|
|
750
|
+
this.$l.linearDepth = this.pos.w;
|
|
751
|
+
this.$if(pb.greaterThanEqual(this.linearDepth, 1), function() {
|
|
752
|
+
if (!blur) {
|
|
753
|
+
this.color = this.sceneColor;
|
|
754
|
+
this.a = 1;
|
|
755
|
+
}
|
|
756
|
+
}).$else(function() {
|
|
757
|
+
this.$l.viewPos = this.pos.xyz;
|
|
758
|
+
this.$l.worldNormal = pb.sub(pb.mul(pb.textureSampleLevel(this.normalTex, this.screenUV, 0).rgb, 2), pb.vec3(1));
|
|
759
|
+
this.$l.viewVec = pb.normalize(this.viewPos);
|
|
760
|
+
this.$l.viewNormal = pb.mul(this.viewMatrix, pb.vec4(this.worldNormal, 0)).xyz;
|
|
761
|
+
this.$l.reflectVec = pb.add(pb.reflect(this.viewVec, this.viewNormal), SSR_calcJitter(this, this.viewPos, this.roughness));
|
|
762
|
+
this.$l.hitInfo = pb.vec4(0);
|
|
763
|
+
if (ctx.HiZTexture) {
|
|
764
|
+
this.hitInfo = 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);
|
|
765
|
+
} else {
|
|
766
|
+
this.hitInfo = 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.camera.ssrCalcThickness);
|
|
767
|
+
}
|
|
768
|
+
this.$l.hitAlpha = pb.clamp(this.hitInfo.w, 0, 1);
|
|
769
|
+
this.$l.hitUV = pb.clamp(this.hitInfo.xy, pb.vec2(0), pb.vec2(1));
|
|
770
|
+
if (blur) {
|
|
771
|
+
this.blurRadius = pb.float(0);
|
|
772
|
+
this.$if(pb.greaterThan(this.roughness, 0.001), function() {
|
|
773
|
+
this.$l.coneAngle = pb.mul(pb.min(this.roughness, 0.999), Math.PI * 0.5);
|
|
774
|
+
this.$l.coneLen = this.$choice(pb.greaterThan(this.hitAlpha, 0), this.hitInfo.z, pb.min(this.targetSize.z, this.targetSize.w));
|
|
775
|
+
this.$l.opLen = pb.mul(pb.tan(this.coneAngle), this.coneLen, 2);
|
|
776
|
+
this.$l.a2 = pb.mul(this.opLen, this.opLen);
|
|
777
|
+
this.$l.fh2 = pb.mul(this.coneLen, this.coneLen, 4);
|
|
778
|
+
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));
|
|
779
|
+
});
|
|
780
|
+
this.a = this.hitAlpha;
|
|
781
|
+
this.color = pb.vec3(this.hitUV, pb.clamp(pb.div(this.blurRadius, 255), 0, 1));
|
|
476
782
|
} else {
|
|
477
|
-
|
|
783
|
+
if (ctx.env.light.envLight?.hasRadiance()) {
|
|
784
|
+
this.$l.reflectVecW = pb.mul(this.invViewMatrix, pb.vec4(this.reflectVec, 0)).xyz;
|
|
785
|
+
this.$l.env = pb.mul(ctx.env.light.envLight.getRadiance(this, this.reflectVecW, this.roughness), this.envLightStrength, this.envLightSpecularStrength);
|
|
786
|
+
} else {
|
|
787
|
+
this.$l.env = pb.vec3(0);
|
|
788
|
+
}
|
|
789
|
+
this.$l.reflectance = pb.mix(this.env, pb.textureSampleLevel(this.colorTex, this.hitUV, 0).rgb, this.hitAlpha);
|
|
790
|
+
this.$l.reflectance = pb.div(this.$l.reflectance, pb.add(this.$l.reflectance, pb.vec3(1)));
|
|
791
|
+
this.$l.strength = pb.vec3();
|
|
792
|
+
this.$if(pb.equal(this.ssrStrengthMode, 0), function() {
|
|
793
|
+
this.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
794
|
+
}).$elseif(pb.equal(this.ssrStrengthMode, 1), function() {
|
|
795
|
+
this.$l.roughAtten = pb.clamp(pb.sub(1, pb.div(this.roughness, pb.max(this.ssrMaxRoughness, 1e-4))), 0, 1);
|
|
796
|
+
this.$l.metallic = pb.clamp(this.roughnessValue.r, 0, 1);
|
|
797
|
+
this.$l.specStrength = pb.clamp(this.roughnessValue.b, 0, 1);
|
|
798
|
+
this.$l.f0 = pb.mix(pb.mul(0.04, this.specStrength), 1, this.metallic);
|
|
799
|
+
this.$l.s = pb.mul(this.roughAtten, this.roughAtten, this.f0);
|
|
800
|
+
this.strength = pb.vec3(this.s);
|
|
801
|
+
}).$else(function() {
|
|
802
|
+
this.strength = this.resolveDeferredStrength(this.screenUV, this.roughnessValue, this.pos);
|
|
803
|
+
});
|
|
804
|
+
this.color = pb.add(pb.mul(this.reflectance, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
478
805
|
}
|
|
479
|
-
|
|
480
|
-
this.reflectance = pb.div(this.reflectance, pb.add(this.reflectance, pb.vec3(1)));
|
|
481
|
-
this.$l.strength = pb.clamp(this.roughnessValue.rgb, pb.vec3(0), pb.vec3(1));
|
|
482
|
-
this.color = pb.add(pb.mul(this.reflectance, this.strength), pb.mul(this.sceneColor, pb.sub(pb.vec3(1), this.strength)));
|
|
483
|
-
}
|
|
806
|
+
});
|
|
484
807
|
});
|
|
485
808
|
this.$if(pb.equal(this.srgbOut, 0), function() {
|
|
486
809
|
this.$outputs.outColor = pb.vec4(this.color, this.a);
|
|
@@ -490,6 +813,9 @@ import '../utility/blueprint/material/texture.js';
|
|
|
490
813
|
});
|
|
491
814
|
}
|
|
492
815
|
});
|
|
816
|
+
if (!program) {
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
493
819
|
program.name = blur ? '@SSR_Intersect_Blur' : '@SSR_Intersect';
|
|
494
820
|
return program;
|
|
495
821
|
}
|