@zephyr3d/scene 0.9.27 → 0.10.0
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/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +54 -0
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +279 -55
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +171 -1
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +104 -178
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +25436 -15990
- package/dist/index.js +65 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +66 -4
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +191 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +333 -191
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +1261 -1438
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +106 -106
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +2 -6
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +4 -13
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +3 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +179 -64
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +25 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +5 -5
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +5 -10
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +247 -157
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +16 -38
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +19 -8
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +162 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +10 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +14 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +272 -55
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +41 -0
- package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +58 -158
- package/dist/render/underwater.js.map +1 -1
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +134 -319
- package/dist/render/water_caustics.js.map +1 -1
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +3 -3
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- 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 +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +633 -268
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssgi.js +63 -0
- package/dist/shaders/ssgi.js.map +1 -0
- package/dist/shaders/ssgi_reprojection.js +118 -0
- package/dist/shaders/ssgi_reprojection.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +32 -82
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +7 -21
- package/dist/shaders/water_medium.js.map +1 -1
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +40 -2
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +34 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +46 -5
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +87 -254
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +1543 -264
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +10 -22
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
- package/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordering helper that encapsulates the side-effect "order token" chain.
|
|
3
|
+
*
|
|
4
|
+
* Side-effect passes (SkyUpdate, ClusterLights, ...) carry no data product, so
|
|
5
|
+
* they are ordered relative to one another through logical tokens rather than
|
|
6
|
+
* texture reads/writes. This scope tracks the most recently emitted token so a
|
|
7
|
+
* pass can chain after the previous one and (optionally) emit its own, without
|
|
8
|
+
* the builder threading a mutable `orderToken` local between blocks.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/ class OrderingScope {
|
|
12
|
+
/** @internal */ _last = null;
|
|
13
|
+
/**
|
|
14
|
+
* Declare a read on the most recently emitted ordering token, if any, to
|
|
15
|
+
* order the current pass after the previous side-effect pass.
|
|
16
|
+
*
|
|
17
|
+
* @param builder - The pass builder of the current pass.
|
|
18
|
+
*/ chainInto(builder) {
|
|
19
|
+
if (this._last) {
|
|
20
|
+
builder.read(this._last);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Emit a new ordering token from the current pass and record it as the latest
|
|
25
|
+
* link in the chain.
|
|
26
|
+
*
|
|
27
|
+
* @param builder - The pass builder of the current pass.
|
|
28
|
+
* @param name - Debug label for the token.
|
|
29
|
+
* @returns The newly created token handle.
|
|
30
|
+
*/ emit(builder, name) {
|
|
31
|
+
const token = builder.createToken(name);
|
|
32
|
+
this._last = token;
|
|
33
|
+
return token;
|
|
34
|
+
}
|
|
35
|
+
/** The most recently emitted ordering token, or null. */ get last() {
|
|
36
|
+
return this._last;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { OrderingScope };
|
|
41
|
+
//# sourceMappingURL=frame_graph_context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame_graph_context.js","sources":["../../../src/render/rendergraph/frame_graph_context.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\nimport type { RGHandle, RGPassBuilder } from './types';\nimport type { RenderGraph } from './rendergraph';\nimport type { RGBlackboard } from './blackboard';\nimport type { HistoryResourceManager } from './history_resource_manager';\nimport type { DrawContext } from '../drawable';\nimport type { RenderQueue } from '../render_queue';\nimport type { Texture2D, FrameBuffer } from '@zephyr3d/device';\nimport type { ForwardPlusOptions, FrameState, ForwardPlusBuildState } from './forward_plus_builder';\n\n/**\n * Ordering helper that encapsulates the side-effect \"order token\" chain.\n *\n * Side-effect passes (SkyUpdate, ClusterLights, ...) carry no data product, so\n * they are ordered relative to one another through logical tokens rather than\n * texture reads/writes. This scope tracks the most recently emitted token so a\n * pass can chain after the previous one and (optionally) emit its own, without\n * the builder threading a mutable `orderToken` local between blocks.\n *\n * @public\n */\nexport class OrderingScope {\n /** @internal */\n private _last: Nullable<RGHandle> = null;\n\n /**\n * Declare a read on the most recently emitted ordering token, if any, to\n * order the current pass after the previous side-effect pass.\n *\n * @param builder - The pass builder of the current pass.\n */\n chainInto(builder: RGPassBuilder): void {\n if (this._last) {\n builder.read(this._last);\n }\n }\n\n /**\n * Emit a new ordering token from the current pass and record it as the latest\n * link in the chain.\n *\n * @param builder - The pass builder of the current pass.\n * @param name - Debug label for the token.\n * @returns The newly created token handle.\n */\n emit(builder: RGPassBuilder, name: string): RGHandle {\n const token = builder.createToken(name);\n this._last = token;\n return token;\n }\n\n /** The most recently emitted ordering token, or null. */\n get last(): Nullable<RGHandle> {\n return this._last;\n }\n}\n\n/**\n * Build-time context threaded through the Forward+ graph assembly.\n *\n * This aggregates everything the individual pass-build blocks previously reached\n * through enclosing function locals (`orderToken`, the mutable `depthHandle`,\n * result bundles, ...). Collecting them here is the seam that lets each pass be\n * expressed as an independent unit reading its inputs from a shared context\n * rather than from closure-captured variables.\n *\n * Handles for well-known frame resources (linear depth, scene color, ...) flow\n * through {@link RenderModuleContext.blackboard} keyed by\n * {@link ./blackboard#FrameResources}; the mutable execute-time state that is\n * not a render-graph resource stays on {@link FrameGraphContext.frame}.\n *\n * @public\n */\nexport interface RenderModuleContext {\n /** The render graph being populated for this frame. */\n readonly graph: RenderGraph;\n /** Frame draw context. */\n readonly ctx: DrawContext;\n /** The culled render queue for this frame. */\n readonly renderQueue: RenderQueue;\n /** Named registry of shared frame-resource handles (see {@link ./blackboard#FrameResources}). */\n readonly blackboard: RGBlackboard;\n /** Cross-frame history resource manager, or null when unavailable. */\n readonly history: Nullable<HistoryResourceManager<Texture2D>>;\n /** Pipeline feature toggles derived from scene/camera state. */\n readonly options: ForwardPlusOptions;\n /** Ordering-token chain for side-effect passes. */\n readonly ordering: OrderingScope;\n /** The imported backbuffer handle (graph sink). */\n readonly backbuffer: RGHandle;\n}\n\n/**\n * Full build-time context threaded through the Forward+ pipeline. Extends the\n * public {@link RenderModuleContext} with the Forward+ pipeline's internal\n * mutable state, which built-in modules read/write but custom modules should\n * not depend on.\n *\n * @internal\n */\nexport interface FrameGraphContext extends RenderModuleContext {\n /** Mutable execute-time state shared between pass callbacks. */\n readonly frame: FrameState;\n /** Mutable build-state shared between modules for non-resource intermediates. */\n readonly state: ForwardPlusBuildState;\n}\n\n/** Backend framebuffer type used by the Forward+ allocator. */\nexport type ForwardPlusFramebuffer = FrameBuffer;\n"],"names":["OrderingScope","_last","chainInto","builder","read","emit","name","token","createToken","last"],"mappings":"AAUA;;;;;;;;;;AAUC,IACM,MAAMA,aAAAA,CAAAA;qBAEX,KAAQC,GAA4B,IAAK;AAEzC;;;;;MAMAC,SAAAA,CAAUC,OAAsB,EAAQ;QACtC,IAAI,IAAI,CAACF,KAAK,EAAE;AACdE,YAAAA,OAAAA,CAAQC,IAAI,CAAC,IAAI,CAACH,KAAK,CAAA;AACzB;AACF;AAEA;;;;;;;AAOC,MACDI,IAAKF,CAAAA,OAAsB,EAAEG,IAAY,EAAY;QACnD,MAAMC,KAAAA,GAAQJ,OAAQK,CAAAA,WAAW,CAACF,IAAAA,CAAAA;QAClC,IAAI,CAACL,KAAK,GAAGM,KAAAA;QACb,OAAOA,KAAAA;AACT;8DAGA,IAAIE,IAA2B,GAAA;QAC7B,OAAO,IAAI,CAACR,KAAK;AACnB;AACF;;;;"}
|
|
@@ -3,6 +3,8 @@ import { MaterialVaryingFlags } from '../../values.js';
|
|
|
3
3
|
import { RenderQueue, InstanceBindGroupAllocator } from '../render_queue.js';
|
|
4
4
|
import { LightPass } from '../lightpass.js';
|
|
5
5
|
import { DepthPass } from '../depthpass.js';
|
|
6
|
+
import { ClusteredLight } from '../cluster_light.js';
|
|
7
|
+
import { ShaderHelper } from '../../material/shader/helper.js';
|
|
6
8
|
|
|
7
9
|
// The facade renders to a single color target.
|
|
8
10
|
const SURFACE_MRT_FLAGS = MaterialVaryingFlags.SCENE_STORE_ROUGHNESS | MaterialVaryingFlags.SSS_STORE_PROFILE | MaterialVaryingFlags.SSS_STORE_DIFFUSE | MaterialVaryingFlags.SCENE_STORE_NORMAL | MaterialVaryingFlags.SSS_STORE_TRANSMISSION | MaterialVaryingFlags.SKIN_SSS_STORE;
|
|
@@ -27,7 +29,10 @@ function snapshotDrawContext(ctx) {
|
|
|
27
29
|
depthPrepassAttachment: ctx.depthPrepassAttachment,
|
|
28
30
|
sunLight: ctx.sunLight,
|
|
29
31
|
primaryDirectionalLight: ctx.primaryDirectionalLight,
|
|
30
|
-
primaryTransmissionLight: ctx.primaryTransmissionLight
|
|
32
|
+
primaryTransmissionLight: ctx.primaryTransmissionLight,
|
|
33
|
+
clusteredLight: ctx.clusteredLight,
|
|
34
|
+
screenSpaceShadowMask: ctx.screenSpaceShadowMask,
|
|
35
|
+
transmissionThickness: ctx.transmissionThickness
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
function restoreDrawContext(ctx, state) {
|
|
@@ -91,7 +96,8 @@ function restoreDrawContext(ctx, state) {
|
|
|
91
96
|
info.skinItemList,
|
|
92
97
|
info.morphItemList,
|
|
93
98
|
info.skinAndMorphItemList,
|
|
94
|
-
info.instanceItemList
|
|
99
|
+
info.instanceItemList,
|
|
100
|
+
info.skinInstanceItemList
|
|
95
101
|
];
|
|
96
102
|
for (const list of sources){
|
|
97
103
|
for (const item of list){
|
|
@@ -195,6 +201,9 @@ function restoreDrawContext(ctx, state) {
|
|
|
195
201
|
ctx.sunLight = queue.sunLight;
|
|
196
202
|
ctx.primaryDirectionalLight = queue.primaryDirectionalLight;
|
|
197
203
|
ctx.primaryTransmissionLight = queue.primaryTransmissionLight;
|
|
204
|
+
if (savedContext.clusteredLight) {
|
|
205
|
+
this._clusterLights(target, queue, camera);
|
|
206
|
+
}
|
|
198
207
|
_sceneLightPass.transmission = false;
|
|
199
208
|
_sceneLightPass.renderSky = false;
|
|
200
209
|
_sceneLightPass.renderOpaque = renderOpaque;
|
|
@@ -215,6 +224,26 @@ function restoreDrawContext(ctx, state) {
|
|
|
215
224
|
device.popDeviceStates();
|
|
216
225
|
}
|
|
217
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Replaces the frame's clusters with ones built for this render.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* The frame's clusters were built for the frame camera's view, the frame queue's
|
|
232
|
+
* lights and the render size, none of which need hold here. The screen-space shadow
|
|
233
|
+
* mask and transmission thickness go too: they were rendered from the frame camera
|
|
234
|
+
* and are indexed by that cluster buffer's ordinals, so shadow-casting lights fall
|
|
235
|
+
* back to the per-light additive path, as on transparent queues. The caller restores
|
|
236
|
+
* all three fields.
|
|
237
|
+
*/ _clusterLights(target, queue, camera) {
|
|
238
|
+
const ctx = this._ctx;
|
|
239
|
+
ctx.screenSpaceShadowMask = false;
|
|
240
|
+
ctx.transmissionThickness = false;
|
|
241
|
+
const clusteredLight = ClusteredLight.acquire(target.getWidth(), target.getHeight());
|
|
242
|
+
// Released after graph execution: the draws reading it may still be pending before.
|
|
243
|
+
this._rgCtx.deferCleanup(()=>ClusteredLight.release(clusteredLight));
|
|
244
|
+
clusteredLight.calculateLightIndex(camera, queue, target.getWidth(), target.getHeight(), false, ShaderHelper.getPreExposure(ctx));
|
|
245
|
+
ctx.clusteredLight = clusteredLight;
|
|
246
|
+
}
|
|
218
247
|
renderDepth(target, queue, opts) {
|
|
219
248
|
const ctx = this._ctx;
|
|
220
249
|
const device = ctx.device;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scene_render_context.js","sources":["../../../src/render/rendergraph/scene_render_context.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { DEPTH_CLEAR_VALUE, Vector4 } from '@zephyr3d/base';\r\nimport type { FrameBuffer, Texture2D } from '@zephyr3d/device';\r\nimport type { Camera } from '../../camera';\r\nimport { MaterialVaryingFlags } from '../../values';\r\nimport type { DrawContext, Drawable } from '../drawable';\r\nimport { RenderQueue, InstanceBindGroupAllocator } from '../render_queue';\r\nimport { LightPass } from '../lightpass';\r\nimport { DepthPass } from '../depthpass';\r\nimport type { RGExecuteContext } from './types';\r\n\r\n// The facade renders to a single color target.\r\nconst SURFACE_MRT_FLAGS =\r\n MaterialVaryingFlags.SCENE_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SCENE_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION |\r\n MaterialVaryingFlags.SKIN_SSS_STORE;\r\n\r\nconst _sceneLightPass = new LightPass();\r\nconst _sceneDepthPass = new DepthPass();\r\n\r\ntype DrawContextState = Pick<\r\n DrawContext,\r\n | 'renderPass'\r\n | 'renderPassHash'\r\n | 'shaderVariantHash'\r\n | 'flip'\r\n | 'drawEnvLight'\r\n | 'env'\r\n | 'queue'\r\n | 'lightBlending'\r\n | 'instanceData'\r\n | 'oit'\r\n | 'currentShadowLight'\r\n | 'materialFlags'\r\n | 'shadowMaskClusterSample'\r\n | 'compositor'\r\n | 'depthPrepassAttachment'\r\n | 'sunLight'\r\n | 'primaryDirectionalLight'\r\n | 'primaryTransmissionLight'\r\n>;\r\n\r\nfunction snapshotDrawContext(ctx: DrawContext): DrawContextState {\r\n return {\r\n renderPass: ctx.renderPass,\r\n renderPassHash: ctx.renderPassHash,\r\n shaderVariantHash: ctx.shaderVariantHash,\r\n flip: ctx.flip,\r\n drawEnvLight: ctx.drawEnvLight,\r\n env: ctx.env,\r\n queue: ctx.queue,\r\n lightBlending: ctx.lightBlending,\r\n instanceData: ctx.instanceData,\r\n oit: ctx.oit,\r\n currentShadowLight: ctx.currentShadowLight,\r\n materialFlags: ctx.materialFlags,\r\n shadowMaskClusterSample: ctx.shadowMaskClusterSample,\r\n compositor: ctx.compositor,\r\n depthPrepassAttachment: ctx.depthPrepassAttachment,\r\n sunLight: ctx.sunLight,\r\n primaryDirectionalLight: ctx.primaryDirectionalLight,\r\n primaryTransmissionLight: ctx.primaryTransmissionLight\r\n };\r\n}\r\n\r\nfunction restoreDrawContext(ctx: DrawContext, state: DrawContextState): void {\r\n Object.assign(ctx, state);\r\n}\r\n\r\n/** Test-only access to the facade-owned pass instances. @internal */\r\nexport function _getSceneRenderPassesForTest() {\r\n return { light: _sceneLightPass, depth: _sceneDepthPass };\r\n}\r\n\r\n/** Scene render options. Omitted or null clear values preserve the target. @public */\r\nexport interface SceneRenderOptions {\r\n /** Camera whose uniforms drive the render. Defaults to the frame's `ctx.camera`. */\r\n camera?: Camera;\r\n /** Color clear value. Omit or pass null to skip the color clear. */\r\n clearColor?: Nullable<Vector4>;\r\n /** Depth clear value. Omit or pass null to skip the depth clear. */\r\n clearDepth?: Nullable<number>;\r\n /** Stencil clear value. Omit or pass null to skip the stencil clear. */\r\n clearStencil?: Nullable<number>;\r\n}\r\n\r\n/** Builder for a pass-scoped render queue. Call `finalize` before rendering. @public */\r\nexport interface SceneRenderQueueBuilder {\r\n /** Add a drawable, using the frame camera by default. */\r\n add(drawable: Drawable, camera?: Camera): this;\r\n\r\n /** Finalize batching and return the renderable queue. */\r\n finalize(camera?: Camera): RenderQueue;\r\n}\r\n\r\n/** Caller-owned render queue that can be reused across frames. @public */\r\nexport interface PersistentSceneQueue {\r\n /** Renderable queue, valid after {@link PersistentSceneQueue.finalize}. */\r\n readonly queue: RenderQueue;\r\n\r\n /** Clear the queue for rebuilding. */\r\n clear(): this;\r\n\r\n /** Add a drawable. */\r\n add(drawable: Drawable, camera: Camera): this;\r\n\r\n /** Finalize batching, optionally creating reusable render bundles. */\r\n finalize(camera: Camera, createRenderBundles?: boolean): this;\r\n\r\n /** Release the queue and its private allocator's GPU resources. */\r\n dispose(): void;\r\n}\r\n\r\n/** Scene rendering facade for custom render graph passes. @public */\r\nexport interface SceneRenderContext {\r\n /** The frame draw context (camera, scene, env, device). */\r\n readonly ctx: DrawContext;\r\n\r\n /** Cull into a pass-scoped queue, optionally filtering drawables. */\r\n cull(camera?: Camera, filter?: (drawable: Drawable) => boolean): RenderQueue;\r\n\r\n /** Start building a user-authored queue. */\r\n createQueue(): SceneRenderQueueBuilder;\r\n\r\n /** Render opaque and transparent geometry into `target`. */\r\n renderScene(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /** Render only the opaque geometry of a queue. See {@link SceneRenderContext.renderScene}. */\r\n renderOpaque(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /** Render only the transparent geometry of a queue. See {@link SceneRenderContext.renderScene}. */\r\n renderTransparent(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /** Render a linear-depth pass for a queue's opaque geometry. See {@link SceneRenderContext.renderScene}. */\r\n renderDepth(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /**\r\n * Create a caller-managed queue. It is not disposed with the current pass.\r\n */\r\n createPersistentQueue(): PersistentSceneQueue;\r\n}\r\n\r\n/** @internal */\r\nclass SceneRenderContextImpl implements SceneRenderContext {\r\n private readonly _ctx: DrawContext;\r\n private readonly _rgCtx: RGExecuteContext;\r\n private readonly _ownedQueues: RenderQueue[] = [];\r\n private _cleanupRegistered = false;\r\n\r\n constructor(ctx: DrawContext, rgCtx: RGExecuteContext) {\r\n this._ctx = ctx;\r\n this._rgCtx = rgCtx;\r\n }\r\n\r\n get ctx(): DrawContext {\r\n return this._ctx;\r\n }\r\n\r\n private _own(queue: RenderQueue): RenderQueue {\r\n this._ownedQueues.push(queue);\r\n if (!this._cleanupRegistered) {\r\n this._cleanupRegistered = true;\r\n this._rgCtx.deferCleanup(() => {\r\n for (const q of this._ownedQueues) {\r\n q.dispose();\r\n }\r\n this._ownedQueues.length = 0;\r\n });\r\n }\r\n return queue;\r\n }\r\n\r\n cull(camera?: Camera, filter?: (drawable: Drawable) => boolean): RenderQueue {\r\n const cullCamera = camera ?? this._ctx.camera;\r\n const savedContext = snapshotDrawContext(this._ctx);\r\n let queue: RenderQueue;\r\n try {\r\n queue = _sceneLightPass.cullScene(this._ctx, cullCamera);\r\n } finally {\r\n restoreDrawContext(this._ctx, savedContext);\r\n }\r\n if (!filter) {\r\n return this._own(queue);\r\n }\r\n // Rebuild because cullScene returns an already-finalized queue.\r\n const filtered = new RenderQueue(_sceneLightPass);\r\n const itemList = queue.itemList;\r\n if (itemList) {\r\n const seen = new Set<Drawable>();\r\n const bundles = [\r\n itemList.opaque,\r\n itemList.transmission,\r\n itemList.transparent,\r\n itemList.transmission_trans\r\n ];\r\n for (const bundle of bundles) {\r\n for (const info of [...bundle.lit, ...bundle.unlit]) {\r\n const sources = [\r\n info.itemList,\r\n info.skinItemList,\r\n info.morphItemList,\r\n info.skinAndMorphItemList,\r\n info.instanceItemList\r\n ];\r\n for (const list of sources) {\r\n for (const item of list) {\r\n const drawable = item.drawable;\r\n if (!seen.has(drawable) && filter(drawable)) {\r\n seen.add(drawable);\r\n filtered.push(cullCamera, drawable);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n filtered.primaryDirectionalLight = queue.primaryDirectionalLight;\r\n filtered.primaryTransmissionLight = queue.primaryTransmissionLight;\r\n filtered.sunLight = queue.sunLight;\r\n finalizeQueue(filtered, cullCamera);\r\n queue.dispose();\r\n return this._own(filtered);\r\n }\r\n\r\n createPersistentQueue(): PersistentSceneQueue {\r\n const allocator = new InstanceBindGroupAllocator();\r\n const queue = new RenderQueue(_sceneLightPass, allocator);\r\n return {\r\n get queue(): RenderQueue {\r\n return queue;\r\n },\r\n clear(): PersistentSceneQueue {\r\n queue.reset();\r\n allocator.reset();\r\n return this;\r\n },\r\n add(drawable: Drawable, camera: Camera): PersistentSceneQueue {\r\n queue.push(camera, drawable);\r\n return this;\r\n },\r\n finalize(camera: Camera, createRenderBundles?: boolean): PersistentSceneQueue {\r\n finalizeQueue(queue, camera, createRenderBundles);\r\n return this;\r\n },\r\n dispose(): void {\r\n queue.dispose();\r\n allocator.dispose();\r\n }\r\n };\r\n }\r\n\r\n createQueue(): SceneRenderQueueBuilder {\r\n const owner = this;\r\n const queue = new RenderQueue(_sceneLightPass);\r\n let finalized = false;\r\n const builder: SceneRenderQueueBuilder = {\r\n add(drawable: Drawable, camera?: Camera): SceneRenderQueueBuilder {\r\n if (finalized) {\r\n throw new Error('SceneRenderQueueBuilder: cannot add() after finalize().');\r\n }\r\n queue.push(camera ?? owner._ctx.camera, drawable);\r\n return builder;\r\n },\r\n finalize(camera?: Camera): RenderQueue {\r\n if (finalized) {\r\n throw new Error('SceneRenderQueueBuilder: finalize() called more than once.');\r\n }\r\n finalized = true;\r\n finalizeQueue(queue, camera ?? owner._ctx.camera);\r\n return owner._own(queue);\r\n }\r\n };\r\n return builder;\r\n }\r\n\r\n renderScene(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n this._renderColor(target, queue, opts, true, true);\r\n }\r\n\r\n renderOpaque(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n this._renderColor(target, queue, opts, true, false);\r\n }\r\n\r\n renderTransparent(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n this._renderColor(target, queue, opts, false, true);\r\n }\r\n\r\n /** @internal */\r\n private _renderColor(\r\n target: FrameBuffer,\r\n queue: RenderQueue,\r\n opts: SceneRenderOptions | undefined,\r\n renderOpaque: boolean,\r\n renderTransparent: boolean\r\n ): void {\r\n const ctx = this._ctx;\r\n const device = ctx.device;\r\n const camera = opts?.camera ?? ctx.camera;\r\n // Restore all shared pass and draw-context state after rendering.\r\n const savedTransmission = _sceneLightPass.transmission;\r\n const savedRenderOpaque = _sceneLightPass.renderOpaque;\r\n const savedRenderTransparent = _sceneLightPass.renderTransparent;\r\n const savedRenderSky = _sceneLightPass.renderSky;\r\n const savedClearColor = _sceneLightPass.clearColor;\r\n const savedClearDepth = _sceneLightPass.clearDepth;\r\n const savedClearStencil = _sceneLightPass.clearStencil;\r\n const savedContext = snapshotDrawContext(ctx);\r\n ctx.depthPrepassAttachment = undefined;\r\n device.pushDeviceStates();\r\n try {\r\n device.setFramebuffer(target);\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n // The facade target has no surface MRT or compositor attachments.\r\n ctx.materialFlags = savedContext.materialFlags & ~SURFACE_MRT_FLAGS;\r\n ctx.compositor = null;\r\n ctx.sunLight = queue.sunLight;\r\n ctx.primaryDirectionalLight = queue.primaryDirectionalLight;\r\n ctx.primaryTransmissionLight = queue.primaryTransmissionLight;\r\n _sceneLightPass.transmission = false;\r\n _sceneLightPass.renderSky = false;\r\n _sceneLightPass.renderOpaque = renderOpaque;\r\n _sceneLightPass.renderTransparent = renderTransparent;\r\n _sceneLightPass.clearColor = opts && 'clearColor' in opts ? (opts.clearColor ?? null) : null;\r\n _sceneLightPass.clearDepth = opts && 'clearDepth' in opts ? (opts.clearDepth ?? null) : null;\r\n _sceneLightPass.clearStencil = opts && 'clearStencil' in opts ? (opts.clearStencil ?? null) : null;\r\n _sceneLightPass.render(ctx, camera, camera, queue);\r\n } finally {\r\n _sceneLightPass.transmission = savedTransmission;\r\n _sceneLightPass.renderOpaque = savedRenderOpaque;\r\n _sceneLightPass.renderTransparent = savedRenderTransparent;\r\n _sceneLightPass.renderSky = savedRenderSky;\r\n _sceneLightPass.clearColor = savedClearColor ?? null;\r\n _sceneLightPass.clearDepth = savedClearDepth;\r\n _sceneLightPass.clearStencil = savedClearStencil;\r\n restoreDrawContext(ctx, savedContext);\r\n device.popDeviceStates();\r\n }\r\n }\r\n\r\n renderDepth(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n const ctx = this._ctx;\r\n const device = ctx.device;\r\n const camera = opts?.camera ?? ctx.camera;\r\n const colorAttachment = target.getColorAttachments()[0] as Nullable<Texture2D>;\r\n const encodeDepth = colorAttachment?.format === 'rgba8unorm';\r\n const savedTransmission = _sceneDepthPass.transmission;\r\n const savedEncodeDepth = _sceneDepthPass.encodeDepth;\r\n const savedRenderBackface = _sceneDepthPass.renderBackface;\r\n const savedClearColor = _sceneDepthPass.clearColor;\r\n const savedClearDepth = _sceneDepthPass.clearDepth;\r\n const savedClearStencil = _sceneDepthPass.clearStencil;\r\n const savedContext = snapshotDrawContext(ctx);\r\n device.pushDeviceStates();\r\n try {\r\n device.setFramebuffer(target);\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n ctx.materialFlags = savedContext.materialFlags & ~SURFACE_MRT_FLAGS;\r\n ctx.sunLight = queue.sunLight;\r\n ctx.primaryDirectionalLight = queue.primaryDirectionalLight;\r\n ctx.primaryTransmissionLight = queue.primaryTransmissionLight;\r\n _sceneDepthPass.transmission = false;\r\n _sceneDepthPass.renderBackface = false;\r\n _sceneDepthPass.encodeDepth = encodeDepth;\r\n _sceneDepthPass.clearColor =\r\n opts && 'clearColor' in opts\r\n ? (opts.clearColor ?? null)\r\n : encodeDepth\r\n ? new Vector4(0, 0, 0, 1)\r\n : new Vector4(1, 1, 1, 1);\r\n _sceneDepthPass.clearDepth =\r\n opts && 'clearDepth' in opts ? (opts.clearDepth ?? null) : DEPTH_CLEAR_VALUE;\r\n _sceneDepthPass.clearStencil = opts && 'clearStencil' in opts ? (opts.clearStencil ?? null) : null;\r\n _sceneDepthPass.render(ctx, camera, camera, queue);\r\n } finally {\r\n _sceneDepthPass.transmission = savedTransmission;\r\n _sceneDepthPass.encodeDepth = savedEncodeDepth;\r\n _sceneDepthPass.renderBackface = savedRenderBackface;\r\n _sceneDepthPass.clearColor = savedClearColor ?? null;\r\n _sceneDepthPass.clearDepth = savedClearDepth;\r\n _sceneDepthPass.clearStencil = savedClearStencil;\r\n restoreDrawContext(ctx, savedContext);\r\n device.popDeviceStates();\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nfunction finalizeQueue(queue: RenderQueue, camera: Camera, createRenderBundles?: boolean): void {\r\n (queue as unknown as { end(camera: Camera, createRenderBundles?: boolean): RenderQueue }).end(\r\n camera,\r\n createRenderBundles\r\n );\r\n}\r\n\r\n/** Create a scene facade bound to the current graph pass. @public */\r\nexport function createSceneRenderer(ctx: DrawContext, rgCtx: RGExecuteContext): SceneRenderContext {\r\n return new SceneRenderContextImpl(ctx, rgCtx);\r\n}\r\n"],"names":["SURFACE_MRT_FLAGS","MaterialVaryingFlags","SCENE_STORE_ROUGHNESS","SSS_STORE_PROFILE","SSS_STORE_DIFFUSE","SCENE_STORE_NORMAL","SSS_STORE_TRANSMISSION","SKIN_SSS_STORE","_sceneLightPass","LightPass","_sceneDepthPass","DepthPass","snapshotDrawContext","ctx","renderPass","renderPassHash","shaderVariantHash","flip","drawEnvLight","env","queue","lightBlending","instanceData","oit","currentShadowLight","materialFlags","shadowMaskClusterSample","compositor","depthPrepassAttachment","sunLight","primaryDirectionalLight","primaryTransmissionLight","restoreDrawContext","state","Object","assign","SceneRenderContextImpl","_ctx","_rgCtx","_ownedQueues","_cleanupRegistered","rgCtx","_own","push","deferCleanup","q","dispose","length","cull","camera","filter","cullCamera","savedContext","cullScene","filtered","RenderQueue","itemList","seen","Set","bundles","opaque","transmission","transparent","transmission_trans","bundle","info","lit","unlit","sources","skinItemList","morphItemList","skinAndMorphItemList","instanceItemList","list","item","drawable","has","add","finalizeQueue","createPersistentQueue","allocator","InstanceBindGroupAllocator","clear","reset","finalize","createRenderBundles","createQueue","owner","finalized","builder","Error","renderScene","target","opts","_renderColor","renderOpaque","renderTransparent","device","savedTransmission","savedRenderOpaque","savedRenderTransparent","savedRenderSky","renderSky","savedClearColor","clearColor","savedClearDepth","clearDepth","savedClearStencil","clearStencil","undefined","pushDeviceStates","setFramebuffer","setViewport","setScissor","render","popDeviceStates","renderDepth","colorAttachment","getColorAttachments","encodeDepth","format","savedEncodeDepth","savedRenderBackface","renderBackface","Vector4","DEPTH_CLEAR_VALUE","end","createSceneRenderer"],"mappings":";;;;;;AAWA;AACA,MAAMA,oBACJC,oBAAqBC,CAAAA,qBAAqB,GAC1CD,oBAAAA,CAAqBE,iBAAiB,GACtCF,oBAAAA,CAAqBG,iBAAiB,GACtCH,qBAAqBI,kBAAkB,GACvCJ,qBAAqBK,sBAAsB,GAC3CL,qBAAqBM,cAAc;AAErC,MAAMC,kBAAkB,IAAIC,SAAAA,EAAAA;AAC5B,MAAMC,kBAAkB,IAAIC,SAAAA,EAAAA;AAwB5B,SAASC,oBAAoBC,GAAgB,EAAA;IAC3C,OAAO;AACLC,QAAAA,UAAAA,EAAYD,IAAIC,UAAU;AAC1BC,QAAAA,cAAAA,EAAgBF,IAAIE,cAAc;AAClCC,QAAAA,iBAAAA,EAAmBH,IAAIG,iBAAiB;AACxCC,QAAAA,IAAAA,EAAMJ,IAAII,IAAI;AACdC,QAAAA,YAAAA,EAAcL,IAAIK,YAAY;AAC9BC,QAAAA,GAAAA,EAAKN,IAAIM,GAAG;AACZC,QAAAA,KAAAA,EAAOP,IAAIO,KAAK;AAChBC,QAAAA,aAAAA,EAAeR,IAAIQ,aAAa;AAChCC,QAAAA,YAAAA,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AAA;YAC7DnH,eAAgBkG,CAAAA,YAAY,GAAGf,IAAQ,IAAA,cAAA,IAAkBA,OAAQA,IAAKe,CAAAA,YAAY,IAAI,IAAQ,GAAA,IAAA;AAC9FlG,YAAAA,eAAAA,CAAgBwG,MAAM,CAACrG,GAAKoC,EAAAA,MAAAA,EAAQA,MAAQ7B,EAAAA,KAAAA,CAAAA;SACpC,QAAA;AACRV,YAAAA,eAAAA,CAAgBmD,YAAY,GAAGqC,iBAAAA;AAC/BxF,YAAAA,eAAAA,CAAgB6G,WAAW,GAAGE,gBAAAA;AAC9B/G,YAAAA,eAAAA,CAAgBiH,cAAc,GAAGD,mBAAAA;YACjChH,eAAgB8F,CAAAA,UAAU,GAAGD,eAAmB,IAAA,IAAA;AAChD7F,YAAAA,eAAAA,CAAgBgG,UAAU,GAAGD,eAAAA;AAC7B/F,YAAAA,eAAAA,CAAgBkG,YAAY,GAAGD,iBAAAA;AAC/B3E,YAAAA,kBAAAA,CAAmBnB,GAAKuC,EAAAA,YAAAA,CAAAA;AACxB6C,YAAAA,MAAAA,CAAOkB,eAAe,EAAA;AACxB;AACF;AACF;AAEA,iBACA,SAASrC,aAAAA,CAAc1D,KAAkB,EAAE6B,MAAc,EAAEoC,mBAA6B,EAAA;IACrFjE,KAAyF0G,CAAAA,GAAG,CAC3F7E,MACAoC,EAAAA,mBAAAA,CAAAA;AAEJ;AAEA,sEACO,SAAS0C,mBAAoBlH,CAAAA,GAAgB,EAAE4B,KAAuB,EAAA;IAC3E,OAAO,IAAIL,uBAAuBvB,GAAK4B,EAAAA,KAAAA,CAAAA;AACzC;;;;"}
|
|
1
|
+
{"version":3,"file":"scene_render_context.js","sources":["../../../src/render/rendergraph/scene_render_context.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { DEPTH_CLEAR_VALUE, Vector4 } from '@zephyr3d/base';\r\nimport type { FrameBuffer, Texture2D } from '@zephyr3d/device';\r\nimport type { Camera } from '../../camera';\r\nimport { MaterialVaryingFlags } from '../../values';\r\nimport type { DrawContext, Drawable } from '../drawable';\r\nimport { RenderQueue, InstanceBindGroupAllocator } from '../render_queue';\r\nimport { LightPass } from '../lightpass';\r\nimport { DepthPass } from '../depthpass';\r\nimport { ClusteredLight } from '../cluster_light';\r\nimport { ShaderHelper } from '../../material/shader/helper';\r\nimport type { RGExecuteContext } from './types';\r\n\r\n// The facade renders to a single color target.\r\nconst SURFACE_MRT_FLAGS =\r\n MaterialVaryingFlags.SCENE_STORE_ROUGHNESS |\r\n MaterialVaryingFlags.SSS_STORE_PROFILE |\r\n MaterialVaryingFlags.SSS_STORE_DIFFUSE |\r\n MaterialVaryingFlags.SCENE_STORE_NORMAL |\r\n MaterialVaryingFlags.SSS_STORE_TRANSMISSION |\r\n MaterialVaryingFlags.SKIN_SSS_STORE;\r\n\r\nconst _sceneLightPass = new LightPass();\r\nconst _sceneDepthPass = new DepthPass();\r\n\r\ntype DrawContextState = Pick<\r\n DrawContext,\r\n | 'renderPass'\r\n | 'renderPassHash'\r\n | 'shaderVariantHash'\r\n | 'flip'\r\n | 'drawEnvLight'\r\n | 'env'\r\n | 'queue'\r\n | 'lightBlending'\r\n | 'instanceData'\r\n | 'oit'\r\n | 'currentShadowLight'\r\n | 'materialFlags'\r\n | 'shadowMaskClusterSample'\r\n | 'compositor'\r\n | 'depthPrepassAttachment'\r\n | 'sunLight'\r\n | 'primaryDirectionalLight'\r\n | 'primaryTransmissionLight'\r\n | 'clusteredLight'\r\n | 'screenSpaceShadowMask'\r\n | 'transmissionThickness'\r\n>;\r\n\r\nfunction snapshotDrawContext(ctx: DrawContext): DrawContextState {\r\n return {\r\n renderPass: ctx.renderPass,\r\n renderPassHash: ctx.renderPassHash,\r\n shaderVariantHash: ctx.shaderVariantHash,\r\n flip: ctx.flip,\r\n drawEnvLight: ctx.drawEnvLight,\r\n env: ctx.env,\r\n queue: ctx.queue,\r\n lightBlending: ctx.lightBlending,\r\n instanceData: ctx.instanceData,\r\n oit: ctx.oit,\r\n currentShadowLight: ctx.currentShadowLight,\r\n materialFlags: ctx.materialFlags,\r\n shadowMaskClusterSample: ctx.shadowMaskClusterSample,\r\n compositor: ctx.compositor,\r\n depthPrepassAttachment: ctx.depthPrepassAttachment,\r\n sunLight: ctx.sunLight,\r\n primaryDirectionalLight: ctx.primaryDirectionalLight,\r\n primaryTransmissionLight: ctx.primaryTransmissionLight,\r\n clusteredLight: ctx.clusteredLight,\r\n screenSpaceShadowMask: ctx.screenSpaceShadowMask,\r\n transmissionThickness: ctx.transmissionThickness\r\n };\r\n}\r\n\r\nfunction restoreDrawContext(ctx: DrawContext, state: DrawContextState): void {\r\n Object.assign(ctx, state);\r\n}\r\n\r\n/** Test-only access to the facade-owned pass instances. @internal */\r\nexport function _getSceneRenderPassesForTest() {\r\n return { light: _sceneLightPass, depth: _sceneDepthPass };\r\n}\r\n\r\n/** Scene render options. Omitted or null clear values preserve the target. @public */\r\nexport interface SceneRenderOptions {\r\n /** Camera whose uniforms drive the render. Defaults to the frame's `ctx.camera`. */\r\n camera?: Camera;\r\n /** Color clear value. Omit or pass null to skip the color clear. */\r\n clearColor?: Nullable<Vector4>;\r\n /** Depth clear value. Omit or pass null to skip the depth clear. */\r\n clearDepth?: Nullable<number>;\r\n /** Stencil clear value. Omit or pass null to skip the stencil clear. */\r\n clearStencil?: Nullable<number>;\r\n}\r\n\r\n/** Builder for a pass-scoped render queue. Call `finalize` before rendering. @public */\r\nexport interface SceneRenderQueueBuilder {\r\n /** Add a drawable, using the frame camera by default. */\r\n add(drawable: Drawable, camera?: Camera): this;\r\n\r\n /** Finalize batching and return the renderable queue. */\r\n finalize(camera?: Camera): RenderQueue;\r\n}\r\n\r\n/** Caller-owned render queue that can be reused across frames. @public */\r\nexport interface PersistentSceneQueue {\r\n /** Renderable queue, valid after {@link PersistentSceneQueue.finalize}. */\r\n readonly queue: RenderQueue;\r\n\r\n /** Clear the queue for rebuilding. */\r\n clear(): this;\r\n\r\n /** Add a drawable. */\r\n add(drawable: Drawable, camera: Camera): this;\r\n\r\n /** Finalize batching, optionally creating reusable render bundles. */\r\n finalize(camera: Camera, createRenderBundles?: boolean): this;\r\n\r\n /** Release the queue and its private allocator's GPU resources. */\r\n dispose(): void;\r\n}\r\n\r\n/** Scene rendering facade for custom render graph passes. @public */\r\nexport interface SceneRenderContext {\r\n /** The frame draw context (camera, scene, env, device). */\r\n readonly ctx: DrawContext;\r\n\r\n /** Cull into a pass-scoped queue, optionally filtering drawables. */\r\n cull(camera?: Camera, filter?: (drawable: Drawable) => boolean): RenderQueue;\r\n\r\n /** Start building a user-authored queue. */\r\n createQueue(): SceneRenderQueueBuilder;\r\n\r\n /** Render opaque and transparent geometry into `target`. */\r\n renderScene(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /** Render only the opaque geometry of a queue. See {@link SceneRenderContext.renderScene}. */\r\n renderOpaque(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /** Render only the transparent geometry of a queue. See {@link SceneRenderContext.renderScene}. */\r\n renderTransparent(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /** Render a linear-depth pass for a queue's opaque geometry. See {@link SceneRenderContext.renderScene}. */\r\n renderDepth(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void;\r\n\r\n /**\r\n * Create a caller-managed queue. It is not disposed with the current pass.\r\n */\r\n createPersistentQueue(): PersistentSceneQueue;\r\n}\r\n\r\n/** @internal */\r\nclass SceneRenderContextImpl implements SceneRenderContext {\r\n private readonly _ctx: DrawContext;\r\n private readonly _rgCtx: RGExecuteContext;\r\n private readonly _ownedQueues: RenderQueue[] = [];\r\n private _cleanupRegistered = false;\r\n\r\n constructor(ctx: DrawContext, rgCtx: RGExecuteContext) {\r\n this._ctx = ctx;\r\n this._rgCtx = rgCtx;\r\n }\r\n\r\n get ctx(): DrawContext {\r\n return this._ctx;\r\n }\r\n\r\n private _own(queue: RenderQueue): RenderQueue {\r\n this._ownedQueues.push(queue);\r\n if (!this._cleanupRegistered) {\r\n this._cleanupRegistered = true;\r\n this._rgCtx.deferCleanup(() => {\r\n for (const q of this._ownedQueues) {\r\n q.dispose();\r\n }\r\n this._ownedQueues.length = 0;\r\n });\r\n }\r\n return queue;\r\n }\r\n\r\n cull(camera?: Camera, filter?: (drawable: Drawable) => boolean): RenderQueue {\r\n const cullCamera = camera ?? this._ctx.camera;\r\n const savedContext = snapshotDrawContext(this._ctx);\r\n let queue: RenderQueue;\r\n try {\r\n queue = _sceneLightPass.cullScene(this._ctx, cullCamera);\r\n } finally {\r\n restoreDrawContext(this._ctx, savedContext);\r\n }\r\n if (!filter) {\r\n return this._own(queue);\r\n }\r\n // Rebuild because cullScene returns an already-finalized queue.\r\n const filtered = new RenderQueue(_sceneLightPass);\r\n const itemList = queue.itemList;\r\n if (itemList) {\r\n const seen = new Set<Drawable>();\r\n const bundles = [\r\n itemList.opaque,\r\n itemList.transmission,\r\n itemList.transparent,\r\n itemList.transmission_trans\r\n ];\r\n for (const bundle of bundles) {\r\n for (const info of [...bundle.lit, ...bundle.unlit]) {\r\n const sources = [\r\n info.itemList,\r\n info.skinItemList,\r\n info.morphItemList,\r\n info.skinAndMorphItemList,\r\n info.instanceItemList,\r\n info.skinInstanceItemList\r\n ];\r\n for (const list of sources) {\r\n for (const item of list) {\r\n const drawable = item.drawable;\r\n if (!seen.has(drawable) && filter(drawable)) {\r\n seen.add(drawable);\r\n filtered.push(cullCamera, drawable);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n filtered.primaryDirectionalLight = queue.primaryDirectionalLight;\r\n filtered.primaryTransmissionLight = queue.primaryTransmissionLight;\r\n filtered.sunLight = queue.sunLight;\r\n finalizeQueue(filtered, cullCamera);\r\n queue.dispose();\r\n return this._own(filtered);\r\n }\r\n\r\n createPersistentQueue(): PersistentSceneQueue {\r\n const allocator = new InstanceBindGroupAllocator();\r\n const queue = new RenderQueue(_sceneLightPass, allocator);\r\n return {\r\n get queue(): RenderQueue {\r\n return queue;\r\n },\r\n clear(): PersistentSceneQueue {\r\n queue.reset();\r\n allocator.reset();\r\n return this;\r\n },\r\n add(drawable: Drawable, camera: Camera): PersistentSceneQueue {\r\n queue.push(camera, drawable);\r\n return this;\r\n },\r\n finalize(camera: Camera, createRenderBundles?: boolean): PersistentSceneQueue {\r\n finalizeQueue(queue, camera, createRenderBundles);\r\n return this;\r\n },\r\n dispose(): void {\r\n queue.dispose();\r\n allocator.dispose();\r\n }\r\n };\r\n }\r\n\r\n createQueue(): SceneRenderQueueBuilder {\r\n const owner = this;\r\n const queue = new RenderQueue(_sceneLightPass);\r\n let finalized = false;\r\n const builder: SceneRenderQueueBuilder = {\r\n add(drawable: Drawable, camera?: Camera): SceneRenderQueueBuilder {\r\n if (finalized) {\r\n throw new Error('SceneRenderQueueBuilder: cannot add() after finalize().');\r\n }\r\n queue.push(camera ?? owner._ctx.camera, drawable);\r\n return builder;\r\n },\r\n finalize(camera?: Camera): RenderQueue {\r\n if (finalized) {\r\n throw new Error('SceneRenderQueueBuilder: finalize() called more than once.');\r\n }\r\n finalized = true;\r\n finalizeQueue(queue, camera ?? owner._ctx.camera);\r\n return owner._own(queue);\r\n }\r\n };\r\n return builder;\r\n }\r\n\r\n renderScene(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n this._renderColor(target, queue, opts, true, true);\r\n }\r\n\r\n renderOpaque(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n this._renderColor(target, queue, opts, true, false);\r\n }\r\n\r\n renderTransparent(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n this._renderColor(target, queue, opts, false, true);\r\n }\r\n\r\n /** @internal */\r\n private _renderColor(\r\n target: FrameBuffer,\r\n queue: RenderQueue,\r\n opts: SceneRenderOptions | undefined,\r\n renderOpaque: boolean,\r\n renderTransparent: boolean\r\n ): void {\r\n const ctx = this._ctx;\r\n const device = ctx.device;\r\n const camera = opts?.camera ?? ctx.camera;\r\n // Restore all shared pass and draw-context state after rendering.\r\n const savedTransmission = _sceneLightPass.transmission;\r\n const savedRenderOpaque = _sceneLightPass.renderOpaque;\r\n const savedRenderTransparent = _sceneLightPass.renderTransparent;\r\n const savedRenderSky = _sceneLightPass.renderSky;\r\n const savedClearColor = _sceneLightPass.clearColor;\r\n const savedClearDepth = _sceneLightPass.clearDepth;\r\n const savedClearStencil = _sceneLightPass.clearStencil;\r\n const savedContext = snapshotDrawContext(ctx);\r\n ctx.depthPrepassAttachment = undefined;\r\n device.pushDeviceStates();\r\n try {\r\n device.setFramebuffer(target);\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n // The facade target has no surface MRT or compositor attachments.\r\n ctx.materialFlags = savedContext.materialFlags & ~SURFACE_MRT_FLAGS;\r\n ctx.compositor = null;\r\n ctx.sunLight = queue.sunLight;\r\n ctx.primaryDirectionalLight = queue.primaryDirectionalLight;\r\n ctx.primaryTransmissionLight = queue.primaryTransmissionLight;\r\n if (savedContext.clusteredLight) {\r\n this._clusterLights(target, queue, camera);\r\n }\r\n _sceneLightPass.transmission = false;\r\n _sceneLightPass.renderSky = false;\r\n _sceneLightPass.renderOpaque = renderOpaque;\r\n _sceneLightPass.renderTransparent = renderTransparent;\r\n _sceneLightPass.clearColor = opts && 'clearColor' in opts ? (opts.clearColor ?? null) : null;\r\n _sceneLightPass.clearDepth = opts && 'clearDepth' in opts ? (opts.clearDepth ?? null) : null;\r\n _sceneLightPass.clearStencil = opts && 'clearStencil' in opts ? (opts.clearStencil ?? null) : null;\r\n _sceneLightPass.render(ctx, camera, camera, queue);\r\n } finally {\r\n _sceneLightPass.transmission = savedTransmission;\r\n _sceneLightPass.renderOpaque = savedRenderOpaque;\r\n _sceneLightPass.renderTransparent = savedRenderTransparent;\r\n _sceneLightPass.renderSky = savedRenderSky;\r\n _sceneLightPass.clearColor = savedClearColor ?? null;\r\n _sceneLightPass.clearDepth = savedClearDepth;\r\n _sceneLightPass.clearStencil = savedClearStencil;\r\n restoreDrawContext(ctx, savedContext);\r\n device.popDeviceStates();\r\n }\r\n }\r\n\r\n /**\r\n * Replaces the frame's clusters with ones built for this render.\r\n *\r\n * @remarks\r\n * The frame's clusters were built for the frame camera's view, the frame queue's\r\n * lights and the render size, none of which need hold here. The screen-space shadow\r\n * mask and transmission thickness go too: they were rendered from the frame camera\r\n * and are indexed by that cluster buffer's ordinals, so shadow-casting lights fall\r\n * back to the per-light additive path, as on transparent queues. The caller restores\r\n * all three fields.\r\n */\r\n private _clusterLights(target: FrameBuffer, queue: RenderQueue, camera: Camera): void {\r\n const ctx = this._ctx;\r\n ctx.screenSpaceShadowMask = false;\r\n ctx.transmissionThickness = false;\r\n const clusteredLight = ClusteredLight.acquire(target.getWidth(), target.getHeight());\r\n // Released after graph execution: the draws reading it may still be pending before.\r\n this._rgCtx.deferCleanup(() => ClusteredLight.release(clusteredLight));\r\n clusteredLight.calculateLightIndex(\r\n camera,\r\n queue,\r\n target.getWidth(),\r\n target.getHeight(),\r\n false,\r\n ShaderHelper.getPreExposure(ctx)\r\n );\r\n ctx.clusteredLight = clusteredLight;\r\n }\r\n\r\n renderDepth(target: FrameBuffer, queue: RenderQueue, opts?: SceneRenderOptions): void {\r\n const ctx = this._ctx;\r\n const device = ctx.device;\r\n const camera = opts?.camera ?? ctx.camera;\r\n const colorAttachment = target.getColorAttachments()[0] as Nullable<Texture2D>;\r\n const encodeDepth = colorAttachment?.format === 'rgba8unorm';\r\n const savedTransmission = _sceneDepthPass.transmission;\r\n const savedEncodeDepth = _sceneDepthPass.encodeDepth;\r\n const savedRenderBackface = _sceneDepthPass.renderBackface;\r\n const savedClearColor = _sceneDepthPass.clearColor;\r\n const savedClearDepth = _sceneDepthPass.clearDepth;\r\n const savedClearStencil = _sceneDepthPass.clearStencil;\r\n const savedContext = snapshotDrawContext(ctx);\r\n device.pushDeviceStates();\r\n try {\r\n device.setFramebuffer(target);\r\n device.setViewport(null);\r\n device.setScissor(null);\r\n ctx.materialFlags = savedContext.materialFlags & ~SURFACE_MRT_FLAGS;\r\n ctx.sunLight = queue.sunLight;\r\n ctx.primaryDirectionalLight = queue.primaryDirectionalLight;\r\n ctx.primaryTransmissionLight = queue.primaryTransmissionLight;\r\n _sceneDepthPass.transmission = false;\r\n _sceneDepthPass.renderBackface = false;\r\n _sceneDepthPass.encodeDepth = encodeDepth;\r\n _sceneDepthPass.clearColor =\r\n opts && 'clearColor' in opts\r\n ? (opts.clearColor ?? null)\r\n : encodeDepth\r\n ? new Vector4(0, 0, 0, 1)\r\n : new Vector4(1, 1, 1, 1);\r\n _sceneDepthPass.clearDepth =\r\n opts && 'clearDepth' in opts ? (opts.clearDepth ?? null) : DEPTH_CLEAR_VALUE;\r\n _sceneDepthPass.clearStencil = opts && 'clearStencil' in opts ? (opts.clearStencil ?? null) : null;\r\n _sceneDepthPass.render(ctx, camera, camera, queue);\r\n } finally {\r\n _sceneDepthPass.transmission = savedTransmission;\r\n _sceneDepthPass.encodeDepth = savedEncodeDepth;\r\n _sceneDepthPass.renderBackface = savedRenderBackface;\r\n _sceneDepthPass.clearColor = savedClearColor ?? null;\r\n _sceneDepthPass.clearDepth = savedClearDepth;\r\n _sceneDepthPass.clearStencil = savedClearStencil;\r\n restoreDrawContext(ctx, savedContext);\r\n device.popDeviceStates();\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nfunction finalizeQueue(queue: RenderQueue, camera: Camera, createRenderBundles?: boolean): void {\r\n (queue as unknown as { end(camera: Camera, createRenderBundles?: boolean): RenderQueue }).end(\r\n camera,\r\n createRenderBundles\r\n );\r\n}\r\n\r\n/** Create a scene facade bound to the current graph pass. @public */\r\nexport function createSceneRenderer(ctx: DrawContext, rgCtx: RGExecuteContext): SceneRenderContext {\r\n return new SceneRenderContextImpl(ctx, rgCtx);\r\n}\r\n"],"names":["SURFACE_MRT_FLAGS","MaterialVaryingFlags","SCENE_STORE_ROUGHNESS","SSS_STORE_PROFILE","SSS_STORE_DIFFUSE","SCENE_STORE_NORMAL","SSS_STORE_TRANSMISSION","SKIN_SSS_STORE","_sceneLightPass","LightPass","_sceneDepthPass","DepthPass","snapshotDrawContext","ctx","renderPass","renderPassHash","shaderVariantHash","flip","drawEnvLight","env","queue","lightBlending","instanceData","oit","currentShadowLight","materialFlags","shadowMaskClusterSample","compositor","depthPrepassAttachment","sunLight","primaryDirectionalLight","primaryTransmissionLight","clusteredLight","screenSpaceShadowMask","transmissionThickness","restoreDrawContext","state","Object","assign","SceneRenderContextImpl","_ctx","_rgCtx","_ownedQueues","_cleanupRegistered","rgCtx","_own","push","deferCleanup","q","dispose","length","cull","camera","filter","cullCamera","savedContext","cullScene","filtered","RenderQueue","itemList","seen","Set","bundles","opaque","transmission","transparent","transmission_trans","bundle","info","lit","unlit","sources","skinItemList","morphItemList","skinAndMorphItemList","instanceItemList","skinInstanceItemList","list","item","drawable","has","add","finalizeQueue","createPersistentQueue","allocator","InstanceBindGroupAllocator","clear","reset","finalize","createRenderBundles","createQueue","owner","finalized","builder","Error","renderScene","target","opts","_renderColor","renderOpaque","renderTransparent","device","savedTransmission","savedRenderOpaque","savedRenderTransparent","savedRenderSky","renderSky","savedClearColor","clearColor","savedClearDepth","clearDepth","savedClearStencil","clearStencil","undefined","pushDeviceStates","setFramebuffer","setViewport","setScissor","_clusterLights","render","popDeviceStates","ClusteredLight","acquire","getWidth","getHeight","release","calculateLightIndex","ShaderHelper","getPreExposure","renderDepth","colorAttachment","getColorAttachments","encodeDepth","format","savedEncodeDepth","savedRenderBackface","renderBackface","Vector4","DEPTH_CLEAR_VALUE","end","createSceneRenderer"],"mappings":";;;;;;;;AAaA;AACA,MAAMA,oBACJC,oBAAqBC,CAAAA,qBAAqB,GAC1CD,oBAAAA,CAAqBE,iBAAiB,GACtCF,oBAAAA,CAAqBG,iBAAiB,GACtCH,qBAAqBI,kBAAkB,GACvCJ,qBAAqBK,sBAAsB,GAC3CL,qBAAqBM,cAAc;AAErC,MAAMC,kBAAkB,IAAIC,SAAAA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OAAO,IAAIL,uBAAuB1B,GAAK+B,EAAAA,KAAAA,CAAAA;AACzC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BaseTexture,\r\n FrameBuffer,\r\n TextureFormat,\r\n TimestampQueryStatus\r\n} from '@zephyr3d/device';\r\nimport type { RGTextureAffinityCache } from './texture_affinity_cache';\r\n\r\n/**\r\n * Texture size mode: fixed pixels or a backbuffer-relative scale. @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/** Descriptor for a graph-managed transient texture. @public */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /**\r\n * Stable identity used to prefer the same pooled texture across graph executions.\r\n * When omitted, the graph derives one from the declaring pass and resource label.\r\n */\r\n allocationKey?: string;\r\n /** Texture format. */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Pixel width or backbuffer scale. Default 1. */\r\n width?: number;\r\n /** Pixel height or backbuffer scale. Default 1. */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n /** Array layers. Any defined value, including 1, requests a 2D array texture. */\r\n arrayLayers?: number;\r\n}\r\n\r\n/** Resource kinds that can be referenced by a graph handle. @public */\r\nexport type RGHandleKind = 'texture' | 'framebuffer' | 'token';\r\n\r\n/** Opaque render graph resource handle. @public */\r\nexport class RGHandle<K extends RGHandleKind = RGHandleKind, TValue = unknown> {\r\n /** Compile-time backing resource type. */\r\n declare readonly _value: TValue;\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n /** Resource kind used for compile-time and runtime validation. */\r\n readonly kind: K;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string, kind: K = 'texture' as K) {\r\n this._id = id;\r\n this._name = name;\r\n this.kind = kind;\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/** Texture resource handle. @public */\r\nexport type RGTextureHandle<TTexture = BaseTexture> = RGHandle<'texture', TTexture>;\r\n\r\n/** Framebuffer resource handle. @public */\r\nexport type RGFramebufferHandle = RGHandle<'framebuffer', FrameBuffer>;\r\n\r\n/** Ordering-only resource handle. @public */\r\nexport type RGTokenHandle = RGHandle<'token', void>;\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/** Render graph resource metadata. @public */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** Stable identity used for cross-frame transient texture allocation affinity. */\r\n readonly allocationKey: string | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass<any> | null = null;\r\n /** The pass that superseded this version via write(), or null while latest. */\r\n nextWriter: RGPass<any> | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass<any>[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id,\r\n allocationKey: string | null = null\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n this.allocationKey = allocationKey;\r\n }\r\n}\r\n\r\n/** Resolves resources during pass execution. @public */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a declared texture handle. Imported textures must first be bound on\r\n * the executor.\r\n */\r\n getTexture<TTexture>(handle: RGTextureHandle<TTexture>): TTexture;\r\n /** Resolve a texture handle stored in a generic resource container. */\r\n getTexture<TTexture = BaseTexture>(handle: RGHandle<RGHandleKind, any>): TTexture;\r\n\r\n /** Resolve a framebuffer declared or created by the current pass. */\r\n getFramebuffer(handle: RGFramebufferHandle): FrameBuffer;\r\n /** Resolve a framebuffer handle stored in a generic resource container. */\r\n getFramebuffer(handle: RGHandle<RGHandleKind, any>): FrameBuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer released after execution. Handle attachments\r\n * must be declared by the current pass.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): FrameBuffer;\r\n\r\n /**\r\n * Run cleanup after execution or abort. Callbacks run in reverse order.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/** Render graph execute callback. @public */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/** Ordered step sharing its parent pass's resources and lifetime. @public */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/** Controls whether a write needs the previous resource contents. @public */\r\nexport interface RGWriteOptions {\r\n /**\r\n * Use `discard` for a full overwrite so old-content producers may be culled.\r\n * Default `load`.\r\n */\r\n load?: 'load' | 'discard';\r\n}\r\n\r\n/** Render graph pass metadata. @public */\r\nexport class RGPass<T = void> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Occurrence of this pass name within the graph, used for stable allocation keys. */\r\n readonly nameOccurrence: number;\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 /**\r\n * RAW/WAW predecessors that propagate liveness.\r\n */\r\n readonly dependencies: RGPass<any>[] = [];\r\n /** WAW predecessors used only for ordering, including discard writes. */\r\n readonly orderingDependencies: RGPass<any>[] = [];\r\n /** WAR predecessors used only when both passes are alive. */\r\n readonly warDependencies: RGPass<any>[] = [];\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 /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string, nameOccurrence = 0) {\r\n this.index = index;\r\n this.name = name;\r\n this.nameOccurrence = nameOccurrence;\r\n }\r\n}\r\n\r\n/** Declares a pass's resource access and execution callback. @public */\r\nexport interface RGPassBuilder<TData = any> {\r\n /** Declare a read of an existing resource. */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Write a new resource version. Use the returned handle for later reads and\r\n * graph outputs. `discard` permits old-content producers to be culled.\r\n */\r\n write<TTexture>(handle: RGTextureHandle<TTexture>, options?: RGWriteOptions): RGTextureHandle<TTexture>;\r\n\r\n /** Generic-container fallback; runtime validation still applies. */\r\n write(handle: RGHandle, options?: RGWriteOptions): RGTextureHandle;\r\n\r\n /** Create a transient texture produced by this pass. */\r\n createTexture<TTexture = BaseTexture>(desc: RGTextureDesc): RGTextureHandle<TTexture>;\r\n\r\n /** Create a logical token for ordering passes without resource dependencies. */\r\n createToken(name?: string): RGTokenHandle;\r\n\r\n /** Create a graph-managed framebuffer and infer attachment dependencies. */\r\n createFramebuffer(desc: RGFramebufferDesc): RGFramebufferHandle;\r\n\r\n /** Prevent this pass from being culled. */\r\n sideEffect(): void;\r\n\r\n /** Add an ordered subpass. Cannot be combined with {@link setExecute}. */\r\n addSubpass<D = TData>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /** Set the pass callback. Cannot be combined with {@link addSubpass}. */\r\n setExecute<D = TData>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n/** Compiled resource lifetime. @public */\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/** Ordered passes and resource lifetimes from graph compilation. @public */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass<any>>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n/** Profiling scope type. @public */\r\nexport type RGProfileScopeType = 'graph' | 'pass' | 'subpass';\r\n\r\n/** GPU timestamp profiling options. @public */\r\nexport interface RGProfilingOptions {\r\n /** Enable render graph timestamp profiling. Default true when an options object is provided. */\r\n enabled?: boolean;\r\n /** Measure the whole graph execution. Default true. */\r\n graph?: boolean;\r\n /** Measure every render graph pass. Default true. */\r\n pass?: boolean;\r\n /** Measure every subpass and expose it as a child scope. Default true. */\r\n subpass?: boolean;\r\n /** Include pending upload/copy commands at timestamp boundaries. Default true. */\r\n includePendingUploads?: boolean;\r\n /** Allow graph profile scopes to remain open across frame boundaries. Default false. */\r\n allowCrossFrame?: boolean;\r\n /** Maximum unresolved profile frames kept by the executor. Default 3. */\r\n maxPendingFrames?: number;\r\n /** Root graph profile label. Default 'RenderGraph'. */\r\n label?: string;\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n}\r\n\r\n/** Render graph executor options. @public */\r\nexport interface RenderGraphExecutorOptions<TTexture = BaseTexture> {\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n /** Render graph timestamp profiling options. Default false. */\r\n profiling?: boolean | RGProfilingOptions;\r\n /** Cross-execution affinity state used to stabilize transient texture identities. */\r\n textureAffinityCache?: RGTextureAffinityCache<TTexture>;\r\n}\r\n\r\n/** External resources bound for one graph execution. @public */\r\nexport interface RenderGraphExecutionBindings<TTexture = BaseTexture> {\r\n /** Imported graph texture handles and their physical textures. */\r\n readonly importedTextures?: ReadonlyMap<RGTextureHandle<TTexture>, TTexture>;\r\n}\r\n\r\n/** Resolved GPU timing for one scope. @public */\r\nexport interface RGProfileScopeResult {\r\n /** Scope label. */\r\n name: string;\r\n /** Scope type. */\r\n type: RGProfileScopeType;\r\n /** Timestamp query id used by the device, or 0 for synthetic/unsupported scopes. */\r\n queryId: number;\r\n /** GPU duration in milliseconds. */\r\n durationMs: number;\r\n /** Timestamp result status. */\r\n status: TimestampQueryStatus;\r\n /** Child scopes. */\r\n children: RGProfileScopeResult[];\r\n /** Optional diagnostic message. */\r\n message?: string;\r\n}\r\n\r\n/** GPU timing tree for one graph execution. @public */\r\nexport interface RGProfileResult {\r\n /** Render frame id when profiling began. */\r\n frameId: number;\r\n /** Aggregate profile status. */\r\n status: TimestampQueryStatus;\r\n /** Root graph scope. */\r\n graph: RGProfileScopeResult;\r\n /** Top-level pass scopes. Same objects as graph.children. */\r\n passes: RGProfileScopeResult[];\r\n}\r\n\r\n/** Resolved texture dimensions. @public */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\nexport type RGTextureAttachment<TTexture = BaseTexture> =\r\n | RGTextureHandle<TTexture>\r\n | TTexture\r\n | TextureFormat;\r\n\r\n/** Backend-independent framebuffer descriptor. @public */\r\nexport interface RGFramebufferDesc<TTexture = BaseTexture> {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: RGTextureAttachment<TTexture> | RGTextureAttachment<TTexture>[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: RGTextureAttachment<TTexture> | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Framebuffers are released before their attachments at the same pass boundary.\r\n * A released framebuffer must retain its attachments until texture release.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = BaseTexture> {\r\n /** Allocate a transient texture, preferring a compatible prior allocation. */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize, preferred?: TTexture): TTexture;\r\n\r\n /** Release a transient texture. */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Retain a transient texture beyond graph execution. The external owner must\r\n * later release it.\r\n */\r\n retain?(texture: TTexture): void;\r\n\r\n /** Allocate a framebuffer released by the executor. */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): FrameBuffer;\r\n\r\n /** Release a temporary framebuffer. */\r\n releaseFramebuffer?(framebuffer: FrameBuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","kind","_id","_name","RGResource","desc","producer","nextWriter","consumers","physicalId","allocationKey","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","orderingDependencies","warDependencies","hasSideEffect","data","subpasses","alive","nameOccurrence"],"mappings":"AAwCA,oDACO,MAAMA,QAAAA,CAAAA;qBAIX,GAAqB;qBAErB,KAAuB;uEAEvB,IAAiB;qBAGjB,YAAYC,EAAU,EAAEC,IAAY,EAAEC,IAAAA,GAAU,SAAc,CAAE;QAC9D,IAAI,CAACC,GAAG,GAAGH,EAAAA;QACX,IAAI,CAACI,KAAK,GAAGH,IAAAA;QACb,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;2DAGA,IAAID,IAAe,GAAA;QACjB,OAAO,IAAI,CAACG,KAAK;AACnB;AACF;AAcA,+CACO,MAAMC,UAAAA,CAAAA;IACFL,EAAW;IACXC,IAAa;IACbC,IAAqB;IACrBI,IAA+C;mFAExD,UAA4B;uFAE5B,aAAsC;2FAEtCC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":3,"file":"types.js","sources":["../../../src/render/rendergraph/types.ts"],"sourcesContent":["import type {\r\n AbstractDevice,\r\n BaseTexture,\r\n FrameBuffer,\r\n TextureFormat,\r\n TimestampQueryStatus\r\n} from '@zephyr3d/device';\r\nimport type { RGTextureAffinityCache } from './texture_affinity_cache';\r\n\r\n/**\r\n * Texture size mode: fixed pixels or a backbuffer-relative scale. @public\r\n */\r\nexport type RGSizeMode = 'absolute' | 'backbuffer-relative';\r\n\r\n/** Descriptor for a graph-managed transient texture. @public */\r\nexport interface RGTextureDesc {\r\n /** Debug label for this resource. */\r\n label?: string;\r\n /**\r\n * Stable identity used to prefer the same pooled texture across graph executions.\r\n * When omitted, the graph derives one from the declaring pass and resource label.\r\n */\r\n allocationKey?: string;\r\n /** Texture format. */\r\n format: TextureFormat;\r\n /** Sizing mode. Default 'backbuffer-relative'. */\r\n sizeMode?: RGSizeMode;\r\n /** Pixel width or backbuffer scale. Default 1. */\r\n width?: number;\r\n /** Pixel height or backbuffer scale. Default 1. */\r\n height?: number;\r\n /** Number of mip levels. Default 1. */\r\n mipLevels?: number;\r\n /** Array layers. Any defined value, including 1, requests a 2D array texture. */\r\n arrayLayers?: number;\r\n}\r\n\r\n/** Resource kinds that can be referenced by a graph handle. @public */\r\nexport type RGHandleKind = 'texture' | 'framebuffer' | 'token';\r\n\r\n/** Opaque render graph resource handle. @public */\r\nexport class RGHandle<K extends RGHandleKind = RGHandleKind, TValue = unknown> {\r\n /** Compile-time backing resource type. */\r\n declare readonly _value: TValue;\r\n /** @internal */\r\n readonly _id: number;\r\n /** @internal */\r\n readonly _name: string;\r\n /** Resource kind used for compile-time and runtime validation. */\r\n readonly kind: K;\r\n\r\n /** @internal */\r\n constructor(id: number, name: string, kind: K = 'texture' as K) {\r\n this._id = id;\r\n this._name = name;\r\n this.kind = kind;\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/** Texture resource handle. @public */\r\nexport type RGTextureHandle<TTexture = BaseTexture> = RGHandle<'texture', TTexture>;\r\n\r\n/** Framebuffer resource handle. @public */\r\nexport type RGFramebufferHandle = RGHandle<'framebuffer', FrameBuffer>;\r\n\r\n/** Ordering-only resource handle. @public */\r\nexport type RGTokenHandle = RGHandle<'token', void>;\r\n\r\n/** @public */\r\nexport type RGResourceKind = 'transient' | 'imported' | 'token' | 'framebuffer';\r\n\r\n/** Render graph resource metadata. @public */\r\nexport class RGResource {\r\n readonly id: number;\r\n readonly name: string;\r\n readonly kind: RGResourceKind;\r\n readonly desc: RGTextureDesc | RGFramebufferDesc | null;\r\n /** Resource ID of the physical backing resource used by imported versions. */\r\n readonly physicalId: number;\r\n /** Stable identity used for cross-frame transient texture allocation affinity. */\r\n readonly allocationKey: string | null;\r\n /** The pass that creates / writes this resource (null for imported until written). */\r\n producer: RGPass<any> | null = null;\r\n /** The pass that superseded this version via write(), or null while latest. */\r\n nextWriter: RGPass<any> | null = null;\r\n /** Passes that read this resource. */\r\n readonly consumers: RGPass<any>[] = [];\r\n\r\n constructor(\r\n id: number,\r\n name: string,\r\n kind: RGResourceKind,\r\n desc: RGTextureDesc | RGFramebufferDesc | null,\r\n physicalId = id,\r\n allocationKey: string | null = null\r\n ) {\r\n this.id = id;\r\n this.name = name;\r\n this.kind = kind;\r\n this.desc = desc;\r\n this.physicalId = physicalId;\r\n this.allocationKey = allocationKey;\r\n }\r\n}\r\n\r\n/** Resolves resources during pass execution. @public */\r\nexport interface RGExecuteContext {\r\n /**\r\n * Resolve a declared texture handle. Imported textures must first be bound on\r\n * the executor.\r\n */\r\n getTexture<TTexture>(handle: RGTextureHandle<TTexture>): TTexture;\r\n /** Resolve a texture handle stored in a generic resource container. */\r\n getTexture<TTexture = BaseTexture>(handle: RGHandle<RGHandleKind, any>): TTexture;\r\n\r\n /** Resolve a framebuffer declared or created by the current pass. */\r\n getFramebuffer(handle: RGFramebufferHandle): FrameBuffer;\r\n /** Resolve a framebuffer handle stored in a generic resource container. */\r\n getFramebuffer(handle: RGHandle<RGHandleKind, any>): FrameBuffer;\r\n\r\n /**\r\n * Create a temporary framebuffer released after execution. Handle attachments\r\n * must be declared by the current pass.\r\n */\r\n createFramebuffer(desc: RGFramebufferDesc): FrameBuffer;\r\n\r\n /**\r\n * Run cleanup after execution or abort. Callbacks run in reverse order.\r\n */\r\n deferCleanup(callback: () => void): void;\r\n}\r\n\r\n/** Render graph execute callback. @public */\r\nexport type RGExecuteFn<T = void> = (ctx: RGExecuteContext, data: T) => void;\r\n\r\n/** Ordered step sharing its parent pass's resources and lifetime. @public */\r\nexport class RGSubpass<T = unknown> {\r\n readonly name: string;\r\n readonly executeFn: RGExecuteFn<T>;\r\n\r\n constructor(name: string, executeFn: RGExecuteFn<T>) {\r\n this.name = name;\r\n this.executeFn = executeFn;\r\n }\r\n}\r\n\r\n/** Controls whether a write needs the previous resource contents. @public */\r\nexport interface RGWriteOptions {\r\n /**\r\n * Use `discard` for a full overwrite so old-content producers may be culled.\r\n * Default `load`.\r\n */\r\n load?: 'load' | 'discard';\r\n}\r\n\r\n/** Render graph pass metadata. @public */\r\nexport class RGPass<T = void> {\r\n readonly index: number;\r\n readonly name: string;\r\n /** Occurrence of this pass name within the graph, used for stable allocation keys. */\r\n readonly nameOccurrence: number;\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 /**\r\n * RAW/WAW predecessors that propagate liveness.\r\n */\r\n readonly dependencies: RGPass<any>[] = [];\r\n /** WAW predecessors used only for ordering, including discard writes. */\r\n readonly orderingDependencies: RGPass<any>[] = [];\r\n /** WAR predecessors used only when both passes are alive. */\r\n readonly warDependencies: RGPass<any>[] = [];\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 /** Ordered subpasses for passes with multiple logical execution steps. */\r\n readonly subpasses: RGSubpass<T>[] = [];\r\n /** Set during compilation: true if this pass is needed. */\r\n alive = true;\r\n\r\n constructor(index: number, name: string, nameOccurrence = 0) {\r\n this.index = index;\r\n this.name = name;\r\n this.nameOccurrence = nameOccurrence;\r\n }\r\n}\r\n\r\n/** Declares a pass's resource access and execution callback. @public */\r\nexport interface RGPassBuilder<TData = any> {\r\n /** Declare a read of an existing resource. */\r\n read(handle: RGHandle): void;\r\n\r\n /**\r\n * Write a new resource version. Use the returned handle for later reads and\r\n * graph outputs. `discard` permits old-content producers to be culled.\r\n */\r\n write<TTexture>(handle: RGTextureHandle<TTexture>, options?: RGWriteOptions): RGTextureHandle<TTexture>;\r\n\r\n /** Generic-container fallback; runtime validation still applies. */\r\n write(handle: RGHandle, options?: RGWriteOptions): RGTextureHandle;\r\n\r\n /** Create a transient texture produced by this pass. */\r\n createTexture<TTexture = BaseTexture>(desc: RGTextureDesc): RGTextureHandle<TTexture>;\r\n\r\n /** Create a logical token for ordering passes without resource dependencies. */\r\n createToken(name?: string): RGTokenHandle;\r\n\r\n /** Create a graph-managed framebuffer and infer attachment dependencies. */\r\n createFramebuffer(desc: RGFramebufferDesc): RGFramebufferHandle;\r\n\r\n /** Prevent this pass from being culled. */\r\n sideEffect(): void;\r\n\r\n /** Add an ordered subpass. Cannot be combined with {@link setExecute}. */\r\n addSubpass<D = TData>(name: string, fn: RGExecuteFn<D>): void;\r\n\r\n /** Set the pass callback. Cannot be combined with {@link addSubpass}. */\r\n setExecute<D = TData>(fn: RGExecuteFn<D>): void;\r\n}\r\n\r\n/** Compiled resource lifetime. @public */\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/** Ordered passes and resource lifetimes from graph compilation. @public */\r\nexport interface CompiledRenderGraph {\r\n /** Topologically sorted passes (only non-culled passes). */\r\n readonly orderedPasses: ReadonlyArray<RGPass<any>>;\r\n /** Resource lifetime information keyed by resource ID. */\r\n readonly lifetimes: ReadonlyMap<number, RGResourceLifetime>;\r\n}\r\n\r\n/**\r\n * Profiling scope type. `'external'` scopes time GPU work recorded through\r\n * {@link RenderGraphExecutor.profileScope} outside the graph's passes.\r\n * @public\r\n */\r\nexport type RGProfileScopeType = 'graph' | 'pass' | 'subpass' | 'external';\r\n\r\n/** GPU timestamp profiling options. @public */\r\nexport interface RGProfilingOptions {\r\n /** Enable render graph timestamp profiling. Default true when an options object is provided. */\r\n enabled?: boolean;\r\n /** Measure the whole graph execution. Default true. */\r\n graph?: boolean;\r\n /** Measure every render graph pass. Default true. */\r\n pass?: boolean;\r\n /** Measure every subpass and expose it as a child scope. Default true. */\r\n subpass?: boolean;\r\n /** Include pending upload/copy commands at timestamp boundaries. Default true. */\r\n includePendingUploads?: boolean;\r\n /** Allow graph profile scopes to remain open across frame boundaries. Default false. */\r\n allowCrossFrame?: boolean;\r\n /** Maximum unresolved profile frames kept by the executor. Default 3. */\r\n maxPendingFrames?: number;\r\n /** Root graph profile label. Default 'RenderGraph'. */\r\n label?: string;\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n}\r\n\r\n/** Render graph executor options. @public */\r\nexport interface RenderGraphExecutorOptions<TTexture = BaseTexture> {\r\n /** Device used for timestamp queries. If omitted, the scene global getDevice() is used. */\r\n device?: AbstractDevice;\r\n /** Render graph timestamp profiling options. Default false. */\r\n profiling?: boolean | RGProfilingOptions;\r\n /** Cross-execution affinity state used to stabilize transient texture identities. */\r\n textureAffinityCache?: RGTextureAffinityCache<TTexture>;\r\n}\r\n\r\n/** External resources bound for one graph execution. @public */\r\nexport interface RenderGraphExecutionBindings<TTexture = BaseTexture> {\r\n /** Imported graph texture handles and their physical textures. */\r\n readonly importedTextures?: ReadonlyMap<RGTextureHandle<TTexture>, TTexture>;\r\n}\r\n\r\n/** Resolved GPU timing for one scope. @public */\r\nexport interface RGProfileScopeResult {\r\n /** Scope label. */\r\n name: string;\r\n /** Scope type. */\r\n type: RGProfileScopeType;\r\n /** Timestamp query id used by the device, or 0 for synthetic/unsupported scopes. */\r\n queryId: number;\r\n /** GPU duration in milliseconds. */\r\n durationMs: number;\r\n /** Timestamp result status. */\r\n status: TimestampQueryStatus;\r\n /** Child scopes. */\r\n children: RGProfileScopeResult[];\r\n /** Optional diagnostic message. */\r\n message?: string;\r\n}\r\n\r\n/** GPU timing tree for one graph execution. @public */\r\nexport interface RGProfileResult {\r\n /** Render frame id when profiling began. */\r\n frameId: number;\r\n /** Aggregate profile status. */\r\n status: TimestampQueryStatus;\r\n /** Root graph scope. */\r\n graph: RGProfileScopeResult;\r\n /**\r\n * Top-level scopes, the same objects as graph.children: the graph's passes,\r\n * preceded by the external scopes recorded since the previous graph ran.\r\n * External scopes lie outside the graph scope's duration.\r\n */\r\n passes: RGProfileScopeResult[];\r\n}\r\n\r\n/** Resolved texture dimensions. @public */\r\nexport interface RGResolvedSize {\r\n width: number;\r\n height: number;\r\n}\r\n\r\nexport type RGTextureAttachment<TTexture = BaseTexture> =\r\n | RGTextureHandle<TTexture>\r\n | TTexture\r\n | TextureFormat;\r\n\r\n/** Backend-independent framebuffer descriptor. @public */\r\nexport interface RGFramebufferDesc<TTexture = BaseTexture> {\r\n /** Debug label for this framebuffer. */\r\n label?: string;\r\n /** Framebuffer width. Required when attachments are formats. */\r\n width?: number;\r\n /** Framebuffer height. Required when attachments are formats. */\r\n height?: number;\r\n /** Color attachments or formats. */\r\n colorAttachments: RGTextureAttachment<TTexture> | RGTextureAttachment<TTexture>[] | null;\r\n /** Depth/stencil attachment or format. */\r\n depthAttachment?: RGTextureAttachment<TTexture> | null;\r\n /** Whether color attachments created from formats should support mipmapping. */\r\n mipmapping?: boolean;\r\n /** Framebuffer sample count. */\r\n sampleCount?: number;\r\n /** Whether to ignore depth/stencil during MSAA resolve. */\r\n ignoreDepthStencil?: boolean;\r\n /** Attachment mip level. */\r\n attachmentMipLevel?: number;\r\n /** Attachment cubemap face. */\r\n attachmentCubeface?: number;\r\n /** Attachment array layer. */\r\n attachmentLayer?: number;\r\n}\r\n\r\n/**\r\n * Interface for allocating and releasing transient textures.\r\n *\r\n * Framebuffers are released before their attachments at the same pass boundary.\r\n * A released framebuffer must retain its attachments until texture release.\r\n *\r\n * @public\r\n */\r\nexport interface RGTextureAllocator<TTexture = BaseTexture> {\r\n /** Allocate a transient texture, preferring a compatible prior allocation. */\r\n allocate(desc: RGTextureDesc, size: RGResolvedSize, preferred?: TTexture): TTexture;\r\n\r\n /** Release a transient texture. */\r\n release(texture: TTexture): void;\r\n\r\n /**\r\n * Retain a transient texture beyond graph execution. The external owner must\r\n * later release it.\r\n */\r\n retain?(texture: TTexture): void;\r\n\r\n /** Allocate a framebuffer released by the executor. */\r\n allocateFramebuffer?(desc: RGFramebufferDesc): FrameBuffer;\r\n\r\n /** Release a temporary framebuffer. */\r\n releaseFramebuffer?(framebuffer: FrameBuffer): void;\r\n}\r\n"],"names":["RGHandle","id","name","kind","_id","_name","RGResource","desc","producer","nextWriter","consumers","physicalId","allocationKey","RGSubpass","executeFn","RGPass","index","reads","writes","dependencies","orderingDependencies","warDependencies","hasSideEffect","data","subpasses","alive","nameOccurrence"],"mappings":"AAwCA,oDACO,MAAMA,QAAAA,CAAAA;qBAIX,GAAqB;qBAErB,KAAuB;uEAEvB,IAAiB;qBAGjB,YAAYC,EAAU,EAAEC,IAAY,EAAEC,IAAAA,GAAU,SAAc,CAAE;QAC9D,IAAI,CAACC,GAAG,GAAGH,EAAAA;QACX,IAAI,CAACI,KAAK,GAAGH,IAAAA;QACb,IAAI,CAACC,IAAI,GAAGA,IAAAA;AACd;2DAGA,IAAID,IAAe,GAAA;QACjB,OAAO,IAAI,CAACG,KAAK;AACnB;AACF;AAcA,+CACO,MAAMC,UAAAA,CAAAA;IACFL,EAAW;IACXC,IAAa;IACbC,IAAqB;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AAc,GAAGA,cAAAA;AACxB;AACF;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Disposable, Vector4, DEPTH_CLEAR_VALUE } from '@zephyr3d/base';
|
|
1
|
+
import { Disposable, Vector4, DEPTH_CLEAR_VALUE, DEBUG_VIEWS } from '@zephyr3d/base';
|
|
2
2
|
import { CullVisitor } from './cull_visitor.js';
|
|
3
3
|
import { RenderQueue } from './render_queue.js';
|
|
4
4
|
import { RenderBundleWrapper } from './renderbundle_wrapper.js';
|
|
5
5
|
import { RENDER_PASS_TYPE_LIGHT, MaterialVaryingFlags } from '../values.js';
|
|
6
6
|
import { getDevice } from '../app/api.js';
|
|
7
|
+
import { isWireframePass, beginWireframe, endWireframe } from './debug_views.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Base class for any kind of render passes
|
|
@@ -72,8 +73,11 @@ import { getDevice } from '../app/api.js';
|
|
|
72
73
|
}
|
|
73
74
|
/** @internal */ drawScene(ctx, renderCamera, cullCamera, renderQueue) {
|
|
74
75
|
const device = ctx.device;
|
|
75
|
-
this.clearFramebuffer();
|
|
76
76
|
const rq = renderQueue ?? this.cullScene(ctx, cullCamera);
|
|
77
|
+
// Compute passes culling batched instances for this view run before the framebuffer is
|
|
78
|
+
// cleared, so they do not split the render pass
|
|
79
|
+
rq?.cullInstances();
|
|
80
|
+
this.clearFramebuffer();
|
|
77
81
|
if (rq) {
|
|
78
82
|
const windingReversed = device.isWindingOrderReversed();
|
|
79
83
|
device.reverseVertexWindingOrder(this.isAutoFlip(ctx) ? !windingReversed : windingReversed);
|
|
@@ -91,13 +95,14 @@ import { getDevice } from '../app/api.js';
|
|
|
91
95
|
* @returns The cull result
|
|
92
96
|
*/ cullScene(ctx, cullCamera) {
|
|
93
97
|
const renderQueue = new RenderQueue(this);
|
|
94
|
-
|
|
98
|
+
// Levels of detail follow the view being rendered, shadow cascades included
|
|
99
|
+
const cullVisitor = new CullVisitor(this, cullCamera, renderQueue, ctx.camera);
|
|
95
100
|
if (ctx.scene.octree) {
|
|
96
101
|
ctx.scene.octree.getRootNode().traverse(cullVisitor);
|
|
97
102
|
} else {
|
|
98
103
|
ctx.scene.rootNode.traverse(cullVisitor);
|
|
99
104
|
}
|
|
100
|
-
renderQueue.end(cullCamera);
|
|
105
|
+
renderQueue.end(cullCamera, false, ctx.camera);
|
|
101
106
|
ctx.sunLight = renderQueue.sunLight;
|
|
102
107
|
ctx.primaryDirectionalLight = renderQueue.primaryDirectionalLight;
|
|
103
108
|
ctx.primaryTransmissionLight = renderQueue.primaryTransmissionLight;
|
|
@@ -105,7 +110,14 @@ import { getDevice } from '../app/api.js';
|
|
|
105
110
|
}
|
|
106
111
|
/** @internal */ internalDrawItemList(ctx, items, renderQueue, renderBundle, reverseWinding, hash) {
|
|
107
112
|
let recording = false;
|
|
108
|
-
|
|
113
|
+
// A wireframe view draws everything as edges (debug views only)
|
|
114
|
+
const wireframe = DEBUG_VIEWS && !!ctx.camera?.wireframe && isWireframePass(ctx);
|
|
115
|
+
// Edges are built asynchronously, so a bundle recorded before they are ready would keep
|
|
116
|
+
// drawing triangles; the bundle key does not know the camera setting either
|
|
117
|
+
const disableRenderBundles = this.shouldDisableRenderBundles(ctx) || wireframe;
|
|
118
|
+
if (wireframe) {
|
|
119
|
+
beginWireframe();
|
|
120
|
+
}
|
|
109
121
|
if (renderBundle && ctx.camera.commandBufferReuse && !disableRenderBundles) {
|
|
110
122
|
const bundle = renderBundle.getRenderBundle(hash);
|
|
111
123
|
if (bundle) {
|
|
@@ -117,6 +129,7 @@ import { getDevice } from '../app/api.js';
|
|
|
117
129
|
}
|
|
118
130
|
for (const item of items){
|
|
119
131
|
ctx.instanceData = item.instanceData;
|
|
132
|
+
ctx.primitiveLod = item.lod ?? 0;
|
|
120
133
|
const reverse = reverseWinding !== item.drawable.getNode().worldMatrixDet < 0;
|
|
121
134
|
if (reverse) {
|
|
122
135
|
ctx.device.reverseVertexWindingOrder(!ctx.device.isWindingOrderReversed());
|
|
@@ -129,6 +142,10 @@ import { getDevice } from '../app/api.js';
|
|
|
129
142
|
ctx.device.reverseVertexWindingOrder(!ctx.device.isWindingOrderReversed());
|
|
130
143
|
}
|
|
131
144
|
}
|
|
145
|
+
ctx.primitiveLod = 0;
|
|
146
|
+
if (wireframe) {
|
|
147
|
+
endWireframe();
|
|
148
|
+
}
|
|
132
149
|
if (renderBundle && ctx.camera.commandBufferReuse && !disableRenderBundles) {
|
|
133
150
|
renderBundle.endRenderBundle(hash);
|
|
134
151
|
}
|
|
@@ -173,6 +190,12 @@ import { getDevice } from '../app/api.js';
|
|
|
173
190
|
itemList.materialList.forEach((mat)=>mat.apply(ctx));
|
|
174
191
|
this.internalDrawItemList(ctx, itemList.instanceItemList, itemList.renderQueue, itemList.instanceRenderBundle ?? null, reverseWinding, hash);
|
|
175
192
|
}
|
|
193
|
+
if (itemList.skinInstanceItemList.length > 0) {
|
|
194
|
+
ctx.materialFlags |= MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.INSTANCING;
|
|
195
|
+
ctx.materialFlags &= ~MaterialVaryingFlags.MORPH_ANIMATION;
|
|
196
|
+
itemList.materialList.forEach((mat)=>mat.apply(ctx));
|
|
197
|
+
this.internalDrawItemList(ctx, itemList.skinInstanceItemList, itemList.renderQueue, itemList.skinInstanceRenderBundle ?? null, reverseWinding, hash);
|
|
198
|
+
}
|
|
176
199
|
}
|
|
177
200
|
}
|
|
178
201
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderpass.js","sources":["../../src/render/renderpass.ts"],"sourcesContent":["import type { Immutable, Nullable } from '@zephyr3d/base';\r\nimport { DEPTH_CLEAR_VALUE, Disposable, Vector4 } from '@zephyr3d/base';\r\nimport { CullVisitor } from './cull_visitor';\r\nimport type { RenderItemListInfo, RenderQueueItem } from './render_queue';\r\nimport { RenderQueue } from './render_queue';\r\nimport type { Camera } from '../camera/camera';\r\nimport type { DrawContext } from './drawable';\r\nimport { RenderBundleWrapper } from './renderbundle_wrapper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport type { BindGroup, FrameBufferClearColors } from '@zephyr3d/device';\r\nimport { getDevice } from '../app/api';\r\n\r\n/**\r\n * Base class for any kind of render passes\r\n * @public\r\n */\r\nexport abstract class RenderPass extends Disposable {\r\n /** @internal */\r\n protected _type: number;\r\n /** @internal */\r\n protected _globalBindGroups: Record<string, BindGroup>;\r\n /** @internal */\r\n protected _clearColor: Nullable<Vector4>;\r\n /** @internal */\r\n protected _clearColors: Nullable<readonly Nullable<Vector4>[]>;\r\n /** @internal */\r\n protected _clearDepth: Nullable<number>;\r\n /** @internal */\r\n protected _clearStencil: Nullable<number>;\r\n /**\r\n * Creates an instanceof RenderPass\r\n * @param type - Render pass type\r\n */\r\n constructor(type: number) {\r\n super();\r\n this._type = type;\r\n this._clearColor = new Vector4(0, 0, 0, 1);\r\n this._clearColors = null;\r\n this._clearDepth = DEPTH_CLEAR_VALUE;\r\n this._clearStencil = 0;\r\n this._globalBindGroups = {};\r\n }\r\n /** Color value that is used to clear the frame buffer */\r\n get clearColor(): Nullable<Immutable<Vector4>> {\r\n return this._clearColor;\r\n }\r\n set clearColor(color: Nullable<Immutable<Vector4>>) {\r\n this._clearColor = color;\r\n this._clearColors = null;\r\n }\r\n /** Per-target color values that are used to clear the frame buffer */\r\n get clearColors(): Nullable<readonly Nullable<Immutable<Vector4>>[]> {\r\n return this._clearColors;\r\n }\r\n set clearColors(colors: Nullable<readonly Nullable<Immutable<Vector4>>[]>) {\r\n this._clearColors = colors as Nullable<readonly Nullable<Vector4>[]>;\r\n }\r\n /** Depth value that is used to clear the frame buffer */\r\n get clearDepth() {\r\n return this._clearDepth;\r\n }\r\n set clearDepth(depth) {\r\n this._clearDepth = depth;\r\n }\r\n /** Stencil value that is used to clear the frame buffer */\r\n get clearStencil() {\r\n return this._clearStencil;\r\n }\r\n set clearStencil(stencil) {\r\n this._clearStencil = stencil;\r\n }\r\n /**\r\n * The render pass type\r\n */\r\n get type() {\r\n return this._type;\r\n }\r\n /** @internal */\r\n isAutoFlip(ctx: DrawContext) {\r\n return !!(ctx.device.getFramebuffer() && ctx.device.type === 'webgpu');\r\n }\r\n /**\r\n * Renders a scene\r\n * @param ctx - Drawing context\r\n */\r\n render(\r\n ctx: DrawContext,\r\n renderCamera?: Nullable<Camera>,\r\n cullCamera?: Nullable<Camera>,\r\n renderQueue?: RenderQueue\r\n ) {\r\n ctx.renderPass = this;\r\n this.drawScene(ctx, renderCamera ?? ctx.camera, cullCamera ?? renderCamera ?? ctx.camera, renderQueue);\r\n }\r\n /** @internal */\r\n getGlobalBindGroupHash(ctx: DrawContext, camera: Camera) {\r\n return `${this.constructor.name}:${this._getGlobalBindGroupHash(ctx, camera)}`;\r\n }\r\n /** @internal */\r\n protected abstract _getGlobalBindGroupHash(ctx: DrawContext, camera: Camera): string;\r\n /** @internal */\r\n protected abstract renderItems(ctx: DrawContext, renderCamera: Camera, renderQueue: RenderQueue): void;\r\n /** @internal */\r\n protected drawScene(ctx: DrawContext, renderCamera: Camera, cullCamera: Camera, renderQueue?: RenderQueue) {\r\n const device = ctx.device;\r\n this.clearFramebuffer();\r\n const rq = renderQueue ?? this.cullScene(ctx, cullCamera);\r\n if (rq) {\r\n const windingReversed = device.isWindingOrderReversed();\r\n device.reverseVertexWindingOrder(this.isAutoFlip(ctx) ? !windingReversed : windingReversed);\r\n this.renderItems(ctx, renderCamera, rq);\r\n device.reverseVertexWindingOrder(windingReversed);\r\n if (rq !== renderQueue) {\r\n rq.dispose();\r\n }\r\n }\r\n }\r\n /**\r\n * Culls a scene by a given camera\r\n * @param ctx - The draw context\r\n * @param cullCamera - The camera that will be used to cull the scene\r\n * @returns The cull result\r\n */\r\n cullScene(ctx: DrawContext, cullCamera: Camera) {\r\n const renderQueue = new RenderQueue(this);\r\n const cullVisitor = new CullVisitor(this, cullCamera, renderQueue);\r\n if (ctx.scene.octree) {\r\n ctx.scene.octree.getRootNode().traverse(cullVisitor);\r\n } else {\r\n ctx.scene.rootNode.traverse(cullVisitor);\r\n }\r\n renderQueue.end(cullCamera);\r\n ctx.sunLight = renderQueue.sunLight;\r\n ctx.primaryDirectionalLight = renderQueue.primaryDirectionalLight;\r\n ctx.primaryTransmissionLight = renderQueue.primaryTransmissionLight;\r\n return renderQueue;\r\n }\r\n /** @internal */\r\n private internalDrawItemList(\r\n ctx: DrawContext,\r\n items: RenderQueueItem[],\r\n renderQueue: Nullable<RenderQueue>,\r\n renderBundle: Nullable<RenderBundleWrapper>,\r\n reverseWinding: boolean,\r\n hash: string\r\n ) {\r\n let recording = false;\r\n const disableRenderBundles = this.shouldDisableRenderBundles(ctx);\r\n if (renderBundle && ctx.camera.commandBufferReuse && !disableRenderBundles) {\r\n const bundle = renderBundle.getRenderBundle(hash);\r\n if (bundle) {\r\n ctx.device.executeRenderBundle(bundle);\r\n return;\r\n }\r\n recording = true;\r\n renderBundle.beginRenderBundle();\r\n }\r\n for (const item of items) {\r\n ctx.instanceData = item.instanceData;\r\n const reverse = reverseWinding !== item.drawable.getNode().worldMatrixDet < 0;\r\n if (reverse) {\r\n ctx.device.reverseVertexWindingOrder(!ctx.device.isWindingOrderReversed());\r\n }\r\n if (recording) {\r\n RenderBundleWrapper.addDrawable(\r\n item.drawable,\r\n item.drawable.getMaterial()?.coreMaterial!,\r\n item.drawable.getPrimitive()!,\r\n renderBundle!,\r\n hash\r\n );\r\n }\r\n item.drawable.draw(ctx, renderQueue, recording || disableRenderBundles ? undefined : hash);\r\n if (reverse) {\r\n ctx.device.reverseVertexWindingOrder(!ctx.device.isWindingOrderReversed());\r\n }\r\n }\r\n if (renderBundle && ctx.camera.commandBufferReuse && !disableRenderBundles) {\r\n renderBundle.endRenderBundle(hash);\r\n }\r\n }\r\n private shouldDisableRenderBundles(ctx: DrawContext) {\r\n return (\r\n (ctx.renderPass?.type === RENDER_PASS_TYPE_LIGHT &&\r\n (!!ctx.SSS || !!ctx.currentShadowLight || !!ctx.lightBlending)) ||\r\n false\r\n );\r\n }\r\n /** @internal */\r\n protected drawItemList(itemList: RenderItemListInfo, ctx: DrawContext, reverseWinding: boolean) {\r\n ctx.instanceData = null;\r\n const windingHash = reverseWinding ? '1' : '0';\r\n const bindGroupHash = ctx.device.getBindGroup(0)[0].getGPUId();\r\n const framebufferHash = ctx.device.getFramebuffer()?.getHash() ?? '';\r\n const ctxHash = `${ctx.sceneColorTexture?.uid ?? 0}-${ctx.linearDepthTexture?.uid ?? 0}`;\r\n const hash = `${windingHash}-${bindGroupHash}-${framebufferHash}-${ctxHash}-${ctx.renderPassHash}`;\r\n if (itemList) {\r\n if (itemList.itemList.length > 0) {\r\n ctx.materialFlags &= ~(\r\n MaterialVaryingFlags.SKIN_ANIMATION |\r\n MaterialVaryingFlags.INSTANCING |\r\n MaterialVaryingFlags.MORPH_ANIMATION\r\n );\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.itemList,\r\n itemList.renderQueue,\r\n itemList.renderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.skinItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SKIN_ANIMATION;\r\n ctx.materialFlags &= ~(MaterialVaryingFlags.MORPH_ANIMATION | MaterialVaryingFlags.INSTANCING);\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.skinItemList,\r\n itemList.renderQueue,\r\n itemList.skinRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.morphItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.MORPH_ANIMATION;\r\n ctx.materialFlags &= ~(MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.INSTANCING);\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.morphItemList,\r\n itemList.renderQueue,\r\n itemList.morphRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.skinAndMorphItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.MORPH_ANIMATION;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.INSTANCING;\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.skinAndMorphItemList,\r\n itemList.renderQueue,\r\n itemList.skinAndMorphRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.instanceItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.INSTANCING;\r\n ctx.materialFlags &= ~(MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.MORPH_ANIMATION);\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.instanceItemList,\r\n itemList.renderQueue,\r\n itemList.instanceRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n }\r\n }\r\n /**\r\n * Disposes the render pass\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._globalBindGroups = {};\r\n }\r\n /** @internal */\r\n private clearFramebuffer() {\r\n const clearColor = (this._clearColors ?? this._clearColor) as FrameBufferClearColors;\r\n if (clearColor || this._clearDepth != null || this._clearStencil != null) {\r\n getDevice().clearFrameBuffer(clearColor, this._clearDepth, this._clearStencil);\r\n }\r\n }\r\n}\r\n"],"names":["RenderPass","Disposable","type","_type","_clearColor","Vector4","_clearColors","_clearDepth","DEPTH_CLEAR_VALUE","_clearStencil","_globalBindGroups","clearColor","color","clearColors","colors","clearDepth","depth","clearStencil","stencil","isAutoFlip","ctx","device","getFramebuffer","render","renderCamera","cullCamera","renderQueue","renderPass","drawScene","camera","getGlobalBindGroupHash","name","_getGlobalBindGroupHash","clearFramebuffer","rq","cullScene","windingReversed","isWindingOrderReversed","reverseVertexWindingOrder","renderItems","dispose","RenderQueue","cullVisitor","CullVisitor","scene","octree","getRootNode","traverse","rootNode","end","sunLight","primaryDirectionalLight","primaryTransmissionLight","internalDrawItemList","items","renderBundle","reverseWinding","hash","recording","disableRenderBundles","shouldDisableRenderBundles","commandBufferReuse","bundle","getRenderBundle","executeRenderBundle","beginRenderBundle","item","instanceData","reverse","drawable","getNode","worldMatrixDet","RenderBundleWrapper","addDrawable","getMaterial","coreMaterial","getPrimitive","draw","undefined","endRenderBundle","RENDER_PASS_TYPE_LIGHT","SSS","currentShadowLight","lightBlending","itemList","windingHash","bindGroupHash","getBindGroup","getGPUId","framebufferHash","getHash","ctxHash","sceneColorTexture","uid","linearDepthTexture","renderPassHash","length","materialFlags","MaterialVaryingFlags","SKIN_ANIMATION","INSTANCING","MORPH_ANIMATION","materialList","forEach","mat","apply","skinItemList","skinRenderBundle","morphItemList","morphRenderBundle","skinAndMorphItemList","skinAndMorphRenderBundle","instanceItemList","instanceRenderBundle","onDispose","getDevice","clearFrameBuffer"],"mappings":";;;;;;;AAYA;;;IAIO,MAAeA,UAAmBC,SAAAA,UAAAA,CAAAA;qBAEvC,KAAwB;qBAExB,iBAAuD;qBAEvD,WAAyC;qBAEzC,YAA+D;qBAE/D,WAAwC;qBAExC,aAA0C;AAC1C;;;MAIA,WAAA,CAAYC,IAAY,CAAE;QACxB,KAAK,EAAA;QACL,IAAI,CAACC,KAAK,GAAGD,IAAAA;AACb,QAAA,IAAI,CAACE,WAAW,GAAG,IAAIC,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,CAAA;QACxC,IAAI,CAACC,YAAY,GAAG,IAAA;QACpB,IAAI,CAACC,WAAW,GAAGC,iBAAAA;QACnB,IAAI,CAACC,aAAa,GAAG,CAAA;QACrB,IAAI,CAACC,iBAAiB,GAAG,EAAC;AAC5B;+DAEA,IAAIC,UAA2C,GAAA;QAC7C,OAAO,IAAI,CAACP,WAAW;AAC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AA,WAAW,EACpB0D,QAAAA,CAAS2B,wBAAwB,IAAI,MACrCvD,cACAC,EAAAA,IAAAA,CAAAA;AAEJ;AACA,YAAA,IAAI2B,QAAS4B,CAAAA,gBAAgB,CAAChB,MAAM,GAAG,CAAG,EAAA;gBACxC5E,GAAI6E,CAAAA,aAAa,IAAIC,oBAAAA,CAAqBE,UAAU;gBACpDhF,GAAI6E,CAAAA,aAAa,IAAI,EAAEC,qBAAqBC,cAAc,GAAGD,oBAAqBG,CAAAA,eAAe,CAAD;gBAChGjB,QAASkB,CAAAA,YAAY,CAACC,OAAO,CAAC,CAACC,GAAQA,GAAAA,GAAAA,CAAIC,KAAK,CAACrF,GAAAA,CAAAA,CAAAA;AACjD,gBAAA,IAAI,CAACiC,oBAAoB,CACvBjC,GAAAA,EACAgE,SAAS4B,gBAAgB,EACzB5B,QAAS1D,CAAAA,WAAW,EACpB0D,QAAAA,CAAS6B,oBAAoB,IAAI,MACjCzD,cACAC,EAAAA,IAAAA,CAAAA;AAEJ;AACF;AACF;AACA;;AAEC,MACD,SAAsB,GAAA;AACpB,QAAA,KAAK,CAACyD,SAAAA,EAAAA;QACN,IAAI,CAACxG,iBAAiB,GAAG,EAAC;AAC5B;qBAEA,gBAA2B,GAAA;AACzB,QAAA,MAAMC,aAAc,IAAI,CAACL,YAAY,IAAI,IAAI,CAACF,WAAW;QACzD,IAAIO,UAAAA,IAAc,IAAI,CAACJ,WAAW,IAAI,QAAQ,IAAI,CAACE,aAAa,IAAI,IAAM,EAAA;YACxE0G,SAAYC,EAAAA,CAAAA,gBAAgB,CAACzG,UAAY,EAAA,IAAI,CAACJ,WAAW,EAAE,IAAI,CAACE,aAAa,CAAA;AAC/E;AACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"renderpass.js","sources":["../../src/render/renderpass.ts"],"sourcesContent":["import type { Immutable, Nullable } from '@zephyr3d/base';\r\nimport { DEBUG_VIEWS, DEPTH_CLEAR_VALUE, Disposable, Vector4 } from '@zephyr3d/base';\r\nimport { CullVisitor } from './cull_visitor';\r\nimport type { RenderItemListInfo, RenderQueueItem } from './render_queue';\r\nimport { RenderQueue } from './render_queue';\r\nimport type { Camera } from '../camera/camera';\r\nimport type { DrawContext } from './drawable';\r\nimport { RenderBundleWrapper } from './renderbundle_wrapper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport type { BindGroup, FrameBufferClearColors } from '@zephyr3d/device';\r\nimport { getDevice } from '../app/api';\r\nimport { beginWireframe, endWireframe, isWireframePass } from './debug_views';\r\n\r\n/**\r\n * Base class for any kind of render passes\r\n * @public\r\n */\r\nexport abstract class RenderPass extends Disposable {\r\n /** @internal */\r\n protected _type: number;\r\n /** @internal */\r\n protected _globalBindGroups: Record<string, BindGroup>;\r\n /** @internal */\r\n protected _clearColor: Nullable<Vector4>;\r\n /** @internal */\r\n protected _clearColors: Nullable<readonly Nullable<Vector4>[]>;\r\n /** @internal */\r\n protected _clearDepth: Nullable<number>;\r\n /** @internal */\r\n protected _clearStencil: Nullable<number>;\r\n /**\r\n * Creates an instanceof RenderPass\r\n * @param type - Render pass type\r\n */\r\n constructor(type: number) {\r\n super();\r\n this._type = type;\r\n this._clearColor = new Vector4(0, 0, 0, 1);\r\n this._clearColors = null;\r\n this._clearDepth = DEPTH_CLEAR_VALUE;\r\n this._clearStencil = 0;\r\n this._globalBindGroups = {};\r\n }\r\n /** Color value that is used to clear the frame buffer */\r\n get clearColor(): Nullable<Immutable<Vector4>> {\r\n return this._clearColor;\r\n }\r\n set clearColor(color: Nullable<Immutable<Vector4>>) {\r\n this._clearColor = color;\r\n this._clearColors = null;\r\n }\r\n /** Per-target color values that are used to clear the frame buffer */\r\n get clearColors(): Nullable<readonly Nullable<Immutable<Vector4>>[]> {\r\n return this._clearColors;\r\n }\r\n set clearColors(colors: Nullable<readonly Nullable<Immutable<Vector4>>[]>) {\r\n this._clearColors = colors as Nullable<readonly Nullable<Vector4>[]>;\r\n }\r\n /** Depth value that is used to clear the frame buffer */\r\n get clearDepth() {\r\n return this._clearDepth;\r\n }\r\n set clearDepth(depth) {\r\n this._clearDepth = depth;\r\n }\r\n /** Stencil value that is used to clear the frame buffer */\r\n get clearStencil() {\r\n return this._clearStencil;\r\n }\r\n set clearStencil(stencil) {\r\n this._clearStencil = stencil;\r\n }\r\n /**\r\n * The render pass type\r\n */\r\n get type() {\r\n return this._type;\r\n }\r\n /** @internal */\r\n isAutoFlip(ctx: DrawContext) {\r\n return !!(ctx.device.getFramebuffer() && ctx.device.type === 'webgpu');\r\n }\r\n /**\r\n * Renders a scene\r\n * @param ctx - Drawing context\r\n */\r\n render(\r\n ctx: DrawContext,\r\n renderCamera?: Nullable<Camera>,\r\n cullCamera?: Nullable<Camera>,\r\n renderQueue?: RenderQueue\r\n ) {\r\n ctx.renderPass = this;\r\n this.drawScene(ctx, renderCamera ?? ctx.camera, cullCamera ?? renderCamera ?? ctx.camera, renderQueue);\r\n }\r\n /** @internal */\r\n getGlobalBindGroupHash(ctx: DrawContext, camera: Camera) {\r\n return `${this.constructor.name}:${this._getGlobalBindGroupHash(ctx, camera)}`;\r\n }\r\n /** @internal */\r\n protected abstract _getGlobalBindGroupHash(ctx: DrawContext, camera: Camera): string;\r\n /** @internal */\r\n protected abstract renderItems(ctx: DrawContext, renderCamera: Camera, renderQueue: RenderQueue): void;\r\n /** @internal */\r\n protected drawScene(ctx: DrawContext, renderCamera: Camera, cullCamera: Camera, renderQueue?: RenderQueue) {\r\n const device = ctx.device;\r\n const rq = renderQueue ?? this.cullScene(ctx, cullCamera);\r\n // Compute passes culling batched instances for this view run before the framebuffer is\r\n // cleared, so they do not split the render pass\r\n rq?.cullInstances();\r\n this.clearFramebuffer();\r\n if (rq) {\r\n const windingReversed = device.isWindingOrderReversed();\r\n device.reverseVertexWindingOrder(this.isAutoFlip(ctx) ? !windingReversed : windingReversed);\r\n this.renderItems(ctx, renderCamera, rq);\r\n device.reverseVertexWindingOrder(windingReversed);\r\n if (rq !== renderQueue) {\r\n rq.dispose();\r\n }\r\n }\r\n }\r\n /**\r\n * Culls a scene by a given camera\r\n * @param ctx - The draw context\r\n * @param cullCamera - The camera that will be used to cull the scene\r\n * @returns The cull result\r\n */\r\n cullScene(ctx: DrawContext, cullCamera: Camera) {\r\n const renderQueue = new RenderQueue(this);\r\n // Levels of detail follow the view being rendered, shadow cascades included\r\n const cullVisitor = new CullVisitor(this, cullCamera, renderQueue, ctx.camera);\r\n if (ctx.scene.octree) {\r\n ctx.scene.octree.getRootNode().traverse(cullVisitor);\r\n } else {\r\n ctx.scene.rootNode.traverse(cullVisitor);\r\n }\r\n renderQueue.end(cullCamera, false, ctx.camera);\r\n ctx.sunLight = renderQueue.sunLight;\r\n ctx.primaryDirectionalLight = renderQueue.primaryDirectionalLight;\r\n ctx.primaryTransmissionLight = renderQueue.primaryTransmissionLight;\r\n return renderQueue;\r\n }\r\n /** @internal */\r\n private internalDrawItemList(\r\n ctx: DrawContext,\r\n items: RenderQueueItem[],\r\n renderQueue: Nullable<RenderQueue>,\r\n renderBundle: Nullable<RenderBundleWrapper>,\r\n reverseWinding: boolean,\r\n hash: string\r\n ) {\r\n let recording = false;\r\n // A wireframe view draws everything as edges (debug views only)\r\n const wireframe = DEBUG_VIEWS && !!ctx.camera?.wireframe && isWireframePass(ctx);\r\n // Edges are built asynchronously, so a bundle recorded before they are ready would keep\r\n // drawing triangles; the bundle key does not know the camera setting either\r\n const disableRenderBundles = this.shouldDisableRenderBundles(ctx) || wireframe;\r\n if (wireframe) {\r\n beginWireframe();\r\n }\r\n if (renderBundle && ctx.camera.commandBufferReuse && !disableRenderBundles) {\r\n const bundle = renderBundle.getRenderBundle(hash);\r\n if (bundle) {\r\n ctx.device.executeRenderBundle(bundle);\r\n return;\r\n }\r\n recording = true;\r\n renderBundle.beginRenderBundle();\r\n }\r\n for (const item of items) {\r\n ctx.instanceData = item.instanceData;\r\n ctx.primitiveLod = item.lod ?? 0;\r\n const reverse = reverseWinding !== item.drawable.getNode().worldMatrixDet < 0;\r\n if (reverse) {\r\n ctx.device.reverseVertexWindingOrder(!ctx.device.isWindingOrderReversed());\r\n }\r\n if (recording) {\r\n RenderBundleWrapper.addDrawable(\r\n item.drawable,\r\n item.drawable.getMaterial()?.coreMaterial!,\r\n item.drawable.getPrimitive()!,\r\n renderBundle!,\r\n hash\r\n );\r\n }\r\n item.drawable.draw(ctx, renderQueue, recording || disableRenderBundles ? undefined : hash);\r\n if (reverse) {\r\n ctx.device.reverseVertexWindingOrder(!ctx.device.isWindingOrderReversed());\r\n }\r\n }\r\n ctx.primitiveLod = 0;\r\n if (wireframe) {\r\n endWireframe();\r\n }\r\n if (renderBundle && ctx.camera.commandBufferReuse && !disableRenderBundles) {\r\n renderBundle.endRenderBundle(hash);\r\n }\r\n }\r\n private shouldDisableRenderBundles(ctx: DrawContext) {\r\n return (\r\n (ctx.renderPass?.type === RENDER_PASS_TYPE_LIGHT &&\r\n (!!ctx.SSS || !!ctx.currentShadowLight || !!ctx.lightBlending)) ||\r\n false\r\n );\r\n }\r\n /** @internal */\r\n protected drawItemList(itemList: RenderItemListInfo, ctx: DrawContext, reverseWinding: boolean) {\r\n ctx.instanceData = null;\r\n const windingHash = reverseWinding ? '1' : '0';\r\n const bindGroupHash = ctx.device.getBindGroup(0)[0].getGPUId();\r\n const framebufferHash = ctx.device.getFramebuffer()?.getHash() ?? '';\r\n const ctxHash = `${ctx.sceneColorTexture?.uid ?? 0}-${ctx.linearDepthTexture?.uid ?? 0}`;\r\n const hash = `${windingHash}-${bindGroupHash}-${framebufferHash}-${ctxHash}-${ctx.renderPassHash}`;\r\n if (itemList) {\r\n if (itemList.itemList.length > 0) {\r\n ctx.materialFlags &= ~(\r\n MaterialVaryingFlags.SKIN_ANIMATION |\r\n MaterialVaryingFlags.INSTANCING |\r\n MaterialVaryingFlags.MORPH_ANIMATION\r\n );\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.itemList,\r\n itemList.renderQueue,\r\n itemList.renderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.skinItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SKIN_ANIMATION;\r\n ctx.materialFlags &= ~(MaterialVaryingFlags.MORPH_ANIMATION | MaterialVaryingFlags.INSTANCING);\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.skinItemList,\r\n itemList.renderQueue,\r\n itemList.skinRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.morphItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.MORPH_ANIMATION;\r\n ctx.materialFlags &= ~(MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.INSTANCING);\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.morphItemList,\r\n itemList.renderQueue,\r\n itemList.morphRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.skinAndMorphItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.MORPH_ANIMATION;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.INSTANCING;\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.skinAndMorphItemList,\r\n itemList.renderQueue,\r\n itemList.skinAndMorphRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.instanceItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.INSTANCING;\r\n ctx.materialFlags &= ~(MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.MORPH_ANIMATION);\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.instanceItemList,\r\n itemList.renderQueue,\r\n itemList.instanceRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n if (itemList.skinInstanceItemList.length > 0) {\r\n ctx.materialFlags |= MaterialVaryingFlags.SKIN_ANIMATION | MaterialVaryingFlags.INSTANCING;\r\n ctx.materialFlags &= ~MaterialVaryingFlags.MORPH_ANIMATION;\r\n itemList.materialList.forEach((mat) => mat.apply(ctx));\r\n this.internalDrawItemList(\r\n ctx,\r\n itemList.skinInstanceItemList,\r\n itemList.renderQueue,\r\n itemList.skinInstanceRenderBundle ?? null,\r\n reverseWinding,\r\n hash\r\n );\r\n }\r\n }\r\n }\r\n /**\r\n * Disposes the render pass\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._globalBindGroups = {};\r\n }\r\n /** @internal */\r\n private clearFramebuffer() {\r\n const clearColor = (this._clearColors ?? this._clearColor) as FrameBufferClearColors;\r\n if (clearColor || this._clearDepth != null || this._clearStencil != null) {\r\n getDevice().clearFrameBuffer(clearColor, this._clearDepth, this._clearStencil);\r\n }\r\n }\r\n}\r\n"],"names":["RenderPass","Disposable","type","_type","_clearColor","Vector4","_clearColors","_clearDepth","DEPTH_CLEAR_VALUE","_clearStencil","_globalBindGroups","clearColor","color","clearColors","colors","clearDepth","depth","clearStencil","stencil","isAutoFlip","ctx","device","getFramebuffer","render","renderCamera","cullCamera","renderQueue","renderPass","drawScene","camera","getGlobalBindGroupHash","name","_getGlobalBindGroupHash","rq","cullScene","cullInstances","clearFramebuffer","windingReversed","isWindingOrderReversed","reverseVertexWindingOrder","renderItems","dispose","RenderQueue","cullVisitor","CullVisitor","scene","octree","getRootNode","traverse","rootNode","end","sunLight","primaryDirectionalLight","primaryTransmissionLight","internalDrawItemList","items","renderBundle","reverseWinding","hash","recording","wireframe","DEBUG_VIEWS","isWireframePass","disableRenderBundles","shouldDisableRenderBundles","beginWireframe","commandBufferReuse","bundle","getRenderBundle","executeRenderBundle","beginRenderBundle","item","instanceData","primitiveLod","lod","reverse","drawable","getNode","worldMatrixDet","RenderBundleWrapper","addDrawable","getMaterial","coreMaterial","getPrimitive","draw","undefined","endWireframe","endRenderBundle","RENDER_PASS_TYPE_LIGHT","SSS","currentShadowLight","lightBlending","itemList","windingHash","bindGroupHash","getBindGroup","getGPUId","framebufferHash","getHash","ctxHash","sceneColorTexture","uid","linearDepthTexture","renderPassHash","length","materialFlags","MaterialVaryingFlags","SKIN_ANIMATION","INSTANCING","MORPH_ANIMATION","materialList","forEach","mat","apply","skinItemList","skinRenderBundle","morphItemList","morphRenderBundle","skinAndMorphItemList","skinAndMorphRenderBundle","instanceItemList","instanceRenderBundle","skinInstanceItemList","skinInstanceRenderBundle","onDispose","getDevice","clearFrameBuffer"],"mappings":";;;;;;;;AAaA;;;IAIO,MAAeA,UAAmBC,SAAAA,UAAAA,CAAAA;qBAEvC,KAAwB;qBAExB,iBAAuD;qBAEvD,WAAyC;qBAEzC,YAA+D;qBAE/D,WAAwC;qBAExC,aAA0C;AAC1C;;;MAIA,WAAA,CAAYC,IAAY,CAAE;QACxB,KAAK,EAAA;QACL,IAAI,CAACC,KAAK,GAAGD,IAAAA;AACb,QAAA,IAAI,CAACE,WAAW,GAAG,IAAIC,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,CAAA;QACxC,IAAI,CAACC,YAAY,GAAG,IAAA;QACpB,IAAI,CAACC,WAAW,GAAGC,iBAAAA;QACnB,IAAI,CAACC,aAAa,GAAG,CAAA;QACrB,IAAI,CAACC,iBAAiB,GAAG,EAAC;AAC5B;+DAEA,IAAIC,UAA2C,GAAA;QAC7C,OAAO,IAAI,CAACP,WAAW;AACzB;IACA,IAAIO,UAAAA,CAAWC,KAAmC,EAAE;QAClD,IAAI,CAACR,WAAW,GAAGQ,KAAAA;QACnB,IAAI,CAACN,YAAY,GAAG,IAAA;AACtB;2EAEA,IAAIO,WAAiE,GAAA;QACnE,OAAO,IAAI,CAACP,YAAY;AAC1B;IACA,IAAIO,WAAAA,CAAYC,MA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