@zephyr3d/scene 0.6.0 → 0.7.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 +1 -1
- package/dist/animation/animation.js +149 -27
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +173 -73
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +65 -10
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +41 -20
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +14 -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 +190 -0
- package/dist/animation/proptrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +29 -11
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +29 -11
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +241 -78
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +30 -11
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/api.js +43 -0
- package/dist/app/api.js.map +1 -0
- package/dist/app/app.js +153 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/engine.js +312 -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/scriptingsystem.js +220 -0
- package/dist/app/scriptingsystem.js.map +1 -0
- package/dist/app/scriptregistry.js +432 -0
- package/dist/app/scriptregistry.js.map +1 -0
- package/dist/asset/assetmanager.js +772 -291
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/builtin.js +7 -43
- package/dist/asset/builtin.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +17 -93
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +8 -18
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +36 -42
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/helpers.js +27 -14
- package/dist/asset/loaders/gltf/helpers.js.map +1 -1
- package/dist/asset/loaders/hdr/hdr.js +17 -12
- package/dist/asset/loaders/hdr/hdr.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +13 -16
- 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.map +1 -1
- package/dist/asset/model.js +158 -4
- 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 +22 -23
- package/dist/blitter/blitter.js.map +1 -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 +141 -34
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +653 -149
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +2 -10
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +132 -59
- package/dist/camera/orbit.js.map +1 -1
- package/dist/camera/orthocamera.js +37 -12
- package/dist/camera/orthocamera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +37 -20
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +18268 -6982
- package/dist/index.js +49 -16
- 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 +346 -73
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +498 -156
- 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 +235 -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 +16 -4
- 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 +98 -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 +186 -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 +521 -287
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/terrain-cm.js +607 -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 +60 -100
- 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 +30 -19
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +429 -101
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +7 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +43 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +14 -5
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +113 -40
- 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 +234 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -0
- package/dist/render/fft_wavegenerator.js +64 -50
- 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 +98 -48
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +4 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +6 -3
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +19 -18
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +4 -4
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/primitive.js +213 -104
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +40 -20
- 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 +326 -185
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +20 -36
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +3 -3
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +864 -541
- 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/batchgroup.js +18 -5
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +78 -48
- 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 +28 -89
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +218 -87
- 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 +684 -0
- package/dist/scene/particlesys.js.map +1 -0
- package/dist/scene/raycast_visitor.js +34 -5
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +309 -85
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +675 -102
- package/dist/scene/scene_node.js.map +1 -1
- 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 +603 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +160 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js +533 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/scene/water.js +378 -0
- package/dist/scene/water.js.map +1 -0
- package/dist/shaders/atmosphere.js +957 -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 +31 -13
- 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 +38 -0
- package/dist/shadow/shader.js.map +1 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadowmapper.js +67 -26
- 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 +181 -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 +120 -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 +256 -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 +15 -5
- package/dist/utility/aabbtree.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +851 -0
- package/dist/utility/blueprint/common/constants.js.map +1 -0
- package/dist/utility/blueprint/common/math.js +2045 -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 +521 -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 +1311 -0
- package/dist/utility/blueprint/material/ir.js.map +1 -0
- package/dist/utility/blueprint/material/pbr.js +362 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -0
- package/dist/utility/blueprint/material/texture.js +1099 -0
- package/dist/utility/blueprint/material/texture.js.map +1 -0
- package/dist/utility/blueprint/node.js +187 -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 +18 -6
- 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 +402 -0
- package/dist/utility/serialization/json.js.map +1 -0
- package/dist/utility/serialization/manager.js +1176 -0
- package/dist/utility/serialization/manager.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +699 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -0
- package/dist/utility/serialization/scene/batch.js +53 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -0
- package/dist/utility/serialization/scene/camera.js +808 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +224 -0
- package/dist/utility/serialization/scene/common.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +589 -0
- package/dist/utility/serialization/scene/light.js.map +1 -0
- package/dist/utility/serialization/scene/material.js +942 -0
- package/dist/utility/serialization/scene/material.js.map +1 -0
- package/dist/utility/serialization/scene/mesh.js +374 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/utility/serialization/scene/misc.js +39 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -0
- package/dist/utility/serialization/scene/node.js +391 -0
- package/dist/utility/serialization/scene/node.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +425 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +582 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/utility/serialization/scene/scene.js +763 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -0
- package/dist/utility/serialization/scene/terrain.js +495 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +465 -0
- package/dist/utility/serialization/scene/water.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 +91 -4
- package/dist/values.js.map +1 -1
- package/package.json +29 -15
- 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
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { ShaderHelper } from '../material/shader/helper.js';
|
|
2
|
+
|
|
3
|
+
const MAX_FLOAT_VALUE = 3.402823466e38;
|
|
4
|
+
/** @internal */ function SSR_calcJitter(scope, viewPos, roughness) {
|
|
5
|
+
const pb = scope.$builder;
|
|
6
|
+
pb.func('SSR_calcJitter', [
|
|
7
|
+
pb.vec3('viewPos'),
|
|
8
|
+
pb.float('roughness')
|
|
9
|
+
], function() {
|
|
10
|
+
this.$l.h = pb.fract(pb.mul(this.viewPos, 0.8));
|
|
11
|
+
this.h = pb.add(this.h, pb.dot(this.h, pb.add(this.h.yxz, pb.vec3(19.19))));
|
|
12
|
+
this.h = pb.fract(pb.mul(pb.add(this.h.xxy, this.h.yxx), this.h.zyx));
|
|
13
|
+
this.h = pb.sub(this.h, pb.vec3(0.5));
|
|
14
|
+
this.$return(pb.mix(pb.vec3(0), this.h, this.roughness));
|
|
15
|
+
});
|
|
16
|
+
return scope.SSR_calcJitter(viewPos, roughness);
|
|
17
|
+
}
|
|
18
|
+
/** @internal */ function invProjectPosition(scope, pos, mat) {
|
|
19
|
+
const pb = scope.$builder;
|
|
20
|
+
pb.func('invProjectPosition', [
|
|
21
|
+
pb.vec3('p'),
|
|
22
|
+
pb.mat4('mat')
|
|
23
|
+
], function() {
|
|
24
|
+
this.$l.c = pb.sub(pb.mul(this.p, 2), pb.vec3(1));
|
|
25
|
+
this.$l.u = pb.mul(this.mat, pb.vec4(this.c, 1));
|
|
26
|
+
this.u = pb.div(this.u, this.u.w);
|
|
27
|
+
this.$return(this.u.xyz);
|
|
28
|
+
});
|
|
29
|
+
return scope.invProjectPosition(pos, mat);
|
|
30
|
+
}
|
|
31
|
+
/** @internal */ function validateHit(scope, hit2D, hit3D, surfaceZ, thickness, uv, traceRay, viewMatrix, invProjMatrix, textureSize, normalTexture) {
|
|
32
|
+
const pb = scope.$builder;
|
|
33
|
+
const funcName = hit3D ? 'SSR_validateHit_HiZ' : 'SSR_validateHit';
|
|
34
|
+
pb.func(funcName, [
|
|
35
|
+
pb.vec2('hit2d'),
|
|
36
|
+
...hit3D ? [
|
|
37
|
+
pb.vec3('hit3d')
|
|
38
|
+
] : [],
|
|
39
|
+
...hit3D ? [
|
|
40
|
+
pb.float('thickness')
|
|
41
|
+
] : [],
|
|
42
|
+
pb.float('surfaceZ'),
|
|
43
|
+
pb.vec2('uv'),
|
|
44
|
+
pb.vec3('viewSpaceRayDirection'),
|
|
45
|
+
pb.mat4('viewMatrix'),
|
|
46
|
+
pb.mat4('invProjMatrix'),
|
|
47
|
+
pb.vec4('textureSize')
|
|
48
|
+
], function() {
|
|
49
|
+
this.$if(pb.or(pb.any(pb.lessThan(this.hit2d, pb.vec2(0))), pb.any(pb.greaterThan(this.hit2d, pb.vec2(1)))), function() {
|
|
50
|
+
this.$return(pb.float(0));
|
|
51
|
+
});
|
|
52
|
+
this.$l.manhattanDist = pb.abs(pb.sub(this.hit2d, this.uv));
|
|
53
|
+
this.$if(pb.all(pb.lessThan(this.manhattanDist, pb.vec2(pb.div(pb.vec2(2), this.textureSize.xy)))), function() {
|
|
54
|
+
this.$return(pb.float(0));
|
|
55
|
+
});
|
|
56
|
+
if (normalTexture) {
|
|
57
|
+
this.$l.hitNormalWS = pb.sub(pb.mul(pb.textureSampleLevel(normalTexture, this.hit2d, 0).rgb, 2), pb.vec3(1));
|
|
58
|
+
this.$l.hitNormalVS = pb.mul(this.viewMatrix, pb.vec4(this.hitNormalWS, 0)).xyz;
|
|
59
|
+
this.$if(pb.greaterThan(pb.dot(this.hitNormalVS, this.viewSpaceRayDirection), 0), function() {
|
|
60
|
+
this.$return(pb.float(0));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
this.$l.viewSpaceSurface = invProjectPosition(this, pb.vec3(this.hit2d, this.surfaceZ), this.invProjMatrix);
|
|
64
|
+
this.$l.fov = pb.mul(pb.vec2(pb.div(this.textureSize.y, this.textureSize.x), 1), 0.05);
|
|
65
|
+
this.$l.border = pb.mul(pb.smoothStep(pb.vec2(0), this.fov, this.hit2d), pb.sub(pb.vec2(1), pb.smoothStep(pb.sub(pb.vec2(1), this.fov), pb.vec2(1), this.hit2d)));
|
|
66
|
+
this.$l.vignette = pb.mul(this.border.x, this.border.y);
|
|
67
|
+
if (this.hit3d) {
|
|
68
|
+
this.$l.distance = pb.distance(this.viewSpaceSurface, this.hit3d);
|
|
69
|
+
this.$l.confidence = pb.sub(1, pb.smoothStep(0, this.thickness, this.distance));
|
|
70
|
+
this.$return(pb.mul(this.vignette, this.confidence, this.confidence));
|
|
71
|
+
} else {
|
|
72
|
+
this.$return(this.vignette);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return hit3D ? scope[funcName](hit2D, hit3D, thickness, surfaceZ, uv, traceRay, viewMatrix, invProjMatrix, textureSize) : scope[funcName](hit2D, surfaceZ, uv, traceRay, viewMatrix, invProjMatrix, textureSize);
|
|
76
|
+
}
|
|
77
|
+
function screenSpaceRayTracing_Linear2D(scope, viewPos, traceRay, viewMatrix, projMatrix, invProjMatrix, cameraNearFar, maxDistance, maxIterations, thickness, stride, textureSize, linearDepthTex, normalTexture, useBackfaceDepth) {
|
|
78
|
+
const pb = scope.$builder;
|
|
79
|
+
pb.func('distanceSquared', [
|
|
80
|
+
pb.vec2('a'),
|
|
81
|
+
pb.vec2('b')
|
|
82
|
+
], function() {
|
|
83
|
+
this.$l.x = pb.sub(this.a, this.b);
|
|
84
|
+
this.$return(pb.dot(this.x, this.x));
|
|
85
|
+
});
|
|
86
|
+
pb.func('rayIntersectDepth', [
|
|
87
|
+
pb.float('zA'),
|
|
88
|
+
pb.float('zB'),
|
|
89
|
+
pb.float('thickness'),
|
|
90
|
+
pb.vec2('uv'),
|
|
91
|
+
pb.float('cameraFar')
|
|
92
|
+
], function() {
|
|
93
|
+
let thickness = this.thickness;
|
|
94
|
+
if (useBackfaceDepth) {
|
|
95
|
+
this.$l.sceneZ = ShaderHelper.sampleLinearDepthWithBackface(this, linearDepthTex, this.uv, 0);
|
|
96
|
+
this.$l.sceneZMax01 = this.sceneZ.x;
|
|
97
|
+
thickness = pb.max(this.thickness, pb.mul(pb.sub(this.sceneZ.y, this.sceneZ.x), this.cameraFar));
|
|
98
|
+
} else {
|
|
99
|
+
this.$l.sceneZMax01 = ShaderHelper.sampleLinearDepth(this, linearDepthTex, this.uv, 0);
|
|
100
|
+
}
|
|
101
|
+
this.sceneZMax = pb.neg(pb.mul(this.sceneZMax01, this.cameraFar));
|
|
102
|
+
this.$return(pb.and(pb.lessThan(this.sceneZMax01, 1), pb.greaterThanEqual(this.zA, pb.sub(this.sceneZMax, thickness)), pb.lessThanEqual(this.zB, this.sceneZMax)));
|
|
103
|
+
});
|
|
104
|
+
pb.func('traceRayLinear2D', [
|
|
105
|
+
pb.vec3('rayOrigin'),
|
|
106
|
+
pb.vec3('rayDirection'),
|
|
107
|
+
pb.float('stride'),
|
|
108
|
+
pb.float('maxDistance'),
|
|
109
|
+
pb.float('maxIterations'),
|
|
110
|
+
pb.float('thickness'),
|
|
111
|
+
pb.vec2('cameraNearFar'),
|
|
112
|
+
pb.mat4('projMatrix'),
|
|
113
|
+
pb.vec4('textureSize'),
|
|
114
|
+
pb.vec3('hit2D').out(),
|
|
115
|
+
pb.vec3('hit3D').out(),
|
|
116
|
+
pb.vec2('origin').out(),
|
|
117
|
+
pb.float('numIterations').out()
|
|
118
|
+
], function() {
|
|
119
|
+
this.$l.rayLen = this.$choice(pb.greaterThan(pb.add(this.rayOrigin.z, pb.mul(this.rayDirection.z, this.maxDistance)), pb.neg(this.cameraNearFar.x)), pb.div(pb.sub(pb.neg(this.cameraNearFar.x), this.rayOrigin.z), this.rayDirection.z), this.maxDistance);
|
|
120
|
+
this.$l.rayEnd = pb.add(this.rayOrigin, pb.mul(this.rayDirection, this.rayLen));
|
|
121
|
+
this.$l.zMin = pb.min(this.rayOrigin.z, this.rayEnd.z);
|
|
122
|
+
this.$l.zMax = pb.max(this.rayOrigin.z, this.rayEnd.z);
|
|
123
|
+
this.$l.rayOriginH = pb.mul(this.projMatrix, pb.vec4(this.rayOrigin, 1));
|
|
124
|
+
this.$l.rayEndH = pb.mul(this.projMatrix, pb.vec4(this.rayEnd, 1));
|
|
125
|
+
this.$l.k0 = pb.div(1, this.rayOriginH.w);
|
|
126
|
+
this.$l.k1 = pb.div(1, this.rayEndH.w);
|
|
127
|
+
this.$l.Q0 = pb.mul(this.rayOrigin, this.k0);
|
|
128
|
+
this.$l.Q1 = pb.mul(this.rayEnd, this.k1);
|
|
129
|
+
this.$l.rayOriginNDC = pb.mul(this.rayOriginH, this.k0);
|
|
130
|
+
this.$l.rayEndNDC = pb.mul(this.rayEndH, this.k1);
|
|
131
|
+
this.origin = pb.add(pb.mul(this.rayOriginNDC.xy, 0.5), pb.vec2(0.5));
|
|
132
|
+
this.$l.P0 = pb.mul(this.origin, this.textureSize.zw);
|
|
133
|
+
this.$l.P1 = pb.mul(pb.add(pb.mul(this.rayEndNDC.xy, 0.5), pb.vec2(0.5)), this.textureSize.zw);
|
|
134
|
+
this.$l.xMin = 0.5;
|
|
135
|
+
this.$l.xMax = pb.sub(this.textureSize.z, 0.5);
|
|
136
|
+
this.$l.yMin = 0.5;
|
|
137
|
+
this.$l.yMax = pb.sub(this.textureSize.w, 0.5);
|
|
138
|
+
this.$l.t = pb.float();
|
|
139
|
+
this.$if(pb.or(pb.greaterThan(this.P1.y, this.yMax), pb.lessThan(this.P1.y, this.yMin)), function() {
|
|
140
|
+
this.t = pb.div(pb.sub(this.P1.y, this.$choice(pb.greaterThan(this.P1.y, this.yMax), this.yMax, this.yMin)), pb.sub(this.P1.y, this.P0.y));
|
|
141
|
+
});
|
|
142
|
+
this.$if(pb.or(pb.greaterThan(this.P1.x, this.xMax), pb.lessThan(this.P1.x, this.xMin)), function() {
|
|
143
|
+
this.t2 = pb.div(pb.sub(this.P1.x, this.$choice(pb.greaterThan(this.P1.x, this.xMax), this.xMax, this.xMin)), pb.sub(this.P1.x, this.P0.x));
|
|
144
|
+
this.t = pb.max(this.t, this.t2);
|
|
145
|
+
});
|
|
146
|
+
this.P1 = pb.mix(this.P1, this.P0, this.t);
|
|
147
|
+
this.k1 = pb.mix(this.k1, this.k0, this.t);
|
|
148
|
+
this.Q1 = pb.mix(this.Q1, this.Q0, this.t);
|
|
149
|
+
this.P1 = this.$choice(pb.lessThan(this.distanceSquared(this.P0, this.P1), 0.0001), pb.add(this.P1, pb.vec2(0.01)), this.P1);
|
|
150
|
+
this.$l.delta = pb.sub(this.P1, this.P0);
|
|
151
|
+
this.$l.permute = false;
|
|
152
|
+
this.$if(pb.lessThan(pb.abs(this.delta.x), pb.abs(this.delta.y)), function() {
|
|
153
|
+
this.permute = true;
|
|
154
|
+
this.delta = this.delta.yx;
|
|
155
|
+
this.P0 = this.P0.yx;
|
|
156
|
+
this.P1 = this.P1.yx;
|
|
157
|
+
});
|
|
158
|
+
this.$l.stepDir = pb.sign(this.delta.x);
|
|
159
|
+
this.$l.invdx = pb.div(this.stepDir, this.delta.x);
|
|
160
|
+
this.$l.dQ = pb.mul(pb.sub(this.Q1, this.Q0), this.invdx);
|
|
161
|
+
this.$l.dK = pb.mul(pb.sub(this.k1, this.k0), this.invdx);
|
|
162
|
+
this.$l.dP = pb.vec2(this.stepDir, pb.mul(this.delta.y, this.invdx));
|
|
163
|
+
//this.$l.strideScalar = pb.sub(1, pb.min(1, pb.div(pb.neg(this.rayOrigin.z), this.strideZCutoff)));
|
|
164
|
+
//this.$l.pixelStride = pb.add(1, pb.mul(this.strideScalar, this.stride));
|
|
165
|
+
this.$l.pixelStride = this.stride;
|
|
166
|
+
this.dP = pb.mul(this.dP, this.pixelStride);
|
|
167
|
+
this.dQ = pb.mul(this.dQ, this.pixelStride);
|
|
168
|
+
this.dK = pb.mul(this.dK, this.pixelStride);
|
|
169
|
+
this.$l.jitter = pb.float(1); //dither(this, this.P0);
|
|
170
|
+
this.P0 = pb.add(this.P0, pb.mul(this.dP, this.jitter));
|
|
171
|
+
this.Q0 = pb.add(this.Q0, pb.mul(this.dQ, this.jitter));
|
|
172
|
+
this.k0 = pb.add(this.k0, pb.mul(this.dK, this.jitter));
|
|
173
|
+
this.$l.prevZMaxEstimate = this.rayOrigin.z;
|
|
174
|
+
this.$l.zA = this.prevZMaxEstimate;
|
|
175
|
+
this.$l.zB = this.prevZMaxEstimate;
|
|
176
|
+
this.$l.pqk = pb.vec4(this.P0, this.Q0.z, this.k0);
|
|
177
|
+
this.$l.dpqk = pb.vec4(this.dP, this.dQ.z, this.dK);
|
|
178
|
+
this.$l.invRenderTargetSize = pb.div(pb.vec2(1), this.textureSize.zw);
|
|
179
|
+
this.$l.intersected = false;
|
|
180
|
+
this.$l.hitUV = pb.vec2();
|
|
181
|
+
this.$l.hitZ = pb.float();
|
|
182
|
+
this.numIterations = 0;
|
|
183
|
+
this.skippedIterations = pb.min(this.maxIterations, 1);
|
|
184
|
+
this.$for(pb.float('i'), 0, pb.getDevice().type === 'webgl' ? 1000 : this.maxIterations, function() {
|
|
185
|
+
if (pb.getDevice().type === 'webgl') {
|
|
186
|
+
this.$if(pb.greaterThanEqual(this.i, this.maxIterations), function() {
|
|
187
|
+
this.$break();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
this.$if(pb.and(this.intersected, pb.greaterThanEqual(this.i, this.skippedIterations)), function() {
|
|
191
|
+
this.$break();
|
|
192
|
+
});
|
|
193
|
+
this.numIterations = pb.add(this.numIterations, 1);
|
|
194
|
+
this.pqk = pb.add(this.pqk, this.dpqk);
|
|
195
|
+
this.zA = this.prevZMaxEstimate;
|
|
196
|
+
this.zB = pb.div(pb.add(pb.mul(this.dpqk.z, 0.5), this.pqk.z), pb.add(pb.mul(this.dpqk.w, 0.5), this.pqk.w));
|
|
197
|
+
this.zB = pb.clamp(this.zB, this.zMin, this.zMax);
|
|
198
|
+
this.prevZMaxEstimate = this.zB;
|
|
199
|
+
this.hitZ = this.zB;
|
|
200
|
+
this.$if(pb.greaterThan(this.zB, this.zA), function() {
|
|
201
|
+
this.$l.t = this.zB;
|
|
202
|
+
this.zB = this.zA;
|
|
203
|
+
this.zA = this.t;
|
|
204
|
+
});
|
|
205
|
+
this.hitUV = this.$choice(this.permute, this.pqk.yx, this.pqk.xy);
|
|
206
|
+
this.hitUV = pb.mul(this.hitUV, this.invRenderTargetSize);
|
|
207
|
+
this.intersected = this.rayIntersectDepth(this.zA, this.zB, this.thickness, this.hitUV, this.cameraNearFar.y);
|
|
208
|
+
});
|
|
209
|
+
this.hit2D = pb.vec3(this.hitUV, this.hitZ);
|
|
210
|
+
this.Q0 = pb.vec3(pb.add(this.Q0.xy, pb.mul(this.dQ.xy, this.numIterations)), this.pqk.z);
|
|
211
|
+
this.hit3D = pb.div(this.Q0, this.pqk.w);
|
|
212
|
+
this.$return(this.intersected);
|
|
213
|
+
});
|
|
214
|
+
pb.func('SSR_Linear2D', [
|
|
215
|
+
pb.vec3('rayOrigin'),
|
|
216
|
+
pb.vec3('rayDirection'),
|
|
217
|
+
pb.mat4('viewMatrix'),
|
|
218
|
+
pb.mat4('projMatrix'),
|
|
219
|
+
pb.mat4('invProjMatrix'),
|
|
220
|
+
pb.float('stride'),
|
|
221
|
+
pb.float('maxDistance'),
|
|
222
|
+
pb.float('maxIterations'),
|
|
223
|
+
pb.float('thickness'),
|
|
224
|
+
pb.vec2('cameraNearFar'),
|
|
225
|
+
pb.vec4('textureSize')
|
|
226
|
+
], function() {
|
|
227
|
+
this.$l.hit2D = pb.vec3();
|
|
228
|
+
this.$l.hit3D = pb.vec3();
|
|
229
|
+
this.$l.origin = pb.vec2();
|
|
230
|
+
this.$l.numIterations = pb.float();
|
|
231
|
+
this.$l.intersected = this.traceRayLinear2D(this.rayOrigin, this.rayDirection, this.stride, this.maxDistance, this.maxIterations, this.thickness, this.cameraNearFar, this.projMatrix, this.textureSize, this.hit2D, this.hit3D, this.origin, this.numIterations);
|
|
232
|
+
this.$if(pb.not(this.intersected), function() {
|
|
233
|
+
this.$return(pb.vec4(0));
|
|
234
|
+
});
|
|
235
|
+
this.$l.surfaceZ01 = ShaderHelper.sampleLinearDepth(this, linearDepthTex, this.hit2D.xy, 0);
|
|
236
|
+
this.$if(pb.equal(this.surfaceZ01, 1), function() {
|
|
237
|
+
this.$return(pb.vec4(0));
|
|
238
|
+
});
|
|
239
|
+
this.$l.surfaceZ = ShaderHelper.linearDepthToNonLinear(this, pb.mul(this.surfaceZ01, this.cameraNearFar.y), this.cameraNearFar);
|
|
240
|
+
this.$l.confidence = validateHit(this, this.hit2D.xy, null, this.surfaceZ, null, this.origin, this.rayDirection, this.viewMatrix, this.invProjMatrix, this.textureSize, normalTexture);
|
|
241
|
+
this.$l.iterationAttenuation = pb.sub(1, pb.smoothStep(0, this.maxIterations, this.numIterations));
|
|
242
|
+
//this.$l.iterationAttenuation = pb.smoothStep(this.maxIterations, 1, this.numIterations);
|
|
243
|
+
this.confidence = pb.mul(this.confidence, this.iterationAttenuation);
|
|
244
|
+
this.$l.hitPixel = pb.mul(this.hit2D.xy, this.textureSize.zw);
|
|
245
|
+
this.$l.startPixel = pb.mul(this.origin.xy, this.textureSize.zw);
|
|
246
|
+
this.$l.hitDistance = pb.length(pb.sub(this.hitPixel, this.startPixel));
|
|
247
|
+
this.$return(pb.vec4(this.hit2D.xy, this.hitDistance, this.confidence));
|
|
248
|
+
});
|
|
249
|
+
return scope.SSR_Linear2D(viewPos, traceRay, viewMatrix, projMatrix, invProjMatrix, stride, maxDistance, maxIterations, thickness, cameraNearFar, textureSize);
|
|
250
|
+
}
|
|
251
|
+
function screenSpaceRayTracing_HiZ(scope, viewPos, traceRay, viewMatrix, projMatrix, invProjMatrix, cameraNearFar, maxMipLevel, maxIterations, thickness, textureSize, HiZTexture, normalTexture) {
|
|
252
|
+
const pb = scope.$builder;
|
|
253
|
+
pb.func('getMipResolution', [
|
|
254
|
+
pb.int('mipLevel')
|
|
255
|
+
], function() {
|
|
256
|
+
this.$return(pb.vec2(pb.textureDimensions(HiZTexture, this.mipLevel)));
|
|
257
|
+
});
|
|
258
|
+
pb.func('SSR_loadDepth', [
|
|
259
|
+
pb.vec2('uv'),
|
|
260
|
+
pb.float('level')
|
|
261
|
+
], function() {
|
|
262
|
+
this.$return(pb.textureSampleLevel(HiZTexture, this.uv, this.level).r);
|
|
263
|
+
});
|
|
264
|
+
pb.func('invProjectPosition', [
|
|
265
|
+
pb.vec3('p'),
|
|
266
|
+
pb.mat4('mat')
|
|
267
|
+
], function() {
|
|
268
|
+
this.$l.c = pb.sub(pb.mul(this.p, 2), pb.vec3(1));
|
|
269
|
+
this.$l.u = pb.mul(this.mat, pb.vec4(this.c, 1));
|
|
270
|
+
this.u = pb.div(this.u, this.u.w);
|
|
271
|
+
this.$return(this.u.xyz);
|
|
272
|
+
});
|
|
273
|
+
pb.func('projectPosition', [
|
|
274
|
+
pb.vec3('p'),
|
|
275
|
+
pb.mat4('mat')
|
|
276
|
+
], function() {
|
|
277
|
+
this.$l.projected = pb.mul(this.mat, pb.vec4(this.p, 1));
|
|
278
|
+
this.projected = pb.div(this.projected, this.projected.w);
|
|
279
|
+
this.projected = pb.add(pb.mul(this.projected, 0.5), pb.vec4(0.5));
|
|
280
|
+
this.$return(this.projected.xyz);
|
|
281
|
+
});
|
|
282
|
+
pb.func('projectDirection', [
|
|
283
|
+
pb.vec3('p'),
|
|
284
|
+
pb.vec3('d'),
|
|
285
|
+
pb.vec3('screenSpacePos'),
|
|
286
|
+
pb.mat4('mat')
|
|
287
|
+
], function() {
|
|
288
|
+
this.$return(pb.sub(this.projectPosition(pb.add(this.p, this.d), this.mat), this.screenSpacePos));
|
|
289
|
+
});
|
|
290
|
+
pb.func('SSR_initialAdvanceRay', [
|
|
291
|
+
pb.vec3('origin'),
|
|
292
|
+
pb.vec3('direction'),
|
|
293
|
+
pb.vec3('invDirection'),
|
|
294
|
+
pb.vec2('currentMipResolution'),
|
|
295
|
+
pb.vec2('invCurrentMipResolution'),
|
|
296
|
+
pb.vec2('floorOffset'),
|
|
297
|
+
pb.vec2('uvOffset'),
|
|
298
|
+
pb.vec3('position').out(),
|
|
299
|
+
pb.float('currentT').out()
|
|
300
|
+
], function() {
|
|
301
|
+
this.$l.currentMipPosition = pb.mul(this.currentMipResolution, this.origin.xy);
|
|
302
|
+
this.$l.xyPlane = pb.add(pb.floor(this.currentMipPosition), this.floorOffset);
|
|
303
|
+
this.xyPlane = pb.add(pb.mul(this.xyPlane, this.invCurrentMipResolution), this.uvOffset);
|
|
304
|
+
this.$l.t = pb.mul(pb.sub(this.xyPlane, this.origin.xy), this.invDirection.xy);
|
|
305
|
+
this.currentT = pb.min(this.t.x, this.t.y);
|
|
306
|
+
this.position = pb.add(this.origin, pb.mul(this.direction, this.currentT));
|
|
307
|
+
});
|
|
308
|
+
pb.func('SSR_advanceRay', [
|
|
309
|
+
pb.vec3('origin'),
|
|
310
|
+
pb.vec3('direction'),
|
|
311
|
+
pb.vec3('invDirection'),
|
|
312
|
+
pb.vec2('currentMipPosition'),
|
|
313
|
+
pb.vec2('invCurrentMipResolution'),
|
|
314
|
+
pb.vec2('floorOffset'),
|
|
315
|
+
pb.vec2('uvOffset'),
|
|
316
|
+
pb.float('surfaceZ'),
|
|
317
|
+
pb.vec3('position').inout(),
|
|
318
|
+
pb.float('currentT').inout()
|
|
319
|
+
], function() {
|
|
320
|
+
this.$l.xyPlane = pb.add(pb.floor(this.currentMipPosition), this.floorOffset);
|
|
321
|
+
this.xyPlane = pb.add(pb.mul(this.xyPlane, this.invCurrentMipResolution), this.uvOffset);
|
|
322
|
+
this.$l.boundaryPlanes = pb.vec3(this.xyPlane, this.surfaceZ);
|
|
323
|
+
this.$l.t = pb.mul(pb.sub(this.boundaryPlanes, this.origin), this.invDirection);
|
|
324
|
+
this.t.z = this.$choice(pb.greaterThan(this.direction.z, 0), this.t.z, MAX_FLOAT_VALUE);
|
|
325
|
+
this.$l.tMin = pb.min(pb.min(this.t.x, this.t.y), this.t.z);
|
|
326
|
+
this.$l.aboveSurface = pb.greaterThan(this.surfaceZ, this.position.z);
|
|
327
|
+
this.$l.skippedTile = pb.and(pb.notEqual(pb.floatBitsToUint(this.tMin), pb.floatBitsToUint(this.t.z)), this.aboveSurface);
|
|
328
|
+
this.currentT = this.$choice(this.aboveSurface, this.tMin, this.currentT);
|
|
329
|
+
this.position = pb.add(this.origin, pb.mul(this.direction, this.currentT));
|
|
330
|
+
this.$return(this.skippedTile);
|
|
331
|
+
});
|
|
332
|
+
pb.func('SSR_RaymarchHiZ', [
|
|
333
|
+
pb.vec3('screenSpacePos'),
|
|
334
|
+
pb.vec3('screenSpaceDirection'),
|
|
335
|
+
pb.vec2('cameraNearFar'),
|
|
336
|
+
pb.vec2('screenSize'),
|
|
337
|
+
pb.int('mostDetailMip'),
|
|
338
|
+
pb.int('maxMipLevel'),
|
|
339
|
+
pb.float('maxIterations'),
|
|
340
|
+
pb.float('numIterations').out()
|
|
341
|
+
], function() {
|
|
342
|
+
this.$l.invDirection = this.$choice(pb.all(pb.compNotEqual(this.screenSpaceDirection, pb.vec3(0))), pb.div(pb.vec3(1), this.screenSpaceDirection), pb.vec3(MAX_FLOAT_VALUE));
|
|
343
|
+
this.$l.currentMip = this.mostDetailMip;
|
|
344
|
+
this.$l.currentMipResolution = this.getMipResolution(this.currentMip);
|
|
345
|
+
this.$l.invCurrentMipResolution = pb.div(pb.vec2(1), this.currentMipResolution);
|
|
346
|
+
this.$l.uvOffset = pb.div(pb.mul(0.005, pb.exp2(pb.float(this.mostDetailMip))), this.screenSize);
|
|
347
|
+
this.uvOffset = pb.vec2(this.$choice(pb.lessThan(this.screenSpaceDirection.x, 0), pb.neg(this.uvOffset.x), this.uvOffset.x), this.$choice(pb.lessThan(this.screenSpaceDirection.y, 0), pb.neg(this.uvOffset.y), this.uvOffset.y));
|
|
348
|
+
this.$l.floorOffset = pb.vec2(this.$choice(pb.lessThan(this.screenSpaceDirection.x, 0), pb.float(0), pb.float(1)), this.$choice(pb.lessThan(this.screenSpaceDirection.y, 0), pb.float(0), pb.float(1)));
|
|
349
|
+
this.$l.currentT = pb.float();
|
|
350
|
+
this.$l.position = pb.vec3();
|
|
351
|
+
this.SSR_initialAdvanceRay(this.screenSpacePos, this.screenSpaceDirection, this.invDirection, this.currentMipResolution, this.invCurrentMipResolution, this.floorOffset, this.uvOffset, this.position, this.currentT);
|
|
352
|
+
this.numIterations = pb.float(0);
|
|
353
|
+
this.$while(pb.and(pb.lessThan(this.numIterations, this.maxIterations), pb.greaterThanEqual(this.currentMip, this.mostDetailMip)), function() {
|
|
354
|
+
this.$l.currentMipPosition = pb.mul(this.currentMipResolution, this.position.xy);
|
|
355
|
+
this.$l.surfaceZ = pb.textureLoad(HiZTexture, pb.ivec2(this.currentMipPosition), this.currentMip).r;
|
|
356
|
+
this.$l.skippedTile = this.SSR_advanceRay(this.screenSpacePos, this.screenSpaceDirection, this.invDirection, this.currentMipPosition, this.invCurrentMipResolution, this.floorOffset, this.uvOffset, this.surfaceZ, this.position, this.currentT);
|
|
357
|
+
this.$l.nextMipIsOutOfRange = pb.and(this.skippedTile, pb.greaterThanEqual(this.currentMip, this.maxMipLevel));
|
|
358
|
+
this.$if(pb.not(this.nextMipIsOutOfRange), function() {
|
|
359
|
+
this.currentMip = pb.add(this.currentMip, this.$choice(this.skippedTile, pb.int(1), pb.int(-1)));
|
|
360
|
+
this.currentMipResolution = pb.mul(this.currentMipResolution, this.$choice(this.skippedTile, 0.5, 2));
|
|
361
|
+
this.invCurrentMipResolution = pb.mul(this.invCurrentMipResolution, this.$choice(this.skippedTile, 2, 0.5));
|
|
362
|
+
});
|
|
363
|
+
this.numIterations = pb.add(this.numIterations, 1);
|
|
364
|
+
});
|
|
365
|
+
this.$l.validHit = this.$choice(pb.lessThanEqual(this.numIterations, this.maxIterations), pb.float(1), pb.float(0));
|
|
366
|
+
this.$return(pb.vec4(this.position, this.validHit));
|
|
367
|
+
});
|
|
368
|
+
pb.func('SSR_HiZ', [
|
|
369
|
+
pb.vec3('viewPos'),
|
|
370
|
+
pb.vec3('traceRay'),
|
|
371
|
+
pb.mat4('viewMatrix'),
|
|
372
|
+
pb.mat4('projMatrix'),
|
|
373
|
+
pb.mat4('invProjMatrix'),
|
|
374
|
+
pb.vec2('cameraNearFar'),
|
|
375
|
+
pb.float('thickness'),
|
|
376
|
+
pb.vec4('textureSize'),
|
|
377
|
+
pb.int('maxMipLevel'),
|
|
378
|
+
pb.float('maxIterations')
|
|
379
|
+
], function() {
|
|
380
|
+
this.$if(pb.greaterThan(this.traceRay.z, 0), function() {
|
|
381
|
+
this.$return(pb.vec4(0));
|
|
382
|
+
});
|
|
383
|
+
this.$l.originH = pb.mul(this.projMatrix, pb.vec4(this.viewPos, 1));
|
|
384
|
+
this.$l.originCS = pb.div(this.originH.xyz, this.originH.w);
|
|
385
|
+
this.$l.originTS = pb.add(pb.mul(this.originCS, 0.5), pb.vec3(0.5));
|
|
386
|
+
this.$l.directionTS = this.projectDirection(this.viewPos, this.traceRay, this.originTS, this.projMatrix);
|
|
387
|
+
this.$l.mostDetailMip = pb.int(0);
|
|
388
|
+
this.$l.numIterations = pb.float();
|
|
389
|
+
this.$l.hit = this.SSR_RaymarchHiZ(this.originTS, this.directionTS, this.cameraNearFar, this.textureSize.zw, this.mostDetailMip, this.maxMipLevel, this.maxIterations, this.numIterations);
|
|
390
|
+
this.$l.confidence = pb.float(0);
|
|
391
|
+
this.$if(pb.notEqual(this.hit.w, 0), function() {
|
|
392
|
+
this.$l.surfaceZ = pb.textureSampleLevel(HiZTexture, this.hit.xy, 0).r;
|
|
393
|
+
this.$if(pb.equal(this.surfaceZ, 1), function() {
|
|
394
|
+
this.$return(pb.vec4(0));
|
|
395
|
+
});
|
|
396
|
+
this.$l.hit3D = invProjectPosition(this, this.hit.xyz, this.invProjMatrix);
|
|
397
|
+
this.confidence = validateHit(this, this.hit.xy, this.hit3D, this.surfaceZ, this.thickness, this.originTS.xy, this.traceRay, this.viewMatrix, this.invProjMatrix, this.textureSize, normalTexture);
|
|
398
|
+
});
|
|
399
|
+
this.$l.iterationAttenuation = pb.sub(1, pb.smoothStep(0, this.maxIterations, this.numIterations));
|
|
400
|
+
this.$l.viewAttenuation = pb.sub(1, pb.smoothStep(-0.5, 0, this.traceRay.z));
|
|
401
|
+
//this.$l.iterationAttenuation = pb.smoothStep(this.maxIterations, 1, this.numIterations);
|
|
402
|
+
this.confidence = pb.mul(this.confidence, this.iterationAttenuation, this.viewAttenuation);
|
|
403
|
+
this.$l.hitPixel = pb.mul(this.hit.xy, this.textureSize.zw);
|
|
404
|
+
this.$l.startPixel = pb.mul(this.originTS.xy, this.textureSize.zw);
|
|
405
|
+
this.$l.hitDistance = pb.length(pb.sub(this.hitPixel, this.startPixel));
|
|
406
|
+
this.$return(pb.vec4(this.hit.xy, this.hitDistance, this.confidence));
|
|
407
|
+
});
|
|
408
|
+
return scope.SSR_HiZ(viewPos, traceRay, viewMatrix, projMatrix, invProjMatrix, cameraNearFar, thickness, textureSize, pb.sub(maxMipLevel, 1), maxIterations);
|
|
409
|
+
} /*
|
|
410
|
+
float2 cell(float2 ray, float2 cell_count, uint camera) {
|
|
411
|
+
return floor(ray.xy * cell_count);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
float2 cell_count(float level) {
|
|
415
|
+
return input_texture2_size / (level == 0.0 ? 1.0 : exp2(level));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
float3 intersect_cell_boundary(float3 pos, float3 dir, float2 cell_id, float2 cell_count, float2 cross_step, float2 cross_offset, uint camera) {
|
|
419
|
+
float2 cell_size = 1.0 / cell_count;
|
|
420
|
+
float2 planes = cell_id/cell_count + cell_size * cross_step;
|
|
421
|
+
|
|
422
|
+
float2 solutions = (planes - pos)/dir.xy;
|
|
423
|
+
float3 intersection_pos = pos + dir * min(solutions.x, solutions.y);
|
|
424
|
+
|
|
425
|
+
intersection_pos.xy += (solutions.x < solutions.y) ? float2(cross_offset.x, 0.0) : float2(0.0, cross_offset.y);
|
|
426
|
+
|
|
427
|
+
return intersection_pos;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
bool crossed_cell_boundary(float2 cell_id_one, float2 cell_id_two) {
|
|
431
|
+
return (int)cell_id_one.x != (int)cell_id_two.x || (int)cell_id_one.y != (int)cell_id_two.y;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
float minimum_depth_plane(float2 ray, float level, float2 cell_count, uint camera) {
|
|
435
|
+
return input_texture2.Load(int3(vr_stereo_to_mono(ray.xy, camera) * cell_count, level)).r;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
float3 hi_z_trace(float3 p, float3 v, in uint camera, out uint iterations) {
|
|
439
|
+
float level = HIZ_START_LEVEL;
|
|
440
|
+
float3 v_z = v/v.z;
|
|
441
|
+
float2 hi_z_size = cell_count(level);
|
|
442
|
+
float3 ray = p;
|
|
443
|
+
|
|
444
|
+
float2 cross_step = float2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);
|
|
445
|
+
float2 cross_offset = cross_step * 0.00001;
|
|
446
|
+
cross_step = saturate(cross_step);
|
|
447
|
+
|
|
448
|
+
float2 ray_cell = cell(ray.xy, hi_z_size.xy, camera);
|
|
449
|
+
ray = intersect_cell_boundary(ray, v, ray_cell, hi_z_size, cross_step, cross_offset, camera);
|
|
450
|
+
|
|
451
|
+
iterations = 0;
|
|
452
|
+
while(level >= HIZ_STOP_LEVEL && iterations < MAX_ITERATIONS) {
|
|
453
|
+
// get the cell number of the current ray
|
|
454
|
+
float2 current_cell_count = cell_count(level);
|
|
455
|
+
float2 old_cell_id = cell(ray.xy, current_cell_count, camera);
|
|
456
|
+
|
|
457
|
+
// get the minimum depth plane in which the current ray resides
|
|
458
|
+
float min_z = minimum_depth_plane(ray.xy, level, current_cell_count, camera);
|
|
459
|
+
|
|
460
|
+
// intersect only if ray depth is below the minimum depth plane
|
|
461
|
+
float3 tmp_ray = ray;
|
|
462
|
+
if(v.z > 0) {
|
|
463
|
+
float min_minus_ray = min_z - ray.z;
|
|
464
|
+
tmp_ray = min_minus_ray > 0 ? ray + v_z*min_minus_ray : tmp_ray;
|
|
465
|
+
float2 new_cell_id = cell(tmp_ray.xy, current_cell_count, camera);
|
|
466
|
+
if(crossed_cell_boundary(old_cell_id, new_cell_id)) {
|
|
467
|
+
tmp_ray = intersect_cell_boundary(ray, v, old_cell_id, current_cell_count, cross_step, cross_offset, camera);
|
|
468
|
+
level = min(HIZ_MAX_LEVEL, level + 2.0f);
|
|
469
|
+
}else{
|
|
470
|
+
if(level == 1 && abs(min_minus_ray) > 0.0001) {
|
|
471
|
+
tmp_ray = intersect_cell_boundary(ray, v, old_cell_id, current_cell_count, cross_step, cross_offset, camera);
|
|
472
|
+
level = 2;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
} else if(ray.z < min_z) {
|
|
476
|
+
tmp_ray = intersect_cell_boundary(ray, v, old_cell_id, current_cell_count, cross_step, cross_offset, camera);
|
|
477
|
+
level = min(HIZ_MAX_LEVEL, level + 2.0f);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
ray.xyz = tmp_ray.xyz;
|
|
481
|
+
--level;
|
|
482
|
+
|
|
483
|
+
++iterations;
|
|
484
|
+
}
|
|
485
|
+
return ray;
|
|
486
|
+
}
|
|
487
|
+
*/
|
|
488
|
+
|
|
489
|
+
export { SSR_calcJitter, screenSpaceRayTracing_HiZ, screenSpaceRayTracing_Linear2D };
|
|
490
|
+
//# sourceMappingURL=ssr.js.map
|