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