@zephyr3d/scene 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animation.js +149 -27
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +173 -73
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +65 -10
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +41 -20
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +14 -38
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +59 -22
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/proptrack.js +190 -0
- package/dist/animation/proptrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +29 -11
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +29 -11
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +241 -78
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +30 -11
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/api.js +43 -0
- package/dist/app/api.js.map +1 -0
- package/dist/app/app.js +153 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/engine.js +312 -0
- package/dist/app/engine.js.map +1 -0
- package/dist/app/inputmgr.js +351 -0
- package/dist/app/inputmgr.js.map +1 -0
- package/dist/app/runtimescript.js +62 -0
- package/dist/app/runtimescript.js.map +1 -0
- package/dist/app/scriptingsystem.js +220 -0
- package/dist/app/scriptingsystem.js.map +1 -0
- package/dist/app/scriptregistry.js +432 -0
- package/dist/app/scriptregistry.js.map +1 -0
- package/dist/asset/assetmanager.js +772 -291
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/builtin.js +7 -43
- package/dist/asset/builtin.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +17 -93
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +8 -18
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +36 -42
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/helpers.js +27 -14
- package/dist/asset/loaders/gltf/helpers.js.map +1 -1
- package/dist/asset/loaders/hdr/hdr.js +17 -12
- package/dist/asset/loaders/hdr/hdr.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +13 -16
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +51 -50
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/model.js +158 -4
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +0 -1
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/blitter.js +22 -23
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/box.js.map +1 -1
- package/dist/blitter/copy.js.map +1 -1
- package/dist/blitter/gaussianblur.js +23 -23
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +141 -34
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +653 -149
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +2 -10
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +132 -59
- package/dist/camera/orbit.js.map +1 -1
- package/dist/camera/orthocamera.js +37 -12
- package/dist/camera/orthocamera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +37 -20
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +18268 -6982
- package/dist/index.js +49 -16
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +5 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/grassmaterial.js +6 -1
- package/dist/material/grassmaterial.js.map +1 -1
- package/dist/material/lambert.js +6 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +346 -73
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +498 -156
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/foliage.js +3 -3
- package/dist/material/mixins/foliage.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +18 -5
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +6 -6
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +235 -0
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -0
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +52 -15
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +27 -9
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +16 -4
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/brdf.js +134 -0
- package/dist/material/mixins/pbr/brdf.js.map +1 -0
- package/dist/material/mixins/pbr/common.js +68 -85
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +98 -83
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +6 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/particle.js +272 -0
- package/dist/material/particle.js.map +1 -0
- package/dist/material/pbrblueprint.js +186 -0
- package/dist/material/pbrblueprint.js.map +1 -0
- package/dist/material/pbrmr.js +10 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +10 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +521 -287
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/terrain-cm.js +607 -0
- package/dist/material/terrain-cm.js.map +1 -0
- package/dist/material/terrainmaterial.js +59 -54
- package/dist/material/terrainmaterial.js.map +1 -1
- package/dist/material/unlit.js +5 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +415 -0
- package/dist/material/water.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
- package/dist/node_modules/es-module-lexer/dist/lexer.js +5 -0
- package/dist/node_modules/es-module-lexer/dist/lexer.js.map +1 -0
- package/dist/posteffect/bloom.js +39 -54
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +95 -128
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +10 -18
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +9 -17
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +105 -0
- package/dist/posteffect/motionblur.js.map +1 -0
- package/dist/posteffect/posteffect.js +66 -35
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +13 -21
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +60 -100
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/taa.js +175 -0
- package/dist/posteffect/taa.js.map +1 -0
- package/dist/posteffect/tonemap.js +12 -20
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +30 -19
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +429 -101
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +7 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +43 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +14 -5
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +113 -40
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +86 -141
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +234 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -0
- package/dist/render/fft_wavegenerator.js +64 -50
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/fullscreenquad.js +2 -2
- package/dist/render/fullscreenquad.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +98 -48
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +4 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +6 -3
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +19 -18
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +4 -4
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/primitive.js +213 -104
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +40 -20
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +65 -15
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +326 -185
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +20 -36
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +3 -3
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +864 -541
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +13 -15
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/batchgroup.js +18 -5
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +78 -48
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +2 -3
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +28 -89
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +218 -87
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +371 -162
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/particlesys.js +684 -0
- package/dist/scene/particlesys.js.map +1 -0
- package/dist/scene/raycast_visitor.js +34 -5
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +309 -85
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +675 -102
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +48 -49
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +46 -44
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +20 -29
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +58 -27
- package/dist/scene/terrain/quadtree.js.map +1 -1
- package/dist/scene/terrain/terrain.js +31 -45
- package/dist/scene/terrain/terrain.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +603 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +160 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js +533 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/scene/water.js +378 -0
- package/dist/scene/water.js.map +1 -0
- package/dist/shaders/atmosphere.js +957 -0
- package/dist/shaders/atmosphere.js.map +1 -0
- package/dist/shaders/fog.js +116 -0
- package/dist/shaders/fog.js.map +1 -0
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +217 -8
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/pbr.js.map +1 -1
- package/dist/shaders/shadow.js +8 -8
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +87 -39
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +216 -0
- package/dist/shaders/temporal.js.map +1 -0
- package/dist/shaders/water.js +42 -20
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +31 -13
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +12 -13
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +12 -13
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +38 -0
- package/dist/shadow/shader.js.map +1 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadowmapper.js +67 -26
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +15 -16
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +33 -16
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/box.js +181 -83
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/cylinder.js +101 -43
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +70 -29
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/shape.js +120 -17
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +78 -44
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/shapes/tetrahedron.js +256 -0
- package/dist/shapes/tetrahedron.js.map +1 -0
- package/dist/shapes/torus.js +76 -55
- package/dist/shapes/torus.js.map +1 -1
- package/dist/src/animation/animation.js +127 -0
- package/dist/src/animation/animation.js.map +1 -0
- package/dist/src/animation/animationset.js +255 -0
- package/dist/src/animation/animationset.js.map +1 -0
- package/dist/src/animation/animationtrack.js +34 -0
- package/dist/src/animation/animationtrack.js.map +1 -0
- package/dist/src/animation/eulerrotationtrack.js +52 -0
- package/dist/src/animation/eulerrotationtrack.js.map +1 -0
- package/dist/src/animation/morphtarget.js +93 -0
- package/dist/src/animation/morphtarget.js.map +1 -0
- package/dist/src/animation/morphtrack.js +70 -0
- package/dist/src/animation/morphtrack.js.map +1 -0
- package/dist/src/animation/proptrack.js +161 -0
- package/dist/src/animation/proptrack.js.map +1 -0
- package/dist/src/animation/rotationtrack.js +51 -0
- package/dist/src/animation/rotationtrack.js.map +1 -0
- package/dist/src/animation/scaletrack.js +50 -0
- package/dist/src/animation/scaletrack.js.map +1 -0
- package/dist/src/animation/skeleton.js +204 -0
- package/dist/src/animation/skeleton.js.map +1 -0
- package/dist/src/animation/translationtrack.js +50 -0
- package/dist/src/animation/translationtrack.js.map +1 -0
- package/dist/{app.js → src/app/app.js} +18 -40
- package/dist/src/app/app.js.map +1 -0
- package/dist/{input → src/app}/inputmgr.js +41 -16
- package/dist/src/app/inputmgr.js.map +1 -0
- package/dist/src/asset/assetmanager.js +404 -0
- package/dist/src/asset/assetmanager.js.map +1 -0
- package/dist/src/asset/builtin.js +337 -0
- package/dist/src/asset/builtin.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds.js +470 -0
- package/dist/src/asset/loaders/dds/dds.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
- package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/helpers.js +327 -0
- package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/src/asset/loaders/hdr/hdr.js +180 -0
- package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
- package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
- package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/src/asset/loaders/loader.js +45 -0
- package/dist/src/asset/loaders/loader.js.map +1 -0
- package/dist/src/asset/model.js +414 -0
- package/dist/src/asset/model.js.map +1 -0
- package/dist/{blitter/depthlimitedgaussion.js → src/blitter/bilateralblur.js} +1 -2
- package/dist/src/blitter/bilateralblur.js.map +1 -0
- package/dist/src/blitter/blitter.js +390 -0
- package/dist/src/blitter/blitter.js.map +1 -0
- package/dist/src/blitter/box.js +118 -0
- package/dist/src/blitter/box.js.map +1 -0
- package/dist/src/blitter/copy.js +22 -0
- package/dist/src/blitter/copy.js.map +1 -0
- package/dist/src/blitter/gaussianblur.js +228 -0
- package/dist/src/blitter/gaussianblur.js.map +1 -0
- package/dist/src/camera/base.js +92 -0
- package/dist/src/camera/base.js.map +1 -0
- package/dist/src/camera/camera.js +1005 -0
- package/dist/src/camera/camera.js.map +1 -0
- package/dist/src/camera/fps.js +238 -0
- package/dist/src/camera/fps.js.map +1 -0
- package/dist/src/camera/orbit.js +245 -0
- package/dist/src/camera/orbit.js.map +1 -0
- package/dist/src/camera/orthocamera.js +167 -0
- package/dist/src/camera/orthocamera.js.map +1 -0
- package/dist/src/camera/perspectivecamera.js +141 -0
- package/dist/src/camera/perspectivecamera.js.map +1 -0
- package/dist/src/index.js +120 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/material/blinn.js +81 -0
- package/dist/src/material/blinn.js.map +1 -0
- package/dist/src/material/grassmaterial.js +113 -0
- package/dist/src/material/grassmaterial.js.map +1 -0
- package/dist/src/material/lambert.js +92 -0
- package/dist/src/material/lambert.js.map +1 -0
- package/dist/src/material/material.js +301 -0
- package/dist/src/material/material.js.map +1 -0
- package/dist/src/material/meshmaterial.js +704 -0
- package/dist/src/material/meshmaterial.js.map +1 -0
- package/dist/src/material/mixins/albedocolor.js +76 -0
- package/dist/src/material/mixins/albedocolor.js.map +1 -0
- package/dist/src/material/mixins/foliage.js +47 -0
- package/dist/src/material/mixins/foliage.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
- package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
- package/dist/src/material/mixins/lit.js +476 -0
- package/dist/src/material/mixins/lit.js.map +1 -0
- package/dist/src/material/mixins/pbr/common.js +918 -0
- package/dist/src/material/mixins/pbr/common.js.map +1 -0
- package/dist/src/material/mixins/texture.js +172 -0
- package/dist/src/material/mixins/texture.js.map +1 -0
- package/dist/src/material/mixins/vertexcolor.js +56 -0
- package/dist/src/material/mixins/vertexcolor.js.map +1 -0
- package/dist/src/material/particle.js +178 -0
- package/dist/src/material/particle.js.map +1 -0
- package/dist/src/material/pbrmr.js +97 -0
- package/dist/src/material/pbrmr.js.map +1 -0
- package/dist/src/material/pbrsg.js +97 -0
- package/dist/src/material/pbrsg.js.map +1 -0
- package/dist/src/material/shader/helper.js +1209 -0
- package/dist/src/material/shader/helper.js.map +1 -0
- package/dist/src/material/terrain-cm.js +606 -0
- package/dist/src/material/terrain-cm.js.map +1 -0
- package/dist/src/material/terrainmaterial.js +375 -0
- package/dist/src/material/terrainmaterial.js.map +1 -0
- package/dist/src/material/unlit.js +41 -0
- package/dist/src/material/unlit.js.map +1 -0
- package/dist/src/material/water.js +417 -0
- package/dist/src/material/water.js.map +1 -0
- package/dist/src/posteffect/bloom.js +361 -0
- package/dist/src/posteffect/bloom.js.map +1 -0
- package/dist/src/posteffect/compositor.js +226 -0
- package/dist/src/posteffect/compositor.js.map +1 -0
- package/dist/src/posteffect/fxaa.js +273 -0
- package/dist/src/posteffect/fxaa.js.map +1 -0
- package/dist/src/posteffect/grayscale.js +69 -0
- package/dist/src/posteffect/grayscale.js.map +1 -0
- package/dist/src/posteffect/motionblur.js +96 -0
- package/dist/src/posteffect/motionblur.js.map +1 -0
- package/dist/src/posteffect/posteffect.js +126 -0
- package/dist/src/posteffect/posteffect.js.map +1 -0
- package/dist/src/posteffect/sao.js +324 -0
- package/dist/src/posteffect/sao.js.map +1 -0
- package/dist/src/posteffect/ssr.js +489 -0
- package/dist/src/posteffect/ssr.js.map +1 -0
- package/dist/src/posteffect/taa.js +172 -0
- package/dist/src/posteffect/taa.js.map +1 -0
- package/dist/src/posteffect/tonemap.js +94 -0
- package/dist/src/posteffect/tonemap.js.map +1 -0
- package/dist/src/render/abuffer_oit.js +361 -0
- package/dist/src/render/abuffer_oit.js.map +1 -0
- package/dist/src/render/clipmap.js +851 -0
- package/dist/src/render/clipmap.js.map +1 -0
- package/dist/src/render/cluster_light.js +333 -0
- package/dist/src/render/cluster_light.js.map +1 -0
- package/dist/src/render/cull_visitor.js +187 -0
- package/dist/src/render/cull_visitor.js.map +1 -0
- package/dist/src/render/depthpass.js +68 -0
- package/dist/src/render/depthpass.js.map +1 -0
- package/dist/src/render/drawable_mixin.js +227 -0
- package/dist/src/render/drawable_mixin.js.map +1 -0
- package/dist/src/render/envlight.js +463 -0
- package/dist/src/render/envlight.js.map +1 -0
- package/dist/src/render/fbm_wavegenerator.js +251 -0
- package/dist/src/render/fbm_wavegenerator.js.map +1 -0
- package/dist/src/render/fft_wavegenerator.js +1006 -0
- package/dist/src/render/fft_wavegenerator.js.map +1 -0
- package/dist/src/render/fullscreenquad.js +38 -0
- package/dist/src/render/fullscreenquad.js.map +1 -0
- package/dist/src/render/gerstner_wavegenerator.js +314 -0
- package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
- package/dist/src/render/globalbindgroup_allocator.js +60 -0
- package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
- package/dist/src/render/hzb.js +273 -0
- package/dist/src/render/hzb.js.map +1 -0
- package/dist/src/render/lightpass.js +172 -0
- package/dist/src/render/lightpass.js.map +1 -0
- package/dist/src/render/objectcolorpass.js +51 -0
- package/dist/src/render/objectcolorpass.js.map +1 -0
- package/dist/src/render/primitive.js +364 -0
- package/dist/src/render/primitive.js.map +1 -0
- package/dist/src/render/render_queue.js +467 -0
- package/dist/src/render/render_queue.js.map +1 -0
- package/dist/src/render/renderbundle_wrapper.js +152 -0
- package/dist/src/render/renderbundle_wrapper.js.map +1 -0
- package/dist/src/render/renderer.js +455 -0
- package/dist/src/render/renderer.js.map +1 -0
- package/dist/src/render/renderpass.js +200 -0
- package/dist/src/render/renderpass.js.map +1 -0
- package/dist/src/render/shadowmap_pass.js +56 -0
- package/dist/src/render/shadowmap_pass.js.map +1 -0
- package/dist/src/render/sky.js +1103 -0
- package/dist/src/render/sky.js.map +1 -0
- package/dist/src/render/weightedblended_oit.js +168 -0
- package/dist/src/render/weightedblended_oit.js.map +1 -0
- package/dist/src/scene/batchgroup.js +162 -0
- package/dist/src/scene/batchgroup.js.map +1 -0
- package/dist/src/scene/environment.js +209 -0
- package/dist/src/scene/environment.js.map +1 -0
- package/dist/src/scene/graph_node.js +72 -0
- package/dist/src/scene/graph_node.js.map +1 -0
- package/dist/src/scene/light.js +416 -0
- package/dist/src/scene/light.js.map +1 -0
- package/dist/src/scene/mesh.js +341 -0
- package/dist/src/scene/mesh.js.map +1 -0
- package/dist/src/scene/octree.js +649 -0
- package/dist/src/scene/octree.js.map +1 -0
- package/dist/src/scene/particlesys.js +738 -0
- package/dist/src/scene/particlesys.js.map +1 -0
- package/dist/src/scene/raycast_visitor.js +103 -0
- package/dist/src/scene/raycast_visitor.js.map +1 -0
- package/dist/src/scene/scene.js +284 -0
- package/dist/src/scene/scene.js.map +1 -0
- package/dist/src/scene/scene_node.js +732 -0
- package/dist/src/scene/scene_node.js.map +1 -0
- package/dist/src/scene/terrain/grass.js +278 -0
- package/dist/src/scene/terrain/grass.js.map +1 -0
- package/dist/src/scene/terrain/heightfield.js +475 -0
- package/dist/src/scene/terrain/heightfield.js.map +1 -0
- package/dist/src/scene/terrain/patch.js +530 -0
- package/dist/src/scene/terrain/patch.js.map +1 -0
- package/dist/src/scene/terrain/quadtree.js +461 -0
- package/dist/src/scene/terrain/quadtree.js.map +1 -0
- package/dist/src/scene/terrain/terrain.js +246 -0
- package/dist/src/scene/terrain/terrain.js.map +1 -0
- package/dist/src/scene/terrain-cm/grass.js +594 -0
- package/dist/src/scene/terrain-cm/grass.js.map +1 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/src/scene/water.js +374 -0
- package/dist/src/scene/water.js.map +1 -0
- package/dist/src/shaders/atmosphere.js +957 -0
- package/dist/src/shaders/atmosphere.js.map +1 -0
- package/dist/src/shaders/fog.js +112 -0
- package/dist/src/shaders/fog.js.map +1 -0
- package/dist/src/shaders/misc.js +266 -0
- package/dist/src/shaders/misc.js.map +1 -0
- package/dist/src/shaders/noise.js +222 -0
- package/dist/src/shaders/noise.js.map +1 -0
- package/dist/src/shaders/pbr.js +51 -0
- package/dist/src/shaders/pbr.js.map +1 -0
- package/dist/src/shaders/shadow.js +636 -0
- package/dist/src/shaders/shadow.js.map +1 -0
- package/dist/src/shaders/ssr.js +490 -0
- package/dist/src/shaders/ssr.js.map +1 -0
- package/dist/src/shaders/temporal.js +215 -0
- package/dist/src/shaders/temporal.js.map +1 -0
- package/dist/src/shaders/water.js +756 -0
- package/dist/src/shaders/water.js.map +1 -0
- package/dist/src/shadow/esm.js +237 -0
- package/dist/src/shadow/esm.js.map +1 -0
- package/dist/src/shadow/pcf_opt.js +181 -0
- package/dist/src/shadow/pcf_opt.js.map +1 -0
- package/dist/src/shadow/pcf_pd.js +189 -0
- package/dist/src/shadow/pcf_pd.js.map +1 -0
- package/dist/src/shadow/shader.js +37 -0
- package/dist/src/shadow/shader.js.map +1 -0
- package/dist/src/shadow/shadow_impl.js +15 -0
- package/dist/src/shadow/shadow_impl.js.map +1 -0
- package/dist/src/shadow/shadowmapper.js +790 -0
- package/dist/src/shadow/shadowmapper.js.map +1 -0
- package/dist/src/shadow/ssm.js +159 -0
- package/dist/src/shadow/ssm.js.map +1 -0
- package/dist/src/shadow/vsm.js +297 -0
- package/dist/src/shadow/vsm.js.map +1 -0
- package/dist/src/shapes/box.js +386 -0
- package/dist/src/shapes/box.js.map +1 -0
- package/dist/src/shapes/cylinder.js +125 -0
- package/dist/src/shapes/cylinder.js.map +1 -0
- package/dist/src/shapes/plane.js +88 -0
- package/dist/src/shapes/plane.js.map +1 -0
- package/dist/src/shapes/shape.js +87 -0
- package/dist/src/shapes/shape.js.map +1 -0
- package/dist/src/shapes/sphere.js +114 -0
- package/dist/src/shapes/sphere.js.map +1 -0
- package/dist/src/shapes/tetrahedron.js +188 -0
- package/dist/src/shapes/tetrahedron.js.map +1 -0
- package/dist/src/shapes/torus.js +111 -0
- package/dist/src/shapes/torus.js.map +1 -0
- package/dist/src/utility/aabbtree.js +400 -0
- package/dist/src/utility/aabbtree.js.map +1 -0
- package/dist/src/utility/bounding_volume.js +29 -0
- package/dist/src/utility/bounding_volume.js.map +1 -0
- package/dist/src/utility/debug.js +28 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/draco/decoder.js +116 -0
- package/dist/src/utility/draco/decoder.js.map +1 -0
- package/dist/src/utility/misc.js +105 -0
- package/dist/src/utility/misc.js.map +1 -0
- package/dist/src/utility/panorama.js +163 -0
- package/dist/src/utility/panorama.js.map +1 -0
- package/dist/src/utility/pmrem.js +354 -0
- package/dist/src/utility/pmrem.js.map +1 -0
- package/dist/src/utility/rendermipmap.js +115 -0
- package/dist/src/utility/rendermipmap.js.map +1 -0
- package/dist/src/utility/serialization/json.js +402 -0
- package/dist/src/utility/serialization/json.js.map +1 -0
- package/dist/src/utility/serialization/manager.js +623 -0
- package/dist/src/utility/serialization/manager.js.map +1 -0
- package/dist/src/utility/serialization/scene/animation.js +248 -0
- package/dist/src/utility/serialization/scene/animation.js.map +1 -0
- package/dist/src/utility/serialization/scene/batch.js +59 -0
- package/dist/src/utility/serialization/scene/batch.js.map +1 -0
- package/dist/src/utility/serialization/scene/camera.js +790 -0
- package/dist/src/utility/serialization/scene/camera.js.map +1 -0
- package/dist/src/utility/serialization/scene/common.js +222 -0
- package/dist/src/utility/serialization/scene/common.js.map +1 -0
- package/dist/src/utility/serialization/scene/light.js +575 -0
- package/dist/src/utility/serialization/scene/light.js.map +1 -0
- package/dist/src/utility/serialization/scene/material.js +1111 -0
- package/dist/src/utility/serialization/scene/material.js.map +1 -0
- package/dist/src/utility/serialization/scene/mesh.js +148 -0
- package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/src/utility/serialization/scene/misc.js +39 -0
- package/dist/src/utility/serialization/scene/misc.js.map +1 -0
- package/dist/src/utility/serialization/scene/node.js +451 -0
- package/dist/src/utility/serialization/scene/node.js.map +1 -0
- package/dist/src/utility/serialization/scene/particle.js +425 -0
- package/dist/src/utility/serialization/scene/particle.js.map +1 -0
- package/dist/src/utility/serialization/scene/primitive.js +692 -0
- package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/src/utility/serialization/scene/scene.js +704 -0
- package/dist/src/utility/serialization/scene/scene.js.map +1 -0
- package/dist/src/utility/serialization/scene/terrain.js +488 -0
- package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/src/utility/serialization/scene/water.js +465 -0
- package/dist/src/utility/serialization/scene/water.js.map +1 -0
- package/dist/src/utility/shprojector.js +297 -0
- package/dist/src/utility/shprojector.js.map +1 -0
- package/dist/{material/mixins → src/utility/textures}/ggxlut.js +1 -1
- package/dist/src/utility/textures/ggxlut.js.map +1 -0
- package/dist/src/utility/textures/gradientnoise.js +62 -0
- package/dist/src/utility/textures/gradientnoise.js.map +1 -0
- package/dist/src/utility/textures/randomnoise.js +41 -0
- package/dist/src/utility/textures/randomnoise.js.map +1 -0
- package/dist/src/values.js +162 -0
- package/dist/src/values.js.map +1 -0
- package/dist/utility/aabbtree.js +15 -5
- package/dist/utility/aabbtree.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +851 -0
- package/dist/utility/blueprint/common/constants.js.map +1 -0
- package/dist/utility/blueprint/common/math.js +2045 -0
- package/dist/utility/blueprint/common/math.js.map +1 -0
- package/dist/utility/blueprint/common.js +7 -0
- package/dist/utility/blueprint/common.js.map +1 -0
- package/dist/utility/blueprint/material/common.js +7 -0
- package/dist/utility/blueprint/material/common.js.map +1 -0
- package/dist/utility/blueprint/material/func.js +521 -0
- package/dist/utility/blueprint/material/func.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +1659 -0
- package/dist/utility/blueprint/material/inputs.js.map +1 -0
- package/dist/utility/blueprint/material/ir.js +1311 -0
- package/dist/utility/blueprint/material/ir.js.map +1 -0
- package/dist/utility/blueprint/material/pbr.js +362 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -0
- package/dist/utility/blueprint/material/texture.js +1099 -0
- package/dist/utility/blueprint/material/texture.js.map +1 -0
- package/dist/utility/blueprint/node.js +187 -0
- package/dist/utility/blueprint/node.js.map +1 -0
- package/dist/utility/bounding_volume.js +0 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/debug.js +26 -0
- package/dist/utility/debug.js.map +1 -0
- package/dist/utility/draco/decoder.js +1 -1
- package/dist/utility/draco/decoder.js.map +1 -1
- package/dist/utility/misc.js +18 -6
- package/dist/utility/misc.js.map +1 -1
- package/dist/utility/panorama.js +8 -6
- package/dist/utility/panorama.js.map +1 -1
- package/dist/utility/pmrem.js +30 -18
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/rendermipmap.js +116 -0
- package/dist/utility/rendermipmap.js.map +1 -0
- package/dist/utility/serialization/blueprint/constants.js +255 -0
- package/dist/utility/serialization/blueprint/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/constants.js +203 -0
- package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/texture.js +165 -0
- package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
- package/dist/utility/serialization/json.js +402 -0
- package/dist/utility/serialization/json.js.map +1 -0
- package/dist/utility/serialization/manager.js +1176 -0
- package/dist/utility/serialization/manager.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +699 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -0
- package/dist/utility/serialization/scene/batch.js +53 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -0
- package/dist/utility/serialization/scene/camera.js +808 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +224 -0
- package/dist/utility/serialization/scene/common.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +589 -0
- package/dist/utility/serialization/scene/light.js.map +1 -0
- package/dist/utility/serialization/scene/material.js +942 -0
- package/dist/utility/serialization/scene/material.js.map +1 -0
- package/dist/utility/serialization/scene/mesh.js +374 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/utility/serialization/scene/misc.js +39 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -0
- package/dist/utility/serialization/scene/node.js +391 -0
- package/dist/utility/serialization/scene/node.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +425 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +582 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/utility/serialization/scene/scene.js +763 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -0
- package/dist/utility/serialization/scene/terrain.js +495 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +465 -0
- package/dist/utility/serialization/scene/water.js.map +1 -0
- package/dist/utility/shprojector.js +313 -0
- package/dist/utility/shprojector.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +4 -5
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/gradientnoise.js +2 -1
- package/dist/utility/textures/gradientnoise.js.map +1 -1
- package/dist/utility/textures/randomnoise.js +1 -0
- package/dist/utility/textures/randomnoise.js.map +1 -1
- package/dist/values.js +91 -4
- package/dist/values.js.map +1 -1
- package/package.json +29 -15
- package/dist/app.js.map +0 -1
- package/dist/blitter/depthlimitedgaussion.js.map +0 -1
- package/dist/input/inputmgr.js.map +0 -1
- package/dist/material/mixins/ggxlut.js.map +0 -1
- package/dist/posteffect/water.js +0 -508
- package/dist/posteffect/water.js.map +0 -1
- package/dist/render/oit.js +0 -16
- package/dist/render/oit.js.map +0 -1
- package/dist/render/scatteringlut.js +0 -634
- package/dist/render/scatteringlut.js.map +0 -1
- package/dist/render/watermesh.js +0 -193
- package/dist/render/watermesh.js.map +0 -1
- package/dist/render/wavegenerator.js +0 -8
- package/dist/render/wavegenerator.js.map +0 -1
- package/dist/scene/xform.js +0 -247
- package/dist/scene/xform.js.map +0 -1
- package/dist/utility/shprojection.js +0 -442
- package/dist/utility/shprojection.js.map +0 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
|
+
import { mixinLight } from '../lit.js';
|
|
3
|
+
import { mixinPBRBRDF } from '../pbr/brdf.js';
|
|
4
|
+
import { ShaderHelper } from '../../shader/helper.js';
|
|
5
|
+
import { getGGXLUT } from '../../../utility/textures/ggxlut.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* PBRBluePrint lighting model mixin
|
|
9
|
+
* @param BaseCls - Class to mix in
|
|
10
|
+
* @returns Mixed class
|
|
11
|
+
* @public
|
|
12
|
+
*/ function mixinPBRBluePrint(BaseCls) {
|
|
13
|
+
if (BaseCls.pbrBluePrint) {
|
|
14
|
+
return BaseCls;
|
|
15
|
+
}
|
|
16
|
+
const S = applyMaterialMixins(BaseCls, mixinPBRBRDF, mixinLight);
|
|
17
|
+
return class extends S {
|
|
18
|
+
static pbrBluePrint = true;
|
|
19
|
+
constructor(){
|
|
20
|
+
super();
|
|
21
|
+
}
|
|
22
|
+
copyFrom(other) {
|
|
23
|
+
super.copyFrom(other);
|
|
24
|
+
}
|
|
25
|
+
getCommonData(scope, data, viewVec, worldPos, worldNorm, worldTangent, worldBinormal, vertexColor, vertexUV, ir) {
|
|
26
|
+
this.calculateCommonData(scope, ir, viewVec, worldPos, worldNorm, worldTangent, worldBinormal, vertexColor, vertexUV, data);
|
|
27
|
+
}
|
|
28
|
+
getCommonDatasStruct(scope) {
|
|
29
|
+
const pb = scope.$builder;
|
|
30
|
+
return pb.defineStruct([
|
|
31
|
+
pb.vec4('f0'),
|
|
32
|
+
pb.vec3('f90'),
|
|
33
|
+
pb.vec4('albedo'),
|
|
34
|
+
pb.vec4('diffuse'),
|
|
35
|
+
pb.float('metallic'),
|
|
36
|
+
pb.float('roughness'),
|
|
37
|
+
pb.vec3('normal'),
|
|
38
|
+
pb.mat3('TBN'),
|
|
39
|
+
pb.vec3('emissive'),
|
|
40
|
+
pb.vec3('specular')
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
PBRLight(scope, worldPos, viewVec, commonData, outRoughness) {
|
|
44
|
+
const pb = scope.$builder;
|
|
45
|
+
const funcName = 'Z_PBRBluePrintLight';
|
|
46
|
+
const that = this;
|
|
47
|
+
pb.func(funcName, [
|
|
48
|
+
that.getCommonDatasStruct(scope)('pbrData'),
|
|
49
|
+
pb.vec3('viewVec'),
|
|
50
|
+
pb.vec3('worldPos'),
|
|
51
|
+
...outRoughness ? [
|
|
52
|
+
pb.vec4('outRoughness').out()
|
|
53
|
+
] : []
|
|
54
|
+
], function() {
|
|
55
|
+
this.$l.lightingColor = pb.vec3(0);
|
|
56
|
+
this.$l.emissiveColor = this.pbrData.emissive;
|
|
57
|
+
if (outRoughness) {
|
|
58
|
+
that.indirectLighting(this, this.viewVec, this.pbrData, this.lightingColor, this.outRoughness);
|
|
59
|
+
} else {
|
|
60
|
+
that.indirectLighting(this, this.viewVec, this.pbrData, this.lightingColor);
|
|
61
|
+
}
|
|
62
|
+
that.forEachLight(this, function(type, posRange, dirCutoff, colorIntensity, shadow) {
|
|
63
|
+
this.$l.diffuse = pb.vec3();
|
|
64
|
+
this.$l.specular = pb.vec3();
|
|
65
|
+
this.$l.lightAtten = that.calculateLightAttenuation(this, type, this.worldPos, posRange, dirCutoff);
|
|
66
|
+
this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);
|
|
67
|
+
this.$l.NoL = pb.clamp(pb.dot(this.pbrData.normal, this.lightDir), 0, 1);
|
|
68
|
+
this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);
|
|
69
|
+
if (shadow) {
|
|
70
|
+
this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));
|
|
71
|
+
}
|
|
72
|
+
that.directLighting(this, this.lightDir, this.lightColor, this.viewVec, this.pbrData, this.lightingColor);
|
|
73
|
+
});
|
|
74
|
+
this.$return(pb.vec4(pb.add(this.lightingColor, this.emissiveColor), this.pbrData.albedo.a));
|
|
75
|
+
});
|
|
76
|
+
return outRoughness ? pb.getGlobalScope()[funcName](commonData, viewVec, worldPos, outRoughness) : pb.getGlobalScope()[funcName](commonData, viewVec, worldPos);
|
|
77
|
+
}
|
|
78
|
+
vertexShader(scope) {
|
|
79
|
+
super.vertexShader(scope);
|
|
80
|
+
}
|
|
81
|
+
fragmentShader(scope) {
|
|
82
|
+
const pb = scope.$builder;
|
|
83
|
+
super.fragmentShader(scope);
|
|
84
|
+
if (this.needFragmentColor()) {
|
|
85
|
+
if (this.drawContext.drawEnvLight) {
|
|
86
|
+
scope.zGGXLut = pb.tex2D().uniform(2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
calculateCommonData(scope, ir, viewVec, worldPos, worldNorm, worldTangent, worldBinormal, vertexColor, vertexUV, data) {
|
|
91
|
+
const that = this;
|
|
92
|
+
const pb = scope.$builder;
|
|
93
|
+
const funcName = 'zCalculateCommonDataPBRBluePrint';
|
|
94
|
+
const params = [
|
|
95
|
+
this.getCommonDatasStruct(scope)('zCommonData').out(),
|
|
96
|
+
pb.vec3('zViewVec'),
|
|
97
|
+
pb.vec3('zWorldPos'),
|
|
98
|
+
pb.vec3('zVertexNormal'),
|
|
99
|
+
pb.vec3('zVertexTangent'),
|
|
100
|
+
pb.vec3('zVertexBinormal'),
|
|
101
|
+
pb.vec4('zVertexColor'),
|
|
102
|
+
pb.vec2('zVertexUV')
|
|
103
|
+
];
|
|
104
|
+
const paramValues = [
|
|
105
|
+
data,
|
|
106
|
+
viewVec,
|
|
107
|
+
worldPos,
|
|
108
|
+
worldNorm,
|
|
109
|
+
worldTangent,
|
|
110
|
+
worldBinormal,
|
|
111
|
+
vertexColor,
|
|
112
|
+
vertexUV
|
|
113
|
+
];
|
|
114
|
+
pb.func(funcName, params, function() {
|
|
115
|
+
const outputs = ir.create(pb);
|
|
116
|
+
this.zCommonData.albedo = pb.vec4(that.getOutput(outputs, 'BaseColor')?.rgb ?? pb.vec3(1), that.getOutput(outputs, 'Opacity') ?? 1);
|
|
117
|
+
this.zCommonData.metallic = that.getOutput(outputs, 'Metallic') ?? 0;
|
|
118
|
+
this.zCommonData.roughness = that.getOutput(outputs, 'Roughness') ? pb.mul(that.getOutput(outputs, 'Roughness'), ShaderHelper.getCameraRoughnessFactor(scope)) : ShaderHelper.getCameraRoughnessFactor(scope);
|
|
119
|
+
this.zCommonData.specular = that.getOutput(outputs, 'Specular') ?? pb.vec3(1);
|
|
120
|
+
this.zCommonData.emissive = that.getOutput(outputs, 'Emissive') ?? pb.vec3(0);
|
|
121
|
+
this.zCommonData.f90 = pb.vec3(1);
|
|
122
|
+
this.zCommonData.f0 = pb.vec4(pb.mix(pb.min(pb.mul(pb.vec3(0.04), this.zCommonData.specular), pb.vec3(1)), this.zCommonData.albedo.rgb, this.zCommonData.metallic), 1.5);
|
|
123
|
+
this.$l.tangent = that.getOutput(outputs, 'Tangent') ?? this.zVertexTangent;
|
|
124
|
+
this.$l.ng = pb.normalize(this.zVertexNormal);
|
|
125
|
+
this.$l.t_ = pb.normalize(this.tangent);
|
|
126
|
+
this.$l.t = pb.normalize(pb.sub(this.t_, pb.mul(this.ng, pb.dot(this.ng, this.t_))));
|
|
127
|
+
this.$l.b = pb.cross(this.ng, this.t);
|
|
128
|
+
this.zCommonData.TBN = pb.mat3(this.t, this.b, this.ng);
|
|
129
|
+
if (that.getOutput(outputs, 'Normal')) {
|
|
130
|
+
this.zCommonData.normal = pb.normalize(pb.mul(this.zCommonData.TBN, that.getOutput(outputs, 'Normal')));
|
|
131
|
+
} else {
|
|
132
|
+
this.zCommonData.normal = this.ng;
|
|
133
|
+
}
|
|
134
|
+
this.zCommonData.diffuse = pb.vec4(pb.mix(this.zCommonData.albedo.rgb, pb.vec3(0), this.zCommonData.metallic), this.zCommonData.albedo.a);
|
|
135
|
+
});
|
|
136
|
+
scope[funcName](...paramValues);
|
|
137
|
+
}
|
|
138
|
+
getOutput(outputs, name) {
|
|
139
|
+
return outputs.find((output)=>output.name === name)?.exp;
|
|
140
|
+
}
|
|
141
|
+
directLighting(scope, lightDir, lightColor, viewVec, commonData, outColor) {
|
|
142
|
+
const pb = scope.$builder;
|
|
143
|
+
const that = this;
|
|
144
|
+
const funcName = 'Z_PBRDirectLighting';
|
|
145
|
+
pb.func(funcName, [
|
|
146
|
+
pb.vec3('L'),
|
|
147
|
+
pb.vec3('lightColor'),
|
|
148
|
+
pb.vec3('viewVec'),
|
|
149
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
150
|
+
pb.vec3('outColor').inout()
|
|
151
|
+
], function() {
|
|
152
|
+
this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));
|
|
153
|
+
this.$l.NoH = pb.clamp(pb.dot(this.data.normal, this.H), 0, 1);
|
|
154
|
+
this.$l.NoL = pb.clamp(pb.dot(this.data.normal, this.L), 0, 1);
|
|
155
|
+
this.$l.NoV = pb.clamp(pb.dot(this.data.normal, this.viewVec), 0, 1);
|
|
156
|
+
this.$if(pb.greaterThan(this.NoL, 0), function() {
|
|
157
|
+
this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);
|
|
158
|
+
this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);
|
|
159
|
+
this.$l.F = this.schlickFresnel;
|
|
160
|
+
this.$l.alphaRoughness = pb.mul(this.data.roughness, this.data.roughness);
|
|
161
|
+
this.$l.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
162
|
+
this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);
|
|
163
|
+
this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F);
|
|
164
|
+
this.outColor = pb.add(this.outColor, this.specular);
|
|
165
|
+
this.$l.diffuseBRDF = pb.mul(pb.sub(pb.vec3(1), this.F), pb.div(this.data.diffuse.rgb, Math.PI));
|
|
166
|
+
this.$l.diffuse = pb.mul(this.lightColor, pb.max(this.diffuseBRDF, pb.vec3(0)));
|
|
167
|
+
this.outColor = pb.add(this.outColor, this.diffuse);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
scope.$g[funcName](lightDir, lightColor, viewVec, commonData, outColor);
|
|
171
|
+
}
|
|
172
|
+
indirectLighting(scope, viewVec, commonData, outColor, outRoughness) {
|
|
173
|
+
const pb = scope.$builder;
|
|
174
|
+
const that = this;
|
|
175
|
+
const ctx = that.drawContext;
|
|
176
|
+
const funcName = 'Z_PBRIndirectLighting';
|
|
177
|
+
pb.func(funcName, [
|
|
178
|
+
pb.vec3('viewVec'),
|
|
179
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
180
|
+
pb.vec3('outColor').inout(),
|
|
181
|
+
...outRoughness ? [
|
|
182
|
+
pb.vec4('outRoughness').out()
|
|
183
|
+
] : []
|
|
184
|
+
], function() {
|
|
185
|
+
if (!ctx.drawEnvLight || !ctx.env.light.envLight.hasRadiance() && !ctx.env.light.envLight.hasIrradiance()) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const envLightStrength = ShaderHelper.getEnvLightStrength(this);
|
|
189
|
+
this.$l.occlusion = envLightStrength;
|
|
190
|
+
this.$l.NoV = pb.clamp(pb.dot(this.data.normal, this.viewVec), 0.0001, 1);
|
|
191
|
+
this.$l.ggxLutSample = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.roughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
|
|
192
|
+
this.$l.f_ab = this.ggxLutSample.rg;
|
|
193
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.data.f0.rgb), this.data.f0.rgb);
|
|
194
|
+
this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
195
|
+
if (outRoughness || ctx.env.light.envLight.hasRadiance()) {
|
|
196
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
197
|
+
this.$l.specularFactor = pb.mul(this.FssEss, this.occlusion);
|
|
198
|
+
if (outRoughness) {
|
|
199
|
+
this.outRoughness = pb.vec4(this.specularFactor /*this.data.f0.rgb*/ , this.data.roughness);
|
|
200
|
+
} else if (ctx.env.light.envLight.hasRadiance()) {
|
|
201
|
+
this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.data.normal), this.data.roughness);
|
|
202
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.radiance, this.specularFactor));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (ctx.env.light.envLight.hasIrradiance()) {
|
|
206
|
+
this.$l.irradiance = ctx.env.light.envLight.getIrradiance(this, this.data.normal);
|
|
207
|
+
this.$l.mixedF0 = this.data.f0.rgb;
|
|
208
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
209
|
+
this.$l.Ems = pb.sub(1, pb.add(this.f_ab.x, this.f_ab.y));
|
|
210
|
+
this.$l.F_avg = pb.add(this.mixedF0, pb.div(pb.sub(pb.vec3(1), this.mixedF0), 21));
|
|
211
|
+
this.$l.FmsEms = pb.div(pb.mul(this.FssEss, this.F_avg, this.Ems), pb.sub(pb.vec3(1), pb.mul(this.F_avg, this.Ems)));
|
|
212
|
+
this.$l.k_D = pb.mul(this.data.diffuse.rgb, pb.add(pb.sub(pb.vec3(1), this.FssEss), this.FmsEms));
|
|
213
|
+
this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D), this.irradiance, this.occlusion);
|
|
214
|
+
this.outColor = pb.add(this.outColor, this.iblDiffuse);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (outRoughness) {
|
|
218
|
+
scope.$g[funcName](viewVec, commonData, outColor, outRoughness);
|
|
219
|
+
} else {
|
|
220
|
+
scope.$g[funcName](viewVec, commonData, outColor);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
applyUniformValues(bindGroup, ctx, pass) {
|
|
224
|
+
super.applyUniformValues(bindGroup, ctx, pass);
|
|
225
|
+
if (this.needFragmentColor(ctx)) {
|
|
226
|
+
if (ctx.drawEnvLight) {
|
|
227
|
+
bindGroup.setTexture('zGGXLut', getGGXLUT(1024));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export { mixinPBRBluePrint };
|
|
235
|
+
//# sourceMappingURL=pbrblueprintmixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbrblueprintmixin.js","sources":["../../../../src/material/mixins/lightmodel/pbrblueprintmixin.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, ShaderTypeFunc } from '@zephyr3d/device';\r\nimport type { PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport type { IMixinPBRBRDF } from '../pbr/brdf';\r\nimport { mixinPBRBRDF } from '../pbr/brdf';\r\nimport type { MaterialBlueprintIR } from '../../../utility/blueprint/material/ir';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport type { DrawContext } from '../../../render';\r\nimport { getGGXLUT } from '../../../utility/textures/ggxlut';\r\n\r\n/**\r\n * Interface for mixinPBRBluePrint lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRBluePrint = {\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n getCommonDatasStruct(scope: PBInsideFunctionScope): ShaderTypeFunc;\r\n getCommonData(\r\n scope: PBInsideFunctionScope,\r\n data: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n worldPos: PBShaderExp,\r\n worldNorm: PBShaderExp,\r\n worldTangent: PBShaderExp,\r\n worldBinormal: PBShaderExp,\r\n vertexColor: PBShaderExp,\r\n vertexUV: PBShaderExp,\r\n ir: MaterialBlueprintIR\r\n ): void;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n ir: MaterialBlueprintIR,\r\n viewVec: PBShaderExp,\r\n worldPos: PBShaderExp,\r\n worldNorm: PBShaderExp,\r\n worldTangent: PBShaderExp,\r\n worldBinormal: PBShaderExp,\r\n vertexColor: PBShaderExp,\r\n vertexUV: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n outColor: PBShaderExp\r\n ): void;\r\n indirectLighting(\r\n scope: PBInsideFunctionScope,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n outColor: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): void;\r\n} & IMixinPBRBRDF &\r\n IMixinLight;\r\n\r\n/**\r\n * PBRBluePrint lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRBluePrint<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrBluePrint) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRBluePrint };\r\n }\r\n const S = applyMaterialMixins(BaseCls, mixinPBRBRDF, mixinLight);\r\n\r\n return class extends S {\r\n static readonly pbrBluePrint = true;\r\n constructor() {\r\n super();\r\n }\r\n copyFrom(other: this): void {\r\n super.copyFrom(other);\r\n }\r\n getCommonData(\r\n scope: PBInsideFunctionScope,\r\n data: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n worldPos: PBShaderExp,\r\n worldNorm: PBShaderExp,\r\n worldTangent: PBShaderExp,\r\n worldBinormal: PBShaderExp,\r\n vertexColor: PBShaderExp,\r\n vertexUV: PBShaderExp,\r\n ir: MaterialBlueprintIR\r\n ) {\r\n this.calculateCommonData(\r\n scope,\r\n ir,\r\n viewVec,\r\n worldPos,\r\n worldNorm,\r\n worldTangent,\r\n worldBinormal,\r\n vertexColor,\r\n vertexUV,\r\n data\r\n );\r\n }\r\n getCommonDatasStruct(scope: PBInsideFunctionScope): ShaderTypeFunc {\r\n const pb = scope.$builder;\r\n return pb.defineStruct([\r\n pb.vec4('f0'),\r\n pb.vec3('f90'),\r\n pb.vec4('albedo'),\r\n pb.vec4('diffuse'),\r\n pb.float('metallic'),\r\n pb.float('roughness'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('emissive'),\r\n pb.vec3('specular')\r\n ]);\r\n }\r\n\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRBluePrintLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n that.getCommonDatasStruct(scope)('pbrData'),\r\n pb.vec3('viewVec'),\r\n pb.vec3('worldPos'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = this.pbrData.emissive;\r\n if (outRoughness) {\r\n that.indirectLighting(this, this.viewVec, this.pbrData, this.lightingColor, this.outRoughness);\r\n } else {\r\n that.indirectLighting(this, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, shadow) {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.pbrData.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor\r\n );\r\n });\r\n this.$return(pb.vec4(pb.add(this.lightingColor, this.emissiveColor), this.pbrData.albedo.a));\r\n }\r\n );\r\n return outRoughness\r\n ? pb.getGlobalScope()[funcName](commonData, viewVec, worldPos, outRoughness)\r\n : pb.getGlobalScope()[funcName](commonData, viewVec, worldPos);\r\n }\r\n vertexShader(scope: PBFunctionScope): void {\r\n super.vertexShader(scope);\r\n }\r\n fragmentShader(scope: PBFunctionScope): void {\r\n const pb = scope.$builder;\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n if (this.drawContext.drawEnvLight) {\r\n scope.zGGXLut = pb.tex2D().uniform(2);\r\n }\r\n }\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n ir: MaterialBlueprintIR,\r\n viewVec: PBShaderExp,\r\n worldPos: PBShaderExp,\r\n worldNorm: PBShaderExp,\r\n worldTangent: PBShaderExp,\r\n worldBinormal: PBShaderExp,\r\n vertexColor: PBShaderExp,\r\n vertexUV: PBShaderExp,\r\n data: PBShaderExp\r\n ): void {\r\n const that = this;\r\n const pb = scope.$builder;\r\n const funcName = 'zCalculateCommonDataPBRBluePrint';\r\n const params: PBShaderExp[] = [\r\n this.getCommonDatasStruct(scope)('zCommonData').out(),\r\n pb.vec3('zViewVec'),\r\n pb.vec3('zWorldPos'),\r\n pb.vec3('zVertexNormal'),\r\n pb.vec3('zVertexTangent'),\r\n pb.vec3('zVertexBinormal'),\r\n pb.vec4('zVertexColor'),\r\n pb.vec2('zVertexUV')\r\n ];\r\n const paramValues: PBShaderExp[] = [\r\n data,\r\n viewVec,\r\n worldPos,\r\n worldNorm,\r\n worldTangent,\r\n worldBinormal,\r\n vertexColor,\r\n vertexUV\r\n ];\r\n pb.func(funcName, params, function () {\r\n const outputs = ir.create(pb);\r\n this.zCommonData.albedo = pb.vec4(\r\n (that.getOutput(outputs, 'BaseColor') as PBShaderExp)?.rgb ?? pb.vec3(1),\r\n that.getOutput(outputs, 'Opacity') ?? 1\r\n );\r\n this.zCommonData.metallic = that.getOutput(outputs, 'Metallic') ?? 0;\r\n this.zCommonData.roughness = that.getOutput(outputs, 'Roughness')\r\n ? pb.mul(that.getOutput(outputs, 'Roughness'), ShaderHelper.getCameraRoughnessFactor(scope))\r\n : ShaderHelper.getCameraRoughnessFactor(scope);\r\n this.zCommonData.specular = that.getOutput(outputs, 'Specular') ?? pb.vec3(1);\r\n this.zCommonData.emissive = that.getOutput(outputs, 'Emissive') ?? pb.vec3(0);\r\n this.zCommonData.f90 = pb.vec3(1);\r\n this.zCommonData.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(pb.vec3(0.04), this.zCommonData.specular), pb.vec3(1)),\r\n this.zCommonData.albedo.rgb,\r\n this.zCommonData.metallic\r\n ),\r\n 1.5\r\n );\r\n this.$l.tangent = that.getOutput(outputs, 'Tangent') ?? this.zVertexTangent;\r\n this.$l.ng = pb.normalize(this.zVertexNormal);\r\n this.$l.t_ = pb.normalize(this.tangent);\r\n this.$l.t = pb.normalize(pb.sub(this.t_, pb.mul(this.ng, pb.dot(this.ng, this.t_))));\r\n this.$l.b = pb.cross(this.ng, this.t);\r\n this.zCommonData.TBN = pb.mat3(this.t, this.b, this.ng);\r\n if (that.getOutput(outputs, 'Normal')) {\r\n this.zCommonData.normal = pb.normalize(\r\n pb.mul(this.zCommonData.TBN, that.getOutput(outputs, 'Normal'))\r\n );\r\n } else {\r\n this.zCommonData.normal = this.ng;\r\n }\r\n this.zCommonData.diffuse = pb.vec4(\r\n pb.mix(this.zCommonData.albedo.rgb, pb.vec3(0), this.zCommonData.metallic),\r\n this.zCommonData.albedo.a\r\n );\r\n });\r\n scope[funcName](...paramValues);\r\n }\r\n private getOutput(\r\n outputs: {\r\n name: string;\r\n exp: number | PBShaderExp;\r\n }[],\r\n name: string\r\n ) {\r\n return outputs.find((output) => output.name === name)?.exp;\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this;\r\n const funcName = 'Z_PBRDirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.data.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.data.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.data.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n this.$l.F = this.schlickFresnel;\r\n this.$l.alphaRoughness = pb.mul(this.data.roughness, this.data.roughness);\r\n this.$l.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F);\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n this.$l.diffuseBRDF = pb.mul(pb.sub(pb.vec3(1), this.F), pb.div(this.data.diffuse.rgb, Math.PI));\r\n this.$l.diffuse = pb.mul(this.lightColor, pb.max(this.diffuseBRDF, pb.vec3(0)));\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n });\r\n }\r\n );\r\n scope.$g[funcName](lightDir, lightColor, viewVec, commonData, outColor);\r\n }\r\n indirectLighting(\r\n scope: PBInsideFunctionScope,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n outColor: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this;\r\n const ctx = that.drawContext;\r\n const funcName = 'Z_PBRIndirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.vec3('outColor').inout(),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n if (\r\n !ctx.drawEnvLight ||\r\n (!ctx.env.light.envLight.hasRadiance() && !ctx.env.light.envLight.hasIrradiance())\r\n ) {\r\n return;\r\n }\r\n const envLightStrength = ShaderHelper.getEnvLightStrength(this);\r\n this.$l.occlusion = envLightStrength;\r\n this.$l.NoV = pb.clamp(pb.dot(this.data.normal, this.viewVec), 0.0001, 1);\r\n this.$l.ggxLutSample = pb.clamp(\r\n pb.textureSampleLevel(\r\n this.zGGXLut,\r\n pb.clamp(pb.vec2(this.NoV, this.data.roughness), pb.vec2(0), pb.vec2(1)),\r\n 0\r\n ),\r\n pb.vec4(0),\r\n pb.vec4(1)\r\n );\r\n this.$l.f_ab = this.ggxLutSample.rg;\r\n this.$l.Fr = pb.sub(\r\n pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.data.f0.rgb),\r\n this.data.f0.rgb\r\n );\r\n this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));\r\n if (outRoughness || ctx.env.light.envLight.hasRadiance()) {\r\n this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));\r\n this.$l.specularFactor = pb.mul(this.FssEss, this.occlusion);\r\n if (outRoughness) {\r\n this.outRoughness = pb.vec4(this.specularFactor /*this.data.f0.rgb*/, this.data.roughness);\r\n } else if (ctx.env.light.envLight.hasRadiance()) {\r\n this.$l.radiance = ctx.env.light.envLight.getRadiance(\r\n this,\r\n pb.reflect(pb.neg(this.viewVec), this.data.normal),\r\n this.data.roughness\r\n );\r\n this.outColor = pb.add(this.outColor, pb.mul(this.radiance, this.specularFactor));\r\n }\r\n }\r\n if (ctx.env.light.envLight.hasIrradiance()) {\r\n this.$l.irradiance = ctx.env.light.envLight.getIrradiance(this, this.data.normal);\r\n this.$l.mixedF0 = this.data.f0.rgb;\r\n this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));\r\n this.$l.Ems = pb.sub(1, pb.add(this.f_ab.x, this.f_ab.y));\r\n this.$l.F_avg = pb.add(this.mixedF0, pb.div(pb.sub(pb.vec3(1), this.mixedF0), 21));\r\n this.$l.FmsEms = pb.div(\r\n pb.mul(this.FssEss, this.F_avg, this.Ems),\r\n pb.sub(pb.vec3(1), pb.mul(this.F_avg, this.Ems))\r\n );\r\n this.$l.k_D = pb.mul(this.data.diffuse.rgb, pb.add(pb.sub(pb.vec3(1), this.FssEss), this.FmsEms));\r\n this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D), this.irradiance, this.occlusion);\r\n this.outColor = pb.add(this.outColor, this.iblDiffuse);\r\n }\r\n }\r\n );\r\n if (outRoughness) {\r\n scope.$g[funcName](viewVec, commonData, outColor, outRoughness);\r\n } else {\r\n scope.$g[funcName](viewVec, commonData, outColor);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number): void {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (ctx.drawEnvLight) {\r\n bindGroup.setTexture('zGGXLut', getGGXLUT(1024));\r\n }\r\n }\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRBluePrint };\r\n}\r\n"],"names":["mixinPBRBluePrint","BaseCls","pbrBluePrint","S","applyMaterialMixins","mixinPBRBRDF","mixinLight","copyFrom","other","getCommonData","scope","data","viewVec","worldPos","worldNorm","worldTangent","worldBinormal","vertexColor","vertexUV","ir","calculateCommonData","getCommonDatasStruct","pb","$builder","defineStruct","vec4","vec3","float","mat3","PBRLight","commonData","outRoughness","funcName","that","func","out","$l","lightingColor","emissiveColor","pbrData","emissive","indirectLighting","forEachLight","type","posRange","dirCutoff","colorIntensity","shadow","diffuse","specular","lightAtten","calculateLightAttenuation","lightDir","calculateLightDirection","NoL","clamp","dot","normal","lightColor","mul","rgb","a","calculateShadow","directLighting","$return","add","albedo","getGlobalScope","vertexShader","fragmentShader","needFragmentColor","drawContext","drawEnvLight","zGGXLut","tex2D","uniform","params","vec2","paramValues","outputs","create","zCommonData","getOutput","metallic","roughness","ShaderHelper","getCameraRoughnessFactor","f90","f0","mix","min","tangent","zVertexTangent","ng","normalize","zVertexNormal","t_","t","sub","b","cross","TBN","name","find","output","exp","outColor","inout","H","L","NoH","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","F","alphaRoughness","D","distributionGGX","V","visGGX","diffuseBRDF","div","Math","PI","max","$g","ctx","env","light","envLight","hasRadiance","hasIrradiance","envLightStrength","getEnvLightStrength","occlusion","ggxLutSample","textureSampleLevel","f_ab","rg","Fr","k_S","pow","FssEss","x","y","specularFactor","radiance","getRadiance","reflect","neg","irradiance","getIrradiance","mixedF0","Ems","F_avg","FmsEms","k_D","iblDiffuse","applyUniformValues","bindGroup","pass","setTexture","getGGXLUT"],"mappings":";;;;;;AAoEA;;;;;IAMO,SAASA,iBAAAA,CAAiDC,OAAU,EAAA;IACzE,IAAKA,OAAgBC,CAAAA,YAAY,EAAE;QACjC,OAAOD,OAAAA;AACT;IACA,MAAME,CAAAA,GAAIC,mBAAoBH,CAAAA,OAAAA,EAASI,YAAcC,EAAAA,UAAAA,CAAAA;AAErD,IAAA,OAAO,cAAcH,CAAAA,CAAAA;AACnB,QAAA,OAAgBD,eAAe,IAAK;QACpC,WAAc,EAAA;YACZ,KAAK,EAAA;AACP;AACAK,QAAAA,QAAAA,CAASC,KAAW,EAAQ;AAC1B,YAAA,KAAK,CAACD,QAASC,CAAAA,KAAAA,CAAAA;AACjB;AACAC,QAAAA,aAAAA,CACEC,KAA4B,EAC5BC,IAAiB,EACjBC,OAAoB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AA;AAC5C;AACF;AACF;AACF,KAAA;AACF;;;;"}
|
|
@@ -4,6 +4,7 @@ import { mixinPBRCommon } from '../pbr/common.js';
|
|
|
4
4
|
import { Vector4 } from '@zephyr3d/base';
|
|
5
5
|
import { mixinLight } from '../lit.js';
|
|
6
6
|
import { ShaderHelper } from '../../shader/helper.js';
|
|
7
|
+
import { MaterialVaryingFlags } from '../../../values.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* PBRMetallicRoughness lighting model mixin
|
|
@@ -14,7 +15,10 @@ import { ShaderHelper } from '../../shader/helper.js';
|
|
|
14
15
|
if (BaseCls.pbrMetallicRoughnessMixed) {
|
|
15
16
|
return BaseCls;
|
|
16
17
|
}
|
|
17
|
-
const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('metallicRoughness'), mixinTextureProps('
|
|
18
|
+
const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('metallicRoughness'), mixinTextureProps('specular'), mixinTextureProps('specularColor'));
|
|
19
|
+
const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');
|
|
20
|
+
const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');
|
|
21
|
+
const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');
|
|
18
22
|
return class extends S {
|
|
19
23
|
static pbrMetallicRoughnessMixed = true;
|
|
20
24
|
_metallic;
|
|
@@ -26,6 +30,12 @@ import { ShaderHelper } from '../../shader/helper.js';
|
|
|
26
30
|
this._roughness = 1;
|
|
27
31
|
this._specularFactor = Vector4.one();
|
|
28
32
|
}
|
|
33
|
+
copyFrom(other) {
|
|
34
|
+
super.copyFrom(other);
|
|
35
|
+
this.metallic = other.metallic;
|
|
36
|
+
this.roughness = other.roughness;
|
|
37
|
+
this.specularFactor = other.specularFactor;
|
|
38
|
+
}
|
|
29
39
|
get metallic() {
|
|
30
40
|
return this._metallic;
|
|
31
41
|
}
|
|
@@ -91,43 +101,70 @@ import { ShaderHelper } from '../../shader/helper.js';
|
|
|
91
101
|
});
|
|
92
102
|
return outRoughness ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness) : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);
|
|
93
103
|
}
|
|
104
|
+
vertexShader(scope) {
|
|
105
|
+
super.vertexShader(scope);
|
|
106
|
+
if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
|
|
107
|
+
scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);
|
|
108
|
+
scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);
|
|
109
|
+
scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
94
112
|
fragmentShader(scope) {
|
|
95
113
|
super.fragmentShader(scope);
|
|
96
114
|
if (this.needFragmentColor()) {
|
|
97
115
|
const pb = scope.$builder;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
117
|
+
scope.zMetallic = pb.float().uniform(2);
|
|
118
|
+
scope.zRoughness = pb.float().uniform(2);
|
|
119
|
+
scope.zSpecularFactor = pb.vec4().uniform(2);
|
|
120
|
+
}
|
|
101
121
|
}
|
|
102
122
|
}
|
|
103
123
|
applyUniformValues(bindGroup, ctx, pass) {
|
|
104
124
|
super.applyUniformValues(bindGroup, ctx, pass);
|
|
105
125
|
if (this.needFragmentColor(ctx)) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
127
|
+
bindGroup.setValue('zMetallic', this._metallic);
|
|
128
|
+
bindGroup.setValue('zRoughness', this._roughness);
|
|
129
|
+
bindGroup.setValue('zSpecularFactor', this._specularFactor);
|
|
130
|
+
}
|
|
109
131
|
}
|
|
110
132
|
}
|
|
133
|
+
calculateMetallic(scope, _albedo, _normal) {
|
|
134
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
135
|
+
return instancing ? scope.$inputs.zMetallic : scope.zMetallic;
|
|
136
|
+
}
|
|
137
|
+
calculateRoughness(scope, _albedo, _normal) {
|
|
138
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
139
|
+
return instancing ? scope.$inputs.zRoughness : scope.zRoughness;
|
|
140
|
+
}
|
|
141
|
+
calculateSpecularFactor(scope, _albedo, _normal) {
|
|
142
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
143
|
+
return instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor;
|
|
144
|
+
}
|
|
111
145
|
calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
|
|
112
146
|
const pb = scope.$builder;
|
|
147
|
+
const metallic = this.calculateMetallic(scope, albedo, normal);
|
|
148
|
+
const roughness = this.calculateRoughness(scope, albedo, normal);
|
|
149
|
+
const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);
|
|
113
150
|
if (this.metallicRoughnessTexture) {
|
|
114
151
|
scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);
|
|
115
|
-
data.metallic = pb.mul(
|
|
116
|
-
data.roughness = pb.mul(
|
|
152
|
+
data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);
|
|
153
|
+
data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);
|
|
117
154
|
} else {
|
|
118
|
-
data.metallic =
|
|
119
|
-
data.roughness =
|
|
155
|
+
data.metallic = metallic;
|
|
156
|
+
data.roughness = roughness;
|
|
120
157
|
}
|
|
121
158
|
data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));
|
|
122
159
|
if (this.specularColorTexture) {
|
|
123
|
-
scope.$l.specularColor = pb.mul(
|
|
160
|
+
scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);
|
|
124
161
|
} else {
|
|
125
|
-
scope.$l.specularColor =
|
|
162
|
+
scope.$l.specularColor = specularFactor.rgb;
|
|
126
163
|
}
|
|
127
164
|
if (this.specularTexture) {
|
|
128
|
-
data.specularWeight = pb.mul(
|
|
165
|
+
data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);
|
|
129
166
|
} else {
|
|
130
|
-
data.specularWeight =
|
|
167
|
+
data.specularWeight = specularFactor.a;
|
|
131
168
|
}
|
|
132
169
|
data.f0 = pb.vec4(pb.mix(pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)), albedo.rgb, data.metallic), this.getF0(scope).a);
|
|
133
170
|
data.f90 = pb.vec3(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrmetallicroughness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport { MaterialVaryingFlags } from '../../../values';\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp);\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<['metallicRoughness', 'occlusion', 'specular', 'specularColor']>;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n }\r\n copyFrom(other: this): void {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n }\r\n get metallic(): number {\r\n return this._metallic;\r\n }\r\n set metallic(val: number) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness(): number {\r\n return this._roughness;\r\n }\r\n set roughness(val: number) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Vector4 {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Vector4) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, shadow) {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor\r\n );\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);\r\n }\r\n vertexShader(scope: PBFunctionScope): void {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope): void {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number): void {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return instancing ? scope.$inputs.zMetallic : scope.zMetallic;\r\n }\r\n calculateRoughness(\r\n scope: PBInsideFunctionScope,\r\n _albedo: PBShaderExp,\r\n _normal: PBShaderExp\r\n ): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return instancing ? scope.$inputs.zRoughness : scope.zRoughness;\r\n }\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n _albedo: PBShaderExp,\r\n _normal: PBShaderExp\r\n ): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","Vector4","one","copyFrom","other","metallic","roughness","specularFactor","val","uniformChanged","equalsTo","set","PBRLight","scope","worldPos","normal","viewVec","albedo","TBN","outRoughness","pb","$builder","funcName","that","func","vec3","mat3","vec4","out","$l","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","type","posRange","dirCutoff","colorIntensity","shadow","diffuse","specular","lightAtten","calculateLightAttenuation","lightDir","calculateLightDirection","NoL","clamp","dot","lightColor","mul","rgb","a","calculateShadow","directLighting","$return","add","getGlobalScope","vertexShader","needFragmentColor","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","float","uniform","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","data","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","z","y","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","specularWeight","sampleSpecularTexture","f0","mix","min","getF0","f90"],"mappings":";;;;;;;;AA8CA;;;;;IAMO,SAASA,yBAAAA,CAAyDC,OAAU,EAAA;IACjF,IAAKA,OAAgBC,CAAAA,yBAAyB,EAAE;QAC9C,OAAOD,OAAAA;AACT;IACA,MAAME,CAAAA,GAAIC,oBACRH,OACAI,EAAAA,cAAAA,EACAC,YACAC,iBAAkB,CAAA,mBAAA,CAAA,EAClBA,iBAAkB,CAAA,UAAA,CAAA,EAClBA,iBAAkB,CAAA,eAAA,CAAA,CAAA;AAEpB,IAAA,MAAMC,gBAAmBL,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,YAAY,OAAS,EAAA,UAAA,CAAA;AACtE,IAAA,MAAMC,iBAAoBP,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,aAAa,OAAS,EAAA,WAAA,CAAA;AACxE,IAA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3
|
import { mixinPBRCommon } from '../pbr/common.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Vector3 } from '@zephyr3d/base';
|
|
5
5
|
import { mixinLight } from '../lit.js';
|
|
6
6
|
import { ShaderHelper } from '../../shader/helper.js';
|
|
7
|
+
import { MaterialVaryingFlags } from '../../../values.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* PBRSpecularGlossiness mixin
|
|
@@ -17,15 +18,22 @@ import { ShaderHelper } from '../../shader/helper.js';
|
|
|
17
18
|
return BaseCls;
|
|
18
19
|
}
|
|
19
20
|
const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('specular'));
|
|
21
|
+
const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgb', 'SpecularFactor');
|
|
22
|
+
const GLOSSINESS_FACTOR_UNIFORM = S.defineInstanceUniform('glossinessFactor', 'float', 'GlossinessFactor');
|
|
20
23
|
return class extends S {
|
|
21
24
|
static pbrSpecularGlossnessMixed = true;
|
|
22
25
|
_specularFactor;
|
|
23
26
|
_glossinessFactor;
|
|
24
27
|
constructor(){
|
|
25
28
|
super();
|
|
26
|
-
this._specularFactor =
|
|
29
|
+
this._specularFactor = Vector3.one();
|
|
27
30
|
this._glossinessFactor = 1;
|
|
28
31
|
}
|
|
32
|
+
copyFrom(other) {
|
|
33
|
+
super.copyFrom(other);
|
|
34
|
+
this.specularFactor = other.specularFactor;
|
|
35
|
+
this.glossinessFactor = other.glossinessFactor;
|
|
36
|
+
}
|
|
29
37
|
get specularFactor() {
|
|
30
38
|
return this._specularFactor;
|
|
31
39
|
}
|
|
@@ -44,17 +52,24 @@ import { ShaderHelper } from '../../shader/helper.js';
|
|
|
44
52
|
this.uniformChanged();
|
|
45
53
|
}
|
|
46
54
|
}
|
|
55
|
+
vertexShader(scope) {
|
|
56
|
+
super.vertexShader(scope);
|
|
57
|
+
if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
|
|
58
|
+
scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);
|
|
59
|
+
scope.$outputs.zGlossinessFactor = this.getInstancedUniform(scope, GLOSSINESS_FACTOR_UNIFORM);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
47
62
|
fragmentShader(scope) {
|
|
48
63
|
super.fragmentShader(scope);
|
|
49
|
-
if (this.needFragmentColor()) {
|
|
64
|
+
if (this.needFragmentColor() && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
50
65
|
const pb = scope.$builder;
|
|
51
|
-
scope.zSpecularFactor = pb.
|
|
66
|
+
scope.zSpecularFactor = pb.vec3().uniform(2);
|
|
52
67
|
scope.zGlossinessFactor = pb.float().uniform(2);
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
70
|
applyUniformValues(bindGroup, ctx, pass) {
|
|
56
71
|
super.applyUniformValues(bindGroup, ctx, pass);
|
|
57
|
-
if (this.needFragmentColor(ctx)) {
|
|
72
|
+
if (this.needFragmentColor(ctx) && !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
58
73
|
bindGroup.setValue('zSpecularFactor', this._specularFactor);
|
|
59
74
|
bindGroup.setValue('zGlossinessFactor', this._glossinessFactor);
|
|
60
75
|
}
|
|
@@ -100,13 +115,16 @@ import { ShaderHelper } from '../../shader/helper.js';
|
|
|
100
115
|
calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
|
|
101
116
|
super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);
|
|
102
117
|
const pb = scope.$builder;
|
|
118
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
119
|
+
const specularFactor = instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor;
|
|
120
|
+
const glossinessFactor = instancing ? scope.$inputs.zGlossinessFactor : scope.zGlossinessFactor;
|
|
103
121
|
if (this.specularTexture) {
|
|
104
122
|
scope.$l.specularTextureSample = this.sampleSpecularTexture(scope);
|
|
105
|
-
data.roughness = pb.sub(1, pb.mul(
|
|
106
|
-
data.f0 = pb.vec4(pb.mul(scope.specularTextureSample.rgb,
|
|
123
|
+
data.roughness = pb.sub(1, pb.mul(glossinessFactor, scope.specularTextureSample.a));
|
|
124
|
+
data.f0 = pb.vec4(pb.mul(scope.specularTextureSample.rgb, specularFactor), this.getF0(scope).a);
|
|
107
125
|
} else {
|
|
108
|
-
data.roughness = pb.sub(1,
|
|
109
|
-
data.f0 = pb.vec4(
|
|
126
|
+
data.roughness = pb.sub(1, glossinessFactor);
|
|
127
|
+
data.f0 = pb.vec4(specularFactor, this.getF0(scope).a);
|
|
110
128
|
}
|
|
111
129
|
data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));
|
|
112
130
|
data.metallic = pb.max(pb.max(data.f0.r, data.f0.g), data.f0.b);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrspecularglossness.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"pbrspecularglossness.js","sources":["../../../../src/material/mixins/lightmodel/pbrspecularglossness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport { Vector3 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport { MaterialVaryingFlags } from '../../../values';\r\n\r\n/**\r\n * Interface for PBRSpecularGlossiness mixin\r\n * @public\r\n */\r\nexport type IMixinPBRSpecularGlossiness = {\r\n specularFactor: Vector3;\r\n glossinessFactor: number;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<['specular']>;\r\n\r\n/**\r\n * PBRSpecularGlossiness mixin\r\n *\r\n * @param BaseCls - Base class to mix in\r\n * @returns Mixed class\r\n *\r\n * @public\r\n */\r\nexport function mixinPBRSpecularGlossness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrSpecularGlossnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRSpecularGlossiness };\r\n }\r\n const S = applyMaterialMixins(BaseCls, mixinPBRCommon, mixinLight, mixinTextureProps('specular'));\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgb', 'SpecularFactor');\r\n const GLOSSINESS_FACTOR_UNIFORM = S.defineInstanceUniform('glossinessFactor', 'float', 'GlossinessFactor');\r\n return class extends S {\r\n static readonly pbrSpecularGlossnessMixed = true;\r\n private readonly _specularFactor: Vector3;\r\n private _glossinessFactor: number;\r\n constructor() {\r\n super();\r\n this._specularFactor = Vector3.one();\r\n this._glossinessFactor = 1;\r\n }\r\n copyFrom(other: this): void {\r\n super.copyFrom(other);\r\n this.specularFactor = other.specularFactor;\r\n this.glossinessFactor = other.glossinessFactor;\r\n }\r\n get specularFactor(): Vector3 {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Vector3) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n get glossinessFactor(): number {\r\n return this._glossinessFactor;\r\n }\r\n set glossinessFactor(val: number) {\r\n if (val !== this._glossinessFactor) {\r\n this._glossinessFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n vertexShader(scope: PBFunctionScope): void {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n scope.$outputs.zGlossinessFactor = this.getInstancedUniform(scope, GLOSSINESS_FACTOR_UNIFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope): void {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor() && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n const pb = scope.$builder;\r\n scope.zSpecularFactor = pb.vec3().uniform(2);\r\n scope.zGlossinessFactor = pb.float().uniform(2);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number): void {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx) && !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zGlossinessFactor', this._glossinessFactor);\r\n }\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRSpecularGlossinessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, shadow) {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(this.lightColor, that.calculateShadow(this, this.worldPos, this.NoL));\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor\r\n );\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo);\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void {\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n const pb = scope.$builder;\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n const specularFactor = instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor;\r\n const glossinessFactor = instancing ? scope.$inputs.zGlossinessFactor : scope.zGlossinessFactor;\r\n if (this.specularTexture) {\r\n scope.$l.specularTextureSample = this.sampleSpecularTexture(scope);\r\n data.roughness = pb.sub(1, pb.mul(glossinessFactor, scope.specularTextureSample.a));\r\n data.f0 = pb.vec4(pb.mul(scope.specularTextureSample.rgb, specularFactor), this.getF0(scope).a);\r\n } else {\r\n data.roughness = pb.sub(1, glossinessFactor);\r\n data.f0 = pb.vec4(specularFactor, this.getF0(scope).a);\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n data.metallic = pb.max(pb.max(data.f0.r, data.f0.g), data.f0.b);\r\n data.diffuse = pb.vec4(pb.mul(albedo.rgb, pb.sub(1, data.metallic)), albedo.a);\r\n data.specularWeight = 1;\r\n data.f90 = pb.vec3(1);\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRSpecularGlossiness };\r\n}\r\n"],"names":["mixinPBRSpecularGlossness","BaseCls","pbrSpecularGlossnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","SPECULAR_FACTOR_UNFORM","defineInstanceUniform","GLOSSINESS_FACTOR_UNIFORM","_specularFactor","_glossinessFactor","Vector3","one","copyFrom","other","specularFactor","glossinessFactor","val","equalsTo","set","uniformChanged","vertexShader","scope","needFragmentColor","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zSpecularFactor","getInstancedUniform","zGlossinessFactor","fragmentShader","pb","$builder","vec3","uniform","float","applyUniformValues","bindGroup","ctx","pass","setValue","PBRLight","worldPos","normal","viewVec","albedo","TBN","outRoughness","funcName","that","func","mat3","vec4","out","$l","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","type","posRange","dirCutoff","colorIntensity","shadow","diffuse","specular","lightAtten","calculateLightAttenuation","lightDir","calculateLightDirection","NoL","clamp","dot","lightColor","mul","rgb","a","calculateShadow","directLighting","$return","add","getGlobalScope","calculateCommonData","data","instancing","$inputs","specularTexture","specularTextureSample","sampleSpecularTexture","roughness","sub","f0","getF0","ShaderHelper","getCameraRoughnessFactor","metallic","max","r","g","b","specularWeight","f90"],"mappings":";;;;;;;;AAyCA;;;;;;;IAQO,SAASA,yBAAAA,CAAyDC,OAAU,EAAA;IACjF,IAAKA,OAAgBC,CAAAA,yBAAyB,EAAE;QAC9C,OAAOD,OAAAA;AACT;AACA,IAAA,MAAME,CAAIC,GAAAA,mBAAAA,CAAoBH,OAASI,EAAAA,cAAAA,EAAgBC,YAAYC,iBAAkB,CAAA,UAAA,CAAA,CAAA;AACrF,IAAA,MAAMC,sBAAyBL,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,kBAAkB,KAAO,EAAA,gBAAA,CAAA;AAChF,IAAA,MAAMC,yBAA4BP,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,oBAAoB,OAAS,EAAA,kBAAA,CAAA;AACvF,IAAA,OAAO,cAAcN,CAAAA,CAAAA;AACnB,QAAA,OAAgBD,4BAA4B,IAAK;QAChCS,eAAyB;QAClCC,iBAA0B;QAClC,WAAc,EAAA;YACZ,KAAK,EAAA;AACL,YAAA,IAAI,CAACD,eAAe,GAAGE,OAAAA,CAAQC,GAAG,EAAA;YAClC,IAAI,CAACF,iBAAiB,GAAG,CAAA;AAC3B;AACAG,QAAAA,QAAAA,CAASC,KAAW,EAAQ;AAC1B,YAAA,KAAK,CAACD,QAASC,CAAAA,KAAAA,CAAAA;AACf,YAAA,IAA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