@zephyr3d/scene 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animation.js +142 -31
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +186 -73
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +66 -10
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +40 -20
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +20 -38
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +59 -22
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/proptrack.js +186 -0
- package/dist/animation/proptrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +28 -11
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +28 -11
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +238 -82
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +29 -11
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/api.js +52 -0
- package/dist/app/api.js.map +1 -0
- package/dist/app/app.js +165 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/engine.js +300 -0
- package/dist/app/engine.js.map +1 -0
- package/dist/app/inputmgr.js +351 -0
- package/dist/app/inputmgr.js.map +1 -0
- package/dist/app/runtimescript.js +62 -0
- package/dist/app/runtimescript.js.map +1 -0
- package/dist/app/screen.js +318 -0
- package/dist/app/screen.js.map +1 -0
- package/dist/app/scriptingsystem.js +224 -0
- package/dist/app/scriptingsystem.js.map +1 -0
- package/dist/app/scriptregistry.js +421 -0
- package/dist/app/scriptregistry.js.map +1 -0
- package/dist/asset/assetmanager.js +823 -321
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/builtin.js +12 -48
- package/dist/asset/builtin.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +23 -95
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +9 -19
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +50 -48
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/helpers.js +33 -16
- package/dist/asset/loaders/gltf/helpers.js.map +1 -1
- package/dist/asset/loaders/hdr/hdr.js +39 -27
- package/dist/asset/loaders/hdr/hdr.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +15 -17
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +51 -50
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js +2 -2
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/model.js +160 -6
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +0 -1
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/blitter.js +28 -31
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/box.js +0 -1
- package/dist/blitter/box.js.map +1 -1
- package/dist/blitter/copy.js.map +1 -1
- package/dist/blitter/gaussianblur.js +23 -23
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +139 -34
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +760 -172
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +21 -27
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +134 -59
- package/dist/camera/orbit.js.map +1 -1
- package/dist/camera/orthocamera.js +52 -21
- package/dist/camera/orthocamera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +60 -34
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +17031 -6901
- package/dist/index.js +60 -21
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +5 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/grassmaterial.js +6 -1
- package/dist/material/grassmaterial.js.map +1 -1
- package/dist/material/lambert.js +6 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +356 -77
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +505 -162
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/foliage.js +3 -3
- package/dist/material/mixins/foliage.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +18 -5
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +6 -6
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +242 -0
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -0
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +52 -15
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +27 -9
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +19 -7
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/brdf.js +134 -0
- package/dist/material/mixins/pbr/brdf.js.map +1 -0
- package/dist/material/mixins/pbr/common.js +68 -85
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +101 -83
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +6 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/particle.js +272 -0
- package/dist/material/particle.js.map +1 -0
- package/dist/material/pbrblueprint.js +344 -0
- package/dist/material/pbrblueprint.js.map +1 -0
- package/dist/material/pbrmr.js +10 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +10 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +533 -316
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite.js +301 -0
- package/dist/material/sprite.js.map +1 -0
- package/dist/material/sprite3d.js +301 -0
- package/dist/material/sprite3d.js.map +1 -0
- package/dist/material/sprite3d_std.js +116 -0
- package/dist/material/sprite3d_std.js.map +1 -0
- package/dist/material/sprite3dblueprint.js +235 -0
- package/dist/material/sprite3dblueprint.js.map +1 -0
- package/dist/material/sprite_std.js +116 -0
- package/dist/material/sprite_std.js.map +1 -0
- package/dist/material/spriteblueprint.js +235 -0
- package/dist/material/spriteblueprint.js.map +1 -0
- package/dist/material/terrain-cm.js +606 -0
- package/dist/material/terrain-cm.js.map +1 -0
- package/dist/material/terrainmaterial.js +59 -54
- package/dist/material/terrainmaterial.js.map +1 -1
- package/dist/material/unlit.js +5 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +415 -0
- package/dist/material/water.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
- package/dist/node_modules/es-module-lexer/dist/lexer.js +5 -0
- package/dist/node_modules/es-module-lexer/dist/lexer.js.map +1 -0
- package/dist/posteffect/bloom.js +39 -54
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +95 -128
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +10 -18
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +9 -17
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +105 -0
- package/dist/posteffect/motionblur.js.map +1 -0
- package/dist/posteffect/posteffect.js +66 -35
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +13 -21
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +65 -103
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/taa.js +175 -0
- package/dist/posteffect/taa.js.map +1 -0
- package/dist/posteffect/tonemap.js +12 -20
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +38 -25
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +424 -106
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +11 -9
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +51 -13
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +15 -7
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable.js +15 -0
- package/dist/render/drawable.js.map +1 -0
- package/dist/render/drawable_mixin.js +121 -44
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +86 -141
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +236 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -0
- package/dist/render/fft_wavegenerator.js +131 -114
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/fullscreenquad.js +2 -2
- package/dist/render/fullscreenquad.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +100 -48
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +7 -3
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +7 -5
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +28 -27
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +6 -9
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/primitive.js +213 -105
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +49 -24
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +65 -15
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +324 -189
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +43 -84
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/rendertarget.js +5 -0
- package/dist/render/rendertarget.js.map +1 -0
- package/dist/render/screenrendertarget.js +56 -0
- package/dist/render/screenrendertarget.js.map +1 -0
- package/dist/render/shadowmap_pass.js +5 -6
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +867 -542
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +13 -15
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +296 -0
- package/dist/scene/basesprite.js.map +1 -0
- package/dist/scene/batchgroup.js +22 -7
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +78 -49
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +2 -3
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +49 -92
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +298 -89
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +371 -162
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/particlesys.js +687 -0
- package/dist/scene/particlesys.js.map +1 -0
- package/dist/scene/raycast_visitor.js +26 -13
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +312 -85
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +663 -105
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sprite.js +18 -0
- package/dist/scene/sprite.js.map +1 -0
- package/dist/scene/sprite3d.js +18 -0
- package/dist/scene/sprite3d.js.map +1 -0
- package/dist/scene/terrain/grass.js +48 -49
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +46 -44
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +20 -29
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +58 -27
- package/dist/scene/terrain/quadtree.js.map +1 -1
- package/dist/scene/terrain/terrain.js +31 -45
- package/dist/scene/terrain/terrain.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +604 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +162 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js +550 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/scene/water.js +383 -0
- package/dist/scene/water.js.map +1 -0
- package/dist/shaders/atmosphere.js +945 -0
- package/dist/shaders/atmosphere.js.map +1 -0
- package/dist/shaders/fog.js +116 -0
- package/dist/shaders/fog.js.map +1 -0
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +217 -8
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/pbr.js.map +1 -1
- package/dist/shaders/shadow.js +8 -8
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +87 -39
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +216 -0
- package/dist/shaders/temporal.js.map +1 -0
- package/dist/shaders/water.js +42 -20
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +32 -14
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +12 -13
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +12 -13
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +40 -0
- package/dist/shadow/shader.js.map +1 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadowmapper.js +73 -44
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +15 -16
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +33 -16
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/box.js +187 -83
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/cylinder.js +101 -43
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +70 -29
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/shape.js +121 -17
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +78 -44
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/shapes/tetrahedron.js +255 -0
- package/dist/shapes/tetrahedron.js.map +1 -0
- package/dist/shapes/torus.js +76 -55
- package/dist/shapes/torus.js.map +1 -1
- package/dist/src/animation/animation.js +127 -0
- package/dist/src/animation/animation.js.map +1 -0
- package/dist/src/animation/animationset.js +255 -0
- package/dist/src/animation/animationset.js.map +1 -0
- package/dist/src/animation/animationtrack.js +34 -0
- package/dist/src/animation/animationtrack.js.map +1 -0
- package/dist/src/animation/eulerrotationtrack.js +52 -0
- package/dist/src/animation/eulerrotationtrack.js.map +1 -0
- package/dist/src/animation/morphtarget.js +93 -0
- package/dist/src/animation/morphtarget.js.map +1 -0
- package/dist/src/animation/morphtrack.js +70 -0
- package/dist/src/animation/morphtrack.js.map +1 -0
- package/dist/src/animation/proptrack.js +161 -0
- package/dist/src/animation/proptrack.js.map +1 -0
- package/dist/src/animation/rotationtrack.js +51 -0
- package/dist/src/animation/rotationtrack.js.map +1 -0
- package/dist/src/animation/scaletrack.js +50 -0
- package/dist/src/animation/scaletrack.js.map +1 -0
- package/dist/src/animation/skeleton.js +204 -0
- package/dist/src/animation/skeleton.js.map +1 -0
- package/dist/src/animation/translationtrack.js +50 -0
- package/dist/src/animation/translationtrack.js.map +1 -0
- package/dist/{app.js → src/app/app.js} +18 -40
- package/dist/src/app/app.js.map +1 -0
- package/dist/{input → src/app}/inputmgr.js +41 -16
- package/dist/src/app/inputmgr.js.map +1 -0
- package/dist/src/asset/assetmanager.js +404 -0
- package/dist/src/asset/assetmanager.js.map +1 -0
- package/dist/src/asset/builtin.js +337 -0
- package/dist/src/asset/builtin.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds.js +470 -0
- package/dist/src/asset/loaders/dds/dds.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
- package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/helpers.js +327 -0
- package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/src/asset/loaders/hdr/hdr.js +180 -0
- package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
- package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
- package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/src/asset/loaders/loader.js +45 -0
- package/dist/src/asset/loaders/loader.js.map +1 -0
- package/dist/src/asset/model.js +414 -0
- package/dist/src/asset/model.js.map +1 -0
- package/dist/{blitter/depthlimitedgaussion.js → src/blitter/bilateralblur.js} +1 -2
- package/dist/src/blitter/bilateralblur.js.map +1 -0
- package/dist/src/blitter/blitter.js +390 -0
- package/dist/src/blitter/blitter.js.map +1 -0
- package/dist/src/blitter/box.js +118 -0
- package/dist/src/blitter/box.js.map +1 -0
- package/dist/src/blitter/copy.js +22 -0
- package/dist/src/blitter/copy.js.map +1 -0
- package/dist/src/blitter/gaussianblur.js +228 -0
- package/dist/src/blitter/gaussianblur.js.map +1 -0
- package/dist/src/camera/base.js +92 -0
- package/dist/src/camera/base.js.map +1 -0
- package/dist/src/camera/camera.js +1005 -0
- package/dist/src/camera/camera.js.map +1 -0
- package/dist/src/camera/fps.js +238 -0
- package/dist/src/camera/fps.js.map +1 -0
- package/dist/src/camera/orbit.js +245 -0
- package/dist/src/camera/orbit.js.map +1 -0
- package/dist/src/camera/orthocamera.js +167 -0
- package/dist/src/camera/orthocamera.js.map +1 -0
- package/dist/src/camera/perspectivecamera.js +141 -0
- package/dist/src/camera/perspectivecamera.js.map +1 -0
- package/dist/src/index.js +120 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/material/blinn.js +81 -0
- package/dist/src/material/blinn.js.map +1 -0
- package/dist/src/material/grassmaterial.js +113 -0
- package/dist/src/material/grassmaterial.js.map +1 -0
- package/dist/src/material/lambert.js +92 -0
- package/dist/src/material/lambert.js.map +1 -0
- package/dist/src/material/material.js +301 -0
- package/dist/src/material/material.js.map +1 -0
- package/dist/src/material/meshmaterial.js +704 -0
- package/dist/src/material/meshmaterial.js.map +1 -0
- package/dist/src/material/mixins/albedocolor.js +76 -0
- package/dist/src/material/mixins/albedocolor.js.map +1 -0
- package/dist/src/material/mixins/foliage.js +47 -0
- package/dist/src/material/mixins/foliage.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
- package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
- package/dist/src/material/mixins/lit.js +476 -0
- package/dist/src/material/mixins/lit.js.map +1 -0
- package/dist/src/material/mixins/pbr/common.js +918 -0
- package/dist/src/material/mixins/pbr/common.js.map +1 -0
- package/dist/src/material/mixins/texture.js +172 -0
- package/dist/src/material/mixins/texture.js.map +1 -0
- package/dist/src/material/mixins/vertexcolor.js +56 -0
- package/dist/src/material/mixins/vertexcolor.js.map +1 -0
- package/dist/src/material/particle.js +178 -0
- package/dist/src/material/particle.js.map +1 -0
- package/dist/src/material/pbrmr.js +97 -0
- package/dist/src/material/pbrmr.js.map +1 -0
- package/dist/src/material/pbrsg.js +97 -0
- package/dist/src/material/pbrsg.js.map +1 -0
- package/dist/src/material/shader/helper.js +1209 -0
- package/dist/src/material/shader/helper.js.map +1 -0
- package/dist/src/material/terrain-cm.js +606 -0
- package/dist/src/material/terrain-cm.js.map +1 -0
- package/dist/src/material/terrainmaterial.js +375 -0
- package/dist/src/material/terrainmaterial.js.map +1 -0
- package/dist/src/material/unlit.js +41 -0
- package/dist/src/material/unlit.js.map +1 -0
- package/dist/src/material/water.js +417 -0
- package/dist/src/material/water.js.map +1 -0
- package/dist/src/posteffect/bloom.js +361 -0
- package/dist/src/posteffect/bloom.js.map +1 -0
- package/dist/src/posteffect/compositor.js +226 -0
- package/dist/src/posteffect/compositor.js.map +1 -0
- package/dist/src/posteffect/fxaa.js +273 -0
- package/dist/src/posteffect/fxaa.js.map +1 -0
- package/dist/src/posteffect/grayscale.js +69 -0
- package/dist/src/posteffect/grayscale.js.map +1 -0
- package/dist/src/posteffect/motionblur.js +96 -0
- package/dist/src/posteffect/motionblur.js.map +1 -0
- package/dist/src/posteffect/posteffect.js +126 -0
- package/dist/src/posteffect/posteffect.js.map +1 -0
- package/dist/src/posteffect/sao.js +324 -0
- package/dist/src/posteffect/sao.js.map +1 -0
- package/dist/src/posteffect/ssr.js +489 -0
- package/dist/src/posteffect/ssr.js.map +1 -0
- package/dist/src/posteffect/taa.js +172 -0
- package/dist/src/posteffect/taa.js.map +1 -0
- package/dist/src/posteffect/tonemap.js +94 -0
- package/dist/src/posteffect/tonemap.js.map +1 -0
- package/dist/src/render/abuffer_oit.js +361 -0
- package/dist/src/render/abuffer_oit.js.map +1 -0
- package/dist/src/render/clipmap.js +851 -0
- package/dist/src/render/clipmap.js.map +1 -0
- package/dist/src/render/cluster_light.js +333 -0
- package/dist/src/render/cluster_light.js.map +1 -0
- package/dist/src/render/cull_visitor.js +187 -0
- package/dist/src/render/cull_visitor.js.map +1 -0
- package/dist/src/render/depthpass.js +68 -0
- package/dist/src/render/depthpass.js.map +1 -0
- package/dist/src/render/drawable_mixin.js +227 -0
- package/dist/src/render/drawable_mixin.js.map +1 -0
- package/dist/src/render/envlight.js +463 -0
- package/dist/src/render/envlight.js.map +1 -0
- package/dist/src/render/fbm_wavegenerator.js +251 -0
- package/dist/src/render/fbm_wavegenerator.js.map +1 -0
- package/dist/src/render/fft_wavegenerator.js +1006 -0
- package/dist/src/render/fft_wavegenerator.js.map +1 -0
- package/dist/src/render/fullscreenquad.js +38 -0
- package/dist/src/render/fullscreenquad.js.map +1 -0
- package/dist/src/render/gerstner_wavegenerator.js +314 -0
- package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
- package/dist/src/render/globalbindgroup_allocator.js +60 -0
- package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
- package/dist/src/render/hzb.js +273 -0
- package/dist/src/render/hzb.js.map +1 -0
- package/dist/src/render/lightpass.js +172 -0
- package/dist/src/render/lightpass.js.map +1 -0
- package/dist/src/render/objectcolorpass.js +51 -0
- package/dist/src/render/objectcolorpass.js.map +1 -0
- package/dist/src/render/primitive.js +364 -0
- package/dist/src/render/primitive.js.map +1 -0
- package/dist/src/render/render_queue.js +467 -0
- package/dist/src/render/render_queue.js.map +1 -0
- package/dist/src/render/renderbundle_wrapper.js +152 -0
- package/dist/src/render/renderbundle_wrapper.js.map +1 -0
- package/dist/src/render/renderer.js +455 -0
- package/dist/src/render/renderer.js.map +1 -0
- package/dist/src/render/renderpass.js +200 -0
- package/dist/src/render/renderpass.js.map +1 -0
- package/dist/src/render/shadowmap_pass.js +56 -0
- package/dist/src/render/shadowmap_pass.js.map +1 -0
- package/dist/src/render/sky.js +1103 -0
- package/dist/src/render/sky.js.map +1 -0
- package/dist/src/render/weightedblended_oit.js +168 -0
- package/dist/src/render/weightedblended_oit.js.map +1 -0
- package/dist/src/scene/batchgroup.js +162 -0
- package/dist/src/scene/batchgroup.js.map +1 -0
- package/dist/src/scene/environment.js +209 -0
- package/dist/src/scene/environment.js.map +1 -0
- package/dist/src/scene/graph_node.js +72 -0
- package/dist/src/scene/graph_node.js.map +1 -0
- package/dist/src/scene/light.js +416 -0
- package/dist/src/scene/light.js.map +1 -0
- package/dist/src/scene/mesh.js +341 -0
- package/dist/src/scene/mesh.js.map +1 -0
- package/dist/src/scene/octree.js +649 -0
- package/dist/src/scene/octree.js.map +1 -0
- package/dist/src/scene/particlesys.js +738 -0
- package/dist/src/scene/particlesys.js.map +1 -0
- package/dist/src/scene/raycast_visitor.js +103 -0
- package/dist/src/scene/raycast_visitor.js.map +1 -0
- package/dist/src/scene/scene.js +284 -0
- package/dist/src/scene/scene.js.map +1 -0
- package/dist/src/scene/scene_node.js +732 -0
- package/dist/src/scene/scene_node.js.map +1 -0
- package/dist/src/scene/terrain/grass.js +278 -0
- package/dist/src/scene/terrain/grass.js.map +1 -0
- package/dist/src/scene/terrain/heightfield.js +475 -0
- package/dist/src/scene/terrain/heightfield.js.map +1 -0
- package/dist/src/scene/terrain/patch.js +530 -0
- package/dist/src/scene/terrain/patch.js.map +1 -0
- package/dist/src/scene/terrain/quadtree.js +461 -0
- package/dist/src/scene/terrain/quadtree.js.map +1 -0
- package/dist/src/scene/terrain/terrain.js +246 -0
- package/dist/src/scene/terrain/terrain.js.map +1 -0
- package/dist/src/scene/terrain-cm/grass.js +594 -0
- package/dist/src/scene/terrain-cm/grass.js.map +1 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/src/scene/water.js +374 -0
- package/dist/src/scene/water.js.map +1 -0
- package/dist/src/shaders/atmosphere.js +957 -0
- package/dist/src/shaders/atmosphere.js.map +1 -0
- package/dist/src/shaders/fog.js +112 -0
- package/dist/src/shaders/fog.js.map +1 -0
- package/dist/src/shaders/misc.js +266 -0
- package/dist/src/shaders/misc.js.map +1 -0
- package/dist/src/shaders/noise.js +222 -0
- package/dist/src/shaders/noise.js.map +1 -0
- package/dist/src/shaders/pbr.js +51 -0
- package/dist/src/shaders/pbr.js.map +1 -0
- package/dist/src/shaders/shadow.js +636 -0
- package/dist/src/shaders/shadow.js.map +1 -0
- package/dist/src/shaders/ssr.js +490 -0
- package/dist/src/shaders/ssr.js.map +1 -0
- package/dist/src/shaders/temporal.js +215 -0
- package/dist/src/shaders/temporal.js.map +1 -0
- package/dist/src/shaders/water.js +756 -0
- package/dist/src/shaders/water.js.map +1 -0
- package/dist/src/shadow/esm.js +237 -0
- package/dist/src/shadow/esm.js.map +1 -0
- package/dist/src/shadow/pcf_opt.js +181 -0
- package/dist/src/shadow/pcf_opt.js.map +1 -0
- package/dist/src/shadow/pcf_pd.js +189 -0
- package/dist/src/shadow/pcf_pd.js.map +1 -0
- package/dist/src/shadow/shader.js +37 -0
- package/dist/src/shadow/shader.js.map +1 -0
- package/dist/src/shadow/shadow_impl.js +15 -0
- package/dist/src/shadow/shadow_impl.js.map +1 -0
- package/dist/src/shadow/shadowmapper.js +790 -0
- package/dist/src/shadow/shadowmapper.js.map +1 -0
- package/dist/src/shadow/ssm.js +159 -0
- package/dist/src/shadow/ssm.js.map +1 -0
- package/dist/src/shadow/vsm.js +297 -0
- package/dist/src/shadow/vsm.js.map +1 -0
- package/dist/src/shapes/box.js +386 -0
- package/dist/src/shapes/box.js.map +1 -0
- package/dist/src/shapes/cylinder.js +125 -0
- package/dist/src/shapes/cylinder.js.map +1 -0
- package/dist/src/shapes/plane.js +88 -0
- package/dist/src/shapes/plane.js.map +1 -0
- package/dist/src/shapes/shape.js +87 -0
- package/dist/src/shapes/shape.js.map +1 -0
- package/dist/src/shapes/sphere.js +114 -0
- package/dist/src/shapes/sphere.js.map +1 -0
- package/dist/src/shapes/tetrahedron.js +188 -0
- package/dist/src/shapes/tetrahedron.js.map +1 -0
- package/dist/src/shapes/torus.js +111 -0
- package/dist/src/shapes/torus.js.map +1 -0
- package/dist/src/utility/aabbtree.js +400 -0
- package/dist/src/utility/aabbtree.js.map +1 -0
- package/dist/src/utility/bounding_volume.js +29 -0
- package/dist/src/utility/bounding_volume.js.map +1 -0
- package/dist/src/utility/debug.js +28 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/draco/decoder.js +116 -0
- package/dist/src/utility/draco/decoder.js.map +1 -0
- package/dist/src/utility/misc.js +105 -0
- package/dist/src/utility/misc.js.map +1 -0
- package/dist/src/utility/panorama.js +163 -0
- package/dist/src/utility/panorama.js.map +1 -0
- package/dist/src/utility/pmrem.js +354 -0
- package/dist/src/utility/pmrem.js.map +1 -0
- package/dist/src/utility/rendermipmap.js +115 -0
- package/dist/src/utility/rendermipmap.js.map +1 -0
- package/dist/src/utility/serialization/json.js +402 -0
- package/dist/src/utility/serialization/json.js.map +1 -0
- package/dist/src/utility/serialization/manager.js +623 -0
- package/dist/src/utility/serialization/manager.js.map +1 -0
- package/dist/src/utility/serialization/scene/animation.js +248 -0
- package/dist/src/utility/serialization/scene/animation.js.map +1 -0
- package/dist/src/utility/serialization/scene/batch.js +59 -0
- package/dist/src/utility/serialization/scene/batch.js.map +1 -0
- package/dist/src/utility/serialization/scene/camera.js +790 -0
- package/dist/src/utility/serialization/scene/camera.js.map +1 -0
- package/dist/src/utility/serialization/scene/common.js +222 -0
- package/dist/src/utility/serialization/scene/common.js.map +1 -0
- package/dist/src/utility/serialization/scene/light.js +575 -0
- package/dist/src/utility/serialization/scene/light.js.map +1 -0
- package/dist/src/utility/serialization/scene/material.js +1111 -0
- package/dist/src/utility/serialization/scene/material.js.map +1 -0
- package/dist/src/utility/serialization/scene/mesh.js +148 -0
- package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/src/utility/serialization/scene/misc.js +39 -0
- package/dist/src/utility/serialization/scene/misc.js.map +1 -0
- package/dist/src/utility/serialization/scene/node.js +451 -0
- package/dist/src/utility/serialization/scene/node.js.map +1 -0
- package/dist/src/utility/serialization/scene/particle.js +425 -0
- package/dist/src/utility/serialization/scene/particle.js.map +1 -0
- package/dist/src/utility/serialization/scene/primitive.js +692 -0
- package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/src/utility/serialization/scene/scene.js +704 -0
- package/dist/src/utility/serialization/scene/scene.js.map +1 -0
- package/dist/src/utility/serialization/scene/terrain.js +488 -0
- package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/src/utility/serialization/scene/water.js +465 -0
- package/dist/src/utility/serialization/scene/water.js.map +1 -0
- package/dist/src/utility/shprojector.js +297 -0
- package/dist/src/utility/shprojector.js.map +1 -0
- package/dist/{material/mixins → src/utility/textures}/ggxlut.js +1 -1
- package/dist/src/utility/textures/ggxlut.js.map +1 -0
- package/dist/src/utility/textures/gradientnoise.js +62 -0
- package/dist/src/utility/textures/gradientnoise.js.map +1 -0
- package/dist/src/utility/textures/randomnoise.js +41 -0
- package/dist/src/utility/textures/randomnoise.js.map +1 -0
- package/dist/src/values.js +162 -0
- package/dist/src/values.js.map +1 -0
- package/dist/utility/aabbtree.js +16 -6
- package/dist/utility/aabbtree.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +1325 -0
- package/dist/utility/blueprint/common/constants.js.map +1 -0
- package/dist/utility/blueprint/common/math.js +2507 -0
- package/dist/utility/blueprint/common/math.js.map +1 -0
- package/dist/utility/blueprint/common.js +7 -0
- package/dist/utility/blueprint/common.js.map +1 -0
- package/dist/utility/blueprint/material/common.js +7 -0
- package/dist/utility/blueprint/material/common.js.map +1 -0
- package/dist/utility/blueprint/material/func.js +525 -0
- package/dist/utility/blueprint/material/func.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +1659 -0
- package/dist/utility/blueprint/material/inputs.js.map +1 -0
- package/dist/utility/blueprint/material/ir.js +1519 -0
- package/dist/utility/blueprint/material/ir.js.map +1 -0
- package/dist/utility/blueprint/material/pbr.js +450 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -0
- package/dist/utility/blueprint/material/texture.js +1116 -0
- package/dist/utility/blueprint/material/texture.js.map +1 -0
- package/dist/utility/blueprint/node.js +214 -0
- package/dist/utility/blueprint/node.js.map +1 -0
- package/dist/utility/bounding_volume.js +0 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/debug.js +26 -0
- package/dist/utility/debug.js.map +1 -0
- package/dist/utility/draco/decoder.js +1 -1
- package/dist/utility/draco/decoder.js.map +1 -1
- package/dist/utility/misc.js +19 -7
- package/dist/utility/misc.js.map +1 -1
- package/dist/utility/panorama.js +8 -6
- package/dist/utility/panorama.js.map +1 -1
- package/dist/utility/pmrem.js +30 -18
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/rendermipmap.js +116 -0
- package/dist/utility/rendermipmap.js.map +1 -0
- package/dist/utility/serialization/blueprint/constants.js +255 -0
- package/dist/utility/serialization/blueprint/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/constants.js +203 -0
- package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/texture.js +165 -0
- package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
- package/dist/utility/serialization/json.js +406 -0
- package/dist/utility/serialization/json.js.map +1 -0
- package/dist/utility/serialization/manager.js +1243 -0
- package/dist/utility/serialization/manager.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +701 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -0
- package/dist/utility/serialization/scene/batch.js +54 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -0
- package/dist/utility/serialization/scene/camera.js +896 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +298 -0
- package/dist/utility/serialization/scene/common.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +591 -0
- package/dist/utility/serialization/scene/light.js.map +1 -0
- package/dist/utility/serialization/scene/material.js +1070 -0
- package/dist/utility/serialization/scene/material.js.map +1 -0
- package/dist/utility/serialization/scene/mesh.js +345 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/utility/serialization/scene/misc.js +40 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -0
- package/dist/utility/serialization/scene/node.js +424 -0
- package/dist/utility/serialization/scene/node.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +427 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +585 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/utility/serialization/scene/scene.js +764 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -0
- package/dist/utility/serialization/scene/sprite.js +164 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -0
- package/dist/utility/serialization/scene/terrain.js +497 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +467 -0
- package/dist/utility/serialization/scene/water.js.map +1 -0
- package/dist/utility/serialization/types.js +6 -0
- package/dist/utility/serialization/types.js.map +1 -0
- package/dist/utility/shprojector.js +313 -0
- package/dist/utility/shprojector.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +4 -5
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/gradientnoise.js +2 -1
- package/dist/utility/textures/gradientnoise.js.map +1 -1
- package/dist/utility/textures/randomnoise.js +1 -0
- package/dist/utility/textures/randomnoise.js.map +1 -1
- package/dist/values.js +103 -16
- package/dist/values.js.map +1 -1
- package/package.json +80 -66
- package/dist/app.js.map +0 -1
- package/dist/blitter/depthlimitedgaussion.js.map +0 -1
- package/dist/input/inputmgr.js.map +0 -1
- package/dist/material/mixins/ggxlut.js.map +0 -1
- package/dist/posteffect/water.js +0 -508
- package/dist/posteffect/water.js.map +0 -1
- package/dist/render/oit.js +0 -16
- package/dist/render/oit.js.map +0 -1
- package/dist/render/scatteringlut.js +0 -634
- package/dist/render/scatteringlut.js.map +0 -1
- package/dist/render/watermesh.js +0 -193
- package/dist/render/watermesh.js.map +0 -1
- package/dist/render/wavegenerator.js +0 -8
- package/dist/render/wavegenerator.js.map +0 -1
- package/dist/scene/xform.js +0 -247
- package/dist/scene/xform.js.map +0 -1
- package/dist/utility/shprojection.js +0 -442
- package/dist/utility/shprojection.js.map +0 -1
package/dist/render/renderer.js
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { LightPass } from './lightpass.js';
|
|
2
2
|
import { ShadowMapPass } from './shadowmap_pass.js';
|
|
3
3
|
import { DepthPass } from './depthpass.js';
|
|
4
|
-
import { Vector4, isPowerOf2, nextPowerOf2 } from '@zephyr3d/base';
|
|
5
|
-
import
|
|
4
|
+
import { Vector4, isPowerOf2, nextPowerOf2, Matrix4x4, Vector3 } from '@zephyr3d/base';
|
|
5
|
+
import './primitive.js';
|
|
6
6
|
import '@zephyr3d/device';
|
|
7
|
+
import { getDevice } from '../app/api.js';
|
|
7
8
|
import { CopyBlitter } from '../blitter/copy.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import '../material/shader/helper.js';
|
|
11
|
-
import '../scene/xform.js';
|
|
12
|
-
import '../scene/octree.js';
|
|
13
|
-
import '../material/lambert.js';
|
|
14
|
-
import '../material/blinn.js';
|
|
15
|
-
import '../material/unlit.js';
|
|
16
|
-
import '../material/meshmaterial.js';
|
|
17
|
-
import '../material/grassmaterial.js';
|
|
18
|
-
import '../material/terrainmaterial.js';
|
|
19
|
-
import '../material/pbrmr.js';
|
|
20
|
-
import '../material/pbrsg.js';
|
|
21
|
-
import './sky.js';
|
|
22
|
-
import './clipmap.js';
|
|
23
|
-
import { fetchSampler } from '../utility/misc.js';
|
|
24
|
-
import { PerspectiveCamera } from '../camera/perspectivecamera.js';
|
|
25
|
-
import { Compositor } from '../posteffect/compositor.js';
|
|
9
|
+
import { Camera } from '../camera/camera.js';
|
|
10
|
+
import { PostEffectLayer, AbstractPostEffect } from '../posteffect/posteffect.js';
|
|
26
11
|
import { ClusteredLight } from './cluster_light.js';
|
|
27
12
|
import { GlobalBindGroupAllocator } from './globalbindgroup_allocator.js';
|
|
28
13
|
import { ObjectColorPass } from './objectcolorpass.js';
|
|
29
14
|
import { buildHiZ } from './hzb.js';
|
|
15
|
+
import { MaterialVaryingFlags } from '../values.js';
|
|
16
|
+
import { fetchSampler } from '../utility/misc.js';
|
|
17
|
+
import { BoxShape } from '../shapes/box.js';
|
|
18
|
+
import '../shapes/cylinder.js';
|
|
19
|
+
import '../shapes/torus.js';
|
|
20
|
+
import '../shapes/plane.js';
|
|
21
|
+
import '../shapes/sphere.js';
|
|
22
|
+
import '../shapes/tetrahedron.js';
|
|
30
23
|
|
|
31
24
|
/**
|
|
32
25
|
* Forward render scheme
|
|
33
26
|
* @internal
|
|
34
27
|
*/ class SceneRenderer {
|
|
35
|
-
/** @internal */ static
|
|
28
|
+
/** @internal */ static _skyMotionVectorProgram = null;
|
|
29
|
+
/** @internal */ static _skyMotionVectorBindGroup = null;
|
|
30
|
+
static _box = null;
|
|
31
|
+
/** @internal */ static _pickCamera = new Camera(null);
|
|
36
32
|
/** @internal */ static _scenePass = new LightPass();
|
|
37
33
|
/** @internal */ static _depthPass = new DepthPass();
|
|
38
34
|
/** @internal */ static _shadowMapPass = new ShadowMapPass();
|
|
@@ -49,9 +45,6 @@ import { buildHiZ } from './hzb.js';
|
|
|
49
45
|
/** shadow map render pass */ static get shadowMapRenderPass() {
|
|
50
46
|
return this._shadowMapPass;
|
|
51
47
|
}
|
|
52
|
-
/** @internal */ static setClearColor(color) {
|
|
53
|
-
this._scenePass.clearColor = color;
|
|
54
|
-
}
|
|
55
48
|
/** @internal */ static getClusteredLight() {
|
|
56
49
|
if (this._clusters.length > 0) {
|
|
57
50
|
return this._clusters.pop();
|
|
@@ -63,107 +56,141 @@ import { buildHiZ } from './hzb.js';
|
|
|
63
56
|
}
|
|
64
57
|
/**
|
|
65
58
|
* Renders a scene by given camera
|
|
66
|
-
* @param scene - The scene
|
|
59
|
+
* @param scene - The scene tondered
|
|
67
60
|
* @param camera - The camera that will be used to render the scene
|
|
68
61
|
* @param compositor - The compositor that will be used to apply postprocess effects
|
|
69
|
-
*/ static renderScene(scene, camera
|
|
70
|
-
const device =
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
primaryCamera: camera,
|
|
75
|
-
picking: false,
|
|
76
|
-
oit: null,
|
|
77
|
-
HiZ: camera.HiZ && device.type !== 'webgl',
|
|
78
|
-
HiZTexture: null,
|
|
79
|
-
globalBindGroupAllocator: GlobalBindGroupAllocator.get(),
|
|
80
|
-
camera,
|
|
81
|
-
compositor: compositor ?? this._defaultCompositor,
|
|
82
|
-
timestamp: device.frameInfo.frameTimestamp,
|
|
83
|
-
queue: 0,
|
|
84
|
-
lightBlending: false,
|
|
85
|
-
renderPass: null,
|
|
86
|
-
renderPassHash: null,
|
|
87
|
-
applyFog: null,
|
|
88
|
-
flip: false,
|
|
89
|
-
drawEnvLight: false,
|
|
90
|
-
env: null,
|
|
91
|
-
materialFlags: 0
|
|
92
|
-
};
|
|
62
|
+
*/ static renderScene(scene, camera) {
|
|
63
|
+
const device = getDevice();
|
|
64
|
+
const colorFormat = camera.HDR && device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';
|
|
65
|
+
const depthFormat = device.getDeviceCaps().framebufferCaps.supportDepth32floatStencil8 ? 'd32fs8' : 'd24s8';
|
|
66
|
+
const globalBindGroupAllocator = GlobalBindGroupAllocator.get();
|
|
93
67
|
scene.frameUpdate();
|
|
68
|
+
scene.frameUpdatePerCamera(camera);
|
|
94
69
|
if (camera && !device.isContextLost()) {
|
|
70
|
+
const defaultViewport = !camera.viewport && !camera.scissor;
|
|
71
|
+
const renderX = camera.viewport ? device.screenXToDevice(camera.viewport[0]) : 0;
|
|
72
|
+
const renderY = camera.viewport ? device.screenYToDevice(camera.viewport[1]) : 0;
|
|
73
|
+
const renderWidth = camera.viewport ? device.screenXToDevice(camera.viewport[2]) : device.getDrawingBufferWidth();
|
|
74
|
+
const renderHeight = camera.viewport ? device.screenYToDevice(camera.viewport[3]) : device.getDrawingBufferHeight();
|
|
75
|
+
if (renderWidth <= 0 || renderHeight <= 0) {
|
|
76
|
+
camera.getPickResultResolveFunc()?.(null);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const tmpFramebuffer = defaultViewport ? null : device.pool.fetchTemporalFramebuffer(false, renderWidth, renderHeight, colorFormat, depthFormat);
|
|
80
|
+
const originFramebuffer = device.getFramebuffer();
|
|
81
|
+
if (tmpFramebuffer) {
|
|
82
|
+
device.pushDeviceStates();
|
|
83
|
+
device.setFramebuffer(tmpFramebuffer);
|
|
84
|
+
}
|
|
85
|
+
device.clearFrameBuffer(camera.clearColor, camera.clearDepth, camera.clearStencil);
|
|
86
|
+
const SSR = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();
|
|
87
|
+
const ctx = {
|
|
88
|
+
device,
|
|
89
|
+
scene,
|
|
90
|
+
renderWidth,
|
|
91
|
+
renderHeight,
|
|
92
|
+
oit: null,
|
|
93
|
+
motionVectors: device.type !== 'webgl' && (camera.TAA || camera.motionBlur),
|
|
94
|
+
HiZ: camera.HiZ && device.type !== 'webgl',
|
|
95
|
+
HiZTexture: null,
|
|
96
|
+
globalBindGroupAllocator,
|
|
97
|
+
camera,
|
|
98
|
+
compositor: camera.compositor,
|
|
99
|
+
queue: 0,
|
|
100
|
+
lightBlending: false,
|
|
101
|
+
renderPass: null,
|
|
102
|
+
renderPassHash: null,
|
|
103
|
+
flip: false,
|
|
104
|
+
depthFormat,
|
|
105
|
+
colorFormat,
|
|
106
|
+
drawEnvLight: false,
|
|
107
|
+
env: null,
|
|
108
|
+
materialFlags: 0,
|
|
109
|
+
SSR,
|
|
110
|
+
SSRCalcThickness: SSR && camera.ssrCalcThickness,
|
|
111
|
+
SSRRoughnessTexture: device.pool.fetchTemporalTexture2D(true, 'rgba8unorm', renderWidth, renderHeight),
|
|
112
|
+
SSRNormalTexture: device.pool.fetchTemporalTexture2D(true, 'rgba8unorm', renderWidth, renderHeight),
|
|
113
|
+
finalFramebuffer: device.getFramebuffer(),
|
|
114
|
+
intermediateFramebuffer: null
|
|
115
|
+
};
|
|
95
116
|
this._renderScene(ctx);
|
|
117
|
+
if (tmpFramebuffer) {
|
|
118
|
+
device.popDeviceStates();
|
|
119
|
+
const oversizedViewport = renderX < 0 || renderY < 0 || renderX + renderWidth > device.getDrawingBufferWidth() || renderY + renderHeight > device.getDrawingBufferHeight();
|
|
120
|
+
const blitter = new CopyBlitter();
|
|
121
|
+
if (oversizedViewport) {
|
|
122
|
+
blitter.destRect = [
|
|
123
|
+
renderX,
|
|
124
|
+
renderY,
|
|
125
|
+
renderWidth,
|
|
126
|
+
renderHeight
|
|
127
|
+
];
|
|
128
|
+
} else {
|
|
129
|
+
blitter.viewport = camera.viewport ? camera.viewport.slice() : null;
|
|
130
|
+
}
|
|
131
|
+
blitter.scissor = camera.scissor ? camera.scissor.slice() : null;
|
|
132
|
+
blitter.srgbOut = !originFramebuffer;
|
|
133
|
+
blitter.blit(tmpFramebuffer.getColorAttachments()[0], originFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
134
|
+
device.pool.releaseFrameBuffer(tmpFramebuffer);
|
|
135
|
+
}
|
|
96
136
|
}
|
|
97
|
-
GlobalBindGroupAllocator.release(
|
|
137
|
+
GlobalBindGroupAllocator.release(globalBindGroupAllocator);
|
|
98
138
|
}
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
139
|
+
static renderSceneDepth(ctx, renderQueue, depthFramebuffer) {
|
|
140
|
+
const transmission = !!depthFramebuffer;
|
|
141
|
+
if (!depthFramebuffer) {
|
|
142
|
+
const format = ctx.device.type === 'webgl' ? ctx.SSRCalcThickness ? 'rgba16f' : 'rgba8unorm' : ctx.SSRCalcThickness ? 'rg32f' : 'r32f';
|
|
143
|
+
const mvFormat = 'rgba16f';
|
|
144
|
+
if (!ctx.finalFramebuffer) {
|
|
145
|
+
depthFramebuffer = ctx.device.pool.fetchTemporalFramebuffer(true, ctx.renderWidth, ctx.renderHeight, ctx.motionVectors ? [
|
|
146
|
+
format,
|
|
147
|
+
mvFormat
|
|
148
|
+
] : format, ctx.depthFormat, false);
|
|
149
|
+
} else {
|
|
150
|
+
const originDepth = ctx.finalFramebuffer?.getDepthAttachment();
|
|
151
|
+
depthFramebuffer = originDepth?.isTexture2D() ? ctx.device.pool.fetchTemporalFramebuffer(true, originDepth.width, originDepth.height, ctx.motionVectors ? [
|
|
152
|
+
format,
|
|
153
|
+
mvFormat
|
|
154
|
+
] : format, originDepth, false) : ctx.device.pool.fetchTemporalFramebuffer(true, ctx.renderWidth, ctx.renderHeight, ctx.motionVectors ? [
|
|
155
|
+
format,
|
|
156
|
+
mvFormat
|
|
157
|
+
] : format, ctx.depthFormat, false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
ctx.device.pushDeviceStates();
|
|
161
|
+
ctx.device.setFramebuffer(depthFramebuffer);
|
|
103
162
|
this._depthPass.encodeDepth = depthFramebuffer.getColorAttachments()[0].format === 'rgba8unorm';
|
|
104
|
-
this._depthPass.clearColor = this._depthPass.encodeDepth ? new Vector4(0, 0, 0, 1) : new Vector4(1, 1, 1, 1);
|
|
105
|
-
this._depthPass.clearDepth = 1;
|
|
106
|
-
|
|
163
|
+
this._depthPass.clearColor = transmission ? null : this._depthPass.encodeDepth ? new Vector4(0, 0, 0, 1) : new Vector4(1, 1, 1, 1);
|
|
164
|
+
this._depthPass.clearDepth = transmission ? null : 1;
|
|
165
|
+
this._depthPass.clearStencil = null;
|
|
166
|
+
this._depthPass.transmission = transmission;
|
|
167
|
+
if (ctx.SSRCalcThickness && !transmission) {
|
|
107
168
|
if (!this._backDepthColorState) {
|
|
108
|
-
this._backDepthColorState = device.createColorState().setColorMask(false, true, false, false);
|
|
169
|
+
this._backDepthColorState = ctx.device.createColorState().setColorMask(false, true, false, false);
|
|
109
170
|
}
|
|
110
171
|
if (!this._frontDepthColorState) {
|
|
111
|
-
this._frontDepthColorState = device.createColorState().setColorMask(true, false, false, false);
|
|
172
|
+
this._frontDepthColorState = ctx.device.createColorState().setColorMask(true, false, false, false);
|
|
112
173
|
}
|
|
113
174
|
ctx.forceColorState = this._backDepthColorState;
|
|
114
175
|
ctx.forceCullMode = 'front';
|
|
115
176
|
this._depthPass.renderBackface = true;
|
|
116
|
-
this._depthPass.
|
|
177
|
+
this._depthPass.transmission = false;
|
|
178
|
+
this._depthPass.render(ctx, null, null, renderQueue);
|
|
117
179
|
this._depthPass.clearColor = null;
|
|
118
180
|
this._depthPass.renderBackface = false;
|
|
119
181
|
ctx.forceColorState = this._frontDepthColorState;
|
|
120
182
|
ctx.forceCullMode = null;
|
|
121
183
|
}
|
|
122
|
-
this._depthPass.render(ctx, null, renderQueue);
|
|
184
|
+
this._depthPass.render(ctx, null, null, renderQueue);
|
|
123
185
|
ctx.forceColorState = null;
|
|
124
|
-
device.popDeviceStates();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const device = ctx.device;
|
|
128
|
-
const SSR = ctx.primaryCamera.SSR && ctx.scene.env.light.envLight && ctx.scene.env.light.envLight.hasRadiance();
|
|
129
|
-
const SSRCalcThickness = SSR && ctx.primaryCamera.ssrCalcThickness;
|
|
130
|
-
const vp = ctx.camera.viewport;
|
|
131
|
-
const scissor = ctx.camera.scissor;
|
|
132
|
-
const finalFramebuffer = device.getFramebuffer();
|
|
133
|
-
const drawingBufferWidth = device.getDrawingBufferWidth();
|
|
134
|
-
const drawingBufferHeight = device.getDrawingBufferHeight();
|
|
135
|
-
ctx.depthFormat = 'd24s8';
|
|
136
|
-
ctx.viewportX = finalFramebuffer ? vp?.[0] ?? 0 : device.screenToDevice(vp?.[0] ?? 0);
|
|
137
|
-
ctx.viewportY = finalFramebuffer ? vp?.[1] ?? 0 : device.screenToDevice(vp?.[1] ?? 0);
|
|
138
|
-
ctx.viewportWidth = finalFramebuffer ? vp?.[2] ?? finalFramebuffer.getWidth() : vp ? device.screenToDevice(vp[2]) : device.getDrawingBufferWidth();
|
|
139
|
-
ctx.viewportHeight = finalFramebuffer ? vp?.[3] ?? finalFramebuffer.getHeight() : vp ? device.screenToDevice(vp[3]) : device.getDrawingBufferHeight();
|
|
140
|
-
ctx.defaultViewport = !finalFramebuffer && !vp;
|
|
141
|
-
const oversizedViewport = vp && !device.getDeviceCaps().miscCaps.supportOversizedViewport && (ctx.viewportX < 0 || ctx.viewportY < 0 || ctx.viewportX + ctx.viewportWidth > drawingBufferWidth || ctx.viewportY + ctx.viewportHeight > drawingBufferHeight);
|
|
142
|
-
// TODO: determin the color buffer format
|
|
143
|
-
const colorFmt = device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';
|
|
144
|
-
let tempFramebuffer = null;
|
|
145
|
-
let depthFramebuffer = null;
|
|
146
|
-
if (ctx.camera.enablePicking) {
|
|
147
|
-
this.renderObjectColors(ctx);
|
|
148
|
-
}
|
|
149
|
-
let HiZFrameBuffer = null;
|
|
150
|
-
const renderQueue = this._scenePass.cullScene(ctx, ctx.camera);
|
|
151
|
-
ctx.sunLight = renderQueue.sunLight;
|
|
152
|
-
ctx.clusteredLight = this.getClusteredLight();
|
|
153
|
-
ctx.clusteredLight.calculateLightIndex(ctx.camera, renderQueue);
|
|
154
|
-
this.renderShadowMaps(ctx, renderQueue.shadowedLights);
|
|
155
|
-
const sampleCount = ctx.compositor ? 1 : ctx.primaryCamera.sampleCount;
|
|
156
|
-
if (SSR || ctx.primaryCamera.depthPrePass || oversizedViewport || renderQueue.needSceneColor || ctx.scene.env.needSceneDepthTexture() || ctx.HiZ || ctx.primaryCamera.oit || ctx.compositor.requireLinearDepth(ctx)) {
|
|
157
|
-
const format = device.type === 'webgl' ? SSRCalcThickness ? 'rgba16f' : 'rgba8unorm' : SSRCalcThickness ? 'rg32f' : 'r32f';
|
|
158
|
-
if (!finalFramebuffer && !vp) {
|
|
159
|
-
depthFramebuffer = device.pool.fetchTemporalFramebuffer(true, drawingBufferWidth, drawingBufferHeight, format, ctx.depthFormat, ctx.HiZ);
|
|
160
|
-
} else {
|
|
161
|
-
const originDepth = finalFramebuffer?.getDepthAttachment();
|
|
162
|
-
depthFramebuffer = originDepth?.isTexture2D() ? device.pool.fetchTemporalFramebuffer(true, originDepth.width, originDepth.height, format, originDepth, ctx.HiZ) : device.pool.fetchTemporalFramebuffer(true, ctx.viewportWidth, ctx.viewportHeight, format, ctx.depthFormat, ctx.HiZ);
|
|
163
|
-
}
|
|
164
|
-
this._renderSceneDepth(ctx, renderQueue, depthFramebuffer, SSRCalcThickness);
|
|
186
|
+
ctx.device.popDeviceStates();
|
|
187
|
+
if (!transmission) {
|
|
188
|
+
ctx.motionVectorTexture = ctx.motionVectors ? depthFramebuffer.getColorAttachments()[1] : null;
|
|
165
189
|
ctx.linearDepthTexture = depthFramebuffer.getColorAttachments()[0];
|
|
166
190
|
ctx.depthTexture = depthFramebuffer.getDepthAttachment();
|
|
191
|
+
if (ctx.motionVectorTexture) {
|
|
192
|
+
this.renderSkyMotionVectors(ctx);
|
|
193
|
+
}
|
|
167
194
|
if (ctx.HiZ) {
|
|
168
195
|
let w = isPowerOf2(ctx.linearDepthTexture.width) ? ctx.linearDepthTexture.width : nextPowerOf2(ctx.linearDepthTexture.width);
|
|
169
196
|
let h = isPowerOf2(ctx.linearDepthTexture.height) ? ctx.linearDepthTexture.height : nextPowerOf2(ctx.linearDepthTexture.height);
|
|
@@ -171,49 +198,63 @@ import { buildHiZ } from './hzb.js';
|
|
|
171
198
|
h = Math.max(1, h >> 1);
|
|
172
199
|
w = ctx.linearDepthTexture.width;
|
|
173
200
|
h = ctx.linearDepthTexture.height;
|
|
174
|
-
HiZFrameBuffer = device.pool.fetchTemporalFramebuffer(true, w, h, ctx.linearDepthTexture.format, null, true);
|
|
201
|
+
const HiZFrameBuffer = ctx.device.pool.fetchTemporalFramebuffer(true, w, h, ctx.linearDepthTexture.format, null, true);
|
|
175
202
|
buildHiZ(ctx.depthTexture, HiZFrameBuffer);
|
|
176
203
|
ctx.HiZTexture = HiZFrameBuffer.getColorAttachments()[0];
|
|
177
204
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
205
|
+
}
|
|
206
|
+
return depthFramebuffer;
|
|
207
|
+
}
|
|
208
|
+
/** @internal */ static _renderScene(ctx) {
|
|
209
|
+
const device = ctx.device;
|
|
210
|
+
// Cull scene
|
|
211
|
+
const renderQueue = this._scenePass.cullScene(ctx, ctx.camera);
|
|
212
|
+
// Update sky
|
|
213
|
+
const sunLightColor = ctx.scene.env.sky.update(ctx);
|
|
214
|
+
// Gather lights
|
|
215
|
+
ctx.clusteredLight = this.getClusteredLight();
|
|
216
|
+
ctx.clusteredLight.calculateLightIndex(ctx.camera, renderQueue);
|
|
217
|
+
// Do GPU ray picking if required
|
|
218
|
+
const pickResolveFunc = ctx.camera.getPickResultResolveFunc();
|
|
219
|
+
if (pickResolveFunc) {
|
|
220
|
+
this.renderObjectColors(ctx, pickResolveFunc, renderQueue);
|
|
221
|
+
}
|
|
222
|
+
// Render shadow maps
|
|
223
|
+
this.renderShadowMaps(ctx, renderQueue.shadowedLights);
|
|
224
|
+
// Render scene depth first
|
|
225
|
+
const depthFramebuffer = this.renderSceneDepth(ctx, renderQueue, null);
|
|
226
|
+
if (ctx.depthTexture === ctx.finalFramebuffer?.getDepthAttachment()) {
|
|
227
|
+
ctx.intermediateFramebuffer = ctx.finalFramebuffer;
|
|
184
228
|
} else {
|
|
185
|
-
ctx.
|
|
186
|
-
ctx.
|
|
187
|
-
if (!vp) {
|
|
188
|
-
tempFramebuffer = finalFramebuffer;
|
|
189
|
-
} else {
|
|
190
|
-
tempFramebuffer = device.pool.fetchTemporalFramebuffer(true, ctx.viewportWidth, ctx.viewportHeight, colorFmt, ctx.depthFormat, false, sampleCount);
|
|
191
|
-
}
|
|
229
|
+
// TODO: fetch resizable framebuffer if ctx.defaultViewport is true
|
|
230
|
+
ctx.intermediateFramebuffer = device.pool.fetchTemporalFramebuffer(false, ctx.depthTexture.width, ctx.depthTexture.height, ctx.colorFormat, ctx.depthTexture);
|
|
192
231
|
}
|
|
193
|
-
if (
|
|
232
|
+
if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {
|
|
194
233
|
device.pushDeviceStates();
|
|
195
|
-
device.setFramebuffer(
|
|
234
|
+
device.setFramebuffer(ctx.intermediateFramebuffer);
|
|
196
235
|
} else {
|
|
197
|
-
device.setViewport(
|
|
198
|
-
device.setScissor(
|
|
236
|
+
device.setViewport(null);
|
|
237
|
+
device.setScissor(null);
|
|
199
238
|
}
|
|
200
239
|
this._scenePass.transmission = false; // transmission
|
|
201
240
|
this._scenePass.clearDepth = ctx.depthTexture ? null : 1;
|
|
202
241
|
this._scenePass.clearStencil = ctx.depthTexture ? null : 0;
|
|
203
|
-
if (SSR && !renderQueue.needSceneColor) {
|
|
242
|
+
if (ctx.SSR && !renderQueue.needSceneColor()) {
|
|
204
243
|
ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
205
244
|
}
|
|
206
245
|
ctx.compositor?.begin(ctx);
|
|
207
|
-
if (renderQueue.needSceneColor) {
|
|
246
|
+
if (renderQueue.needSceneColor()) {
|
|
247
|
+
const compositor = ctx.compositor;
|
|
248
|
+
ctx.compositor = null;
|
|
208
249
|
const sceneColorFramebuffer = device.pool.fetchTemporalFramebuffer(true, ctx.depthTexture.width, ctx.depthTexture.height, ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS ? [
|
|
209
|
-
|
|
250
|
+
ctx.colorFormat,
|
|
210
251
|
device.getFramebuffer().getColorAttachments()[1],
|
|
211
252
|
device.getFramebuffer().getColorAttachments()[2]
|
|
212
|
-
] :
|
|
253
|
+
] : ctx.colorFormat, ctx.depthTexture, false);
|
|
213
254
|
device.pushDeviceStates();
|
|
214
255
|
device.setFramebuffer(sceneColorFramebuffer);
|
|
215
256
|
this._scenePass.transmission = false;
|
|
216
|
-
this._scenePass.render(ctx, null, renderQueue);
|
|
257
|
+
this._scenePass.render(ctx, null, null, renderQueue);
|
|
217
258
|
device.popDeviceStates();
|
|
218
259
|
ctx.sceneColorTexture = sceneColorFramebuffer.getColorAttachments()[0];
|
|
219
260
|
new CopyBlitter().blit(ctx.sceneColorTexture, device.getFramebuffer() ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
@@ -221,31 +262,95 @@ import { buildHiZ } from './hzb.js';
|
|
|
221
262
|
this._scenePass.clearColor = null;
|
|
222
263
|
this._scenePass.clearDepth = null;
|
|
223
264
|
this._scenePass.clearStencil = null;
|
|
265
|
+
ctx.compositor = compositor;
|
|
266
|
+
}
|
|
267
|
+
this._scenePass.render(ctx, null, null, renderQueue);
|
|
268
|
+
if (renderQueue.needSceneColor()) {
|
|
269
|
+
this.renderSceneDepth(ctx, renderQueue, depthFramebuffer);
|
|
224
270
|
}
|
|
225
|
-
|
|
271
|
+
ctx.compositor?.drawPostEffects(ctx, PostEffectLayer.end, ctx.linearDepthTexture);
|
|
226
272
|
ctx.compositor?.end(ctx);
|
|
227
273
|
renderQueue.dispose();
|
|
228
274
|
ctx.materialFlags &= ~MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
229
|
-
if (
|
|
275
|
+
if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {
|
|
230
276
|
const blitter = new CopyBlitter();
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
ctx.viewportY,
|
|
235
|
-
ctx.viewportWidth,
|
|
236
|
-
ctx.viewportHeight
|
|
237
|
-
];
|
|
238
|
-
} else {
|
|
239
|
-
blitter.viewport = vp;
|
|
240
|
-
}
|
|
241
|
-
blitter.scissor = scissor;
|
|
242
|
-
blitter.srgbOut = !finalFramebuffer;
|
|
243
|
-
const srcTex = tempFramebuffer.getColorAttachments()[0];
|
|
244
|
-
blitter.blit(srcTex, finalFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
277
|
+
blitter.srgbOut = !ctx.finalFramebuffer;
|
|
278
|
+
const srcTex = ctx.intermediateFramebuffer.getColorAttachments()[0];
|
|
279
|
+
blitter.blit(srcTex, ctx.finalFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
245
280
|
device.popDeviceStates();
|
|
281
|
+
device.pool.releaseFrameBuffer(ctx.intermediateFramebuffer);
|
|
246
282
|
}
|
|
247
|
-
ShadowMapper.releaseTemporalResources(ctx);
|
|
283
|
+
//ShadowMapper.releaseTemporalResources(ctx);
|
|
248
284
|
this.freeClusteredLight(ctx.clusteredLight);
|
|
285
|
+
// Restore sun color
|
|
286
|
+
if (sunLightColor) {
|
|
287
|
+
ctx.sunLight.color = sunLightColor;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
static _getSkyMotionVectorProgram(ctx) {
|
|
291
|
+
if (!this._skyMotionVectorProgram) {
|
|
292
|
+
this._skyMotionVectorProgram = ctx.device.buildRenderProgram({
|
|
293
|
+
vertex (pb) {
|
|
294
|
+
this.$inputs.pos = pb.vec3().attrib('position');
|
|
295
|
+
this.VPMatrix = pb.mat4().uniform(0);
|
|
296
|
+
this.prevVPMatrix = pb.mat4().uniform(0);
|
|
297
|
+
this.cameraPos = pb.vec3().uniform(0);
|
|
298
|
+
this.prevCameraPos = pb.vec3().uniform(0);
|
|
299
|
+
pb.main(function() {
|
|
300
|
+
this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);
|
|
301
|
+
this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);
|
|
302
|
+
this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));
|
|
303
|
+
this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));
|
|
304
|
+
this.clipPos.z = this.clipPos.w;
|
|
305
|
+
this.$builtins.position = this.clipPos;
|
|
306
|
+
this.$outputs.currentPos = this.clipPos;
|
|
307
|
+
this.$outputs.prevPos = this.prevClipPos;
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
fragment (pb) {
|
|
311
|
+
this.$outputs.color = pb.vec4();
|
|
312
|
+
pb.main(function() {
|
|
313
|
+
this.$l.motionVector = pb.mul(pb.sub(pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w), pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)), 0.5);
|
|
314
|
+
this.$outputs.color = pb.vec4(this.motionVector, 0, 1);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
this._skyMotionVectorProgram.name = '@TAA_SkyMotionVector';
|
|
319
|
+
}
|
|
320
|
+
return this._skyMotionVectorProgram;
|
|
321
|
+
}
|
|
322
|
+
static _getBox(_ctx) {
|
|
323
|
+
if (!this._box) {
|
|
324
|
+
this._box = new BoxShape({
|
|
325
|
+
size: 2,
|
|
326
|
+
needNormal: false,
|
|
327
|
+
needUV: false
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
return this._box;
|
|
331
|
+
}
|
|
332
|
+
/** @internal */ static renderSkyMotionVectors(ctx) {
|
|
333
|
+
if (!ctx.motionVectorTexture) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 0, 0, ctx.motionVectorTexture, ctx.depthTexture);
|
|
337
|
+
const program = this._getSkyMotionVectorProgram(ctx);
|
|
338
|
+
if (!this._skyMotionVectorBindGroup) {
|
|
339
|
+
this._skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);
|
|
340
|
+
}
|
|
341
|
+
const box = this._getBox(ctx);
|
|
342
|
+
this._skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);
|
|
343
|
+
this._skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix);
|
|
344
|
+
this._skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
|
|
345
|
+
this._skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition);
|
|
346
|
+
ctx.device.pushDeviceStates();
|
|
347
|
+
ctx.device.setProgram(program);
|
|
348
|
+
ctx.device.setBindGroup(0, this._skyMotionVectorBindGroup);
|
|
349
|
+
ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));
|
|
350
|
+
ctx.device.setFramebuffer(fb);
|
|
351
|
+
box.draw();
|
|
352
|
+
ctx.device.popDeviceStates();
|
|
353
|
+
ctx.device.pool.releaseFrameBuffer(fb);
|
|
249
354
|
}
|
|
250
355
|
/** @internal */ static renderShadowMaps(ctx, lights) {
|
|
251
356
|
ctx.renderPass = this._shadowMapPass;
|
|
@@ -255,64 +360,94 @@ import { buildHiZ } from './hzb.js';
|
|
|
255
360
|
}
|
|
256
361
|
ctx.device.popDeviceStates();
|
|
257
362
|
}
|
|
258
|
-
/** @internal */ static
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
363
|
+
/** @internal */ static decodeNormalizedFloat(rgba) {
|
|
364
|
+
const a = rgba[0] / 255;
|
|
365
|
+
const b = rgba[1] / 255;
|
|
366
|
+
const c = rgba[2] / 255;
|
|
367
|
+
const d = rgba[3] / 255;
|
|
368
|
+
return a / (256 * 256 * 256) + b / (256 * 256) + c / 256 + d;
|
|
369
|
+
}
|
|
370
|
+
/** @internal */ static renderObjectColors(ctx, pickResolveFunc, renderQueue) {
|
|
371
|
+
const camera = ctx.camera;
|
|
372
|
+
const isWebGL1 = ctx.device.type === 'webgl';
|
|
262
373
|
ctx.renderPass = this._objectColorPass;
|
|
263
374
|
ctx.device.pushDeviceStates();
|
|
264
|
-
const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 1, 1,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
375
|
+
const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 1, 1, isWebGL1 ? [
|
|
376
|
+
'rgba8unorm',
|
|
377
|
+
'rgba8unorm'
|
|
378
|
+
] : [
|
|
379
|
+
'rgba8unorm',
|
|
380
|
+
'rgba32f'
|
|
381
|
+
], ctx.depthFormat, false);
|
|
382
|
+
ctx.device.setViewport(camera.viewport);
|
|
269
383
|
const vp = ctx.device.getViewport();
|
|
270
|
-
const windowX =
|
|
271
|
-
const windowY = (vp.height -
|
|
384
|
+
const windowX = camera.getPickPosX() / vp.width;
|
|
385
|
+
const windowY = (vp.height - camera.getPickPosY() - 1) / vp.height;
|
|
272
386
|
const windowW = 1 / vp.width;
|
|
273
387
|
const windowH = 1 / vp.height;
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
388
|
+
const pickCamera = this._pickCamera;
|
|
389
|
+
camera.worldMatrix.decompose(pickCamera.scale, pickCamera.rotation, pickCamera.position);
|
|
390
|
+
let left = camera.getProjectionMatrix().getLeftPlane();
|
|
391
|
+
let right = camera.getProjectionMatrix().getRightPlane();
|
|
392
|
+
let bottom = camera.getProjectionMatrix().getBottomPlane();
|
|
393
|
+
let top = camera.getProjectionMatrix().getTopPlane();
|
|
394
|
+
const near = camera.getProjectionMatrix().getNearPlane();
|
|
395
|
+
const far = camera.getProjectionMatrix().getFarPlane();
|
|
396
|
+
const width = right - left;
|
|
397
|
+
const height = top - bottom;
|
|
398
|
+
left += width * windowX;
|
|
399
|
+
bottom += height * windowY;
|
|
400
|
+
right = left + width * windowW;
|
|
401
|
+
top = bottom + height * windowH;
|
|
402
|
+
pickCamera.setProjectionMatrix(camera.isPerspective() ? Matrix4x4.frustum(left, right, bottom, top, near, far) : Matrix4x4.ortho(left, right, bottom, top, near, far));
|
|
403
|
+
const cameraPos = isWebGL1 ? new Vector3(pickCamera.position) : null;
|
|
404
|
+
const ray = isWebGL1 ? camera.constructRay(camera.getPickPosX(), camera.getPickPosY()) : null;
|
|
282
405
|
ctx.device.setFramebuffer(fb);
|
|
283
406
|
this._objectColorPass.clearColor = Vector4.zero();
|
|
284
407
|
this._objectColorPass.clearDepth = 1;
|
|
285
|
-
const
|
|
286
|
-
this._objectColorPass.render(ctx,
|
|
287
|
-
|
|
288
|
-
ctx.camera.scissor = savedScissor;
|
|
289
|
-
ctx.camera.window = savedWindow;
|
|
408
|
+
const rq = this._objectColorPass.cullScene(ctx, pickCamera);
|
|
409
|
+
this._objectColorPass.render(ctx, pickCamera, null, rq);
|
|
410
|
+
rq.dispose();
|
|
290
411
|
ctx.device.popDeviceStates();
|
|
291
|
-
const
|
|
292
|
-
const
|
|
293
|
-
const
|
|
412
|
+
const colorTex = fb.getColorAttachments()[0];
|
|
413
|
+
const distanceTex = fb.getColorAttachments()[1];
|
|
414
|
+
const colorPixels = new Uint8Array(4);
|
|
415
|
+
const distancePixels = isWebGL1 ? new Uint8Array(4) : new Float32Array(4);
|
|
294
416
|
const device = ctx.device;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
417
|
+
let fence;
|
|
418
|
+
if (ctx.device.type === 'webgl') {
|
|
419
|
+
fence = Promise.all([
|
|
420
|
+
ctx.device.runNextFrameAsync(()=>colorTex.readPixels(0, 0, 1, 1, 0, 0, colorPixels)),
|
|
421
|
+
ctx.device.runNextFrameAsync(()=>distanceTex.readPixels(0, 0, 1, 1, 0, 0, distancePixels))
|
|
422
|
+
]);
|
|
423
|
+
} else {
|
|
424
|
+
fence = Promise.all([
|
|
425
|
+
colorTex.readPixels(0, 0, 1, 1, 0, 0, colorPixels),
|
|
426
|
+
distanceTex.readPixels(0, 0, 1, 1, 0, 0, distancePixels)
|
|
427
|
+
]);
|
|
428
|
+
}
|
|
429
|
+
fence.then(()=>{
|
|
430
|
+
const drawable = renderQueue.getDrawableByColor(colorPixels);
|
|
431
|
+
let d = isWebGL1 ? this.decodeNormalizedFloat(distancePixels) * far : distancePixels[0];
|
|
432
|
+
const intersectedPoint = new Vector3(distancePixels[0], distancePixels[1], distancePixels[2]);
|
|
433
|
+
if (isWebGL1) {
|
|
434
|
+
intersectedPoint.x = cameraPos.x + ray.direction.x * d;
|
|
435
|
+
intersectedPoint.y = cameraPos.y + ray.direction.y * d;
|
|
436
|
+
intersectedPoint.z = cameraPos.z + ray.direction.z * d;
|
|
437
|
+
d = Vector3.distance(intersectedPoint, cameraPos);
|
|
438
|
+
}
|
|
439
|
+
pickResolveFunc(drawable ? {
|
|
440
|
+
distance: d,
|
|
441
|
+
intersectedPoint,
|
|
442
|
+
drawable,
|
|
443
|
+
target: drawable.getPickTarget()
|
|
444
|
+
} : null);
|
|
445
|
+
device.pool.releaseFrameBuffer(fb);
|
|
446
|
+
}).catch((_err)=>{
|
|
447
|
+
camera.getPickResultResolveFunc()?.(null);
|
|
448
|
+
device.pool.releaseFrameBuffer(fb);
|
|
307
449
|
});
|
|
308
|
-
|
|
309
|
-
tex.readPixels(0, 0, 1, 1, 0, 0, pixels).then(() => {
|
|
310
|
-
const drawable = renderQueue.getDrawableByColor(pixels);
|
|
311
|
-
camera.pickResult =
|
|
312
|
-
drawable && drawable.getPickTarget()?.pickable ? { drawable, node: drawable.getPickTarget() } : null;
|
|
313
|
-
device.pool.releaseFrameBuffer(fb);
|
|
314
|
-
});
|
|
315
|
-
*/ }
|
|
450
|
+
}
|
|
316
451
|
}
|
|
317
452
|
|
|
318
453
|
export { SceneRenderer };
|