@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
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { ProgramBuilder } from '@zephyr3d/device';
|
|
2
|
-
import { RENDER_PASS_TYPE_OBJECT_COLOR, QUEUE_OPAQUE, RENDER_PASS_TYPE_SHADOWMAP,
|
|
2
|
+
import { RENDER_PASS_TYPE_OBJECT_COLOR, QUEUE_OPAQUE, RENDER_PASS_TYPE_SHADOWMAP, RENDER_PASS_TYPE_LIGHT, MaterialVaryingFlags, RENDER_PASS_TYPE_DEPTH, QUEUE_TRANSPARENT } from '../values.js';
|
|
3
3
|
import { Material } from './material.js';
|
|
4
4
|
import { encodeNormalizedFloatToRGBA } from '../shaders/misc.js';
|
|
5
|
-
import { Application } from '../app.js';
|
|
6
5
|
import { ShaderHelper } from './shader/helper.js';
|
|
7
|
-
import { Vector4, Vector3, Vector2, applyMixins } from '@zephyr3d/base';
|
|
6
|
+
import { Vector4, DRef, Vector3, Vector2, applyMixins } from '@zephyr3d/base';
|
|
7
|
+
import { RenderBundleWrapper } from '../render/renderbundle_wrapper.js';
|
|
8
|
+
import { getDevice } from '../app/api.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
* Apply material mixins to
|
|
11
|
-
* @param target - Material class
|
|
12
|
-
* @param mixins - mixins
|
|
13
|
-
* @returns Mixed mesh material class
|
|
11
|
+
* Apply material mixins to a target material class.
|
|
14
12
|
*
|
|
13
|
+
* Useful for composing optional capabilities (e.g., base color, normal map, PBR terms).
|
|
14
|
+
*
|
|
15
|
+
* @param target - The material class (constructor or prototype).
|
|
16
|
+
* @param mixins - One or more mixin functions.
|
|
17
|
+
* @returns The target class augmented with the mixins (intersection type).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* class MyMaterial extends MeshMaterial \{\}
|
|
21
|
+
* const Mixed = applyMaterialMixins(MyMaterial, WithBaseColor, WithNormalMap);
|
|
22
|
+
* const m = new Mixed();
|
|
15
23
|
* @public
|
|
16
24
|
*/ function applyMaterialMixins(target, ...mixins) {
|
|
17
25
|
return applyMixins(target, ...mixins);
|
|
@@ -19,97 +27,278 @@ import { Vector4, Vector3, Vector2, applyMixins } from '@zephyr3d/base';
|
|
|
19
27
|
let FEATURE_ALPHATEST = 0;
|
|
20
28
|
let FEATURE_ALPHABLEND = 0;
|
|
21
29
|
let FEATURE_ALPHATOCOVERAGE = 0;
|
|
30
|
+
let FEATURE_DISABLE_TAA = 0;
|
|
22
31
|
/**
|
|
23
|
-
* Base class for
|
|
32
|
+
* Base class for mesh materials.
|
|
33
|
+
*
|
|
34
|
+
* Key responsibilities:
|
|
35
|
+
* - Defines feature-based shader variants (alpha test, blending, alpha-to-coverage, TAA toggle, etc.).
|
|
36
|
+
* - Provides a material instancing mechanism (per-instance uniforms via a shared core material).
|
|
37
|
+
* - Implements the base shader scaffolding for multiple render passes (LIGHT, DEPTH, OBJECT_COLOR, SHADOWMAP).
|
|
38
|
+
* - Updates render states depending on pass and features (blending, depth, culling).
|
|
39
|
+
* - Submits material uniforms and cooperates with OIT/TAA/SSR/motion vectors.
|
|
40
|
+
*
|
|
41
|
+
* Variant system:
|
|
42
|
+
* - Features are stored in `_featureStates` and hashed into `_createHash()`.
|
|
43
|
+
* - Changing features calls `useFeature(...)` which triggers `optionChanged(true)` to rebuild programs.
|
|
44
|
+
*
|
|
45
|
+
* Instancing:
|
|
46
|
+
* - `defineInstanceUniform` registers per-instance fields with packed layout.
|
|
47
|
+
* - `createInstance()` returns a lightweight instance that shares the core’s GPU programs and updates
|
|
48
|
+
* instance uniform buffer only. This improves batching/instancing support.
|
|
49
|
+
*
|
|
50
|
+
* Shader hooks:
|
|
51
|
+
* - `vertexShader(scope)` and `fragmentShader(scope)` provide per-pass hook points to implement the
|
|
52
|
+
* material’s vertex/fragment logic. The base class wires up common I/O (skin, morph, instancing).
|
|
53
|
+
* - `outputFragmentColor(...)` centralizes final color output across passes, handling OIT and alpha ops.
|
|
54
|
+
*
|
|
55
|
+
* Render states and queues:
|
|
56
|
+
* - `updateRenderStates(...)` sets depth/blend/cull states based on blending, alpha-to-coverage,
|
|
57
|
+
* depth equality optimizations, pass type, and optional OIT overrides.
|
|
58
|
+
* - `getQueueType()` chooses between opaque and transparent queues.
|
|
59
|
+
*
|
|
60
|
+
* Extending:
|
|
61
|
+
* - Override `vertexShader`, `fragmentShader`, and optionally `outputFragmentColor`.
|
|
62
|
+
* - Override `supportLighting`, `isTransparentPass`, `needFragmentColor`, etc., as needed.
|
|
63
|
+
* - Use `uniformChanged()` when changing uniform-only values that do not alter shader variants.
|
|
64
|
+
* - Use `useFeature()` when toggling options that affect shader variants.
|
|
24
65
|
*
|
|
25
66
|
* @public
|
|
26
67
|
*/ class MeshMaterial extends Material {
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Registered instance uniforms for this material class.
|
|
70
|
+
*
|
|
71
|
+
* Each entry defines property name, type, and packed offset (float-aligned).
|
|
72
|
+
* @internal
|
|
73
|
+
*/ static INSTANCE_UNIFORMS = [];
|
|
74
|
+
/**
|
|
75
|
+
* Next free feature index for subclasses to define their own feature toggles.
|
|
76
|
+
* @internal
|
|
77
|
+
*/ static NEXT_FEATURE_INDEX = 3;
|
|
78
|
+
/**
|
|
79
|
+
* Built-in per-instance uniform: object color (rgba), used for GPU picking/object-ID pass.
|
|
80
|
+
* @internal
|
|
81
|
+
*/ static OBJECT_COLOR_UNIFORM = this.defineInstanceUniform('objectColor', 'rgba');
|
|
82
|
+
/**
|
|
83
|
+
* Built-in per-instance uniform: opacity (float), used in transparent passes.
|
|
84
|
+
* @internal
|
|
85
|
+
*/ static OPACITY_UNIFORM = this.defineInstanceUniform('opacity', 'float', 'Opacity');
|
|
86
|
+
/** @internal Feature state array (indexed by feature indices). */ _featureStates;
|
|
87
|
+
/** @internal Alpha test cutoff in [0, 1]. */ _alphaCutoff;
|
|
88
|
+
/** @internal Blending mode. */ _blendMode;
|
|
89
|
+
/** @internal Face culling mode. */ _cullMode;
|
|
90
|
+
/** @internal Opacity in [0, 1]. */ _opacity;
|
|
91
|
+
/**
|
|
92
|
+
* @internal TAA strength in [0, 1], where higher value typically means stronger accumulation
|
|
93
|
+
* (here used inversely when mapping to motion vector output).
|
|
94
|
+
*/ _taaStrength;
|
|
95
|
+
/** @internal Per-object color for object picking pass. */ _objectColor;
|
|
96
|
+
/** @internal Last draw context used for shader creation. */ _ctx;
|
|
97
|
+
/** @internal Current material pass index during program building. */ _materialPass;
|
|
98
|
+
/**
|
|
99
|
+
* Create a MeshMaterial with default opaque settings.
|
|
100
|
+
*
|
|
101
|
+
* Defaults:
|
|
102
|
+
* - `blendMode = 'none'`
|
|
103
|
+
* - `cullMode = 'back'`
|
|
104
|
+
* - `opacity = 1`
|
|
105
|
+
* - `alphaCutoff = 0`
|
|
106
|
+
* - `taaStrength = 1 - 1/16`
|
|
107
|
+
*/ constructor(){
|
|
42
108
|
super();
|
|
43
109
|
this._featureStates = [];
|
|
44
110
|
this._alphaCutoff = 0;
|
|
45
111
|
this._blendMode = 'none';
|
|
46
112
|
this._cullMode = 'back';
|
|
47
113
|
this._opacity = 1;
|
|
114
|
+
this._taaStrength = 1 - 1 / 16;
|
|
48
115
|
this._objectColor = Vector4.one();
|
|
49
116
|
this._ctx = null;
|
|
50
117
|
this._materialPass = -1;
|
|
118
|
+
this.useFeature(FEATURE_ALPHABLEND, this._blendMode);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create a shallow clone of this material.
|
|
122
|
+
* Subclasses should override to copy custom fields.
|
|
123
|
+
*/ clone() {
|
|
124
|
+
const other = new MeshMaterial();
|
|
125
|
+
other.copyFrom(this);
|
|
126
|
+
return other;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Copy common MeshMaterial properties from another material.
|
|
130
|
+
* Call `super.copyFrom(other)` first when overriding in subclasses.
|
|
131
|
+
*
|
|
132
|
+
* @param other - Source material.
|
|
133
|
+
*/ copyFrom(other) {
|
|
134
|
+
super.copyFrom(other);
|
|
135
|
+
this.alphaCutoff = other.alphaCutoff;
|
|
136
|
+
this.blendMode = other.blendMode;
|
|
137
|
+
this.cullMode = other.cullMode;
|
|
138
|
+
this.opacity = other.opacity;
|
|
139
|
+
this.objectColor = other.objectColor;
|
|
51
140
|
}
|
|
52
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Mark uniform-only changes so uniforms are re-uploaded on next apply, without
|
|
143
|
+
* rebuilding shader programs.
|
|
144
|
+
*/ uniformChanged() {
|
|
53
145
|
this.optionChanged(false);
|
|
54
146
|
}
|
|
55
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Define a new feature bit/index for shader variants.
|
|
149
|
+
* Subclasses may use this to add their own switches.
|
|
150
|
+
*/ static defineFeature() {
|
|
56
151
|
const val = this.NEXT_FEATURE_INDEX;
|
|
57
152
|
this.NEXT_FEATURE_INDEX++;
|
|
58
153
|
return val;
|
|
59
154
|
}
|
|
60
|
-
/**
|
|
61
|
-
if (
|
|
155
|
+
/** @internal Helper: get number of scalar components for a given instance uniform type. */ static getNumComponents(type) {
|
|
156
|
+
if (type === 'float') {
|
|
157
|
+
return 1;
|
|
158
|
+
}
|
|
159
|
+
if (type === 'vec2') {
|
|
160
|
+
return 2;
|
|
161
|
+
}
|
|
162
|
+
if (type === 'rgb' || type === 'vec3') {
|
|
163
|
+
return 3;
|
|
164
|
+
}
|
|
165
|
+
if (type === 'rgba' || type === 'vec4') {
|
|
166
|
+
return 4;
|
|
167
|
+
}
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Define a per-instance uniform for this class.
|
|
172
|
+
*
|
|
173
|
+
* Returns a compact index encoding the vector index and component offset, which can be
|
|
174
|
+
* used in shader code via `getInstancedUniform(...)`.
|
|
175
|
+
*
|
|
176
|
+
* @param prop - Property name exposed on instances.
|
|
177
|
+
* @param type - Uniform data type.
|
|
178
|
+
* @returns Encoded index for use in `getInstancedUniform`.
|
|
179
|
+
*
|
|
180
|
+
* @throws If the property is already defined or type is invalid.
|
|
181
|
+
*/ static defineInstanceUniform(prop, type, name = '') {
|
|
182
|
+
if (this.INSTANCE_UNIFORMS.findIndex((val)=>val.prop === prop) >= 0) {
|
|
62
183
|
throw new Error(`${this.name}.defineInstanceUniform(): ${prop} was already defined`);
|
|
63
184
|
}
|
|
64
|
-
|
|
185
|
+
const numComponents = this.getNumComponents(type);
|
|
186
|
+
if (numComponents === 0) {
|
|
65
187
|
throw new Error(`${this.name}.defineInstanceUniform(): invalid uniform type ${type}`);
|
|
66
188
|
}
|
|
67
|
-
this.INSTANCE_UNIFORMS
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
189
|
+
let index = this.INSTANCE_UNIFORMS.length;
|
|
190
|
+
let offset = 0;
|
|
191
|
+
if (this.INSTANCE_UNIFORMS.length > 0) {
|
|
192
|
+
const lastUniform = this.INSTANCE_UNIFORMS[this.INSTANCE_UNIFORMS.length - 1];
|
|
193
|
+
const finalOffset = lastUniform.offset + 4 & -4;
|
|
194
|
+
offset = finalOffset;
|
|
195
|
+
for(let i = 0; i < this.INSTANCE_UNIFORMS.length; i++){
|
|
196
|
+
const offset1 = this.INSTANCE_UNIFORMS[i].offset;
|
|
197
|
+
const numComps1 = this.getNumComponents(this.INSTANCE_UNIFORMS[i].type);
|
|
198
|
+
const offset2 = i === this.INSTANCE_UNIFORMS.length - 1 ? finalOffset : this.INSTANCE_UNIFORMS[i + 1].offset;
|
|
199
|
+
if (offset1 + numComps1 + numComponents <= offset2) {
|
|
200
|
+
index = i + 1;
|
|
201
|
+
offset = offset1 + numComps1;
|
|
202
|
+
if (offset + numComponents === offset2) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
this.INSTANCE_UNIFORMS = this.INSTANCE_UNIFORMS.slice();
|
|
209
|
+
this.INSTANCE_UNIFORMS.splice(index, 0, {
|
|
210
|
+
prop,
|
|
211
|
+
offset,
|
|
212
|
+
type,
|
|
213
|
+
name
|
|
214
|
+
});
|
|
215
|
+
return offset << 2 | numComponents - 1;
|
|
75
216
|
}
|
|
76
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Read an encoded per-instance uniform in shader code.
|
|
219
|
+
*
|
|
220
|
+
* Encoded index packs: vector index, component offset, and component count.
|
|
221
|
+
*
|
|
222
|
+
* @param scope - Inside-function shader scope.
|
|
223
|
+
* @param uniformIndex - Encoded index from `defineInstanceUniform`.
|
|
224
|
+
* @returns The shader expression reading the selected components.
|
|
225
|
+
*/ getInstancedUniform(scope, uniformIndex) {
|
|
77
226
|
const pb = scope.$builder;
|
|
78
227
|
const instanceID = scope.$builtins.instanceIndex;
|
|
79
228
|
const uniformName = ShaderHelper.getInstanceDataUniformName();
|
|
80
229
|
const strideName = ShaderHelper.getInstanceDataStrideUniformName();
|
|
81
230
|
const offsetName = ShaderHelper.getInstanceDataOffsetUniformName();
|
|
82
|
-
|
|
231
|
+
const numComponents = (uniformIndex & 3) + 1;
|
|
232
|
+
const vecIndex = uniformIndex >> 4;
|
|
233
|
+
const vecOffset = uniformIndex >> 2 & 3;
|
|
234
|
+
const u = scope[uniformName].at(pb.add(pb.mul(scope[strideName], instanceID), ShaderHelper.MATERIAL_INSTANCE_DATA_OFFSET + vecIndex, scope[offsetName]));
|
|
235
|
+
const m = [
|
|
236
|
+
'x',
|
|
237
|
+
'y',
|
|
238
|
+
'z',
|
|
239
|
+
'w'
|
|
240
|
+
].slice(vecOffset, vecOffset + numComponents).join('');
|
|
241
|
+
return u[m];
|
|
83
242
|
}
|
|
84
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Get the list of per-instance uniforms for this material class.
|
|
245
|
+
*/ getInstancedUniforms() {
|
|
246
|
+
return this.constructor.INSTANCE_UNIFORMS;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Create a material instance (preferred for GPU instancing).
|
|
250
|
+
*
|
|
251
|
+
* - On WebGL1 (or when instancing unsupported), falls back to cloning.
|
|
252
|
+
* - Otherwise, returns a proxy instance that shares GPU programs and
|
|
253
|
+
* stores per-instance uniforms in a compact Float32Array.
|
|
254
|
+
*
|
|
255
|
+
* The returned instance:
|
|
256
|
+
* - Exposes properties defined by `defineInstanceUniform` with getter/setter
|
|
257
|
+
* that read/write the packed buffer and notify `RenderBundleWrapper`.
|
|
258
|
+
* - Delegates methods to the core material via prototype chain.
|
|
259
|
+
*/ createInstance() {
|
|
85
260
|
if (this.$isInstance) {
|
|
86
261
|
return this.coreMaterial.createInstance();
|
|
87
262
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
263
|
+
const isWebGL1 = getDevice().type === 'webgl';
|
|
264
|
+
if (isWebGL1 || !this.supportInstancing()) {
|
|
265
|
+
return this.clone();
|
|
266
|
+
}
|
|
267
|
+
const instanceUniforms = this.getInstancedUniforms();
|
|
268
|
+
const uniformsHolder = instanceUniforms.length > 0 ? new Float32Array(instanceUniforms[instanceUniforms.length - 1].offset + 4 & -4) : null;
|
|
91
269
|
const instance = {};
|
|
92
270
|
const that = this;
|
|
93
|
-
|
|
271
|
+
const coreMaterial = new DRef(that);
|
|
272
|
+
let disposed = false;
|
|
273
|
+
instance.isBatchable = ()=>true; //!isWebGL1 && that.supportInstancing();
|
|
274
|
+
instance.dispose = ()=>{
|
|
275
|
+
if (!disposed) {
|
|
276
|
+
disposed = true;
|
|
277
|
+
coreMaterial.dispose();
|
|
278
|
+
}
|
|
279
|
+
};
|
|
94
280
|
instance.$instanceUniforms = uniformsHolder;
|
|
95
281
|
instance.$isInstance = true;
|
|
96
|
-
instance
|
|
282
|
+
Object.defineProperty(instance, 'coreMaterial', {
|
|
283
|
+
get: function() {
|
|
284
|
+
return coreMaterial.get();
|
|
285
|
+
}
|
|
286
|
+
});
|
|
97
287
|
// Copy original uniform values
|
|
98
288
|
for(let i = 0; i < instanceUniforms.length; i++){
|
|
99
|
-
const
|
|
100
|
-
const [prop, type] = instanceUniforms[instanceIndex];
|
|
289
|
+
const { prop, offset, type } = instanceUniforms[i];
|
|
101
290
|
const value = that[prop];
|
|
102
291
|
switch(type){
|
|
103
292
|
case 'float':
|
|
104
293
|
{
|
|
105
|
-
uniformsHolder[
|
|
294
|
+
uniformsHolder[offset] = Number(value);
|
|
106
295
|
Object.defineProperty(instance, prop, {
|
|
107
296
|
get () {
|
|
108
|
-
return uniformsHolder[
|
|
297
|
+
return uniformsHolder[offset];
|
|
109
298
|
},
|
|
110
299
|
set (value) {
|
|
111
|
-
uniformsHolder[
|
|
112
|
-
|
|
300
|
+
uniformsHolder[offset] = value;
|
|
301
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
113
302
|
}
|
|
114
303
|
});
|
|
115
304
|
break;
|
|
@@ -119,69 +308,71 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
119
308
|
if (!(value instanceof Vector2)) {
|
|
120
309
|
throw new Error(`Instance uniform property ${prop} must be of type Vector2`);
|
|
121
310
|
}
|
|
122
|
-
uniformsHolder[
|
|
123
|
-
uniformsHolder[
|
|
311
|
+
uniformsHolder[offset] = value.x;
|
|
312
|
+
uniformsHolder[offset + 1] = value.y;
|
|
124
313
|
Object.defineProperty(instance, prop, {
|
|
125
314
|
get () {
|
|
126
|
-
return new Vector2(uniformsHolder[
|
|
315
|
+
return new Vector2(uniformsHolder[offset], uniformsHolder[offset + 1]);
|
|
127
316
|
},
|
|
128
317
|
set (value) {
|
|
129
318
|
if (!(value instanceof Vector2)) {
|
|
130
319
|
throw new Error(`Instance uniform property ${prop} must be of type Vector2`);
|
|
131
320
|
}
|
|
132
|
-
uniformsHolder[
|
|
133
|
-
uniformsHolder[
|
|
134
|
-
|
|
321
|
+
uniformsHolder[offset] = value.x;
|
|
322
|
+
uniformsHolder[offset + 1] = value.y;
|
|
323
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
135
324
|
}
|
|
136
325
|
});
|
|
137
326
|
break;
|
|
138
327
|
}
|
|
139
328
|
case 'vec3':
|
|
329
|
+
case 'rgb':
|
|
140
330
|
{
|
|
141
331
|
if (!(value instanceof Vector3)) {
|
|
142
332
|
throw new Error(`Instance uniform property ${prop} must be of type Vector3`);
|
|
143
333
|
}
|
|
144
|
-
uniformsHolder[
|
|
145
|
-
uniformsHolder[
|
|
146
|
-
uniformsHolder[
|
|
334
|
+
uniformsHolder[offset] = value.x;
|
|
335
|
+
uniformsHolder[offset + 1] = value.y;
|
|
336
|
+
uniformsHolder[offset + 2] = value.z;
|
|
147
337
|
Object.defineProperty(instance, prop, {
|
|
148
338
|
get () {
|
|
149
|
-
return new Vector3(uniformsHolder[
|
|
339
|
+
return new Vector3(uniformsHolder[offset], uniformsHolder[offset + 1], uniformsHolder[offset + 2]);
|
|
150
340
|
},
|
|
151
341
|
set (value) {
|
|
152
342
|
if (!(value instanceof Vector3)) {
|
|
153
343
|
throw new Error(`Instance uniform property ${prop} must be of type Vector3`);
|
|
154
344
|
}
|
|
155
|
-
uniformsHolder[
|
|
156
|
-
uniformsHolder[
|
|
157
|
-
uniformsHolder[
|
|
158
|
-
|
|
345
|
+
uniformsHolder[offset] = value.x;
|
|
346
|
+
uniformsHolder[offset + 1] = value.y;
|
|
347
|
+
uniformsHolder[offset + 2] = value.z;
|
|
348
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
159
349
|
}
|
|
160
350
|
});
|
|
161
351
|
break;
|
|
162
352
|
}
|
|
163
353
|
case 'vec4':
|
|
354
|
+
case 'rgba':
|
|
164
355
|
{
|
|
165
356
|
if (!(value instanceof Vector4)) {
|
|
166
357
|
throw new Error(`Instance uniform property ${prop} must be of type Vector4`);
|
|
167
358
|
}
|
|
168
|
-
uniformsHolder[
|
|
169
|
-
uniformsHolder[
|
|
170
|
-
uniformsHolder[
|
|
171
|
-
uniformsHolder[
|
|
359
|
+
uniformsHolder[offset] = value.x;
|
|
360
|
+
uniformsHolder[offset + 1] = value.y;
|
|
361
|
+
uniformsHolder[offset + 2] = value.z;
|
|
362
|
+
uniformsHolder[offset + 3] = value.w;
|
|
172
363
|
Object.defineProperty(instance, prop, {
|
|
173
364
|
get () {
|
|
174
|
-
return new Vector4(uniformsHolder[
|
|
365
|
+
return new Vector4(uniformsHolder[offset], uniformsHolder[offset + 1], uniformsHolder[offset + 2], uniformsHolder[offset + 3]);
|
|
175
366
|
},
|
|
176
367
|
set (value) {
|
|
177
368
|
if (!(value instanceof Vector4)) {
|
|
178
369
|
throw new Error(`Instance uniform property ${prop} must be of type Vector4`);
|
|
179
370
|
}
|
|
180
|
-
uniformsHolder[
|
|
181
|
-
uniformsHolder[
|
|
182
|
-
uniformsHolder[
|
|
183
|
-
uniformsHolder[
|
|
184
|
-
|
|
371
|
+
uniformsHolder[offset] = value.x;
|
|
372
|
+
uniformsHolder[offset + 1] = value.y;
|
|
373
|
+
uniformsHolder[offset + 2] = value.z;
|
|
374
|
+
uniformsHolder[offset + 3] = value.w;
|
|
375
|
+
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
185
376
|
}
|
|
186
377
|
});
|
|
187
378
|
break;
|
|
@@ -191,13 +382,28 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
191
382
|
Object.setPrototypeOf(instance, that);
|
|
192
383
|
return instance;
|
|
193
384
|
}
|
|
194
|
-
/**
|
|
385
|
+
/**
|
|
386
|
+
* Draw context captured during program creation, available inside shader hooks.
|
|
387
|
+
*
|
|
388
|
+
* @returns The last `DrawContext` used to build or apply this material.
|
|
389
|
+
*/ get drawContext() {
|
|
195
390
|
return this._ctx;
|
|
196
391
|
}
|
|
197
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* Current material pass index during program building.
|
|
394
|
+
* Typically used inside shader hooks to select per-pass logic.
|
|
395
|
+
*
|
|
396
|
+
* @returns The active pass index while building the program, or -1 when idle.
|
|
397
|
+
* @internal
|
|
398
|
+
*/ get pass() {
|
|
198
399
|
return this._materialPass;
|
|
199
400
|
}
|
|
200
|
-
/**
|
|
401
|
+
/**
|
|
402
|
+
* Alpha test cutoff in [0, 1].
|
|
403
|
+
* - 0 disables alpha testing.
|
|
404
|
+
* - \> 0 discards fragments with alpha \< cutoff.
|
|
405
|
+
* Changing this marks uniforms dirty (no shader rebuild).
|
|
406
|
+
*/ get alphaCutoff() {
|
|
201
407
|
return this._alphaCutoff;
|
|
202
408
|
}
|
|
203
409
|
set alphaCutoff(val) {
|
|
@@ -207,57 +413,108 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
207
413
|
this.uniformChanged();
|
|
208
414
|
}
|
|
209
415
|
}
|
|
210
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Whether TAA is disabled for this material.
|
|
418
|
+
* - When true, motion vectors encode a large sentinel to skip TAA accumulation.
|
|
419
|
+
* - Managed via an internal feature toggle.
|
|
420
|
+
*/ get TAADisabled() {
|
|
421
|
+
return !!this.featureUsed(FEATURE_DISABLE_TAA);
|
|
422
|
+
}
|
|
423
|
+
set TAADisabled(val) {
|
|
424
|
+
this.useFeature(FEATURE_DISABLE_TAA, !!val);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* TAA strength in [0, 1].
|
|
428
|
+
* - Higher values generally imply stronger accumulation.
|
|
429
|
+
* - The value is mapped when writing motion-vector outputs during depth pass.
|
|
430
|
+
*/ get TAAStrength() {
|
|
431
|
+
return this._taaStrength;
|
|
432
|
+
}
|
|
433
|
+
set TAAStrength(val) {
|
|
434
|
+
val = val > 1 ? 1 : val < 0 ? 0 : val;
|
|
435
|
+
if (this._taaStrength !== val) {
|
|
436
|
+
this._taaStrength = val;
|
|
437
|
+
this.uniformChanged();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Alpha-to-coverage toggle.
|
|
442
|
+
* - Useful to approximate transparency for MSAA targets.
|
|
443
|
+
* - Managed as a shader feature; toggling rebuilds variants.
|
|
444
|
+
*/ get alphaToCoverage() {
|
|
211
445
|
return this.featureUsed(FEATURE_ALPHATOCOVERAGE);
|
|
212
446
|
}
|
|
213
447
|
set alphaToCoverage(val) {
|
|
214
448
|
this.useFeature(FEATURE_ALPHATOCOVERAGE, !!val);
|
|
215
449
|
}
|
|
216
|
-
/**
|
|
450
|
+
/**
|
|
451
|
+
* Blending mode of this material.
|
|
452
|
+
* - 'none' for opaque, 'blend' for standard alpha, 'additive' for emissive FX.
|
|
453
|
+
* - Changing the mode toggles an internal feature and rebuilds variants.
|
|
454
|
+
*/ get blendMode() {
|
|
217
455
|
return this._blendMode;
|
|
218
456
|
}
|
|
219
457
|
set blendMode(val) {
|
|
220
458
|
if (this._blendMode !== val) {
|
|
221
459
|
this._blendMode = val;
|
|
222
|
-
this.useFeature(FEATURE_ALPHABLEND, this._blendMode
|
|
460
|
+
this.useFeature(FEATURE_ALPHABLEND, this._blendMode);
|
|
223
461
|
}
|
|
224
462
|
}
|
|
225
|
-
/**
|
|
463
|
+
/**
|
|
464
|
+
* Face culling mode: 'none' | 'front' | 'back'.
|
|
465
|
+
* - Does not force shader rebuild; affects rasterizer state.
|
|
466
|
+
*/ get cullMode() {
|
|
226
467
|
return this._cullMode;
|
|
227
468
|
}
|
|
228
469
|
set cullMode(val) {
|
|
229
470
|
this._cullMode = val;
|
|
230
471
|
}
|
|
231
|
-
/**
|
|
472
|
+
/**
|
|
473
|
+
* Material opacity in [0, 1].
|
|
474
|
+
* - Used in transparent passes. Changing marks uniforms dirty only.
|
|
475
|
+
*/ get opacity() {
|
|
232
476
|
return this._opacity;
|
|
233
477
|
}
|
|
234
478
|
set opacity(val) {
|
|
235
479
|
val = val < 0 ? 0 : val > 1 ? 1 : val;
|
|
236
480
|
if (this._opacity !== val) {
|
|
237
481
|
this._opacity = val;
|
|
238
|
-
this.useFeature(FEATURE_ALPHABLEND, this._blendMode !== 'none' || this._opacity < 1);
|
|
239
482
|
this.uniformChanged();
|
|
240
483
|
}
|
|
241
484
|
}
|
|
242
|
-
/**
|
|
485
|
+
/**
|
|
486
|
+
* Per-object color used for GPU picking/object-ID pass.
|
|
487
|
+
* - Changing marks uniforms dirty only.
|
|
488
|
+
*/ get objectColor() {
|
|
243
489
|
return this._objectColor;
|
|
244
490
|
}
|
|
245
491
|
set objectColor(val) {
|
|
246
492
|
if (val !== this._objectColor) {
|
|
247
|
-
this._objectColor
|
|
493
|
+
this._objectColor.set(val ?? Vector4.one());
|
|
248
494
|
this.uniformChanged();
|
|
249
495
|
}
|
|
250
496
|
}
|
|
251
|
-
/**
|
|
497
|
+
/**
|
|
498
|
+
* Whether this material responds to scene lighting.
|
|
499
|
+
* Override to return false for unlit materials.
|
|
500
|
+
*
|
|
501
|
+
* @returns True if lighting affects this material; otherwise false.
|
|
502
|
+
*/ supportLighting() {
|
|
252
503
|
return true;
|
|
253
504
|
}
|
|
254
505
|
/**
|
|
255
|
-
*
|
|
506
|
+
* Update render states per pass and draw context.
|
|
507
|
+
* Sets blending, alpha-to-coverage, depth test/write, cull mode, color mask, and cooperates with OIT.
|
|
508
|
+
*
|
|
509
|
+
* @param pass - Current material pass index.
|
|
510
|
+
* @param stateSet - Render state set to update.
|
|
511
|
+
* @param ctx - Current draw context.
|
|
512
|
+
* @returns void
|
|
256
513
|
*/ updateRenderStates(pass, stateSet, ctx) {
|
|
257
514
|
const isObjectColorPass = ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR;
|
|
258
|
-
const blending = !isObjectColorPass && (this.featureUsed(FEATURE_ALPHABLEND) || ctx.lightBlending);
|
|
515
|
+
const blending = !isObjectColorPass && (this.featureUsed(FEATURE_ALPHABLEND) !== 'none' || ctx.lightBlending);
|
|
259
516
|
const a2c = !isObjectColorPass && this.featureUsed(FEATURE_ALPHATOCOVERAGE);
|
|
260
|
-
const ztestEq = ctx.queue === QUEUE_OPAQUE && !!ctx.depthTexture;
|
|
517
|
+
const ztestEq = ctx.queue === QUEUE_OPAQUE && !!ctx.depthTexture && !ctx.sceneColorTexture;
|
|
261
518
|
if (blending || a2c) {
|
|
262
519
|
const blendingState = stateSet.useBlendingState();
|
|
263
520
|
if (blending) {
|
|
@@ -280,7 +537,7 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
280
537
|
} else {
|
|
281
538
|
stateSet.defaultDepthState();
|
|
282
539
|
}
|
|
283
|
-
} else
|
|
540
|
+
} else {
|
|
284
541
|
stateSet.defaultBlendingState();
|
|
285
542
|
if (ztestEq) {
|
|
286
543
|
stateSet.useDepthState().setCompareFunc('eq').enableTest(true).enableWrite(false);
|
|
@@ -306,39 +563,53 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
306
563
|
}
|
|
307
564
|
}
|
|
308
565
|
/**
|
|
309
|
-
* Submit
|
|
566
|
+
* Submit material uniforms/resources to the material bind group (set 2).
|
|
567
|
+
* Handles alpha cutoff, opacity (non-instanced transparent), OIT, object color, and TAA strength.
|
|
310
568
|
*
|
|
311
|
-
* @param bindGroup -
|
|
312
|
-
* @param ctx -
|
|
313
|
-
* @param pass - Current pass
|
|
569
|
+
* @param bindGroup - The material bind group to write into.
|
|
570
|
+
* @param ctx - Current draw context.
|
|
571
|
+
* @param pass - Current material pass index.
|
|
572
|
+
* @returns void
|
|
314
573
|
*/ applyUniformValues(bindGroup, ctx, pass) {
|
|
315
574
|
if (this.featureUsed(FEATURE_ALPHATEST)) {
|
|
316
575
|
bindGroup.setValue('zAlphaCutoff', this._alphaCutoff);
|
|
317
576
|
}
|
|
318
|
-
if (this.isTransparentPass(pass)) {
|
|
577
|
+
if (this.isTransparentPass(pass) && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT && !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
319
578
|
bindGroup.setValue('zOpacity', this._opacity);
|
|
320
579
|
}
|
|
321
580
|
if (ctx.oit) {
|
|
322
581
|
ctx.oit.applyUniforms(ctx, bindGroup);
|
|
323
582
|
}
|
|
324
|
-
if (
|
|
325
|
-
bindGroup.setValue('
|
|
583
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH && ctx.motionVectors) {
|
|
584
|
+
bindGroup.setValue('zTAAStrength', (1 - this._taaStrength) * 50000);
|
|
326
585
|
}
|
|
327
586
|
}
|
|
328
587
|
/**
|
|
329
|
-
* Determine
|
|
330
|
-
*
|
|
588
|
+
* Determine the render queue for this material.
|
|
589
|
+
* Transparent materials are queued as `QUEUE_TRANSPARENT`, otherwise `QUEUE_OPAQUE`.
|
|
590
|
+
*
|
|
591
|
+
* @returns The queue type constant.
|
|
331
592
|
*/ getQueueType() {
|
|
332
593
|
return this.isTransparentPass(0) ? QUEUE_TRANSPARENT : QUEUE_OPAQUE;
|
|
333
594
|
}
|
|
334
595
|
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
|
|
339
|
-
|
|
596
|
+
* Whether the given pass is transparent.
|
|
597
|
+
* Default returns true when `blendMode !== 'none'`.
|
|
598
|
+
*
|
|
599
|
+
* @param pass - Material pass index.
|
|
600
|
+
* @returns True if the pass is transparent; otherwise false.
|
|
601
|
+
*/ isTransparentPass(_pass) {
|
|
602
|
+
return this.featureUsed(FEATURE_ALPHABLEND) !== 'none';
|
|
340
603
|
}
|
|
341
|
-
/**
|
|
604
|
+
/**
|
|
605
|
+
* Create the GPU program for a given pass and draw context.
|
|
606
|
+
* Enables depth-clamp emulation for shadow map passes when required by the light, then delegates to `_createProgram`.
|
|
607
|
+
*
|
|
608
|
+
* @param ctx - Current draw context.
|
|
609
|
+
* @param pass - Material pass index.
|
|
610
|
+
* @returns The created `GPUProgram`.
|
|
611
|
+
* @internal
|
|
612
|
+
*/ createProgram(ctx, pass) {
|
|
342
613
|
const pb = new ProgramBuilder(ctx.device);
|
|
343
614
|
if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
344
615
|
const shadowMapParams = ctx.shadowMapInfo.get(ctx.renderPass.light);
|
|
@@ -347,18 +618,21 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
347
618
|
return this._createProgram(pb, ctx, pass);
|
|
348
619
|
}
|
|
349
620
|
/**
|
|
350
|
-
*
|
|
621
|
+
* Query a feature flag’s current value.
|
|
351
622
|
*
|
|
352
|
-
* @
|
|
353
|
-
* @
|
|
623
|
+
* @typeParam T - Expected value type.
|
|
624
|
+
* @param feature - The feature index.
|
|
625
|
+
* @returns The current value for the feature, typed as `T`.
|
|
354
626
|
*/ featureUsed(feature) {
|
|
355
627
|
return this._featureStates[feature];
|
|
356
628
|
}
|
|
357
629
|
/**
|
|
358
|
-
*
|
|
630
|
+
* Enable or disable a feature and trigger variant rebuild when changed.
|
|
631
|
+
* Calls `optionChanged(true)` internally on change.
|
|
359
632
|
*
|
|
360
|
-
* @param feature -
|
|
361
|
-
* @param use -
|
|
633
|
+
* @param feature - The feature index to set.
|
|
634
|
+
* @param use - The new feature value (typed by convention).
|
|
635
|
+
* @returns void
|
|
362
636
|
*/ useFeature(feature, use) {
|
|
363
637
|
if (this._featureStates[feature] !== use) {
|
|
364
638
|
this._featureStates[feature] = use;
|
|
@@ -366,48 +640,74 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
366
640
|
}
|
|
367
641
|
}
|
|
368
642
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
643
|
+
* Create the material-specific hash fragment from feature state.
|
|
644
|
+
* Contributes to program variant hashing.
|
|
371
645
|
*
|
|
646
|
+
* @returns The hash fragment string.
|
|
372
647
|
* @internal
|
|
373
648
|
*/ _createHash() {
|
|
374
649
|
return this._featureStates.map((val)=>val === undefined ? '' : val).join('|');
|
|
375
650
|
}
|
|
376
651
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
652
|
+
* Apply material uniforms to the bind group (set 2).
|
|
653
|
+
* Default implementation delegates to `applyUniformValues`.
|
|
379
654
|
*
|
|
655
|
+
* @param bindGroup - The material bind group to update.
|
|
656
|
+
* @param ctx - Current draw context.
|
|
657
|
+
* @param pass - Current material pass index.
|
|
658
|
+
* @returns void
|
|
380
659
|
* @internal
|
|
381
660
|
*/ _applyUniforms(bindGroup, ctx, pass) {
|
|
382
661
|
this.applyUniformValues(bindGroup, ctx, pass);
|
|
383
662
|
}
|
|
384
663
|
/**
|
|
385
|
-
*
|
|
664
|
+
* Whether the fragment shader needs to compute color.
|
|
665
|
+
* Returns true for LIGHT pass, or when alpha test or alpha-to-coverage is enabled.
|
|
666
|
+
* Override if the material writes color in other passes.
|
|
386
667
|
*
|
|
387
|
-
* @
|
|
668
|
+
* @param ctx - Optional draw context; defaults to the last captured `drawContext`.
|
|
669
|
+
* @returns True if fragment color computation is needed; otherwise false.
|
|
388
670
|
*/ needFragmentColor(ctx) {
|
|
389
671
|
return (ctx ?? this.drawContext).renderPass.type === RENDER_PASS_TYPE_LIGHT || this._alphaCutoff > 0 || this.alphaToCoverage;
|
|
390
672
|
}
|
|
391
673
|
/**
|
|
392
|
-
* Vertex shader
|
|
393
|
-
*
|
|
674
|
+
* Vertex shader hook.
|
|
675
|
+
* Prepares common inputs (skin/morph/instancing), varyings, and pass-dependent outputs.
|
|
676
|
+
* Override to implement per-vertex logic; use `ShaderHelper` as needed.
|
|
677
|
+
*
|
|
678
|
+
* @param scope - Vertex shader function scope.
|
|
679
|
+
* @returns void
|
|
394
680
|
*/ vertexShader(scope) {
|
|
395
681
|
const pb = scope.$builder;
|
|
396
682
|
ShaderHelper.prepareVertexShader(pb, this.drawContext);
|
|
397
683
|
if (this.drawContext.materialFlags & MaterialVaryingFlags.SKIN_ANIMATION) {
|
|
398
684
|
scope.$inputs.zBlendIndices = pb.vec4().attrib('blendIndices');
|
|
399
685
|
scope.$inputs.zBlendWeights = pb.vec4().attrib('blendWeights');
|
|
686
|
+
ShaderHelper.prepareSkinAnimation(scope);
|
|
400
687
|
}
|
|
401
688
|
if (this.drawContext.materialFlags & MaterialVaryingFlags.MORPH_ANIMATION && this.drawContext.device.type === 'webgl') {
|
|
402
689
|
scope.$inputs.zFakeVertexID = pb.float().attrib('texCoord7');
|
|
403
690
|
}
|
|
404
|
-
if (this.drawContext.
|
|
405
|
-
|
|
691
|
+
if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
|
|
692
|
+
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
693
|
+
scope.$outputs.zObjectColor = this.getInstancedUniform(scope, MeshMaterial.OBJECT_COLOR_UNIFORM);
|
|
694
|
+
}
|
|
695
|
+
if (this.isTransparentPass(this.pass)) {
|
|
696
|
+
scope.$outputs.zOpacity = this.getInstancedUniform(scope, MeshMaterial.OPACITY_UNIFORM);
|
|
697
|
+
}
|
|
698
|
+
} else {
|
|
699
|
+
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
700
|
+
scope.$outputs.zObjectColor = scope[ShaderHelper.getObjectColorUniformName()];
|
|
701
|
+
}
|
|
406
702
|
}
|
|
407
703
|
}
|
|
408
704
|
/**
|
|
409
|
-
* Fragment shader
|
|
410
|
-
*
|
|
705
|
+
* Fragment shader hook.
|
|
706
|
+
* Declares pass-dependent uniforms (e.g., opacity, objectColor, alphaCutoff).
|
|
707
|
+
* Override to implement per-fragment logic, and call `outputFragmentColor` to finalize writes.
|
|
708
|
+
*
|
|
709
|
+
* @param scope - Fragment shader function scope.
|
|
710
|
+
* @returns void
|
|
411
711
|
*/ fragmentShader(scope) {
|
|
412
712
|
const pb = scope.$builder;
|
|
413
713
|
ShaderHelper.prepareFragmentShader(pb, this.drawContext);
|
|
@@ -415,17 +715,19 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
415
715
|
scope.zAlphaCutoff = pb.float().uniform(2);
|
|
416
716
|
}
|
|
417
717
|
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
418
|
-
if (this.isTransparentPass(this.pass)) {
|
|
718
|
+
if (this.isTransparentPass(this.pass) && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
419
719
|
scope.zOpacity = pb.float().uniform(2);
|
|
420
720
|
}
|
|
421
|
-
} else if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
422
|
-
scope.zObjectColor = pb.vec4().uniform(2);
|
|
423
721
|
}
|
|
424
722
|
}
|
|
425
723
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
724
|
+
* Build and return the GPU program for this pass.
|
|
725
|
+
* Wires `vertexShader` and `fragmentShader`; sets up pass-dependent outputs (OIT, SSR, motion vectors, distance/object color).
|
|
428
726
|
*
|
|
727
|
+
* @param pb - Program builder.
|
|
728
|
+
* @param ctx - Current draw context.
|
|
729
|
+
* @param pass - Material pass index.
|
|
730
|
+
* @returns The created `GPUProgram`.
|
|
429
731
|
* @internal
|
|
430
732
|
*/ _createProgram(pb, ctx, pass) {
|
|
431
733
|
const that = this;
|
|
@@ -446,27 +748,38 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
446
748
|
this.$outputs.zSSRRoughness = pb.vec4();
|
|
447
749
|
this.$outputs.zSSRNormal = pb.vec4();
|
|
448
750
|
}
|
|
751
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH && ctx.motionVectors) {
|
|
752
|
+
this.$outputs.zMotionVector = pb.vec4();
|
|
753
|
+
this.zTAAStrength = pb.float().uniform(2);
|
|
754
|
+
}
|
|
755
|
+
if (ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
756
|
+
this.$outputs.zDistance = pb.vec4();
|
|
757
|
+
}
|
|
449
758
|
}
|
|
450
759
|
pb.main(function() {
|
|
451
760
|
that.fragmentShader(this);
|
|
452
761
|
});
|
|
453
762
|
}
|
|
454
763
|
});
|
|
455
|
-
|
|
456
|
-
if (program) {
|
|
457
|
-
console.log(program.getShaderSource('vertex'));
|
|
458
|
-
console.log(program.getShaderSource('fragment'));
|
|
459
|
-
}
|
|
460
|
-
*/ return program;
|
|
764
|
+
return program;
|
|
461
765
|
}
|
|
462
|
-
doAlphaTest(scope, color) {}
|
|
463
766
|
/**
|
|
464
|
-
*
|
|
767
|
+
* Centralized final color write and per-pass output composition.
|
|
465
768
|
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
769
|
+
* Behavior by pass:
|
|
770
|
+
* - LIGHT: clipping, alpha handling, optional OIT integration, fog application, color output encoding.
|
|
771
|
+
* - DEPTH: encoded depth; optional motion vectors (TAA enabled/disabled handling).
|
|
772
|
+
* - OBJECT_COLOR: object color and distance output (linear depth or world-pos + distance).
|
|
773
|
+
* - SHADOWMAP: writes shadow depth via light’s shadow implementation.
|
|
468
774
|
*
|
|
469
|
-
*
|
|
775
|
+
* Also writes SSR roughness/normal buffers when requested via material flags.
|
|
776
|
+
*
|
|
777
|
+
* @param scope - Inside-function shader scope.
|
|
778
|
+
* @param worldPos - Fragment world-space position expression.
|
|
779
|
+
* @param color - Lit fragment color expression; may be undefined for depth-only paths.
|
|
780
|
+
* @param ssrRoughness - Optional SSR roughness output expression.
|
|
781
|
+
* @param ssrNormal - Optional SSR normal output expression.
|
|
782
|
+
* @returns void
|
|
470
783
|
*/ outputFragmentColor(scope, worldPos, color, ssrRoughness, ssrNormal) {
|
|
471
784
|
const pb = scope.$builder;
|
|
472
785
|
const that = this;
|
|
@@ -480,28 +793,35 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
480
793
|
this.$l.outColor = color ? this.color : pb.vec4();
|
|
481
794
|
if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
482
795
|
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
483
|
-
|
|
796
|
+
let output = true;
|
|
797
|
+
if (!that.isTransparentPass(that.pass) && !that.alphaToCoverage) {
|
|
484
798
|
this.outColor.a = 1;
|
|
485
|
-
} else if (
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if (this.zAlphaCutoff) {
|
|
489
|
-
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
490
|
-
pb.discard();
|
|
491
|
-
});
|
|
799
|
+
} else if (that.isTransparentPass(that.pass)) {
|
|
800
|
+
const opacity = that.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING ? this.$inputs.zOpacity : this.zOpacity;
|
|
801
|
+
this.outColor.a = pb.mul(this.outColor.a, opacity);
|
|
492
802
|
}
|
|
493
803
|
if (that.isTransparentPass(that.pass)) {
|
|
494
|
-
if (
|
|
495
|
-
this
|
|
804
|
+
if (this.zAlphaCutoff) {
|
|
805
|
+
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
806
|
+
pb.discard();
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
if (!that.drawContext.oit || that.drawContext.oit.wantsPremultipliedAlpha()) {
|
|
810
|
+
this.outColor = pb.vec4(pb.mul(this.outColor.rgb, this.outColor.a), that.featureUsed(FEATURE_ALPHABLEND) === 'additive' ? 0 : this.outColor.a);
|
|
496
811
|
}
|
|
812
|
+
output = !that.drawContext.oit || !that.drawContext.oit.outputFragmentColor(this, this.outColor);
|
|
813
|
+
}
|
|
814
|
+
if (output) {
|
|
815
|
+
ShaderHelper.applyFog(this, this.worldPos, this.outColor, that.drawContext);
|
|
816
|
+
this.$outputs.zFragmentOutput = ShaderHelper.encodeColorOutput(this, this.outColor);
|
|
497
817
|
}
|
|
498
|
-
ShaderHelper.applyFog(this, this.worldPos, this.outColor, that.drawContext);
|
|
499
|
-
this.$outputs.zFragmentOutput = ShaderHelper.encodeColorOutput(this, this.outColor);
|
|
500
818
|
} else if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_DEPTH) {
|
|
501
819
|
if (color) {
|
|
502
|
-
|
|
503
|
-
pb.
|
|
504
|
-
|
|
820
|
+
if (this.zAlphaCutoff) {
|
|
821
|
+
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
822
|
+
pb.discard();
|
|
823
|
+
});
|
|
824
|
+
}
|
|
505
825
|
}
|
|
506
826
|
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
507
827
|
const depthPass = that.drawContext.renderPass;
|
|
@@ -513,6 +833,17 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
513
833
|
} else {
|
|
514
834
|
this.$outputs.zFragmentOutput = pb.vec4(this.depth, 0, 0, 1);
|
|
515
835
|
}
|
|
836
|
+
if (that.drawContext.motionVectors) {
|
|
837
|
+
if (that.featureUsed(FEATURE_DISABLE_TAA)) {
|
|
838
|
+
this.$outputs.zMotionVector = pb.vec4(6e4, 6e4, 1, 1);
|
|
839
|
+
} else {
|
|
840
|
+
if (this.$inputs.zMotionVectorPosCurrent && this.$inputs.zMotionVectorPosPrev) {
|
|
841
|
+
this.$outputs.zMotionVector = pb.vec4(pb.mul(pb.sub(pb.div(this.$inputs.zMotionVectorPosCurrent.xy, this.$inputs.zMotionVectorPosCurrent.w), pb.div(this.$inputs.zMotionVectorPosPrev.xy, this.$inputs.zMotionVectorPosPrev.w)), 0.5), this.zTAAStrength, 1);
|
|
842
|
+
} else {
|
|
843
|
+
this.$outputs.zMotionVector = pb.vec4(0, 0, 1, 1);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
516
847
|
} else if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
517
848
|
if (color) {
|
|
518
849
|
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
@@ -520,7 +851,13 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
520
851
|
});
|
|
521
852
|
}
|
|
522
853
|
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
523
|
-
this.$outputs.zFragmentOutput =
|
|
854
|
+
this.$outputs.zFragmentOutput = scope.$inputs.zObjectColor;
|
|
855
|
+
if (that.drawContext.device.type === 'webgl') {
|
|
856
|
+
this.$l.linearDepth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.$builtins.fragCoord.z);
|
|
857
|
+
this.$outputs.zDistance = encodeNormalizedFloatToRGBA(this, this.linearDepth);
|
|
858
|
+
} else {
|
|
859
|
+
this.$outputs.zDistance = pb.vec4(this.worldPos, pb.distance(ShaderHelper.getCameraPosition(this), this.worldPos));
|
|
860
|
+
}
|
|
524
861
|
} else {
|
|
525
862
|
if (color) {
|
|
526
863
|
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
@@ -532,7 +869,11 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
532
869
|
this.$outputs.zFragmentOutput = shadowMapParams.impl.computeShadowMapDepth(shadowMapParams, this, this.worldPos);
|
|
533
870
|
}
|
|
534
871
|
});
|
|
535
|
-
|
|
872
|
+
if (color) {
|
|
873
|
+
pb.getGlobalScope()[funcName](worldPos, color);
|
|
874
|
+
} else {
|
|
875
|
+
pb.getGlobalScope()[funcName](worldPos);
|
|
876
|
+
}
|
|
536
877
|
if (that.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
537
878
|
scope.$outputs.zSSRRoughness = ssrRoughness ?? pb.vec4(1, 0, 0, 1);
|
|
538
879
|
scope.$outputs.zSSRNormal = ssrNormal ?? pb.vec4(0);
|
|
@@ -542,6 +883,7 @@ let FEATURE_ALPHATOCOVERAGE = 0;
|
|
|
542
883
|
FEATURE_ALPHATEST = MeshMaterial.defineFeature();
|
|
543
884
|
FEATURE_ALPHABLEND = MeshMaterial.defineFeature();
|
|
544
885
|
FEATURE_ALPHATOCOVERAGE = MeshMaterial.defineFeature();
|
|
886
|
+
FEATURE_DISABLE_TAA = MeshMaterial.defineFeature();
|
|
545
887
|
|
|
546
888
|
export { MeshMaterial, applyMaterialMixins };
|
|
547
889
|
//# sourceMappingURL=meshmaterial.js.map
|