@zephyr3d/scene 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationset.js +220 -1
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +3 -4
- package/dist/animation/ik/ccd_solver.js.map +1 -1
- package/dist/animation/ik/fabrik_solver.js +3 -4
- package/dist/animation/ik/fabrik_solver.js.map +1 -1
- package/dist/animation/ik/ik_pole_constraint.js +7 -2
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/ik/ik_utils.js +0 -79
- package/dist/animation/ik/ik_utils.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +3 -4
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/skeleton.js +157 -125
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/spring_bone.js +240 -0
- package/dist/animation/spring/spring_bone.js.map +1 -0
- package/dist/animation/spring/spring_bone_collider.js +198 -0
- package/dist/animation/spring/spring_bone_collider.js.map +1 -0
- package/dist/animation/spring/spring_bone_constraint.js +170 -0
- package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
- package/dist/animation/spring/spring_bone_system.js +328 -0
- package/dist/animation/spring/spring_bone_system.js.map +1 -0
- package/dist/asset/model.js +2 -2
- package/dist/index.d.ts +17 -0
- package/dist/material/mixins/pbr/common.js +20 -17
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/render/gpu_picking.js +100 -0
- package/dist/render/gpu_picking.js.map +1 -0
- package/dist/render/rendergraph/device_pool_allocator.js +41 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
- package/dist/render/rendergraph/executor.js +146 -0
- package/dist/render/rendergraph/executor.js.map +1 -0
- package/dist/render/rendergraph/forward_plus_builder.js +414 -0
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +306 -0
- package/dist/render/rendergraph/rendergraph.js.map +1 -0
- package/dist/render/rendergraph/types.js +57 -0
- package/dist/render/rendergraph/types.js.map +1 -0
- package/dist/render/sky_motion_vector.js +85 -0
- package/dist/render/sky_motion_vector.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +3 -3
- package/dist/utility/serialization/scene/node.js +1 -1
- package/package.json +2 -2
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.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/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
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { RGHandle, RGPass, RGResource } from './types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Render Graph — declarative, configurable render pipeline.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ```ts
|
|
8
|
+
* const graph = new RenderGraph();
|
|
9
|
+
* const backbuffer = graph.importTexture('backbuffer');
|
|
10
|
+
*
|
|
11
|
+
* let linearDepth: RGHandle;
|
|
12
|
+
* graph.addPass('DepthPrepass', (builder) => {
|
|
13
|
+
* linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });
|
|
14
|
+
* builder.setExecute(() => { ... });
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* graph.addPass('LightPass', (builder) => {
|
|
18
|
+
* builder.read(linearDepth);
|
|
19
|
+
* builder.write(backbuffer);
|
|
20
|
+
* builder.setExecute(() => { ... });
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const compiled = graph.compile([backbuffer]);
|
|
24
|
+
* graph.execute(compiled);
|
|
25
|
+
* graph.reset();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/ class RenderGraph {
|
|
30
|
+
/** @internal */ _nextResourceId = 0;
|
|
31
|
+
/** @internal */ _resources = new Map();
|
|
32
|
+
/** @internal */ _passes = [];
|
|
33
|
+
/** @internal */ _compiled = null;
|
|
34
|
+
// ─── Graph Building ─────────────────────────────────────────────────
|
|
35
|
+
/**
|
|
36
|
+
* Import an external (persistent) texture into the graph.
|
|
37
|
+
*
|
|
38
|
+
* Imported resources are not allocated or released by the graph.
|
|
39
|
+
* Typically used for the backbuffer or any texture that outlives a single frame.
|
|
40
|
+
*
|
|
41
|
+
* @param name - Debug label for the imported resource.
|
|
42
|
+
* @returns A handle referencing the imported resource.
|
|
43
|
+
*/ importTexture(name) {
|
|
44
|
+
const id = this._nextResourceId++;
|
|
45
|
+
const resource = new RGResource(id, name, 'imported', null);
|
|
46
|
+
this._resources.set(id, resource);
|
|
47
|
+
this._compiled = null;
|
|
48
|
+
return new RGHandle(id, name);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Add a render pass to the graph.
|
|
52
|
+
*
|
|
53
|
+
* The setup callback receives a {@link RGPassBuilder} to declare resource
|
|
54
|
+
* dependencies. Call `builder.setExecute(fn)` inside setup to provide the
|
|
55
|
+
* execution callback.
|
|
56
|
+
*
|
|
57
|
+
* @param name - Debug label for the pass.
|
|
58
|
+
* @param setup - Setup callback that declares resources and sets the execute function.
|
|
59
|
+
*/ addPass(name, setup) {
|
|
60
|
+
const pass = new RGPass(this._passes.length, name);
|
|
61
|
+
const builder = this._createBuilder(pass);
|
|
62
|
+
const data = setup(builder);
|
|
63
|
+
pass.data = data;
|
|
64
|
+
this._passes.push(pass);
|
|
65
|
+
this._compiled = null;
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
// ─── Compilation ────────────────────────────────────────────────────
|
|
69
|
+
/**
|
|
70
|
+
* Compile the render graph.
|
|
71
|
+
*
|
|
72
|
+
* Performs dead-pass culling, topological sorting, and resource lifetime analysis.
|
|
73
|
+
*
|
|
74
|
+
* @param outputs - Handles of resources that must be produced (graph sinks).
|
|
75
|
+
* Passes that do not contribute to these outputs (directly or transitively)
|
|
76
|
+
* are culled, unless marked as side-effect passes.
|
|
77
|
+
* @returns The compiled graph ready for execution.
|
|
78
|
+
*/ compile(outputs) {
|
|
79
|
+
if (this._compiled) {
|
|
80
|
+
return this._compiled;
|
|
81
|
+
}
|
|
82
|
+
// 1. Mark alive passes via backward traversal from outputs + side-effect passes
|
|
83
|
+
this._cullDeadPasses(outputs);
|
|
84
|
+
// 2. Topological sort of alive passes
|
|
85
|
+
const ordered = this._topologicalSort();
|
|
86
|
+
// 3. Resource lifetime analysis
|
|
87
|
+
const lifetimes = this._analyzeLifetimes(ordered);
|
|
88
|
+
this._compiled = {
|
|
89
|
+
orderedPasses: ordered,
|
|
90
|
+
lifetimes
|
|
91
|
+
};
|
|
92
|
+
return this._compiled;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Execute a compiled render graph (simple mode, no resource management).
|
|
96
|
+
*
|
|
97
|
+
* For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.
|
|
98
|
+
*
|
|
99
|
+
* @param compiled - The compiled graph from {@link compile}.
|
|
100
|
+
*/ execute(compiled) {
|
|
101
|
+
const noopCtx = {
|
|
102
|
+
getTexture () {
|
|
103
|
+
throw new Error('RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.');
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
for (const pass of compiled.orderedPasses){
|
|
107
|
+
if (pass.executeFn) {
|
|
108
|
+
pass.executeFn(noopCtx, pass.data);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Reset the graph for the next frame.
|
|
114
|
+
*
|
|
115
|
+
* Clears all passes, transient resources, and compiled state.
|
|
116
|
+
* Imported resources are also cleared — re-import them each frame.
|
|
117
|
+
*/ reset() {
|
|
118
|
+
this._passes.length = 0;
|
|
119
|
+
this._resources.clear();
|
|
120
|
+
this._nextResourceId = 0;
|
|
121
|
+
this._compiled = null;
|
|
122
|
+
}
|
|
123
|
+
// ─── Accessors (for testing / debugging) ────────────────────────────
|
|
124
|
+
/** @internal */ getResource(handle) {
|
|
125
|
+
return this._resources.get(handle._id);
|
|
126
|
+
}
|
|
127
|
+
/** @internal */ get passes() {
|
|
128
|
+
return this._passes;
|
|
129
|
+
}
|
|
130
|
+
/** @internal */ get resources() {
|
|
131
|
+
return this._resources;
|
|
132
|
+
}
|
|
133
|
+
// ─── Private: Builder ───────────────────────────────────────────────
|
|
134
|
+
/** @internal */ _createBuilder(pass) {
|
|
135
|
+
const graph = this;
|
|
136
|
+
return {
|
|
137
|
+
read (handle) {
|
|
138
|
+
const res = graph._resources.get(handle._id);
|
|
139
|
+
if (!res) {
|
|
140
|
+
throw new Error(`RenderGraph: unknown resource "${handle.name}" (id=${handle._id})`);
|
|
141
|
+
}
|
|
142
|
+
pass.reads.push(res);
|
|
143
|
+
res.consumers.push(pass);
|
|
144
|
+
},
|
|
145
|
+
write (handle) {
|
|
146
|
+
const res = graph._resources.get(handle._id);
|
|
147
|
+
if (!res) {
|
|
148
|
+
throw new Error(`RenderGraph: unknown resource "${handle.name}" (id=${handle._id})`);
|
|
149
|
+
}
|
|
150
|
+
if (res.producer && res.producer !== pass) {
|
|
151
|
+
throw new Error(`RenderGraph: resource "${res.name}" already produced by pass "${res.producer.name}", ` + `cannot be written by pass "${pass.name}"`);
|
|
152
|
+
}
|
|
153
|
+
res.producer = pass;
|
|
154
|
+
pass.writes.push(res);
|
|
155
|
+
},
|
|
156
|
+
createTexture (desc) {
|
|
157
|
+
const id = graph._nextResourceId++;
|
|
158
|
+
const name = desc.label ?? `_tex_${id}`;
|
|
159
|
+
const res = new RGResource(id, name, 'transient', desc);
|
|
160
|
+
res.producer = pass;
|
|
161
|
+
graph._resources.set(id, res);
|
|
162
|
+
pass.writes.push(res);
|
|
163
|
+
return new RGHandle(id, name);
|
|
164
|
+
},
|
|
165
|
+
sideEffect () {
|
|
166
|
+
pass.hasSideEffect = true;
|
|
167
|
+
},
|
|
168
|
+
setExecute (fn) {
|
|
169
|
+
pass.executeFn = fn;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// ─── Private: Dead Pass Culling ─────────────────────────────────────
|
|
174
|
+
/** @internal */ _cullDeadPasses(outputs) {
|
|
175
|
+
// Start with all passes marked dead
|
|
176
|
+
for (const pass of this._passes){
|
|
177
|
+
pass.alive = false;
|
|
178
|
+
}
|
|
179
|
+
// Seed: resources that are requested outputs
|
|
180
|
+
const neededResources = new Set();
|
|
181
|
+
const stack = [];
|
|
182
|
+
for (const handle of outputs){
|
|
183
|
+
const res = this._resources.get(handle._id);
|
|
184
|
+
if (res) {
|
|
185
|
+
neededResources.add(res.id);
|
|
186
|
+
stack.push(res);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Seed: side-effect passes (always alive) — push their read dependencies
|
|
190
|
+
for (const pass of this._passes){
|
|
191
|
+
if (pass.hasSideEffect) {
|
|
192
|
+
pass.alive = true;
|
|
193
|
+
for (const res of pass.reads){
|
|
194
|
+
if (!neededResources.has(res.id)) {
|
|
195
|
+
neededResources.add(res.id);
|
|
196
|
+
stack.push(res);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Backward traversal: for each needed resource, mark its producer alive
|
|
202
|
+
// and recursively mark the producer's read dependencies as needed
|
|
203
|
+
while(stack.length > 0){
|
|
204
|
+
const res = stack.pop();
|
|
205
|
+
const producer = res.producer;
|
|
206
|
+
if (producer && !producer.alive) {
|
|
207
|
+
producer.alive = true;
|
|
208
|
+
for (const dep of producer.reads){
|
|
209
|
+
if (!neededResources.has(dep.id)) {
|
|
210
|
+
neededResources.add(dep.id);
|
|
211
|
+
stack.push(dep);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────
|
|
218
|
+
/** @internal */ _topologicalSort() {
|
|
219
|
+
const alivePasses = this._passes.filter((p)=>p.alive);
|
|
220
|
+
if (alivePasses.length === 0) {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
// Build adjacency: producer -> consumers (only among alive passes)
|
|
224
|
+
const aliveSet = new Set(alivePasses);
|
|
225
|
+
const inDegree = new Map();
|
|
226
|
+
const adjacency = new Map();
|
|
227
|
+
for (const pass of alivePasses){
|
|
228
|
+
inDegree.set(pass, 0);
|
|
229
|
+
adjacency.set(pass, []);
|
|
230
|
+
}
|
|
231
|
+
// For each resource, its producer has an edge to each of its consumers
|
|
232
|
+
for (const res of this._resources.values()){
|
|
233
|
+
if (!res.producer || !aliveSet.has(res.producer)) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
for (const consumer of res.consumers){
|
|
237
|
+
if (!aliveSet.has(consumer)) {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
adjacency.get(res.producer).push(consumer);
|
|
241
|
+
inDegree.set(consumer, inDegree.get(consumer) + 1);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Kahn's algorithm
|
|
245
|
+
const queue = [];
|
|
246
|
+
for (const pass of alivePasses){
|
|
247
|
+
if (inDegree.get(pass) === 0) {
|
|
248
|
+
queue.push(pass);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const result = [];
|
|
252
|
+
while(queue.length > 0){
|
|
253
|
+
const pass = queue.shift();
|
|
254
|
+
result.push(pass);
|
|
255
|
+
for (const neighbor of adjacency.get(pass)){
|
|
256
|
+
const deg = inDegree.get(neighbor) - 1;
|
|
257
|
+
inDegree.set(neighbor, deg);
|
|
258
|
+
if (deg === 0) {
|
|
259
|
+
queue.push(neighbor);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (result.length !== alivePasses.length) {
|
|
264
|
+
throw new Error(`RenderGraph: circular dependency detected. ` + `Sorted ${result.length} of ${alivePasses.length} alive passes.`);
|
|
265
|
+
}
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
// ─── Private: Resource Lifetime Analysis ────────────────────────────
|
|
269
|
+
/** @internal */ _analyzeLifetimes(orderedPasses) {
|
|
270
|
+
const lifetimes = new Map();
|
|
271
|
+
// Build pass -> order index map
|
|
272
|
+
const orderMap = new Map();
|
|
273
|
+
for(let i = 0; i < orderedPasses.length; i++){
|
|
274
|
+
orderMap.set(orderedPasses[i], i);
|
|
275
|
+
}
|
|
276
|
+
for (const res of this._resources.values()){
|
|
277
|
+
let first = Infinity;
|
|
278
|
+
let last = -Infinity;
|
|
279
|
+
// Producer
|
|
280
|
+
if (res.producer && orderMap.has(res.producer)) {
|
|
281
|
+
const idx = orderMap.get(res.producer);
|
|
282
|
+
first = Math.min(first, idx);
|
|
283
|
+
last = Math.max(last, idx);
|
|
284
|
+
}
|
|
285
|
+
// Consumers
|
|
286
|
+
for (const consumer of res.consumers){
|
|
287
|
+
if (orderMap.has(consumer)) {
|
|
288
|
+
const idx = orderMap.get(consumer);
|
|
289
|
+
first = Math.min(first, idx);
|
|
290
|
+
last = Math.max(last, idx);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (first !== Infinity) {
|
|
294
|
+
lifetimes.set(res.id, {
|
|
295
|
+
resource: res,
|
|
296
|
+
firstUse: first,
|
|
297
|
+
lastUse: last
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return lifetimes;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export { RenderGraph };
|
|
306
|
+
//# sourceMappingURL=rendergraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendergraph.js","sources":["../../../src/render/rendergraph/rendergraph.ts"],"sourcesContent":["import {\r\n RGHandle,\r\n RGResource,\r\n RGPass,\r\n type RGTextureDesc,\r\n type RGPassBuilder,\r\n type RGExecuteFn,\r\n type RGExecuteContext,\r\n type CompiledRenderGraph,\r\n type RGResourceLifetime\r\n} from './types';\r\n\r\n/**\r\n * Render Graph — declarative, configurable render pipeline.\r\n *\r\n * Usage:\r\n * ```ts\r\n * const graph = new RenderGraph();\r\n * const backbuffer = graph.importTexture('backbuffer');\r\n *\r\n * let linearDepth: RGHandle;\r\n * graph.addPass('DepthPrepass', (builder) => {\r\n * linearDepth = builder.createTexture({ format: 'r32f', label: 'linearDepth' });\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * graph.addPass('LightPass', (builder) => {\r\n * builder.read(linearDepth);\r\n * builder.write(backbuffer);\r\n * builder.setExecute(() => { ... });\r\n * });\r\n *\r\n * const compiled = graph.compile([backbuffer]);\r\n * graph.execute(compiled);\r\n * graph.reset();\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport class RenderGraph {\r\n /** @internal */\r\n private _nextResourceId = 0;\r\n /** @internal */\r\n private _resources: Map<number, RGResource> = new Map();\r\n /** @internal */\r\n private _passes: RGPass[] = [];\r\n /** @internal */\r\n private _compiled: CompiledRenderGraph | null = null;\r\n\r\n // ─── Graph Building ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Import an external (persistent) texture into the graph.\r\n *\r\n * Imported resources are not allocated or released by the graph.\r\n * Typically used for the backbuffer or any texture that outlives a single frame.\r\n *\r\n * @param name - Debug label for the imported resource.\r\n * @returns A handle referencing the imported resource.\r\n */\r\n importTexture(name: string): RGHandle {\r\n const id = this._nextResourceId++;\r\n const resource = new RGResource(id, name, 'imported', null);\r\n this._resources.set(id, resource);\r\n this._compiled = null;\r\n return new RGHandle(id, name);\r\n }\r\n\r\n /**\r\n * Add a render pass to the graph.\r\n *\r\n * The setup callback receives a {@link RGPassBuilder} to declare resource\r\n * dependencies. Call `builder.setExecute(fn)` inside setup to provide the\r\n * execution callback.\r\n *\r\n * @param name - Debug label for the pass.\r\n * @param setup - Setup callback that declares resources and sets the execute function.\r\n */\r\n addPass<T = void>(name: string, setup: (builder: RGPassBuilder) => T): T {\r\n const pass = new RGPass(this._passes.length, name);\r\n const builder = this._createBuilder(pass);\r\n const data = setup(builder);\r\n pass.data = data;\r\n this._passes.push(pass);\r\n this._compiled = null;\r\n return data;\r\n }\r\n\r\n // ─── Compilation ────────────────────────────────────────────────────\r\n\r\n /**\r\n * Compile the render graph.\r\n *\r\n * Performs dead-pass culling, topological sorting, and resource lifetime analysis.\r\n *\r\n * @param outputs - Handles of resources that must be produced (graph sinks).\r\n * Passes that do not contribute to these outputs (directly or transitively)\r\n * are culled, unless marked as side-effect passes.\r\n * @returns The compiled graph ready for execution.\r\n */\r\n compile(outputs: RGHandle[]): CompiledRenderGraph {\r\n if (this._compiled) {\r\n return this._compiled;\r\n }\r\n // 1. Mark alive passes via backward traversal from outputs + side-effect passes\r\n this._cullDeadPasses(outputs);\r\n // 2. Topological sort of alive passes\r\n const ordered = this._topologicalSort();\r\n // 3. Resource lifetime analysis\r\n const lifetimes = this._analyzeLifetimes(ordered);\r\n\r\n this._compiled = { orderedPasses: ordered, lifetimes };\r\n return this._compiled;\r\n }\r\n\r\n /**\r\n * Execute a compiled render graph (simple mode, no resource management).\r\n *\r\n * For automatic resource allocation/release, use {@link RenderGraphExecutor} instead.\r\n *\r\n * @param compiled - The compiled graph from {@link compile}.\r\n */\r\n execute(compiled: CompiledRenderGraph): void {\r\n const noopCtx: RGExecuteContext = {\r\n getTexture() {\r\n throw new Error(\r\n 'RenderGraph.execute(): resource resolution not available. Use RenderGraphExecutor for managed execution.'\r\n );\r\n }\r\n };\r\n for (const pass of compiled.orderedPasses) {\r\n if (pass.executeFn) {\r\n (pass.executeFn as RGExecuteFn<unknown>)(noopCtx, pass.data);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Reset the graph for the next frame.\r\n *\r\n * Clears all passes, transient resources, and compiled state.\r\n * Imported resources are also cleared — re-import them each frame.\r\n */\r\n reset(): void {\r\n this._passes.length = 0;\r\n this._resources.clear();\r\n this._nextResourceId = 0;\r\n this._compiled = null;\r\n }\r\n\r\n // ─── Accessors (for testing / debugging) ────────────────────────────\r\n\r\n /** @internal */\r\n getResource(handle: RGHandle): RGResource | undefined {\r\n return this._resources.get(handle._id);\r\n }\r\n\r\n /** @internal */\r\n get passes(): ReadonlyArray<RGPass> {\r\n return this._passes;\r\n }\r\n\r\n /** @internal */\r\n get resources(): ReadonlyMap<number, RGResource> {\r\n return this._resources;\r\n }\r\n\r\n // ─── Private: Builder ───────────────────────────────────────────────\r\n\r\n /** @internal */\r\n private _createBuilder(pass: RGPass): RGPassBuilder {\r\n const graph = this;\r\n return {\r\n read(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n pass.reads.push(res);\r\n res.consumers.push(pass);\r\n },\r\n write(handle: RGHandle): void {\r\n const res = graph._resources.get(handle._id);\r\n if (!res) {\r\n throw new Error(`RenderGraph: unknown resource \"${handle.name}\" (id=${handle._id})`);\r\n }\r\n if (res.producer && res.producer !== pass) {\r\n throw new Error(\r\n `RenderGraph: resource \"${res.name}\" already produced by pass \"${res.producer.name}\", ` +\r\n `cannot be written by pass \"${pass.name}\"`\r\n );\r\n }\r\n res.producer = pass;\r\n pass.writes.push(res);\r\n },\r\n createTexture(desc: RGTextureDesc): RGHandle {\r\n const id = graph._nextResourceId++;\r\n const name = desc.label ?? `_tex_${id}`;\r\n const res = new RGResource(id, name, 'transient', desc);\r\n res.producer = pass;\r\n graph._resources.set(id, res);\r\n pass.writes.push(res);\r\n return new RGHandle(id, name);\r\n },\r\n sideEffect(): void {\r\n pass.hasSideEffect = true;\r\n },\r\n setExecute<D>(fn: RGExecuteFn<D>): void {\r\n pass.executeFn = fn as RGExecuteFn<unknown>;\r\n }\r\n };\r\n }\r\n\r\n // ─── Private: Dead Pass Culling ─────────────────────────────────────\r\n\r\n /** @internal */\r\n private _cullDeadPasses(outputs: RGHandle[]): void {\r\n // Start with all passes marked dead\r\n for (const pass of this._passes) {\r\n pass.alive = false;\r\n }\r\n\r\n // Seed: resources that are requested outputs\r\n const neededResources = new Set<number>();\r\n const stack: RGResource[] = [];\r\n\r\n for (const handle of outputs) {\r\n const res = this._resources.get(handle._id);\r\n if (res) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n\r\n // Seed: side-effect passes (always alive) — push their read dependencies\r\n for (const pass of this._passes) {\r\n if (pass.hasSideEffect) {\r\n pass.alive = true;\r\n for (const res of pass.reads) {\r\n if (!neededResources.has(res.id)) {\r\n neededResources.add(res.id);\r\n stack.push(res);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Backward traversal: for each needed resource, mark its producer alive\r\n // and recursively mark the producer's read dependencies as needed\r\n while (stack.length > 0) {\r\n const res = stack.pop()!;\r\n const producer = res.producer;\r\n if (producer && !producer.alive) {\r\n producer.alive = true;\r\n for (const dep of producer.reads) {\r\n if (!neededResources.has(dep.id)) {\r\n neededResources.add(dep.id);\r\n stack.push(dep);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // ─── Private: Topological Sort (Kahn's Algorithm) ───────────────────\r\n\r\n /** @internal */\r\n private _topologicalSort(): RGPass[] {\r\n const alivePasses = this._passes.filter((p) => p.alive);\r\n if (alivePasses.length === 0) {\r\n return [];\r\n }\r\n\r\n // Build adjacency: producer -> consumers (only among alive passes)\r\n const aliveSet = new Set(alivePasses);\r\n const inDegree = new Map<RGPass, number>();\r\n const adjacency = new Map<RGPass, RGPass[]>();\r\n\r\n for (const pass of alivePasses) {\r\n inDegree.set(pass, 0);\r\n adjacency.set(pass, []);\r\n }\r\n\r\n // For each resource, its producer has an edge to each of its consumers\r\n for (const res of this._resources.values()) {\r\n if (!res.producer || !aliveSet.has(res.producer)) {\r\n continue;\r\n }\r\n for (const consumer of res.consumers) {\r\n if (!aliveSet.has(consumer)) {\r\n continue;\r\n }\r\n adjacency.get(res.producer)!.push(consumer);\r\n inDegree.set(consumer, inDegree.get(consumer)! + 1);\r\n }\r\n }\r\n\r\n // Kahn's algorithm\r\n const queue: RGPass[] = [];\r\n for (const pass of alivePasses) {\r\n if (inDegree.get(pass) === 0) {\r\n queue.push(pass);\r\n }\r\n }\r\n\r\n const result: RGPass[] = [];\r\n while (queue.length > 0) {\r\n const pass = queue.shift()!;\r\n result.push(pass);\r\n for (const neighbor of adjacency.get(pass)!) {\r\n const deg = inDegree.get(neighbor)! - 1;\r\n inDegree.set(neighbor, deg);\r\n if (deg === 0) {\r\n queue.push(neighbor);\r\n }\r\n }\r\n }\r\n\r\n if (result.length !== alivePasses.length) {\r\n throw new Error(\r\n `RenderGraph: circular dependency detected. ` +\r\n `Sorted ${result.length} of ${alivePasses.length} alive passes.`\r\n );\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // ─── Private: Resource Lifetime Analysis ────────────────────────────\r\n\r\n /** @internal */\r\n private _analyzeLifetimes(orderedPasses: RGPass[]): Map<number, RGResourceLifetime> {\r\n const lifetimes = new Map<number, RGResourceLifetime>();\r\n\r\n // Build pass -> order index map\r\n const orderMap = new Map<RGPass, number>();\r\n for (let i = 0; i < orderedPasses.length; i++) {\r\n orderMap.set(orderedPasses[i], i);\r\n }\r\n\r\n for (const res of this._resources.values()) {\r\n let first = Infinity;\r\n let last = -Infinity;\r\n\r\n // Producer\r\n if (res.producer && orderMap.has(res.producer)) {\r\n const idx = orderMap.get(res.producer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n\r\n // Consumers\r\n for (const consumer of res.consumers) {\r\n if (orderMap.has(consumer)) {\r\n const idx = orderMap.get(consumer)!;\r\n first = Math.min(first, idx);\r\n last = Math.max(last, idx);\r\n }\r\n }\r\n\r\n if (first !== Infinity) {\r\n lifetimes.set(res.id, { resource: res, firstUse: first, lastUse: last });\r\n }\r\n }\r\n\r\n return lifetimes;\r\n }\r\n}\r\n"],"names":["RenderGraph","_nextResourceId","_resources","Map","_passes","_compiled","importTexture","name","id","resource","RGResource","set","RGHandle","addPass","setup","pass","RGPass","length","builder","_createBuilder","data","push","compile","outputs","_cullDeadPasses","ordered","_topologicalSort","lifetimes","_analyzeLifetimes","orderedPasses","execute","compiled","noopCtx","getTexture","Error","executeFn","reset","clear","getResource","handle","get","_id","passes","resources","graph","read","res","reads","consumers","write","producer","writes","createTexture","desc","label","sideEffect","hasSideEffect","setExecute","fn","alive","neededResources","Set","stack","add","has","pop","dep","alivePasses","filter","p","aliveSet","inDegree","adjacency","values","consumer","queue","result","shift","neighbor","deg","orderMap","i","first","Infinity","last","idx","Math","min","max","firstUse","lastUse"],"mappings":";;AAYA;;;;;;;;;;;;;;;;;;;;;;;;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AI,CAAA;AAC1C,YAAA,IAAIS,KAAQC,GAAAA,QAAAA;AACZ,YAAA,IAAIC,OAAO,CAACD,QAAAA;;YAGZ,IAAIrC,GAAAA,CAAII,QAAQ,IAAI8B,QAAAA,CAAShB,GAAG,CAAClB,GAAAA,CAAII,QAAQ,CAAG,EAAA;AAC9C,gBAAA,MAAMmC,GAAML,GAAAA,QAAAA,CAASxC,GAAG,CAACM,IAAII,QAAQ,CAAA;gBACrCgC,KAAQI,GAAAA,IAAAA,CAAKC,GAAG,CAACL,KAAOG,EAAAA,GAAAA,CAAAA;gBACxBD,IAAOE,GAAAA,IAAAA,CAAKE,GAAG,CAACJ,IAAMC,EAAAA,GAAAA,CAAAA;AACxB;;AAGA,YAAA,KAAK,MAAMX,QAAAA,IAAY5B,GAAIE,CAAAA,SAAS,CAAE;gBACpC,IAAIgC,QAAAA,CAAShB,GAAG,CAACU,QAAW,CAAA,EAAA;oBAC1B,MAAMW,GAAAA,GAAML,QAASxC,CAAAA,GAAG,CAACkC,QAAAA,CAAAA;oBACzBQ,KAAQI,GAAAA,IAAAA,CAAKC,GAAG,CAACL,KAAOG,EAAAA,GAAAA,CAAAA;oBACxBD,IAAOE,GAAAA,IAAAA,CAAKE,GAAG,CAACJ,IAAMC,EAAAA,GAAAA,CAAAA;AACxB;AACF;AAEA,YAAA,IAAIH,UAAUC,QAAU,EAAA;AACtBxD,gBAAAA,SAAAA,CAAUhB,GAAG,CAACmC,GAAItC,CAAAA,EAAE,EAAE;oBAAEC,QAAUqC,EAAAA,GAAAA;oBAAK2C,QAAUP,EAAAA,KAAAA;oBAAOQ,OAASN,EAAAA;AAAK,iBAAA,CAAA;AACxE;AACF;QAEA,OAAOzD,SAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// ─── Handles ────────────────────────────────────────────────────────────
|
|
2
|
+
/**
|
|
3
|
+
* Opaque handle referencing a resource within the render graph.
|
|
4
|
+
*
|
|
5
|
+
* Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},
|
|
6
|
+
* or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare
|
|
7
|
+
* dependencies between passes.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/ class RGHandle {
|
|
11
|
+
/** @internal */ _id;
|
|
12
|
+
/** @internal */ _name;
|
|
13
|
+
/** @internal */ constructor(id, name){
|
|
14
|
+
this._id = id;
|
|
15
|
+
this._name = name;
|
|
16
|
+
}
|
|
17
|
+
/** Debug-friendly name of the referenced resource. */ get name() {
|
|
18
|
+
return this._name;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Internal bookkeeping for a resource within the render graph.
|
|
23
|
+
* @internal
|
|
24
|
+
*/ class RGResource {
|
|
25
|
+
id;
|
|
26
|
+
name;
|
|
27
|
+
kind;
|
|
28
|
+
desc;
|
|
29
|
+
/** The pass that creates / writes this resource (null for imported until written). */ producer = null;
|
|
30
|
+
/** Passes that read this resource. */ consumers = [];
|
|
31
|
+
constructor(id, name, kind, desc){
|
|
32
|
+
this.id = id;
|
|
33
|
+
this.name = name;
|
|
34
|
+
this.kind = kind;
|
|
35
|
+
this.desc = desc;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Internal bookkeeping for a pass within the render graph.
|
|
40
|
+
* @internal
|
|
41
|
+
*/ class RGPass {
|
|
42
|
+
index;
|
|
43
|
+
name;
|
|
44
|
+
/** Resources this pass reads (dependencies). */ reads = [];
|
|
45
|
+
/** Resources this pass creates or writes. */ writes = [];
|
|
46
|
+
/** Whether this pass has side effects and must not be culled. */ hasSideEffect = false;
|
|
47
|
+
/** User data returned from the setup function. */ data = null;
|
|
48
|
+
/** Execute callback. */ executeFn = null;
|
|
49
|
+
/** Set during compilation: true if this pass is needed. */ alive = true;
|
|
50
|
+
constructor(index, name){
|
|
51
|
+
this.index = index;
|
|
52
|
+
this.name = name;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { RGHandle, RGPass, RGResource };
|
|
57
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type { TextureFormat } from '@zephyr3d/device';\r\n\r\n// ─── Resource Descriptors ───────────────────────────────────────────────\r\n\r\n/**\r\n * Sizing mode for render graph textures.\r\n *\r\n * - 'absolute': fixed pixel dimensions\r\n * - 'backbuffer-relative': scaled relative to the backbuffer size\r\n *\r\n * @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/**\r\n * Descriptor for a transient texture resource within the render graph.\r\n *\r\n * Transient textures are allocated and released automatically by the graph compiler.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /** Texture format (e.g. 'rgba8unorm', 'r32f', 'rgba16f'). */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Width in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n width?: number;\r\n /** Height in pixels (absolute) or scale factor (backbuffer-relative, default 1.0). */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n}\r\n\r\n// ─── Handles ────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Opaque handle referencing a resource within the render graph.\r\n *\r\n * Handles are obtained from {@link RGPassBuilder.createTexture}, {@link RenderGraph.importTexture},\r\n * or {@link RGPassBuilder.write}. They are lightweight identifiers used to declare\r\n * dependencies between passes.\r\n *\r\n * @public\r\n */\r\nexport class RGHandle {\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string) {\r\n this._id = id;\r\n this._name = name;\r\n }\r\n\r\n /** Debug-friendly name of the referenced resource. */\r\n get name(): string {\r\n return this._name;\r\n }\r\n}\r\n\r\n// ─── Internal Resource Tracking ─────────────────────────────────────────\r\n\r\n/** @internal */\r\nexport type RGResourceKind = 'transient' | 'imported';\r\n\r\n/**\r\n * Internal bookkeeping for a resource within the render graph.\r\n * @internal\r\n */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass[] = [];\r\n\r\n constructor(id: number, name: string, kind: RGResourceKind, desc: RGTextureDesc | null) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n }\r\n}\r\n\r\n// ─── Internal Pass Tracking ─────────────────────────────────────────────\r\n\r\n// ─── Execution Context ──────────────────────────────────────────────\r\n\r\n/**\r\n * Context passed to pass execute callbacks during graph execution.\r\n *\r\n * Provides access to resolved GPU resources by their handles.\r\n *\r\n * @public\r\n */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a handle to the actual GPU texture object.\r\n *\r\n * For transient resources, this returns the texture allocated by the executor.\r\n * For imported resources, this returns the texture registered via\r\n * {@link RenderGraphExecutor.setImportedTexture}.\r\n *\r\n * @param handle - Handle of the resource to resolve.\r\n * @returns The resolved texture object (type depends on the allocator).\r\n */\r\n getTexture<TTexture = unknown>(handle: RGHandle): TTexture;\r\n}\r\n\r\n/**\r\n * Execute callback signature.\r\n *\r\n * The callback receives a context for resolving handles to GPU resources,\r\n * plus the user data returned from the setup function.\r\n *\r\n * @public\r\n */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/**\r\n * Internal bookkeeping for a pass within the render graph.\r\n * @internal\r\n */\r\nexport class RGPass<T = unknown> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Resources this pass reads (dependencies). */\r\n readonly reads: RGResource[] = [];\r\n /** Resources this pass creates or writes. */\r\n readonly writes: RGResource[] = [];\r\n /** Whether this pass has side effects and must not be culled. */\r\n hasSideEffect = false;\r\n /** User data returned from the setup function. */\r\n data: T | null = null;\r\n /** Execute callback. */\r\n executeFn: RGExecuteFn<T> | null = null;\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string) {\r\n this.index = index;\r\n this.name = name;\r\n }\r\n}\r\n\r\n// ─── Pass Builder ───────────────────────────────────────────────────────\r\n\r\n/**\r\n * Builder interface used within the setup callback of {@link RenderGraph.addPass}\r\n * to declare a pass's resource requirements.\r\n *\r\n * @public\r\n */\r\nexport interface RGPassBuilder {\r\n /**\r\n * Declare a read dependency on an existing resource.\r\n *\r\n * The resource must have been created by a prior pass or imported into the graph.\r\n *\r\n * @param handle - Handle of the resource to read.\r\n */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Declare that this pass writes to an existing resource (typically an imported resource).\r\n *\r\n * @param handle - Handle of the resource to write to.\r\n */\r\n write(handle: RGHandle): void;\r\n\r\n /**\r\n * Create a new transient texture resource that this pass will produce.\r\n *\r\n * @param desc - Texture descriptor.\r\n * @returns A handle referencing the newly created resource.\r\n */\r\n createTexture(desc: RGTextureDesc): RGHandle;\r\n\r\n /**\r\n * Mark this pass as having side effects.\r\n *\r\n * Side-effect passes are never culled by the graph compiler, regardless of\r\n * whether their outputs are consumed. Use this for GPU readback, picking,\r\n * debug overlays, etc.\r\n */\r\n sideEffect(): void;\r\n\r\n /**\r\n * Set the execution callback for this pass.\r\n *\r\n * @param fn - Callback invoked during graph execution.\r\n */\r\n setExecute<D>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n// ─── Compiled Graph ─────────────────────────────────────────────────────\r\n\r\n/**\r\n * Lifetime information for a resource within the compiled graph.\r\n *\r\n * @public\r\n */\r\nexport interface RGResourceLifetime {\r\n /** The resource. */\r\n readonly resource: RGResource;\r\n /** Index of the first pass that uses (produces or reads) this resource. */\r\n readonly firstUse: number;\r\n /** Index of the last pass that uses this resource. */\r\n readonly lastUse: number;\r\n}\r\n\r\n/**\r\n * Result of compiling a render graph.\r\n *\r\n * Contains the ordered list of passes to execute and lifetime information\r\n * for automatic resource management.\r\n *\r\n * @public\r\n */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n// ─── Texture Allocator ──────────────────────────────────────────────\r\n\r\n/**\r\n * Resolved dimensions for a texture allocation.\r\n * @public\r\n */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Implement this to bridge the render graph with your GPU device's resource pool.\r\n * The executor calls {@link allocate} before a resource's first use and\r\n * {@link release} after its last use.\r\n *\r\n * @typeParam TTexture - The concrete texture type (e.g. `Texture2D`).\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = unknown> {\r\n /**\r\n * Allocate a transient texture matching the given descriptor and resolved size.\r\n *\r\n * @param desc - The texture descriptor from the pass builder.\r\n * @param size - The resolved pixel dimensions.\r\n * @returns The allocated texture object.\r\n */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize): TTexture;\r\n\r\n /**\r\n * Release a previously allocated transient texture back to the pool.\r\n *\r\n * @param texture - The texture to release.\r\n */\r\n release(texture: TTexture): void;\r\n}\r\n"],"names":["RGHandle","id","name","_id","_name","RGResource","kind","desc","producer","consumers","RGPass","index","reads","writes","hasSideEffect","data","executeFn","alive"],"mappings":"AAoCA;AAEA;;;;;;;;AAQC,IACM,MAAMA,QAAAA,CAAAA;qBAEX,GAAqB;qBAErB,KAAuB;AAEvB,qBACA,WAAA,CAAYC,EAAU,EAAEC,IAAY,CAAE;QACpC,IAAI,CAACC,GAAG,GAAGF,EAAAA;QACX,IAAI,CAACG,KAAK,GAAGF,IAAAA;AACf;2DAGA,IAAIA,IAAe,GAAA;QACjB,OAAO,IAAI,CAACE,KAAK;AACnB;AACF;AAOA;;;AAGC,IACM,MAAMC,UAAAA,CAAAA;IACFJ,EAAW;IACXC,IAAa;IACbI,IAAqB;IACrBC,IAA2B;2FAEpCC,WAA0B,IAAK;AAC/B,2CACSC,SAAsB,GAAA,EAAE;AAEjC,IAAA,WAAA,CAAYR,EAAU,EAAEC,IAAY,EAAEI,IAAoB,EAAEC,IAA0B,CAAE;QACtF,IAAI,CAACN,EAAE,GAAGA,EAAAA;QACV,IAAI,CAACC,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACI,IAAI,GAAGA,IAAAA;QACZ,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;AACF;AAqCA;;;AAGC,IACM,MAAMG,MAAAA,CAAAA;IACFC,KAAc;IACdT,IAAa;AACtB,qDACSU,KAAsB,GAAA,EAAE;AACjC,kDACSC,MAAuB,GAAA,EAAE;sEAElCC,gBAAgB,KAAM;uDAEtBC,OAAiB,IAAK;6BAEtBC,YAAmC,IAAK;gEAExCC,QAAQ,IAAK;IAEb,WAAYN,CAAAA,KAAa,EAAET,IAAY,CAAE;QACvC,IAAI,CAACS,KAAK,GAAGA,KAAAA;QACb,IAAI,CAACT,IAAI,GAAGA,IAAAA;AACd;AACF;;;;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AbstractPostEffect } from '../posteffect/posteffect.js';
|
|
2
|
+
import '@zephyr3d/base';
|
|
3
|
+
import './primitive.js';
|
|
4
|
+
import { BoxShape } from '../shapes/box.js';
|
|
5
|
+
import '../shapes/cylinder.js';
|
|
6
|
+
import '../shapes/torus.js';
|
|
7
|
+
import '../shapes/plane.js';
|
|
8
|
+
import '../shapes/sphere.js';
|
|
9
|
+
import '../shapes/tetrahedron.js';
|
|
10
|
+
|
|
11
|
+
let _skyMotionVectorProgram = null;
|
|
12
|
+
let _skyMotionVectorBindGroup = null;
|
|
13
|
+
let _box = null;
|
|
14
|
+
function getSkyMotionVectorProgram(ctx) {
|
|
15
|
+
if (!_skyMotionVectorProgram) {
|
|
16
|
+
_skyMotionVectorProgram = ctx.device.buildRenderProgram({
|
|
17
|
+
vertex (pb) {
|
|
18
|
+
this.$inputs.pos = pb.vec3().attrib('position');
|
|
19
|
+
this.VPMatrix = pb.mat4().uniform(0);
|
|
20
|
+
this.prevVPMatrix = pb.mat4().uniform(0);
|
|
21
|
+
this.cameraPos = pb.vec3().uniform(0);
|
|
22
|
+
this.prevCameraPos = pb.vec3().uniform(0);
|
|
23
|
+
pb.main(function() {
|
|
24
|
+
this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);
|
|
25
|
+
this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);
|
|
26
|
+
this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));
|
|
27
|
+
this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));
|
|
28
|
+
this.clipPos.z = this.clipPos.w;
|
|
29
|
+
this.$builtins.position = this.clipPos;
|
|
30
|
+
this.$outputs.currentPos = this.clipPos;
|
|
31
|
+
this.$outputs.prevPos = this.prevClipPos;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
fragment (pb) {
|
|
35
|
+
this.$outputs.color = pb.vec4();
|
|
36
|
+
pb.main(function() {
|
|
37
|
+
this.$l.motionVector = pb.mul(pb.sub(pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w), pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)), 0.5);
|
|
38
|
+
this.$outputs.color = pb.vec4(this.motionVector, 0, 1);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
_skyMotionVectorProgram.name = '@TAA_SkyMotionVector';
|
|
43
|
+
}
|
|
44
|
+
return _skyMotionVectorProgram;
|
|
45
|
+
}
|
|
46
|
+
function getBox() {
|
|
47
|
+
if (!_box) {
|
|
48
|
+
_box = new BoxShape({
|
|
49
|
+
size: 2,
|
|
50
|
+
needNormal: false,
|
|
51
|
+
needUV: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return _box;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Renders sky motion vectors into ctx.motionVectorTexture.
|
|
58
|
+
* Must be called after opaque pass with ctx.motionVectorTexture set.
|
|
59
|
+
* @internal
|
|
60
|
+
*/ function renderSkyMotionVectors(ctx) {
|
|
61
|
+
if (!ctx.motionVectorTexture) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 0, 0, ctx.motionVectorTexture, ctx.depthTexture);
|
|
65
|
+
const program = getSkyMotionVectorProgram(ctx);
|
|
66
|
+
if (!_skyMotionVectorBindGroup) {
|
|
67
|
+
_skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);
|
|
68
|
+
}
|
|
69
|
+
const box = getBox();
|
|
70
|
+
_skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);
|
|
71
|
+
_skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix);
|
|
72
|
+
_skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
|
|
73
|
+
_skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition);
|
|
74
|
+
ctx.device.pushDeviceStates();
|
|
75
|
+
ctx.device.setProgram(program);
|
|
76
|
+
ctx.device.setBindGroup(0, _skyMotionVectorBindGroup);
|
|
77
|
+
ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));
|
|
78
|
+
ctx.device.setFramebuffer(fb);
|
|
79
|
+
box.draw();
|
|
80
|
+
ctx.device.popDeviceStates();
|
|
81
|
+
ctx.device.pool.releaseFrameBuffer(fb);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { renderSkyMotionVectors };
|
|
85
|
+
//# sourceMappingURL=sky_motion_vector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sky_motion_vector.js","sources":["../../src/render/sky_motion_vector.ts"],"sourcesContent":["import type { BindGroup, GPUProgram } from '@zephyr3d/device';\nimport type { Nullable } from '@zephyr3d/base';\nimport { AbstractPostEffect } from '../posteffect/posteffect';\nimport { BoxShape } from '../shapes';\nimport type { DrawContext } from './drawable';\nimport type { Primitive } from '.';\n\nlet _skyMotionVectorProgram: Nullable<GPUProgram> = null;\nlet _skyMotionVectorBindGroup: Nullable<BindGroup> = null;\nlet _box: Nullable<Primitive> = null;\n\nfunction getSkyMotionVectorProgram(ctx: DrawContext): GPUProgram {\n if (!_skyMotionVectorProgram) {\n _skyMotionVectorProgram = ctx.device.buildRenderProgram({\n vertex(pb) {\n this.$inputs.pos = pb.vec3().attrib('position');\n this.VPMatrix = pb.mat4().uniform(0);\n this.prevVPMatrix = pb.mat4().uniform(0);\n this.cameraPos = pb.vec3().uniform(0);\n this.prevCameraPos = pb.vec3().uniform(0);\n pb.main(function () {\n this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);\n this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);\n this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));\n this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));\n this.clipPos.z = this.clipPos.w;\n this.$builtins.position = this.clipPos;\n this.$outputs.currentPos = this.clipPos;\n this.$outputs.prevPos = this.prevClipPos;\n });\n },\n fragment(pb) {\n this.$outputs.color = pb.vec4();\n pb.main(function () {\n this.$l.motionVector = pb.mul(\n pb.sub(\n pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w),\n pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)\n ),\n 0.5\n );\n this.$outputs.color = pb.vec4(this.motionVector, 0, 1);\n });\n }\n })!;\n _skyMotionVectorProgram.name = '@TAA_SkyMotionVector';\n }\n return _skyMotionVectorProgram;\n}\n\nfunction getBox(): Primitive {\n if (!_box) {\n _box = new BoxShape({ size: 2, needNormal: false, needUV: false });\n }\n return _box;\n}\n\n/**\n * Renders sky motion vectors into ctx.motionVectorTexture.\n * Must be called after opaque pass with ctx.motionVectorTexture set.\n * @internal\n */\nexport function renderSkyMotionVectors(ctx: DrawContext): void {\n if (!ctx.motionVectorTexture) {\n return;\n }\n const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 0, 0, ctx.motionVectorTexture, ctx.depthTexture);\n const program = getSkyMotionVectorProgram(ctx);\n if (!_skyMotionVectorBindGroup) {\n _skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);\n }\n const box = getBox();\n _skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);\n _skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix!);\n _skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());\n _skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition!);\n ctx.device.pushDeviceStates();\n ctx.device.setProgram(program);\n ctx.device.setBindGroup(0, _skyMotionVectorBindGroup);\n ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));\n ctx.device.setFramebuffer(fb);\n box.draw();\n ctx.device.popDeviceStates();\n ctx.device.pool.releaseFrameBuffer(fb);\n}\n"],"names":["_skyMotionVectorProgram","_skyMotionVectorBindGroup","_box","getSkyMotionVectorProgram","ctx","device","buildRenderProgram","vertex","pb","$inputs","pos","vec3","attrib","VPMatrix","mat4","uniform","prevVPMatrix","cameraPos","prevCameraPos","main","$l","worldPos","add","prevWorldPos","clipPos","mul","vec4","prevClipPos","z","w","$builtins","position","$outputs","currentPos","prevPos","fragment","color","motionVector","sub","div","xy","name","getBox","BoxShape","size","needNormal","needUV","renderSkyMotionVectors","motionVectorTexture","fb","pool","fetchTemporalFramebuffer","depthTexture","program","createBindGroup","bindGroupLayouts","box","setValue","camera","viewProjectionMatrix","getWorldPosition","prevPosition","pushDeviceStates","setProgram","setBindGroup","setRenderStates","AbstractPostEffect","getDefaultRenderState","setFramebuffer","draw","popDeviceStates","releaseFrameBuffer"],"mappings":";;;;;;;;;;AAOA,IAAIA,uBAAgD,GAAA,IAAA;AACpD,IAAIC,yBAAiD,GAAA,IAAA;AACrD,IAAIC,IAA4B,GAAA,IAAA;AAEhC,SAASC,0BAA0BC,GAAgB,EAAA;AACjD,IAAA,IAAI,CAACJ,uBAAyB,EAAA;AAC5BA,QAAAA,uBAAAA,GAA0BI,GAAIC,CAAAA,MAAM,CAACC,kBAAkB,CAAC;AACtDC,YAAAA,MAAAA,CAAAA,CAAOC,EAAE,EAAA;gBACP,IAAI,CAACC,OAAO,CAACC,GAAG,GAAGF,EAAGG,CAAAA,IAAI,EAAGC,CAAAA,MAAM,CAAC,UAAA,CAAA;AACpC,gBAAA,IAAI,CAACC,QAAQ,GAAGL,GAAGM,IAAI,EAAA,CAAGC,OAAO,CAAC,CAAA,CAAA;AAClC,gBAAA,IAAI,CAACC,YAAY,GAAGR,GAAGM,IAAI,EAAA,CAAGC,OAAO,CAAC,CAAA,CAAA;AACtC,gBAAA,IAAI,CAACE,SAAS,GAAGT,GAAGG,IAAI,EAAA,CAAGI,OAAO,CAAC,CAAA,CAAA;AACnC,gBAAA,IAAI,CAACG,aAAa,GAAGV,GAAGG,IAAI,EAAA,CAAGI,OAAO,CAAC,CAAA,CAAA;AACvCP,gBAAAA,EAAAA,CAAGW,IAAI,CAAC,WAAA;AACN,oBAAA,IAAI,CAACC,EAAE,CAACC,QAAQ,GAAGb,GAAGc,GAAG,CAAC,IAAI,CAACb,OAAO,CAACC,GAAG,EAAE,IAAI,CAACO,SAAS,CAAA;AAC1D,oBAAA,IAAI,CAACG,EAAE,CAACG,YAAY,GAAGf,GAAGc,GAA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A,yBAAAA,CAA0BwD,QAAQ,CAAC,cAAA,EAAgBrD,GAAIsD,CAAAA,MAAM,CAAC1C,YAAY,CAAA;AAC1Ef,IAAAA,yBAAAA,CAA0BwD,QAAQ,CAAC,WAAA,EAAarD,GAAIsD,CAAAA,MAAM,CAACE,gBAAgB,EAAA,CAAA;AAC3E3D,IAAAA,yBAAAA,CAA0BwD,QAAQ,CAAC,eAAA,EAAiBrD,GAAIsD,CAAAA,MAAM,CAACG,YAAY,CAAA;IAC3EzD,GAAIC,CAAAA,MAAM,CAACyD,gBAAgB,EAAA;IAC3B1D,GAAIC,CAAAA,MAAM,CAAC0D,UAAU,CAACV,OAAAA,CAAAA;AACtBjD,IAAAA,GAAAA,CAAIC,MAAM,CAAC2D,YAAY,CAAC,CAAG/D,EAAAA,yBAAAA,CAAAA;AAC3BG,IAAAA,GAAAA,CAAIC,MAAM,CAAC4D,eAAe,CAACC,kBAAmBC,CAAAA,qBAAqB,CAAC/D,GAAK,EAAA,IAAA,CAAA,CAAA;IACzEA,GAAIC,CAAAA,MAAM,CAAC+D,cAAc,CAACnB,EAAAA,CAAAA;AAC1BO,IAAAA,GAAAA,CAAIa,IAAI,EAAA;IACRjE,GAAIC,CAAAA,MAAM,CAACiE,eAAe,EAAA;AAC1BlE,IAAAA,GAAAA,CAAIC,MAAM,CAAC6C,IAAI,CAACqB,kBAAkB,CAACtB,EAAAA,CAAAA;AACrC;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Interpolator, base64ToUint8Array, uint8ArrayToBase64, AABB, Vector3, Matrix4x4, Quaternion } from '@zephyr3d/base';
|
|
2
2
|
import { AnimationClip } from '../../../animation/animation.js';
|
|
3
|
-
import { AnimationTrack } from '../../../animation/animationtrack.js';
|
|
4
|
-
import { NodeTranslationTrack } from '../../../animation/translationtrack.js';
|
|
5
3
|
import { NodeRotationTrack } from '../../../animation/rotationtrack.js';
|
|
6
4
|
import { NodeEulerRotationTrack } from '../../../animation/eulerrotationtrack.js';
|
|
5
|
+
import { NodeTranslationTrack } from '../../../animation/translationtrack.js';
|
|
7
6
|
import { NodeScaleTrack } from '../../../animation/scaletrack.js';
|
|
7
|
+
import { Skeleton } from '../../../animation/skeleton.js';
|
|
8
|
+
import { AnimationTrack } from '../../../animation/animationtrack.js';
|
|
8
9
|
import { PropertyTrack } from '../../../animation/proptrack.js';
|
|
9
10
|
import { MorphTargetTrack } from '../../../animation/morphtrack.js';
|
|
10
|
-
import { Skeleton } from '../../../animation/skeleton.js';
|
|
11
11
|
import { defineProps } from '../types.js';
|
|
12
12
|
import '../../../scene/scene.js';
|
|
13
13
|
import '../../../values.js';
|
|
@@ -33,9 +33,9 @@ import '../../../scene/batchgroup.js';
|
|
|
33
33
|
import '../../../scene/terrain-cm/terrain-cm.js';
|
|
34
34
|
import '../../../scene/terrain-cm/grass.js';
|
|
35
35
|
import { AnimationClip } from '../../../animation/animation.js';
|
|
36
|
-
import { NodeTranslationTrack } from '../../../animation/translationtrack.js';
|
|
37
36
|
import { NodeRotationTrack } from '../../../animation/rotationtrack.js';
|
|
38
37
|
import '../../../animation/eulerrotationtrack.js';
|
|
38
|
+
import { NodeTranslationTrack } from '../../../animation/translationtrack.js';
|
|
39
39
|
import { NodeScaleTrack } from '../../../animation/scaletrack.js';
|
|
40
40
|
import '../../../animation/skeleton.js';
|
|
41
41
|
import { JSONData } from '../json.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zephyr3d/scene",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Scene API for zephyr3d",
|
|
5
5
|
"homepage": "https://github.com/gavinyork/zephyr3d#readme",
|
|
6
6
|
"type": "module",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@types/draco3d": "^1.4.9",
|
|
69
69
|
"@webgpu/types": "^0.1.65",
|
|
70
|
-
"@zephyr3d/base": "^0.2.
|
|
70
|
+
"@zephyr3d/base": "^0.2.2",
|
|
71
71
|
"@zephyr3d/device": "^0.2.7",
|
|
72
72
|
"es-module-lexer": "^1.7.0"
|
|
73
73
|
},
|