@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Vector4 } from '@zephyr3d/base';
|
|
2
|
+
import { RenderQueue } from '../render_queue.js';
|
|
2
3
|
import { LightPass } from '../lightpass.js';
|
|
3
4
|
import { ShadowMapPass } from '../shadowmap_pass.js';
|
|
4
5
|
import { DepthPass } from '../depthpass.js';
|
|
@@ -32,47 +33,184 @@ const _clusters = [];
|
|
|
32
33
|
const _devicePoolAllocator = new DevicePoolAllocator();
|
|
33
34
|
let _backDepthColorState = null;
|
|
34
35
|
let _frontDepthColorState = null;
|
|
36
|
+
const SURFACE_MRT_FLAGS = MaterialVaryingFlags.SSR_STORE_ROUGHNESS | MaterialVaryingFlags.SSS_STORE_PROFILE | MaterialVaryingFlags.SSS_STORE_DIFFUSE | MaterialVaryingFlags.SSS_STORE_NORMAL | MaterialVaryingFlags.SSS_STORE_TRANSMISSION;
|
|
35
37
|
function getClusteredLight() {
|
|
36
38
|
return _clusters.length > 0 ? _clusters.pop() : new ClusteredLight();
|
|
37
39
|
}
|
|
38
40
|
function freeClusteredLight(cl) {
|
|
39
41
|
_clusters.push(cl);
|
|
40
42
|
}
|
|
43
|
+
function getCoreMaterial(material) {
|
|
44
|
+
return material?.coreMaterial ?? material ?? null;
|
|
45
|
+
}
|
|
46
|
+
function hasSSSMaterialCore(material) {
|
|
47
|
+
return !!getCoreMaterial(material)?.subsurfaceProfile;
|
|
48
|
+
}
|
|
49
|
+
function renderQueueHasActiveSSS(renderQueue) {
|
|
50
|
+
const itemList = renderQueue.itemList;
|
|
51
|
+
if (!itemList) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const lists = [
|
|
55
|
+
...itemList.opaque.lit,
|
|
56
|
+
...itemList.opaque.unlit
|
|
57
|
+
];
|
|
58
|
+
for (const list of lists){
|
|
59
|
+
for (const material of list.materialList){
|
|
60
|
+
if (hasSSSMaterialCore(material)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
function filterActualSSSItemList(items) {
|
|
68
|
+
return items.filter((item)=>hasSSSMaterialCore(item.drawable.getMaterial?.()));
|
|
69
|
+
}
|
|
70
|
+
function filterActualSSSMaterialList(materialList) {
|
|
71
|
+
const filtered = new Set();
|
|
72
|
+
materialList.forEach((mat)=>{
|
|
73
|
+
if (hasSSSMaterialCore(mat)) {
|
|
74
|
+
filtered.add(mat);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return filtered;
|
|
78
|
+
}
|
|
79
|
+
function cloneActualSSSListInfo(source, _targetQueue) {
|
|
80
|
+
return {
|
|
81
|
+
itemList: filterActualSSSItemList(source.itemList),
|
|
82
|
+
skinItemList: filterActualSSSItemList(source.skinItemList),
|
|
83
|
+
morphItemList: filterActualSSSItemList(source.morphItemList),
|
|
84
|
+
skinAndMorphItemList: filterActualSSSItemList(source.skinAndMorphItemList),
|
|
85
|
+
instanceItemList: filterActualSSSItemList(source.instanceItemList),
|
|
86
|
+
materialList: filterActualSSSMaterialList(source.materialList),
|
|
87
|
+
instanceList: {},
|
|
88
|
+
renderQueue: source.renderQueue
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function cloneActualSSSBundle(source, targetQueue) {
|
|
92
|
+
return {
|
|
93
|
+
lit: source.lit.map((info)=>cloneActualSSSListInfo(info)),
|
|
94
|
+
unlit: source.unlit.map((info)=>cloneActualSSSListInfo(info))
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function hasAnyActualSSSItems(renderItems) {
|
|
98
|
+
return renderItems.some((info)=>info.itemList.length > 0 || info.skinItemList.length > 0 || info.morphItemList.length > 0 || info.skinAndMorphItemList.length > 0 || info.instanceItemList.length > 0);
|
|
99
|
+
}
|
|
100
|
+
function createActualSSSRenderQueue(renderQueue) {
|
|
101
|
+
const itemList = renderQueue.itemList;
|
|
102
|
+
if (!itemList) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const queue = new RenderQueue(_scenePass);
|
|
106
|
+
const sssOpaque = cloneActualSSSBundle(itemList.opaque);
|
|
107
|
+
if (!hasAnyActualSSSItems([
|
|
108
|
+
...sssOpaque.lit,
|
|
109
|
+
...sssOpaque.unlit
|
|
110
|
+
])) {
|
|
111
|
+
queue.dispose();
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const emptyBundle = {
|
|
115
|
+
lit: [],
|
|
116
|
+
unlit: []
|
|
117
|
+
};
|
|
118
|
+
const target = queue;
|
|
119
|
+
target._itemList = {
|
|
120
|
+
opaque: sssOpaque,
|
|
121
|
+
transmission: emptyBundle,
|
|
122
|
+
transparent: emptyBundle,
|
|
123
|
+
transmission_trans: emptyBundle
|
|
124
|
+
};
|
|
125
|
+
target._shadowedLightList = renderQueue.shadowedLights;
|
|
126
|
+
target._unshadowedLightList = renderQueue.unshadowedLights;
|
|
127
|
+
target._sunLight = renderQueue.sunLight;
|
|
128
|
+
target._primaryDirectionalLight = renderQueue.primaryDirectionalLight;
|
|
129
|
+
target._primaryTransmissionLight = renderQueue.primaryTransmissionLight;
|
|
130
|
+
target._needSceneColor = false;
|
|
131
|
+
target._needSceneDepth = false;
|
|
132
|
+
target._needSceneColorWithDepth = false;
|
|
133
|
+
target._drawTransparent = false;
|
|
134
|
+
return queue;
|
|
135
|
+
}
|
|
136
|
+
function getSurfaceTextureFormat(ctx) {
|
|
137
|
+
const caps = ctx.device.getDeviceCaps?.();
|
|
138
|
+
return caps?.textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';
|
|
139
|
+
}
|
|
140
|
+
function getTextureFormatBytes(ctx, format) {
|
|
141
|
+
return ctx.device.getDeviceCaps().textureCaps.getTextureFormatInfo(format).size;
|
|
142
|
+
}
|
|
143
|
+
function shouldStoreSSSDiffuse(ctx) {
|
|
144
|
+
return ctx.camera.sssStrength > 0 && ctx.camera.sssBlurScale > 0;
|
|
145
|
+
}
|
|
146
|
+
function shouldStoreSSSTransmission(ctx) {
|
|
147
|
+
return ctx.camera.sssStrength > 0 && ctx.camera.sssTransmissionStrength > 0;
|
|
148
|
+
}
|
|
149
|
+
function getSSSLightingTextureFormat(ctx, attachmentCount, includeSSRSurfaceMRT) {
|
|
150
|
+
const colorFormat = ctx.colorFormat;
|
|
151
|
+
if (!includeSSRSurfaceMRT || attachmentCount === 0) {
|
|
152
|
+
return colorFormat;
|
|
153
|
+
}
|
|
154
|
+
const caps = ctx.device.getDeviceCaps();
|
|
155
|
+
const roughnessFormat = ctx.SSRRoughnessTexture?.format ?? colorFormat;
|
|
156
|
+
const normalFormat = ctx.SSRNormalTexture?.format ?? colorFormat;
|
|
157
|
+
const colorBytes = getTextureFormatBytes(ctx, colorFormat) + getTextureFormatBytes(ctx, roughnessFormat) + getTextureFormatBytes(ctx, normalFormat);
|
|
158
|
+
const fullPrecisionBytes = colorBytes + getTextureFormatBytes(ctx, colorFormat) * attachmentCount;
|
|
159
|
+
if (fullPrecisionBytes <= caps.framebufferCaps.maxColorAttachmentBytesPerSample) {
|
|
160
|
+
return colorFormat;
|
|
161
|
+
}
|
|
162
|
+
return 'rgba8unorm';
|
|
163
|
+
}
|
|
164
|
+
function getFullMipLevelCount(width, height) {
|
|
165
|
+
return Math.max(1, Math.floor(Math.log2(Math.max(1, width, height))) + 1);
|
|
166
|
+
}
|
|
167
|
+
function hasSurfaceMRT(ctx) {
|
|
168
|
+
return !!(ctx.materialFlags & SURFACE_MRT_FLAGS);
|
|
169
|
+
}
|
|
170
|
+
function getLightPassColorAttachments(ctx, colorAttachment) {
|
|
171
|
+
const attachments = [
|
|
172
|
+
colorAttachment
|
|
173
|
+
];
|
|
174
|
+
if (ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
175
|
+
attachments.push(ctx.SSRRoughnessTexture, ctx.SSRNormalTexture);
|
|
176
|
+
} else if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_NORMAL) {
|
|
177
|
+
attachments.push(ctx.SSRNormalTexture);
|
|
178
|
+
}
|
|
179
|
+
if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_PROFILE) {
|
|
180
|
+
attachments.push(ctx.SSSProfileTexture, ctx.SSSParamTexture);
|
|
181
|
+
}
|
|
182
|
+
if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_DIFFUSE) {
|
|
183
|
+
attachments.push(ctx.SSSDiffuseTexture);
|
|
184
|
+
}
|
|
185
|
+
if (ctx.materialFlags & MaterialVaryingFlags.SSS_STORE_TRANSMISSION) {
|
|
186
|
+
attachments.push(ctx.SSSTransmissionTexture);
|
|
187
|
+
}
|
|
188
|
+
return attachments.length === 1 ? attachments[0] : attachments;
|
|
189
|
+
}
|
|
41
190
|
/**
|
|
42
191
|
* Derive pipeline options from the current scene/camera state.
|
|
43
192
|
* @internal
|
|
44
193
|
*/ function deriveForwardPlusOptions(scene, camera, deviceType, renderQueue) {
|
|
45
194
|
const ssr = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();
|
|
195
|
+
const sss = camera.SSS && renderQueueHasActiveSSS(renderQueue);
|
|
196
|
+
const needSceneColor = renderQueue.needSceneColor();
|
|
197
|
+
const needSceneColorWithDepth = renderQueue.needSceneColorWithDepth();
|
|
46
198
|
return {
|
|
47
199
|
depthPrepass: true,
|
|
48
|
-
motionVectors: deviceType !== 'webgl' && (camera.TAA || camera.motionBlur),
|
|
200
|
+
motionVectors: deviceType !== 'webgl' && (camera.TAA || camera.motionBlur || !!ssr && camera.ssrTemporal),
|
|
49
201
|
hiZ: camera.HiZ && deviceType !== 'webgl',
|
|
50
202
|
ssr: !!ssr,
|
|
51
203
|
ssrCalcThickness: !!ssr && camera.ssrCalcThickness,
|
|
52
204
|
gpuPicking: !!camera.getPickResultResolveFunc(),
|
|
53
|
-
needSceneColor
|
|
205
|
+
needSceneColor,
|
|
206
|
+
needSceneColorWithDepth,
|
|
207
|
+
needsTransmissionDepthForSSR: !!ssr && needSceneColor && !needSceneColorWithDepth,
|
|
208
|
+
sss: !!sss
|
|
54
209
|
};
|
|
55
210
|
}
|
|
56
|
-
// ─── Forward+ Graph Builder ─────────────────────────────────────────
|
|
57
|
-
/**
|
|
58
|
-
* Constructs a render graph representing the forward+ pipeline.
|
|
59
|
-
*
|
|
60
|
-
* Each step in the existing `SceneRenderer._renderScene` becomes a graph pass.
|
|
61
|
-
* Execute callbacks delegate to the existing rendering code, sharing a mutable
|
|
62
|
-
* `FrameState`.
|
|
63
|
-
*
|
|
64
|
-
* @param graph - The render graph to populate.
|
|
65
|
-
* @param ctx - The draw context for this frame.
|
|
66
|
-
* @param renderQueue - The culled render queue.
|
|
67
|
-
* @param options - Pipeline feature toggles.
|
|
68
|
-
* @returns The backbuffer handle (graph output).
|
|
69
|
-
*
|
|
70
|
-
* @public
|
|
71
|
-
*/ function buildForwardPlusGraph(graph, ctx, renderQueue, options) {
|
|
72
|
-
return buildForwardPlusGraphInternal(graph, ctx, renderQueue, options).backbuffer;
|
|
73
|
-
}
|
|
74
211
|
function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
75
212
|
const backbuffer = graph.importTexture('backbuffer');
|
|
213
|
+
ctx.SSS = !!options.sss;
|
|
76
214
|
// Shared mutable frame state
|
|
77
215
|
const frame = {
|
|
78
216
|
ctx,
|
|
@@ -192,16 +330,31 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
192
330
|
const depthHandle = depthPassResult.depthHandle;
|
|
193
331
|
const motionVectorHandle = depthPassResult.motionVectorHandle;
|
|
194
332
|
const renderDepthAttachment = depthPassResult.graphDepthAttachmentHandle ?? depthPassResult.externalDepthAttachment ?? null;
|
|
333
|
+
let preLightTransmissionDepthToken;
|
|
334
|
+
if (options.needsTransmissionDepthForSSR) {
|
|
335
|
+
preLightTransmissionDepthToken = graph.addPass('TransmissionDepthForSSR', (builder)=>{
|
|
336
|
+
builder.read(depthPassResult.depthFramebufferHandle);
|
|
337
|
+
const done = builder.createToken('TransmissionDepthForSSRDone');
|
|
338
|
+
builder.sideEffect();
|
|
339
|
+
builder.setExecute((rgCtx)=>{
|
|
340
|
+
renderTransmissionDepthPass(frame, rgCtx);
|
|
341
|
+
});
|
|
342
|
+
return done;
|
|
343
|
+
});
|
|
344
|
+
}
|
|
195
345
|
// ── 6. Hi-Z (optional) ───────────────────────────────────────────
|
|
196
346
|
let hiZHandle;
|
|
197
347
|
if (options.hiZ) {
|
|
198
348
|
graph.addPass('HiZ', (builder)=>{
|
|
199
349
|
builder.read(depthHandle);
|
|
200
350
|
builder.read(depthPassResult.depthFramebufferHandle);
|
|
351
|
+
if (preLightTransmissionDepthToken) {
|
|
352
|
+
builder.read(preLightTransmissionDepthToken);
|
|
353
|
+
}
|
|
201
354
|
hiZHandle = builder.createTexture({
|
|
202
355
|
format: 'r32f',
|
|
203
356
|
label: 'hiZ',
|
|
204
|
-
mipLevels:
|
|
357
|
+
mipLevels: getFullMipLevelCount(ctx.renderWidth, ctx.renderHeight)
|
|
205
358
|
});
|
|
206
359
|
const hiZFramebufferHandle = builder.createFramebuffer({
|
|
207
360
|
label: 'HiZFramebuffer',
|
|
@@ -223,12 +376,120 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
223
376
|
});
|
|
224
377
|
}
|
|
225
378
|
// ── 7. Main Light Pass ────────────────────────────────────────────
|
|
379
|
+
const historyManager = ctx.camera?.getHistoryResourceManager?.() ?? null;
|
|
380
|
+
const lightHistoryReadBindings = [];
|
|
381
|
+
const compositeHistoryReadBindings = [];
|
|
382
|
+
const historySize = {
|
|
383
|
+
width: ctx.renderWidth,
|
|
384
|
+
height: ctx.renderHeight
|
|
385
|
+
};
|
|
386
|
+
if (historyManager && options.ssr && ctx.camera?.ssrTemporal && options.motionVectors) {
|
|
387
|
+
const reflectHistoryHandle = historyManager.importPreviousIfCompatible(graph, RGHistoryResources.SSR_REFLECT, {
|
|
388
|
+
format: 'rgba16f',
|
|
389
|
+
sizeMode: 'absolute',
|
|
390
|
+
width: ctx.renderWidth,
|
|
391
|
+
height: ctx.renderHeight
|
|
392
|
+
}, historySize);
|
|
393
|
+
const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(graph, RGHistoryResources.SSR_MOTION_VECTOR, {
|
|
394
|
+
format: 'rgba16f',
|
|
395
|
+
sizeMode: 'absolute',
|
|
396
|
+
width: ctx.renderWidth,
|
|
397
|
+
height: ctx.renderHeight
|
|
398
|
+
}, historySize);
|
|
399
|
+
if (reflectHistoryHandle && motionVectorHistoryHandle) {
|
|
400
|
+
lightHistoryReadBindings.push({
|
|
401
|
+
name: RGHistoryResources.SSR_REFLECT,
|
|
402
|
+
handle: reflectHistoryHandle
|
|
403
|
+
}, {
|
|
404
|
+
name: RGHistoryResources.SSR_MOTION_VECTOR,
|
|
405
|
+
handle: motionVectorHistoryHandle
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (historyManager && ctx.camera?.TAA && options.motionVectors) {
|
|
410
|
+
const colorHistoryHandle = historyManager.importPreviousIfCompatible(graph, RGHistoryResources.TAA_COLOR, {
|
|
411
|
+
format: ctx.colorFormat,
|
|
412
|
+
sizeMode: 'absolute',
|
|
413
|
+
width: ctx.renderWidth,
|
|
414
|
+
height: ctx.renderHeight
|
|
415
|
+
}, historySize);
|
|
416
|
+
const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(graph, RGHistoryResources.TAA_MOTION_VECTOR, {
|
|
417
|
+
format: 'rgba16f',
|
|
418
|
+
sizeMode: 'absolute',
|
|
419
|
+
width: ctx.renderWidth,
|
|
420
|
+
height: ctx.renderHeight
|
|
421
|
+
}, historySize);
|
|
422
|
+
if (colorHistoryHandle && motionVectorHistoryHandle) {
|
|
423
|
+
compositeHistoryReadBindings.push({
|
|
424
|
+
name: RGHistoryResources.TAA_COLOR,
|
|
425
|
+
handle: colorHistoryHandle
|
|
426
|
+
}, {
|
|
427
|
+
name: RGHistoryResources.TAA_MOTION_VECTOR,
|
|
428
|
+
handle: motionVectorHistoryHandle
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
let sssProfileResult;
|
|
433
|
+
if (options.sss) {
|
|
434
|
+
sssProfileResult = graph.addPass('SSSProfile', (builder)=>{
|
|
435
|
+
builder.read(depthHandle);
|
|
436
|
+
builder.read(depthPassResult.depthFramebufferHandle);
|
|
437
|
+
if (preLightTransmissionDepthToken) {
|
|
438
|
+
builder.read(preLightTransmissionDepthToken);
|
|
439
|
+
}
|
|
440
|
+
const profileHandle = builder.createTexture({
|
|
441
|
+
format: 'rgba16f',
|
|
442
|
+
label: 'sssProfile'
|
|
443
|
+
});
|
|
444
|
+
const paramHandle = builder.createTexture({
|
|
445
|
+
format: 'rgba8unorm',
|
|
446
|
+
label: 'sssParam'
|
|
447
|
+
});
|
|
448
|
+
const normalHandle = options.ssr ? undefined : builder.createTexture({
|
|
449
|
+
format: getSurfaceTextureFormat(ctx),
|
|
450
|
+
label: 'sssNormal'
|
|
451
|
+
});
|
|
452
|
+
const colorAttachments = normalHandle ? [
|
|
453
|
+
ctx.colorFormat,
|
|
454
|
+
normalHandle,
|
|
455
|
+
profileHandle,
|
|
456
|
+
paramHandle
|
|
457
|
+
] : [
|
|
458
|
+
ctx.colorFormat,
|
|
459
|
+
profileHandle,
|
|
460
|
+
paramHandle
|
|
461
|
+
];
|
|
462
|
+
const framebufferHandle = builder.createFramebuffer({
|
|
463
|
+
label: 'SSSProfileFramebuffer',
|
|
464
|
+
width: ctx.renderWidth,
|
|
465
|
+
height: ctx.renderHeight,
|
|
466
|
+
colorAttachments,
|
|
467
|
+
depthAttachment: renderDepthAttachment,
|
|
468
|
+
ignoreDepthStencil: false
|
|
469
|
+
});
|
|
470
|
+
builder.setExecute((rgCtx)=>{
|
|
471
|
+
renderForwardSSSProfile(frame, rgCtx.getFramebuffer(framebufferHandle), rgCtx.getTexture(profileHandle), rgCtx.getTexture(paramHandle), normalHandle ? rgCtx.getTexture(normalHandle) : null);
|
|
472
|
+
});
|
|
473
|
+
return {
|
|
474
|
+
profileHandle,
|
|
475
|
+
paramHandle,
|
|
476
|
+
normalHandle,
|
|
477
|
+
framebufferHandle
|
|
478
|
+
};
|
|
479
|
+
});
|
|
480
|
+
}
|
|
226
481
|
const lightPassResult = graph.addPass('LightPass', (builder)=>{
|
|
227
482
|
builder.read(depthHandle);
|
|
228
483
|
builder.read(depthPassResult.depthFramebufferHandle);
|
|
484
|
+
if (preLightTransmissionDepthToken) {
|
|
485
|
+
builder.read(preLightTransmissionDepthToken);
|
|
486
|
+
}
|
|
229
487
|
if (hiZHandle) {
|
|
230
488
|
builder.read(hiZHandle);
|
|
231
489
|
}
|
|
490
|
+
for (const binding of lightHistoryReadBindings){
|
|
491
|
+
builder.read(binding.handle);
|
|
492
|
+
}
|
|
232
493
|
// Create scene color texture (intermediate render target)
|
|
233
494
|
const sceneColorHandle = builder.createTexture({
|
|
234
495
|
format: ctx.colorFormat,
|
|
@@ -242,6 +503,29 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
242
503
|
label: 'sceneColorCopy'
|
|
243
504
|
});
|
|
244
505
|
}
|
|
506
|
+
if (sssProfileResult) {
|
|
507
|
+
builder.read(sssProfileResult.profileHandle);
|
|
508
|
+
builder.read(sssProfileResult.paramHandle);
|
|
509
|
+
if (sssProfileResult.normalHandle) {
|
|
510
|
+
builder.read(sssProfileResult.normalHandle);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const includeSSRSurfaceMRT = !!options.ssr;
|
|
514
|
+
const writeSSSDiffuse = options.sss && shouldStoreSSSDiffuse(ctx);
|
|
515
|
+
let writeSSSTransmission = options.sss && shouldStoreSSSTransmission(ctx);
|
|
516
|
+
if (writeSSSDiffuse && writeSSSTransmission && includeSSRSurfaceMRT && getSSSLightingTextureFormat(ctx, 2, includeSSRSurfaceMRT) !== ctx.colorFormat) {
|
|
517
|
+
writeSSSTransmission = false;
|
|
518
|
+
}
|
|
519
|
+
const sssLightingAttachmentCount = (writeSSSDiffuse ? 1 : 0) + (writeSSSTransmission ? 1 : 0);
|
|
520
|
+
const sssLightingFormat = getSSSLightingTextureFormat(ctx, sssLightingAttachmentCount, includeSSRSurfaceMRT);
|
|
521
|
+
const sssDiffuseHandle = writeSSSDiffuse ? builder.createTexture({
|
|
522
|
+
format: sssLightingFormat,
|
|
523
|
+
label: 'sssDiffuse'
|
|
524
|
+
}) : undefined;
|
|
525
|
+
const sssTransmissionHandle = writeSSSTransmission ? builder.createTexture({
|
|
526
|
+
format: sssLightingFormat,
|
|
527
|
+
label: 'sssTransmission'
|
|
528
|
+
}) : undefined;
|
|
245
529
|
const useFinalFramebufferAsIntermediate = !!depthPassResult.externalDepthAttachment && depthPassResult.externalDepthAttachment === ctx.finalFramebuffer?.getDepthAttachment();
|
|
246
530
|
const sceneColorFramebufferHandle = useFinalFramebufferAsIntermediate ? undefined : builder.createFramebuffer({
|
|
247
531
|
label: 'SceneColorFramebuffer',
|
|
@@ -250,7 +534,10 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
250
534
|
colorAttachments: sceneColorHandle,
|
|
251
535
|
depthAttachment: renderDepthAttachment
|
|
252
536
|
});
|
|
253
|
-
|
|
537
|
+
// SSR may pre-insert transmission depth before LightPass for Hi-Z. In that case the
|
|
538
|
+
// refraction scene-color copy needs an isolated depth buffer so transmission surfaces
|
|
539
|
+
// do not occlude the background color they are about to sample.
|
|
540
|
+
const sceneColorCopyFramebufferHandle = sceneColorCopyHandle && !options.needsTransmissionDepthForSSR ? builder.createFramebuffer({
|
|
254
541
|
label: 'SceneColorCopyFramebuffer',
|
|
255
542
|
width: ctx.renderWidth,
|
|
256
543
|
height: ctx.renderHeight,
|
|
@@ -261,7 +548,29 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
261
548
|
builder.setExecute((rgCtx)=>{
|
|
262
549
|
const sceneColorTex = rgCtx.getTexture(sceneColorHandle);
|
|
263
550
|
const sceneColorCopyTex = sceneColorCopyHandle ? rgCtx.getTexture(sceneColorCopyHandle) : null;
|
|
264
|
-
|
|
551
|
+
if (sssProfileResult) {
|
|
552
|
+
ctx.SSSProfileTexture = rgCtx.getTexture(sssProfileResult.profileHandle);
|
|
553
|
+
ctx.SSSParamTexture = rgCtx.getTexture(sssProfileResult.paramHandle);
|
|
554
|
+
if (sssProfileResult.normalHandle) {
|
|
555
|
+
ctx.SSRNormalTexture = rgCtx.getTexture(sssProfileResult.normalHandle);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
ctx.SSSDiffuseTexture = sssDiffuseHandle ? rgCtx.getTexture(sssDiffuseHandle) : null;
|
|
559
|
+
ctx.SSSTransmissionTexture = sssTransmissionHandle ? rgCtx.getTexture(sssTransmissionHandle) : null;
|
|
560
|
+
const renderLightPass = ()=>renderMainLightPass(frame, sceneColorTex, sceneColorCopyTex, rgCtx, sceneColorFramebufferHandle, sceneColorCopyFramebufferHandle);
|
|
561
|
+
if (historyManager && lightHistoryReadBindings.length > 0) {
|
|
562
|
+
historyManager.beginReadScope(lightHistoryReadBindings.map((binding)=>({
|
|
563
|
+
name: binding.name,
|
|
564
|
+
texture: rgCtx.getTexture(binding.handle)
|
|
565
|
+
})));
|
|
566
|
+
try {
|
|
567
|
+
renderLightPass();
|
|
568
|
+
} finally{
|
|
569
|
+
historyManager.endReadScope();
|
|
570
|
+
}
|
|
571
|
+
} else {
|
|
572
|
+
renderLightPass();
|
|
573
|
+
}
|
|
265
574
|
});
|
|
266
575
|
return {
|
|
267
576
|
sceneColorHandle,
|
|
@@ -270,38 +579,9 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
270
579
|
};
|
|
271
580
|
});
|
|
272
581
|
const sceneColorHandle = lightPassResult.sceneColorHandle;
|
|
273
|
-
const historyManager = ctx.camera?.getHistoryResourceManager?.() ?? null;
|
|
274
|
-
const historyReadBindings = [];
|
|
275
|
-
if (historyManager && ctx.camera?.TAA && options.motionVectors) {
|
|
276
|
-
const historySize = {
|
|
277
|
-
width: ctx.renderWidth,
|
|
278
|
-
height: ctx.renderHeight
|
|
279
|
-
};
|
|
280
|
-
const colorHistoryHandle = historyManager.importPreviousIfCompatible(graph, RGHistoryResources.TAA_COLOR, {
|
|
281
|
-
format: ctx.colorFormat,
|
|
282
|
-
sizeMode: 'absolute',
|
|
283
|
-
width: ctx.renderWidth,
|
|
284
|
-
height: ctx.renderHeight
|
|
285
|
-
}, historySize);
|
|
286
|
-
const motionVectorHistoryHandle = historyManager.importPreviousIfCompatible(graph, RGHistoryResources.TAA_MOTION_VECTOR, {
|
|
287
|
-
format: 'rgba16f',
|
|
288
|
-
sizeMode: 'absolute',
|
|
289
|
-
width: ctx.renderWidth,
|
|
290
|
-
height: ctx.renderHeight
|
|
291
|
-
}, historySize);
|
|
292
|
-
if (colorHistoryHandle && motionVectorHistoryHandle) {
|
|
293
|
-
historyReadBindings.push({
|
|
294
|
-
name: RGHistoryResources.TAA_COLOR,
|
|
295
|
-
handle: colorHistoryHandle
|
|
296
|
-
}, {
|
|
297
|
-
name: RGHistoryResources.TAA_MOTION_VECTOR,
|
|
298
|
-
handle: motionVectorHistoryHandle
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
582
|
// 8. Transmission depth pass (optional)
|
|
303
583
|
let transmissionDepthToken;
|
|
304
|
-
if (options.needSceneColor) {
|
|
584
|
+
if (options.needSceneColor && !options.needsTransmissionDepthForSSR) {
|
|
305
585
|
transmissionDepthToken = graph.addPass('TransmissionDepth', (builder)=>{
|
|
306
586
|
builder.read(sceneColorHandle);
|
|
307
587
|
builder.read(depthPassResult.depthFramebufferHandle);
|
|
@@ -329,13 +609,13 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
329
609
|
if (transmissionDepthToken) {
|
|
330
610
|
builder.read(transmissionDepthToken);
|
|
331
611
|
}
|
|
332
|
-
for (const binding of
|
|
612
|
+
for (const binding of compositeHistoryReadBindings){
|
|
333
613
|
builder.read(binding.handle);
|
|
334
614
|
}
|
|
335
615
|
const outputBackbuffer = builder.write(backbuffer);
|
|
336
616
|
builder.setExecute((rgCtx)=>{
|
|
337
|
-
if (historyManager &&
|
|
338
|
-
historyManager.beginReadScope(
|
|
617
|
+
if (historyManager && compositeHistoryReadBindings.length > 0) {
|
|
618
|
+
historyManager.beginReadScope(compositeHistoryReadBindings.map((binding)=>({
|
|
339
619
|
name: binding.name,
|
|
340
620
|
texture: rgCtx.getTexture(binding.handle)
|
|
341
621
|
})));
|
|
@@ -370,6 +650,65 @@ function buildForwardPlusGraphInternal(graph, ctx, renderQueue, options) {
|
|
|
370
650
|
ctx.device.popDeviceStates();
|
|
371
651
|
}
|
|
372
652
|
}
|
|
653
|
+
function renderForwardSSSProfile(frame, profileFramebuffer, profileTexture, paramTexture, normalTexture) {
|
|
654
|
+
const { ctx, renderQueue } = frame;
|
|
655
|
+
if (!ctx.SSS || !ctx.depthTexture) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const sssRenderQueue = createActualSSSRenderQueue(renderQueue);
|
|
659
|
+
if (!sssRenderQueue) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const device = ctx.device;
|
|
663
|
+
const savedMaterialFlags = ctx.materialFlags;
|
|
664
|
+
const savedCompositor = ctx.compositor;
|
|
665
|
+
const savedTransmission = _scenePass.transmission;
|
|
666
|
+
const savedRenderOpaque = _scenePass.renderOpaque;
|
|
667
|
+
const savedRenderTransparent = _scenePass.renderTransparent;
|
|
668
|
+
const savedClearColor = _scenePass.clearColor;
|
|
669
|
+
const savedClearDepth = _scenePass.clearDepth;
|
|
670
|
+
const savedClearStencil = _scenePass.clearStencil;
|
|
671
|
+
const savedCommandBufferReuse = ctx.camera.commandBufferReuse;
|
|
672
|
+
const savedProfileTexture = ctx.SSSProfileTexture;
|
|
673
|
+
const savedParamTexture = ctx.SSSParamTexture;
|
|
674
|
+
const savedNormalTexture = ctx.SSRNormalTexture;
|
|
675
|
+
let profileFlags = MaterialVaryingFlags.SSS_STORE_PROFILE;
|
|
676
|
+
if (normalTexture) {
|
|
677
|
+
profileFlags |= MaterialVaryingFlags.SSS_STORE_NORMAL;
|
|
678
|
+
}
|
|
679
|
+
device.pushDeviceStates();
|
|
680
|
+
try {
|
|
681
|
+
device.setFramebuffer(profileFramebuffer);
|
|
682
|
+
ctx.SSSProfileTexture = profileTexture;
|
|
683
|
+
ctx.SSSParamTexture = paramTexture;
|
|
684
|
+
ctx.SSRNormalTexture = normalTexture;
|
|
685
|
+
ctx.compositor = null;
|
|
686
|
+
ctx.camera.commandBufferReuse = false;
|
|
687
|
+
ctx.materialFlags = ctx.materialFlags & ~(MaterialVaryingFlags.SSR_STORE_ROUGHNESS | MaterialVaryingFlags.SSS_STORE_PROFILE | MaterialVaryingFlags.SSS_STORE_NORMAL | MaterialVaryingFlags.SSS_STORE_DIFFUSE | MaterialVaryingFlags.SSS_STORE_TRANSMISSION) | profileFlags;
|
|
688
|
+
_scenePass.transmission = false;
|
|
689
|
+
_scenePass.renderOpaque = true;
|
|
690
|
+
_scenePass.renderTransparent = false;
|
|
691
|
+
_scenePass.clearColor = Vector4.zero();
|
|
692
|
+
_scenePass.clearDepth = null;
|
|
693
|
+
_scenePass.clearStencil = null;
|
|
694
|
+
_scenePass.render(ctx, null, null, sssRenderQueue);
|
|
695
|
+
} finally{
|
|
696
|
+
_scenePass.clearColor = savedClearColor;
|
|
697
|
+
_scenePass.clearDepth = savedClearDepth;
|
|
698
|
+
_scenePass.clearStencil = savedClearStencil;
|
|
699
|
+
_scenePass.renderTransparent = savedRenderTransparent;
|
|
700
|
+
_scenePass.renderOpaque = savedRenderOpaque;
|
|
701
|
+
_scenePass.transmission = savedTransmission;
|
|
702
|
+
ctx.camera.commandBufferReuse = savedCommandBufferReuse;
|
|
703
|
+
ctx.materialFlags = savedMaterialFlags;
|
|
704
|
+
ctx.compositor = savedCompositor;
|
|
705
|
+
ctx.SSSProfileTexture = savedProfileTexture;
|
|
706
|
+
ctx.SSSParamTexture = savedParamTexture;
|
|
707
|
+
ctx.SSRNormalTexture = savedNormalTexture;
|
|
708
|
+
device.popDeviceStates();
|
|
709
|
+
sssRenderQueue.dispose();
|
|
710
|
+
}
|
|
711
|
+
}
|
|
373
712
|
function releaseIntermediateFramebuffer(frame) {
|
|
374
713
|
const { ctx } = frame;
|
|
375
714
|
if (frame.intermediateDeviceStatePushed) {
|
|
@@ -496,6 +835,7 @@ function cleanupFrame(frame) {
|
|
|
496
835
|
ctx.motionVectorTexture = ctx.motionVectors ? depthFramebuffer.getColorAttachments()[1] : null;
|
|
497
836
|
ctx.linearDepthTexture = depthFramebuffer.getColorAttachments()[0];
|
|
498
837
|
ctx.depthTexture = depthFramebuffer.getDepthAttachment();
|
|
838
|
+
ctx.depthPrepassAttachment = ctx.depthTexture;
|
|
499
839
|
// HiZ is now built in the dedicated HiZ pass
|
|
500
840
|
}
|
|
501
841
|
return depthFramebuffer;
|
|
@@ -564,20 +904,37 @@ let _skyMVBox = null;
|
|
|
564
904
|
_skyMVBox.draw();
|
|
565
905
|
device.popDeviceStates();
|
|
566
906
|
}
|
|
907
|
+
function blitToCurrentColorAttachment(ctx, source) {
|
|
908
|
+
const framebuffer = ctx.device.getFramebuffer();
|
|
909
|
+
const destination = framebuffer?.getColorAttachment(0) ?? null;
|
|
910
|
+
new CopyBlitter().blit(source, destination, fetchSampler('clamp_nearest_nomip'));
|
|
911
|
+
}
|
|
567
912
|
/** @internal */ function renderMainLightPass(frame, sceneColorTex, sceneColorCopyTex, rgCtx, sceneColorFramebufferHandle, sceneColorCopyFramebufferHandle) {
|
|
568
913
|
const { ctx, renderQueue } = frame;
|
|
569
914
|
const device = ctx.device;
|
|
570
915
|
// Use RenderGraph-allocated scene color texture
|
|
571
916
|
const depthTex = frame.depthFramebuffer?.getDepthAttachment();
|
|
917
|
+
ctx.materialFlags &= ~(MaterialVaryingFlags.SSR_STORE_ROUGHNESS | MaterialVaryingFlags.SSS_STORE_PROFILE | MaterialVaryingFlags.SSS_STORE_DIFFUSE | MaterialVaryingFlags.SSS_STORE_NORMAL | MaterialVaryingFlags.SSS_STORE_TRANSMISSION);
|
|
918
|
+
if (ctx.SSR) {
|
|
919
|
+
ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
920
|
+
}
|
|
921
|
+
if (ctx.SSS) {
|
|
922
|
+
if (ctx.SSSDiffuseTexture) {
|
|
923
|
+
ctx.materialFlags |= MaterialVaryingFlags.SSS_STORE_DIFFUSE;
|
|
924
|
+
}
|
|
925
|
+
if (ctx.SSSTransmissionTexture) {
|
|
926
|
+
ctx.materialFlags |= MaterialVaryingFlags.SSS_STORE_TRANSMISSION;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
572
929
|
if (depthTex === ctx.finalFramebuffer?.getDepthAttachment()) {
|
|
573
930
|
ctx.intermediateFramebuffer = ctx.finalFramebuffer;
|
|
574
|
-
} else if (sceneColorFramebufferHandle) {
|
|
931
|
+
} else if (sceneColorFramebufferHandle && !hasSurfaceMRT(ctx)) {
|
|
575
932
|
ctx.intermediateFramebuffer = rgCtx.getFramebuffer(sceneColorFramebufferHandle);
|
|
576
933
|
} else {
|
|
577
934
|
ctx.intermediateFramebuffer = rgCtx.createFramebuffer({
|
|
578
935
|
width: sceneColorTex.width,
|
|
579
936
|
height: sceneColorTex.height,
|
|
580
|
-
colorAttachments: sceneColorTex,
|
|
937
|
+
colorAttachments: getLightPassColorAttachments(ctx, sceneColorTex),
|
|
581
938
|
depthAttachment: depthTex
|
|
582
939
|
});
|
|
583
940
|
}
|
|
@@ -592,23 +949,22 @@ let _skyMVBox = null;
|
|
|
592
949
|
_scenePass.transmission = false;
|
|
593
950
|
_scenePass.clearDepth = depthTex ? null : 1;
|
|
594
951
|
_scenePass.clearStencil = depthTex ? null : 0;
|
|
595
|
-
if (ctx.SSR && !renderQueue.needSceneColor()) {
|
|
596
|
-
ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
597
|
-
}
|
|
598
952
|
ctx.compositor?.begin(ctx);
|
|
599
953
|
if (renderQueue.needSceneColor() && sceneColorCopyTex) {
|
|
600
954
|
const compositor = ctx.compositor;
|
|
601
955
|
ctx.compositor = null;
|
|
956
|
+
const isolateSceneColorDepth = frame.options.needsTransmissionDepthForSSR;
|
|
957
|
+
const savedDepthPrepassAttachment = ctx.depthPrepassAttachment;
|
|
958
|
+
const savedClearDepth = _scenePass.clearDepth;
|
|
959
|
+
const savedClearStencil = _scenePass.clearStencil;
|
|
960
|
+
const savedMaterialFlags = ctx.materialFlags;
|
|
602
961
|
// Use RenderGraph-allocated sceneColorCopy texture
|
|
603
|
-
const
|
|
962
|
+
const sceneColorMaterialFlags = ctx.materialFlags & ~SURFACE_MRT_FLAGS;
|
|
963
|
+
const sceneColorFramebuffer = sceneColorCopyFramebufferHandle ? rgCtx.getFramebuffer(sceneColorCopyFramebufferHandle) : rgCtx.createFramebuffer({
|
|
604
964
|
width: sceneColorCopyTex.width,
|
|
605
965
|
height: sceneColorCopyTex.height,
|
|
606
|
-
colorAttachments:
|
|
607
|
-
|
|
608
|
-
device.getFramebuffer().getColorAttachments()[1],
|
|
609
|
-
device.getFramebuffer().getColorAttachments()[2]
|
|
610
|
-
] : sceneColorCopyTex,
|
|
611
|
-
depthAttachment: depthTex,
|
|
966
|
+
colorAttachments: sceneColorCopyTex,
|
|
967
|
+
depthAttachment: isolateSceneColorDepth ? ctx.depthFormat : depthTex,
|
|
612
968
|
ignoreDepthStencil: false
|
|
613
969
|
});
|
|
614
970
|
let sceneColorStatePushed = false;
|
|
@@ -617,15 +973,27 @@ let _skyMVBox = null;
|
|
|
617
973
|
sceneColorStatePushed = true;
|
|
618
974
|
device.setFramebuffer(sceneColorFramebuffer);
|
|
619
975
|
_scenePass.transmission = false;
|
|
976
|
+
if (isolateSceneColorDepth) {
|
|
977
|
+
ctx.depthPrepassAttachment = undefined;
|
|
978
|
+
_scenePass.clearDepth = 1;
|
|
979
|
+
_scenePass.clearStencil = 0;
|
|
980
|
+
}
|
|
981
|
+
ctx.materialFlags = sceneColorMaterialFlags;
|
|
620
982
|
_scenePass.render(ctx, null, null, renderQueue);
|
|
621
983
|
} finally{
|
|
984
|
+
ctx.materialFlags = savedMaterialFlags;
|
|
985
|
+
if (isolateSceneColorDepth) {
|
|
986
|
+
ctx.depthPrepassAttachment = savedDepthPrepassAttachment;
|
|
987
|
+
_scenePass.clearDepth = savedClearDepth;
|
|
988
|
+
_scenePass.clearStencil = savedClearStencil;
|
|
989
|
+
}
|
|
622
990
|
if (sceneColorStatePushed) {
|
|
623
991
|
device.popDeviceStates();
|
|
624
992
|
}
|
|
625
993
|
ctx.compositor = compositor;
|
|
626
994
|
}
|
|
627
995
|
ctx.sceneColorTexture = sceneColorCopyTex;
|
|
628
|
-
|
|
996
|
+
blitToCurrentColorAttachment(ctx, ctx.sceneColorTexture);
|
|
629
997
|
_scenePass.transmission = true;
|
|
630
998
|
_scenePass.clearColor = null;
|
|
631
999
|
_scenePass.clearDepth = null;
|
|
@@ -642,6 +1010,10 @@ let _skyMVBox = null;
|
|
|
642
1010
|
ctx.compositor?.end(ctx);
|
|
643
1011
|
disposeRenderQueue(frame);
|
|
644
1012
|
ctx.materialFlags &= ~MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
1013
|
+
ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_PROFILE;
|
|
1014
|
+
ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_DIFFUSE;
|
|
1015
|
+
ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_NORMAL;
|
|
1016
|
+
ctx.materialFlags &= ~MaterialVaryingFlags.SSS_STORE_TRANSMISSION;
|
|
645
1017
|
if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {
|
|
646
1018
|
const blitter = new CopyBlitter();
|
|
647
1019
|
blitter.srgbOut = !ctx.finalFramebuffer;
|
|
@@ -664,37 +1036,51 @@ let _skyMVBox = null;
|
|
|
664
1036
|
*/ function executeForwardPlusGraph(ctx) {
|
|
665
1037
|
const device = ctx.device;
|
|
666
1038
|
const graph = new RenderGraph();
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
let
|
|
672
|
-
if (!historyManager) {
|
|
673
|
-
historyManager = new HistoryResourceManager(_devicePoolAllocator);
|
|
674
|
-
ctx.camera.setHistoryResourceManager(historyManager);
|
|
675
|
-
}
|
|
676
|
-
historyManager.beginFrame();
|
|
677
|
-
const { backbuffer, frame } = buildForwardPlusGraphInternal(graph, ctx, renderQueue, options);
|
|
678
|
-
const compiled = graph.compile([
|
|
679
|
-
backbuffer
|
|
680
|
-
]);
|
|
681
|
-
// Use RenderGraphExecutor for automatic resource management
|
|
682
|
-
const executor = new RenderGraphExecutor(_devicePoolAllocator, ctx.renderWidth, ctx.renderHeight);
|
|
683
|
-
// Register imported backbuffer (if using finalFramebuffer)
|
|
684
|
-
if (ctx.finalFramebuffer) {
|
|
685
|
-
const backbufferTex = ctx.finalFramebuffer.getColorAttachments()[0];
|
|
686
|
-
executor.setImportedTexture(backbuffer, backbufferTex);
|
|
687
|
-
}
|
|
688
|
-
historyManager.bindImportedTextures(executor);
|
|
1039
|
+
let renderQueue = null;
|
|
1040
|
+
let frame = null;
|
|
1041
|
+
let executor = null;
|
|
1042
|
+
let historyManager = null;
|
|
1043
|
+
let historyFrameStarted = false;
|
|
689
1044
|
try {
|
|
1045
|
+
// Cull scene first (needed to derive options)
|
|
1046
|
+
renderQueue = _scenePass.cullScene(ctx, ctx.camera);
|
|
1047
|
+
const options = deriveForwardPlusOptions(ctx.scene, ctx.camera, device.type, renderQueue);
|
|
1048
|
+
ctx.SSS = options.sss;
|
|
1049
|
+
// Ensure the camera has a history resource manager for temporal effects (TAA, motion blur)
|
|
1050
|
+
historyManager = ctx.camera.getHistoryResourceManager();
|
|
1051
|
+
if (!historyManager) {
|
|
1052
|
+
historyManager = new HistoryResourceManager(_devicePoolAllocator);
|
|
1053
|
+
ctx.camera.setHistoryResourceManager(historyManager);
|
|
1054
|
+
}
|
|
1055
|
+
historyManager.beginFrame();
|
|
1056
|
+
historyFrameStarted = true;
|
|
1057
|
+
const buildResult = buildForwardPlusGraphInternal(graph, ctx, renderQueue, options);
|
|
1058
|
+
frame = buildResult.frame;
|
|
1059
|
+
const compiled = graph.compile([
|
|
1060
|
+
buildResult.backbuffer
|
|
1061
|
+
]);
|
|
1062
|
+
// Use RenderGraphExecutor for automatic resource management
|
|
1063
|
+
executor = new RenderGraphExecutor(_devicePoolAllocator, ctx.renderWidth, ctx.renderHeight);
|
|
1064
|
+
// Register imported backbuffer (if using finalFramebuffer)
|
|
1065
|
+
if (ctx.finalFramebuffer) {
|
|
1066
|
+
const backbufferTex = ctx.finalFramebuffer.getColorAttachments()[0];
|
|
1067
|
+
executor.setImportedTexture(buildResult.backbuffer, backbufferTex);
|
|
1068
|
+
}
|
|
1069
|
+
historyManager.bindImportedTextures(executor);
|
|
690
1070
|
executor.execute(compiled);
|
|
691
1071
|
historyManager.commitFrame();
|
|
692
1072
|
} finally{
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1073
|
+
if (historyFrameStarted) {
|
|
1074
|
+
historyManager?.discardFrame();
|
|
1075
|
+
}
|
|
1076
|
+
if (frame) {
|
|
1077
|
+
cleanupFrame(frame);
|
|
1078
|
+
} else {
|
|
1079
|
+
renderQueue?.dispose();
|
|
1080
|
+
}
|
|
1081
|
+
executor?.reset();
|
|
696
1082
|
}
|
|
697
1083
|
}
|
|
698
1084
|
|
|
699
|
-
export {
|
|
1085
|
+
export { deriveForwardPlusOptions, executeForwardPlusGraph };
|
|
700
1086
|
//# sourceMappingURL=forward_plus_builder.js.map
|