@zephyr3d/scene 0.9.5 → 0.9.7
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/joint_dynamics/controller.js +92 -32
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +71 -27
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +21 -20
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/skeleton.js +7 -10
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/app/engine.js +134 -140
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +47 -16
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +3 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +346 -7
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +20 -16
- package/dist/avatar/wardrobe.js.map +1 -1
- package/dist/camera/camera.js +416 -210
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1350 -621
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +1 -1
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +23 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +178 -23
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +4 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +2 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +1 -1
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +276 -65
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +3 -3
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +2 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/msdf_text.js +3 -3
- package/dist/material/msdf_text.js.map +1 -1
- package/dist/material/mtoon.js +574 -0
- package/dist/material/mtoon.js.map +1 -0
- package/dist/material/pbrblueprint.js +499 -336
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +118 -100
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +1 -1
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +324 -294
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +812 -0
- package/dist/material/subsurfaceprofile.js.map +1 -0
- package/dist/material/unlit.js +1 -1
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/compositor.js +46 -11
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/ssr.js +422 -96
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +1053 -0
- package/dist/posteffect/sss.js.map +1 -0
- package/dist/posteffect/taa.js +61 -60
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +63 -12
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +6 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +1 -5
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +2 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +2 -1
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +2 -1
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/lightpass.js +110 -23
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/render_queue.js +51 -8
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +80 -66
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +8 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +481 -95
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +55 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +10 -4
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sky.js +31 -1
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +23 -5
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +4 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -1
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +11 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +21 -3
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +29 -14
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +5 -2
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +5 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +3 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +6 -5
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +4 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +2 -1
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -2
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +4 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +26 -393
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/esm.js +112 -12
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +2 -2
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +19 -10
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +58 -7
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +6 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +229 -0
- package/dist/shadow/shadow_region.js.map +1 -0
- package/dist/shadow/shadowmapper.js +67 -59
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +45 -19
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/text/font/cff_font.js +890 -0
- package/dist/text/font/cff_font.js.map +1 -0
- package/dist/text/font/font_asset.js +17 -3
- package/dist/text/font/font_asset.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +8 -8
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +31 -4
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +1 -17
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +327 -359
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +5 -2
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -1
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +249 -54
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +37 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +42 -3
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1112 -646
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +7 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +31 -12
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -1
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +3 -1
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +18 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +5 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +3 -1
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -1
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +6 -0
- package/dist/utility/textures/ltcdata.js.map +1 -0
- package/dist/utility/textures/ltclut.js +61 -0
- package/dist/utility/textures/ltclut.js.map +1 -0
- package/dist/values.js +9 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/animation/ik/ik_pole_constraint.js +0 -123
- package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
- package/dist/animation/ik/ik_track.js +0 -96
- package/dist/animation/ik/ik_track.js.map +0 -1
- package/dist/animation/ik_postprocessor.js +0 -71
- package/dist/animation/ik_postprocessor.js.map +0 -1
- package/dist/animation/joint_dynamics/math.js +0 -16
- package/dist/animation/joint_dynamics/math.js.map +0 -1
- package/dist/animation/manual_transform_processor.js +0 -156
- package/dist/animation/manual_transform_processor.js.map +0 -1
- package/dist/animation/skeleton_postprocessor.js +0 -50
- package/dist/animation/skeleton_postprocessor.js.map +0 -1
- package/dist/animation/spring2/collision.js +0 -469
- package/dist/animation/spring2/collision.js.map +0 -1
- package/dist/animation/spring2/constraints.js +0 -329
- package/dist/animation/spring2/constraints.js.map +0 -1
- package/dist/animation/spring2/controller.js +0 -434
- package/dist/animation/spring2/controller.js.map +0 -1
- package/dist/animation/spring2/math.js +0 -16
- package/dist/animation/spring2/math.js.map +0 -1
- package/dist/animation/spring2/solver.js +0 -624
- package/dist/animation/spring2/solver.js.map +0 -1
- package/dist/animation/spring2/spring_system.js +0 -118
- package/dist/animation/spring2/spring_system.js.map +0 -1
- package/dist/animation/spring2/types.js +0 -19
- package/dist/animation/spring2/types.js.map +0 -1
- package/dist/animation/spring_postprocessor.js +0 -54
- package/dist/animation/spring_postprocessor.js.map +0 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +0 -1276
- package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/asset/loaders/gltf/helpers.js +0 -331
- package/dist/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/material/sprite3d.js +0 -301
- package/dist/material/sprite3d.js.map +0 -1
- package/dist/material/sprite3d_std.js +0 -116
- package/dist/material/sprite3d_std.js.map +0 -1
- package/dist/material/sprite3dblueprint.js +0 -235
- package/dist/material/sprite3dblueprint.js.map +0 -1
- package/dist/material/sprite_sdf.js +0 -106
- package/dist/material/sprite_sdf.js.map +0 -1
- package/dist/material/terrainmaterial.js +0 -368
- package/dist/material/terrainmaterial.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/render/deferredlightpass.js +0 -510
- package/dist/render/deferredlightpass.js.map +0 -1
- package/dist/render/deferredshadowlightpass.js +0 -428
- package/dist/render/deferredshadowlightpass.js.map +0 -1
- package/dist/render/gbufferpass.js +0 -50
- package/dist/render/gbufferpass.js.map +0 -1
- package/dist/scene/sdftextsprite.js +0 -322
- package/dist/scene/sdftextsprite.js.map +0 -1
- package/dist/scene/sprite3d.js +0 -18
- package/dist/scene/sprite3d.js.map +0 -1
- package/dist/scene/terrain/grass.js +0 -280
- package/dist/scene/terrain/grass.js.map +0 -1
- package/dist/scene/terrain/heightfield.js +0 -475
- package/dist/scene/terrain/heightfield.js.map +0 -1
- package/dist/scene/terrain/patch.js +0 -532
- package/dist/scene/terrain/patch.js.map +0 -1
- package/dist/scene/terrain/quadtree.js +0 -461
- package/dist/scene/terrain/quadtree.js.map +0 -1
- package/dist/scene/terrain/terrain.js +0 -231
- package/dist/scene/terrain/terrain.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
- package/dist/utility/serialization/scene/cloth_script.js +0 -834
- package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
- package/dist/utility/serialization/scene/spring_script.js +0 -596
- package/dist/utility/serialization/scene/spring_script.js.map +0 -1
|
@@ -1,704 +0,0 @@
|
|
|
1
|
-
import { ProgramBuilder } from '@zephyr3d/device';
|
|
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
|
-
import { Material } from './material.js';
|
|
4
|
-
import { encodeNormalizedFloatToRGBA } from '../shaders/misc.js';
|
|
5
|
-
import { Application } from '../app/app.js';
|
|
6
|
-
import { ShaderHelper } from './shader/helper.js';
|
|
7
|
-
import { Vector4, DRef, DWeakRef, Vector3, Vector2, applyMixins } from '@zephyr3d/base';
|
|
8
|
-
import { RenderBundleWrapper } from '../render/renderbundle_wrapper.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Apply material mixins to specific material class
|
|
12
|
-
* @param target - Material class
|
|
13
|
-
* @param mixins - mixins
|
|
14
|
-
* @returns Mixed mesh material class
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/ function applyMaterialMixins(target, ...mixins) {
|
|
18
|
-
return applyMixins(target, ...mixins);
|
|
19
|
-
}
|
|
20
|
-
let FEATURE_ALPHATEST = 0;
|
|
21
|
-
let FEATURE_ALPHABLEND = 0;
|
|
22
|
-
let FEATURE_ALPHATOCOVERAGE = 0;
|
|
23
|
-
let FEATURE_DISABLE_TAA = 0;
|
|
24
|
-
/**
|
|
25
|
-
* Base class for any kind of mesh materials
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
*/ class MeshMaterial extends Material {
|
|
29
|
-
/** @internal */ static INSTANCE_UNIFORMS = [];
|
|
30
|
-
/** @internal */ static NEXT_FEATURE_INDEX = 3;
|
|
31
|
-
/** @internal */ static OBJECT_COLOR_UNIFORM = this.defineInstanceUniform('objectColor', 'rgba');
|
|
32
|
-
/** @internal */ static OPACITY_UNIFORM = this.defineInstanceUniform('opacity', 'float');
|
|
33
|
-
/** @internal */ _featureStates;
|
|
34
|
-
/** @internal */ _alphaCutoff;
|
|
35
|
-
/** @internal */ _blendMode;
|
|
36
|
-
/** @internal */ _cullMode;
|
|
37
|
-
/** @internal */ _opacity;
|
|
38
|
-
/** @internal */ _taaStrength;
|
|
39
|
-
/** @internal */ _objectColor;
|
|
40
|
-
/** @internal */ _ctx;
|
|
41
|
-
/** @internal */ _materialPass;
|
|
42
|
-
/**
|
|
43
|
-
* Creates an instance of MeshMaterial class
|
|
44
|
-
* @param args - constructor arguments
|
|
45
|
-
*/ constructor(){
|
|
46
|
-
super();
|
|
47
|
-
this._featureStates = [];
|
|
48
|
-
this._alphaCutoff = 0;
|
|
49
|
-
this._blendMode = 'none';
|
|
50
|
-
this._cullMode = 'back';
|
|
51
|
-
this._opacity = 1;
|
|
52
|
-
this._taaStrength = 1 - 1 / 16;
|
|
53
|
-
this._objectColor = Vector4.one();
|
|
54
|
-
this._ctx = null;
|
|
55
|
-
this._materialPass = -1;
|
|
56
|
-
this.useFeature(FEATURE_ALPHABLEND, this._blendMode);
|
|
57
|
-
}
|
|
58
|
-
clone() {
|
|
59
|
-
const other = new MeshMaterial();
|
|
60
|
-
other.copyFrom(this);
|
|
61
|
-
return other;
|
|
62
|
-
}
|
|
63
|
-
copyFrom(other) {
|
|
64
|
-
super.copyFrom(other);
|
|
65
|
-
this.alphaCutoff = other.alphaCutoff;
|
|
66
|
-
this.blendMode = other.blendMode;
|
|
67
|
-
this.cullMode = other.cullMode;
|
|
68
|
-
this.opacity = other.opacity;
|
|
69
|
-
this.objectColor = other.objectColor;
|
|
70
|
-
}
|
|
71
|
-
/** Indicate that the uniform has changed and needs to be resubmitted. */ uniformChanged() {
|
|
72
|
-
this.optionChanged(false);
|
|
73
|
-
}
|
|
74
|
-
/** Define feature index */ static defineFeature() {
|
|
75
|
-
const val = this.NEXT_FEATURE_INDEX;
|
|
76
|
-
this.NEXT_FEATURE_INDEX++;
|
|
77
|
-
return val;
|
|
78
|
-
}
|
|
79
|
-
/** @internal */ static getNumComponents(type) {
|
|
80
|
-
if (type === 'float') {
|
|
81
|
-
return 1;
|
|
82
|
-
}
|
|
83
|
-
if (type === 'vec2') {
|
|
84
|
-
return 2;
|
|
85
|
-
}
|
|
86
|
-
if (type === 'rgb' || type === 'vec3') {
|
|
87
|
-
return 3;
|
|
88
|
-
}
|
|
89
|
-
if (type === 'rgba' || type === 'vec4') {
|
|
90
|
-
return 4;
|
|
91
|
-
}
|
|
92
|
-
return 0;
|
|
93
|
-
}
|
|
94
|
-
/** Define instance uniform index */ static defineInstanceUniform(prop, type) {
|
|
95
|
-
if (this.INSTANCE_UNIFORMS.findIndex((val)=>val.prop === prop) >= 0) {
|
|
96
|
-
throw new Error(`${this.name}.defineInstanceUniform(): ${prop} was already defined`);
|
|
97
|
-
}
|
|
98
|
-
const numComponents = this.getNumComponents(type);
|
|
99
|
-
if (numComponents === 0) {
|
|
100
|
-
throw new Error(`${this.name}.defineInstanceUniform(): invalid uniform type ${type}`);
|
|
101
|
-
}
|
|
102
|
-
let index = this.INSTANCE_UNIFORMS.length;
|
|
103
|
-
let offset = 0;
|
|
104
|
-
if (this.INSTANCE_UNIFORMS.length > 0) {
|
|
105
|
-
const lastUniform = this.INSTANCE_UNIFORMS[this.INSTANCE_UNIFORMS.length - 1];
|
|
106
|
-
const finalOffset = lastUniform.offset + 4 & -4;
|
|
107
|
-
offset = finalOffset;
|
|
108
|
-
for(let i = 0; i < this.INSTANCE_UNIFORMS.length; i++){
|
|
109
|
-
const offset1 = this.INSTANCE_UNIFORMS[i].offset;
|
|
110
|
-
const numComps1 = this.getNumComponents(this.INSTANCE_UNIFORMS[i].type);
|
|
111
|
-
const offset2 = i === this.INSTANCE_UNIFORMS.length - 1 ? finalOffset : this.INSTANCE_UNIFORMS[i + 1].offset;
|
|
112
|
-
if (offset1 + numComps1 + numComponents <= offset2) {
|
|
113
|
-
index = i + 1;
|
|
114
|
-
offset = offset1 + numComps1;
|
|
115
|
-
if (offset + numComponents === offset2) {
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
this.INSTANCE_UNIFORMS = this.INSTANCE_UNIFORMS.slice();
|
|
122
|
-
this.INSTANCE_UNIFORMS.splice(index, 0, {
|
|
123
|
-
prop,
|
|
124
|
-
offset,
|
|
125
|
-
type
|
|
126
|
-
});
|
|
127
|
-
return offset << 2 | numComponents - 1;
|
|
128
|
-
}
|
|
129
|
-
getInstancedUniform(scope, uniformIndex) {
|
|
130
|
-
const pb = scope.$builder;
|
|
131
|
-
const instanceID = scope.$builtins.instanceIndex;
|
|
132
|
-
const uniformName = ShaderHelper.getInstanceDataUniformName();
|
|
133
|
-
const strideName = ShaderHelper.getInstanceDataStrideUniformName();
|
|
134
|
-
const offsetName = ShaderHelper.getInstanceDataOffsetUniformName();
|
|
135
|
-
const numComponents = (uniformIndex & 3) + 1;
|
|
136
|
-
const vecIndex = uniformIndex >> 4;
|
|
137
|
-
const vecOffset = uniformIndex >> 2 & 3;
|
|
138
|
-
const u = scope[uniformName].at(pb.add(pb.mul(scope[strideName], instanceID), ShaderHelper.MATERIAL_INSTANCE_DATA_OFFSET + vecIndex, scope[offsetName]));
|
|
139
|
-
const m = [
|
|
140
|
-
'x',
|
|
141
|
-
'y',
|
|
142
|
-
'z',
|
|
143
|
-
'w'
|
|
144
|
-
].slice(vecOffset, vecOffset + numComponents).join('');
|
|
145
|
-
return u[m];
|
|
146
|
-
}
|
|
147
|
-
/** Get instanced material property list */ getInstancedUniforms() {
|
|
148
|
-
return this.constructor.INSTANCE_UNIFORMS;
|
|
149
|
-
}
|
|
150
|
-
/** Create material instance */ createInstance() {
|
|
151
|
-
if (this.$isInstance) {
|
|
152
|
-
return this.coreMaterial.createInstance();
|
|
153
|
-
}
|
|
154
|
-
const isWebGL1 = Application.instance.device.type === 'webgl';
|
|
155
|
-
if (isWebGL1 || !this.supportInstancing) {
|
|
156
|
-
return this.clone();
|
|
157
|
-
}
|
|
158
|
-
const instanceUniforms = this.getInstancedUniforms();
|
|
159
|
-
const uniformsHolder = instanceUniforms.length > 0 ? new Float32Array(instanceUniforms[instanceUniforms.length - 1].offset + 4 & -4) : null;
|
|
160
|
-
const instance = {};
|
|
161
|
-
const that = this;
|
|
162
|
-
const coreMaterial = new DRef(that);
|
|
163
|
-
let disposed = false;
|
|
164
|
-
instance.isBatchable = ()=>true; //!isWebGL1 && that.supportInstancing();
|
|
165
|
-
instance.dispose = ()=>{
|
|
166
|
-
if (!disposed) {
|
|
167
|
-
disposed = true;
|
|
168
|
-
coreMaterial.dispose();
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
instance.$instanceUniforms = uniformsHolder;
|
|
172
|
-
instance.$isInstance = true;
|
|
173
|
-
let persistentId = crypto.randomUUID();
|
|
174
|
-
Material._registry.set(persistentId, new DWeakRef(instance));
|
|
175
|
-
Object.defineProperty(instance, 'coreMaterial', {
|
|
176
|
-
get: function() {
|
|
177
|
-
return coreMaterial.get();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(instance, 'persistentId', {
|
|
181
|
-
get: function() {
|
|
182
|
-
return persistentId;
|
|
183
|
-
},
|
|
184
|
-
set: function(val) {
|
|
185
|
-
if (val !== persistentId) {
|
|
186
|
-
const m = Material._registry.get(persistentId);
|
|
187
|
-
if (!m || m.get() !== instance) {
|
|
188
|
-
throw new Error('Registry material mismatch');
|
|
189
|
-
}
|
|
190
|
-
Material._registry.delete(persistentId);
|
|
191
|
-
persistentId = val;
|
|
192
|
-
Material._registry.set(persistentId, m);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
// Copy original uniform values
|
|
197
|
-
for(let i = 0; i < instanceUniforms.length; i++){
|
|
198
|
-
const { prop, offset, type } = instanceUniforms[i];
|
|
199
|
-
const value = that[prop];
|
|
200
|
-
switch(type){
|
|
201
|
-
case 'float':
|
|
202
|
-
{
|
|
203
|
-
uniformsHolder[offset] = Number(value);
|
|
204
|
-
Object.defineProperty(instance, prop, {
|
|
205
|
-
get () {
|
|
206
|
-
return uniformsHolder[offset];
|
|
207
|
-
},
|
|
208
|
-
set (value) {
|
|
209
|
-
uniformsHolder[offset] = value;
|
|
210
|
-
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
case 'vec2':
|
|
216
|
-
{
|
|
217
|
-
if (!(value instanceof Vector2)) {
|
|
218
|
-
throw new Error(`Instance uniform property ${prop} must be of type Vector2`);
|
|
219
|
-
}
|
|
220
|
-
uniformsHolder[offset] = value.x;
|
|
221
|
-
uniformsHolder[offset + 1] = value.y;
|
|
222
|
-
Object.defineProperty(instance, prop, {
|
|
223
|
-
get () {
|
|
224
|
-
return new Vector2(uniformsHolder[offset], uniformsHolder[offset + 1]);
|
|
225
|
-
},
|
|
226
|
-
set (value) {
|
|
227
|
-
if (!(value instanceof Vector2)) {
|
|
228
|
-
throw new Error(`Instance uniform property ${prop} must be of type Vector2`);
|
|
229
|
-
}
|
|
230
|
-
uniformsHolder[offset] = value.x;
|
|
231
|
-
uniformsHolder[offset + 1] = value.y;
|
|
232
|
-
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
case 'vec3':
|
|
238
|
-
case 'rgb':
|
|
239
|
-
{
|
|
240
|
-
if (!(value instanceof Vector3)) {
|
|
241
|
-
throw new Error(`Instance uniform property ${prop} must be of type Vector3`);
|
|
242
|
-
}
|
|
243
|
-
uniformsHolder[offset] = value.x;
|
|
244
|
-
uniformsHolder[offset + 1] = value.y;
|
|
245
|
-
uniformsHolder[offset + 2] = value.z;
|
|
246
|
-
Object.defineProperty(instance, prop, {
|
|
247
|
-
get () {
|
|
248
|
-
return new Vector3(uniformsHolder[offset], uniformsHolder[offset + 1], uniformsHolder[offset + 2]);
|
|
249
|
-
},
|
|
250
|
-
set (value) {
|
|
251
|
-
if (!(value instanceof Vector3)) {
|
|
252
|
-
throw new Error(`Instance uniform property ${prop} must be of type Vector3`);
|
|
253
|
-
}
|
|
254
|
-
uniformsHolder[offset] = value.x;
|
|
255
|
-
uniformsHolder[offset + 1] = value.y;
|
|
256
|
-
uniformsHolder[offset + 2] = value.z;
|
|
257
|
-
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
case 'vec4':
|
|
263
|
-
case 'rgba':
|
|
264
|
-
{
|
|
265
|
-
if (!(value instanceof Vector4)) {
|
|
266
|
-
throw new Error(`Instance uniform property ${prop} must be of type Vector4`);
|
|
267
|
-
}
|
|
268
|
-
uniformsHolder[offset] = value.x;
|
|
269
|
-
uniformsHolder[offset + 1] = value.y;
|
|
270
|
-
uniformsHolder[offset + 2] = value.z;
|
|
271
|
-
uniformsHolder[offset + 3] = value.w;
|
|
272
|
-
Object.defineProperty(instance, prop, {
|
|
273
|
-
get () {
|
|
274
|
-
return new Vector4(uniformsHolder[offset], uniformsHolder[offset + 1], uniformsHolder[offset + 2], uniformsHolder[offset + 3]);
|
|
275
|
-
},
|
|
276
|
-
set (value) {
|
|
277
|
-
if (!(value instanceof Vector4)) {
|
|
278
|
-
throw new Error(`Instance uniform property ${prop} must be of type Vector4`);
|
|
279
|
-
}
|
|
280
|
-
uniformsHolder[offset] = value.x;
|
|
281
|
-
uniformsHolder[offset + 1] = value.y;
|
|
282
|
-
uniformsHolder[offset + 2] = value.z;
|
|
283
|
-
uniformsHolder[offset + 3] = value.w;
|
|
284
|
-
RenderBundleWrapper.materialUniformsChanged(instance);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
Object.setPrototypeOf(instance, that);
|
|
292
|
-
return instance;
|
|
293
|
-
}
|
|
294
|
-
/** Draw context for shader creation */ get drawContext() {
|
|
295
|
-
return this._ctx;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Current material pass
|
|
299
|
-
* @internal
|
|
300
|
-
**/ get pass() {
|
|
301
|
-
return this._materialPass;
|
|
302
|
-
}
|
|
303
|
-
/** A value between 0 and 1, presents the cutoff for alpha testing */ get alphaCutoff() {
|
|
304
|
-
return this._alphaCutoff;
|
|
305
|
-
}
|
|
306
|
-
set alphaCutoff(val) {
|
|
307
|
-
if (this._alphaCutoff !== val) {
|
|
308
|
-
this.useFeature(FEATURE_ALPHATEST, val > 0);
|
|
309
|
-
this._alphaCutoff = val;
|
|
310
|
-
this.uniformChanged();
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
/** Whether TAA should be disabled on this material */ get TAADisabled() {
|
|
314
|
-
return !!this.featureUsed(FEATURE_DISABLE_TAA);
|
|
315
|
-
}
|
|
316
|
-
set TAADisabled(val) {
|
|
317
|
-
this.useFeature(FEATURE_DISABLE_TAA, !!val);
|
|
318
|
-
}
|
|
319
|
-
/** TAA strength */ get TAAStrength() {
|
|
320
|
-
return this._taaStrength;
|
|
321
|
-
}
|
|
322
|
-
set TAAStrength(val) {
|
|
323
|
-
val = val > 1 ? 1 : val < 0 ? 0 : val;
|
|
324
|
-
if (this._taaStrength !== val) {
|
|
325
|
-
this._taaStrength = val;
|
|
326
|
-
this.uniformChanged();
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
get alphaToCoverage() {
|
|
330
|
-
return this.featureUsed(FEATURE_ALPHATOCOVERAGE);
|
|
331
|
-
}
|
|
332
|
-
set alphaToCoverage(val) {
|
|
333
|
-
this.useFeature(FEATURE_ALPHATOCOVERAGE, !!val);
|
|
334
|
-
}
|
|
335
|
-
/** Blending mode */ get blendMode() {
|
|
336
|
-
return this._blendMode;
|
|
337
|
-
}
|
|
338
|
-
set blendMode(val) {
|
|
339
|
-
if (this._blendMode !== val) {
|
|
340
|
-
this._blendMode = val;
|
|
341
|
-
this.useFeature(FEATURE_ALPHABLEND, this._blendMode);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/** Cull mode */ get cullMode() {
|
|
345
|
-
return this._cullMode;
|
|
346
|
-
}
|
|
347
|
-
set cullMode(val) {
|
|
348
|
-
this._cullMode = val;
|
|
349
|
-
}
|
|
350
|
-
/** A value between 0 and 1, presents the opacity */ get opacity() {
|
|
351
|
-
return this._opacity;
|
|
352
|
-
}
|
|
353
|
-
set opacity(val) {
|
|
354
|
-
val = val < 0 ? 0 : val > 1 ? 1 : val;
|
|
355
|
-
if (this._opacity !== val) {
|
|
356
|
-
this._opacity = val;
|
|
357
|
-
this.uniformChanged();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
/** Object color used for GPU picking */ get objectColor() {
|
|
361
|
-
return this._objectColor;
|
|
362
|
-
}
|
|
363
|
-
set objectColor(val) {
|
|
364
|
-
if (val !== this._objectColor) {
|
|
365
|
-
this._objectColor.set(val ?? Vector4.one());
|
|
366
|
-
this.uniformChanged();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/** Returns true if shading of the material will be affected by lights */ supportLighting() {
|
|
370
|
-
return true;
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* {@inheritDoc Material.updateRenderStates}
|
|
374
|
-
*/ updateRenderStates(pass, stateSet, ctx) {
|
|
375
|
-
const isObjectColorPass = ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR;
|
|
376
|
-
const blending = !isObjectColorPass && (this.featureUsed(FEATURE_ALPHABLEND) !== 'none' || ctx.lightBlending);
|
|
377
|
-
const a2c = !isObjectColorPass && this.featureUsed(FEATURE_ALPHATOCOVERAGE);
|
|
378
|
-
const ztestEq = ctx.queue === QUEUE_OPAQUE && !!ctx.depthTexture && !ctx.sceneColorTexture;
|
|
379
|
-
if (blending || a2c) {
|
|
380
|
-
const blendingState = stateSet.useBlendingState();
|
|
381
|
-
if (blending) {
|
|
382
|
-
blendingState.enable(true);
|
|
383
|
-
blendingState.setBlendFuncAlpha('zero', 'one');
|
|
384
|
-
blendingState.setBlendEquation('add', 'add');
|
|
385
|
-
if (this._blendMode === 'additive' || ctx.lightBlending) {
|
|
386
|
-
blendingState.setBlendFuncRGB('one', 'one');
|
|
387
|
-
} else {
|
|
388
|
-
blendingState.setBlendFuncRGB('one', 'inv-src-alpha');
|
|
389
|
-
}
|
|
390
|
-
} else {
|
|
391
|
-
blendingState.enable(false);
|
|
392
|
-
}
|
|
393
|
-
blendingState.enableAlphaToCoverage(a2c);
|
|
394
|
-
if (ztestEq) {
|
|
395
|
-
stateSet.useDepthState().setCompareFunc('eq').enableTest(true).enableWrite(false);
|
|
396
|
-
} else if (blendingState.enabled) {
|
|
397
|
-
stateSet.useDepthState().enableTest(true).enableWrite(false);
|
|
398
|
-
} else {
|
|
399
|
-
stateSet.defaultDepthState();
|
|
400
|
-
}
|
|
401
|
-
} else {
|
|
402
|
-
stateSet.defaultBlendingState();
|
|
403
|
-
if (ztestEq) {
|
|
404
|
-
stateSet.useDepthState().setCompareFunc('eq').enableTest(true).enableWrite(false);
|
|
405
|
-
} else {
|
|
406
|
-
stateSet.defaultDepthState();
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
if (ctx.forceCullMode || this._cullMode !== 'back') {
|
|
410
|
-
stateSet.useRasterizerState().cullMode = ctx.forceCullMode || this._cullMode;
|
|
411
|
-
} else if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
412
|
-
stateSet.useRasterizerState().cullMode = 'none';
|
|
413
|
-
} else {
|
|
414
|
-
stateSet.defaultRasterizerState();
|
|
415
|
-
}
|
|
416
|
-
if (ctx.forceColorState) {
|
|
417
|
-
stateSet.useColorState(ctx.forceColorState);
|
|
418
|
-
} else {
|
|
419
|
-
stateSet.defaultColorState();
|
|
420
|
-
}
|
|
421
|
-
stateSet.defaultStencilState();
|
|
422
|
-
if (ctx.oit) {
|
|
423
|
-
ctx.oit.setRenderStates(stateSet);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Submit Uniform values before rendering with this material.
|
|
428
|
-
*
|
|
429
|
-
* @param bindGroup - Bind group for this material
|
|
430
|
-
* @param ctx - Draw context
|
|
431
|
-
* @param pass - Current pass of the material
|
|
432
|
-
*/ applyUniformValues(bindGroup, ctx, pass) {
|
|
433
|
-
if (this.featureUsed(FEATURE_ALPHATEST)) {
|
|
434
|
-
bindGroup.setValue('zAlphaCutoff', this._alphaCutoff);
|
|
435
|
-
}
|
|
436
|
-
if (this.isTransparentPass(pass) && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT && !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
437
|
-
bindGroup.setValue('zOpacity', this._opacity);
|
|
438
|
-
}
|
|
439
|
-
if (ctx.oit) {
|
|
440
|
-
ctx.oit.applyUniforms(ctx, bindGroup);
|
|
441
|
-
}
|
|
442
|
-
if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING) && ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
443
|
-
bindGroup.setValue('zObjectColor', this._objectColor);
|
|
444
|
-
}
|
|
445
|
-
if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH && ctx.motionVectors) {
|
|
446
|
-
bindGroup.setValue('zTAAStrength', (1 - this._taaStrength) * 50000);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Determine which queue should be used to render this material.
|
|
451
|
-
* @returns QUEUE_TRANSPARENT or QUEUE_OPAQUE
|
|
452
|
-
*/ getQueueType() {
|
|
453
|
-
return this.isTransparentPass(0) ? QUEUE_TRANSPARENT : QUEUE_OPAQUE;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Determine if a certain pass of this material is translucent.
|
|
457
|
-
* @param pass - Pass of the material
|
|
458
|
-
* @returns True if it is translucent, otherwise false.
|
|
459
|
-
*/ isTransparentPass(_pass) {
|
|
460
|
-
return this.featureUsed(FEATURE_ALPHABLEND) !== 'none';
|
|
461
|
-
}
|
|
462
|
-
/** @internal */ createProgram(ctx, pass) {
|
|
463
|
-
const pb = new ProgramBuilder(ctx.device);
|
|
464
|
-
if (ctx.renderPass.type === RENDER_PASS_TYPE_SHADOWMAP) {
|
|
465
|
-
const shadowMapParams = ctx.shadowMapInfo.get(ctx.renderPass.light);
|
|
466
|
-
pb.emulateDepthClamp = !!shadowMapParams.depthClampEnabled;
|
|
467
|
-
}
|
|
468
|
-
return this._createProgram(pb, ctx, pass);
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Check if a feature is in use for given render pass type.
|
|
472
|
-
*
|
|
473
|
-
* @param feature - The feature index
|
|
474
|
-
* @returns true if the feature is in use, otherwise false.
|
|
475
|
-
*/ featureUsed(feature) {
|
|
476
|
-
return this._featureStates[feature];
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Use or unuse a feature of the material, this will cause the shader to be rebuild.
|
|
480
|
-
*
|
|
481
|
-
* @param feature - Which feature will be used or unused
|
|
482
|
-
* @param use - true if use the feature, otherwise false
|
|
483
|
-
*/ useFeature(feature, use) {
|
|
484
|
-
if (this._featureStates[feature] !== use) {
|
|
485
|
-
this._featureStates[feature] = use;
|
|
486
|
-
this.optionChanged(true);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* {@inheritDoc Material._createHash}
|
|
491
|
-
* @override
|
|
492
|
-
*
|
|
493
|
-
* @internal
|
|
494
|
-
*/ _createHash() {
|
|
495
|
-
return this._featureStates.map((val)=>val === undefined ? '' : val).join('|');
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* {@inheritDoc Material._applyUniforms}
|
|
499
|
-
* @override
|
|
500
|
-
*
|
|
501
|
-
* @internal
|
|
502
|
-
*/ _applyUniforms(bindGroup, ctx, pass) {
|
|
503
|
-
this.applyUniformValues(bindGroup, ctx, pass);
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Check if the color should be computed in fragment shader, this is required for forward render pass or alpha test is in use or alpha to coverage is in use.
|
|
507
|
-
*
|
|
508
|
-
* @returns - true if the color should be computed in fragment shader, otherwise false.
|
|
509
|
-
*/ needFragmentColor(ctx) {
|
|
510
|
-
return (ctx ?? this.drawContext).renderPass.type === RENDER_PASS_TYPE_LIGHT || this._alphaCutoff > 0 || this.alphaToCoverage;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Vertex shader implementation of this material
|
|
514
|
-
* @param scope - Shader scope
|
|
515
|
-
*/ vertexShader(scope) {
|
|
516
|
-
const pb = scope.$builder;
|
|
517
|
-
ShaderHelper.prepareVertexShader(pb, this.drawContext);
|
|
518
|
-
if (this.drawContext.materialFlags & MaterialVaryingFlags.SKIN_ANIMATION) {
|
|
519
|
-
scope.$inputs.zBlendIndices = pb.vec4().attrib('blendIndices');
|
|
520
|
-
scope.$inputs.zBlendWeights = pb.vec4().attrib('blendWeights');
|
|
521
|
-
ShaderHelper.prepareSkinAnimation(scope);
|
|
522
|
-
}
|
|
523
|
-
if (this.drawContext.materialFlags & MaterialVaryingFlags.MORPH_ANIMATION && this.drawContext.device.type === 'webgl') {
|
|
524
|
-
scope.$inputs.zFakeVertexID = pb.float().attrib('texCoord7');
|
|
525
|
-
}
|
|
526
|
-
if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
|
|
527
|
-
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
528
|
-
scope.$outputs.zObjectColor = this.getInstancedUniform(scope, MeshMaterial.OBJECT_COLOR_UNIFORM);
|
|
529
|
-
}
|
|
530
|
-
if (this.isTransparentPass(this.pass)) {
|
|
531
|
-
scope.$outputs.zOpacity = this.getInstancedUniform(scope, MeshMaterial.OPACITY_UNIFORM);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Fragment shader implementation of this material
|
|
537
|
-
* @param scope - Shader scope
|
|
538
|
-
*/ fragmentShader(scope) {
|
|
539
|
-
const pb = scope.$builder;
|
|
540
|
-
ShaderHelper.prepareFragmentShader(pb, this.drawContext);
|
|
541
|
-
if (this._alphaCutoff > 0) {
|
|
542
|
-
scope.zAlphaCutoff = pb.float().uniform(2);
|
|
543
|
-
}
|
|
544
|
-
if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
545
|
-
if (this.isTransparentPass(this.pass) && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
546
|
-
scope.zOpacity = pb.float().uniform(2);
|
|
547
|
-
}
|
|
548
|
-
} else if (this.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
549
|
-
scope.zObjectColor = pb.vec4().uniform(2);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* {@inheritDoc Material._createProgram}
|
|
554
|
-
* @override
|
|
555
|
-
*
|
|
556
|
-
* @internal
|
|
557
|
-
*/ _createProgram(pb, ctx, pass) {
|
|
558
|
-
const that = this;
|
|
559
|
-
this._ctx = ctx;
|
|
560
|
-
this._materialPass = pass;
|
|
561
|
-
const program = pb.buildRenderProgram({
|
|
562
|
-
vertex (pb) {
|
|
563
|
-
pb.main(function() {
|
|
564
|
-
that.vertexShader(this);
|
|
565
|
-
});
|
|
566
|
-
},
|
|
567
|
-
fragment (pb) {
|
|
568
|
-
if (that.drawContext.oit) {
|
|
569
|
-
that.drawContext.oit.setupFragmentOutput(this);
|
|
570
|
-
} else {
|
|
571
|
-
this.$outputs.zFragmentOutput = pb.vec4();
|
|
572
|
-
if (ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
573
|
-
this.$outputs.zSSRRoughness = pb.vec4();
|
|
574
|
-
this.$outputs.zSSRNormal = pb.vec4();
|
|
575
|
-
}
|
|
576
|
-
if (ctx.renderPass.type === RENDER_PASS_TYPE_DEPTH && ctx.motionVectors) {
|
|
577
|
-
this.$outputs.zMotionVector = pb.vec4();
|
|
578
|
-
this.zTAAStrength = pb.float().uniform(2);
|
|
579
|
-
}
|
|
580
|
-
if (ctx.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
581
|
-
this.$outputs.zDistance = pb.vec4();
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
pb.main(function() {
|
|
585
|
-
that.fragmentShader(this);
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
return program;
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Calculate final fragment color for output.
|
|
593
|
-
*
|
|
594
|
-
* @param scope - Shader scope
|
|
595
|
-
* @param color - Lit fragment color
|
|
596
|
-
*
|
|
597
|
-
* @returns The final fragment color
|
|
598
|
-
*/ outputFragmentColor(scope, worldPos, color, ssrRoughness, ssrNormal) {
|
|
599
|
-
const pb = scope.$builder;
|
|
600
|
-
const that = this;
|
|
601
|
-
const funcName = 'Z_outputFragmentColor';
|
|
602
|
-
pb.func(funcName, color ? [
|
|
603
|
-
pb.vec3('worldPos'),
|
|
604
|
-
pb.vec4('color')
|
|
605
|
-
] : [
|
|
606
|
-
pb.vec3('worldPos')
|
|
607
|
-
], function() {
|
|
608
|
-
this.$l.outColor = color ? this.color : pb.vec4();
|
|
609
|
-
if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
610
|
-
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
611
|
-
let output = true;
|
|
612
|
-
if (!that.isTransparentPass(that.pass) && !that.alphaToCoverage) {
|
|
613
|
-
this.outColor.a = 1;
|
|
614
|
-
} else if (that.isTransparentPass(that.pass)) {
|
|
615
|
-
const opacity = that.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING ? this.$inputs.zOpacity : this.zOpacity;
|
|
616
|
-
this.outColor.a = pb.mul(this.outColor.a, opacity);
|
|
617
|
-
}
|
|
618
|
-
if (that.isTransparentPass(that.pass)) {
|
|
619
|
-
if (this.zAlphaCutoff) {
|
|
620
|
-
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
621
|
-
pb.discard();
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
if (!that.drawContext.oit || that.drawContext.oit.wantsPremultipliedAlpha()) {
|
|
625
|
-
this.outColor = pb.vec4(pb.mul(this.outColor.rgb, this.outColor.a), that.featureUsed(FEATURE_ALPHABLEND) === 'additive' ? 0 : this.outColor.a);
|
|
626
|
-
}
|
|
627
|
-
output = !that.drawContext.oit || !that.drawContext.oit.outputFragmentColor(this, this.outColor);
|
|
628
|
-
}
|
|
629
|
-
if (output) {
|
|
630
|
-
ShaderHelper.applyFog(this, this.worldPos, this.outColor, that.drawContext);
|
|
631
|
-
this.$outputs.zFragmentOutput = ShaderHelper.encodeColorOutput(this, this.outColor);
|
|
632
|
-
}
|
|
633
|
-
} else if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_DEPTH) {
|
|
634
|
-
if (color) {
|
|
635
|
-
if (this.zAlphaCutoff) {
|
|
636
|
-
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
637
|
-
pb.discard();
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
642
|
-
const depthPass = that.drawContext.renderPass;
|
|
643
|
-
this.$l.depth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.$builtins.fragCoord.z);
|
|
644
|
-
if (depthPass.encodeDepth) {
|
|
645
|
-
this.$outputs.zFragmentOutput = encodeNormalizedFloatToRGBA(this, this.depth);
|
|
646
|
-
} else if (depthPass.renderBackface) {
|
|
647
|
-
this.$outputs.zFragmentOutput = pb.vec4(0, this.depth, 0, 1);
|
|
648
|
-
} else {
|
|
649
|
-
this.$outputs.zFragmentOutput = pb.vec4(this.depth, 0, 0, 1);
|
|
650
|
-
}
|
|
651
|
-
if (that.drawContext.motionVectors) {
|
|
652
|
-
if (that.featureUsed(FEATURE_DISABLE_TAA)) {
|
|
653
|
-
this.$outputs.zMotionVector = pb.vec4(6e4, 6e4, 1, 1);
|
|
654
|
-
} else {
|
|
655
|
-
if (this.$inputs.zMotionVectorPosCurrent && this.$inputs.zMotionVectorPosPrev) {
|
|
656
|
-
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);
|
|
657
|
-
} else {
|
|
658
|
-
this.$outputs.zMotionVector = pb.vec4(0, 0, 1, 1);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
} else if (that.drawContext.renderPass.type === RENDER_PASS_TYPE_OBJECT_COLOR) {
|
|
663
|
-
if (color) {
|
|
664
|
-
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
665
|
-
pb.discard();
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
669
|
-
this.$outputs.zFragmentOutput = that.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING ? scope.$inputs.zObjectColor : scope.zObjectColor;
|
|
670
|
-
if (that.drawContext.device.type === 'webgl') {
|
|
671
|
-
this.$l.linearDepth = ShaderHelper.nonLinearDepthToLinearNormalized(this, this.$builtins.fragCoord.z);
|
|
672
|
-
this.$outputs.zDistance = encodeNormalizedFloatToRGBA(this, this.linearDepth);
|
|
673
|
-
} else {
|
|
674
|
-
this.$outputs.zDistance = pb.vec4(this.worldPos, pb.distance(ShaderHelper.getCameraPosition(this), this.worldPos));
|
|
675
|
-
}
|
|
676
|
-
} else {
|
|
677
|
-
if (color) {
|
|
678
|
-
this.$if(pb.lessThan(this.outColor.a, this.zAlphaCutoff), function() {
|
|
679
|
-
pb.discard();
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
ShaderHelper.discardIfClipped(this, this.worldPos);
|
|
683
|
-
const shadowMapParams = that.drawContext.shadowMapInfo.get(that.drawContext.renderPass.light);
|
|
684
|
-
this.$outputs.zFragmentOutput = shadowMapParams.impl.computeShadowMapDepth(shadowMapParams, this, this.worldPos);
|
|
685
|
-
}
|
|
686
|
-
});
|
|
687
|
-
if (color) {
|
|
688
|
-
pb.getGlobalScope()[funcName](worldPos, color);
|
|
689
|
-
} else {
|
|
690
|
-
pb.getGlobalScope()[funcName](worldPos);
|
|
691
|
-
}
|
|
692
|
-
if (that.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
693
|
-
scope.$outputs.zSSRRoughness = ssrRoughness ?? pb.vec4(1, 0, 0, 1);
|
|
694
|
-
scope.$outputs.zSSRNormal = ssrNormal ?? pb.vec4(0);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
FEATURE_ALPHATEST = MeshMaterial.defineFeature();
|
|
699
|
-
FEATURE_ALPHABLEND = MeshMaterial.defineFeature();
|
|
700
|
-
FEATURE_ALPHATOCOVERAGE = MeshMaterial.defineFeature();
|
|
701
|
-
FEATURE_DISABLE_TAA = MeshMaterial.defineFeature();
|
|
702
|
-
|
|
703
|
-
export { MeshMaterial, applyMaterialMixins };
|
|
704
|
-
//# sourceMappingURL=meshmaterial.js.map
|