@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,918 @@
|
|
|
1
|
+
import { applyMaterialMixins } from '../../meshmaterial.js';
|
|
2
|
+
import { Vector4, Vector3 } from '@zephyr3d/base';
|
|
3
|
+
import { getGGXLUT } from '../../../utility/textures/ggxlut.js';
|
|
4
|
+
import { mixinTextureProps } from '../texture.js';
|
|
5
|
+
import { ShaderHelper } from '../../shader/helper.js';
|
|
6
|
+
import { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../../../values.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* PBR common stuff mixin
|
|
10
|
+
* @param BaseCls - Class to mix in
|
|
11
|
+
* @returns Mixed class
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/ function mixinPBRCommon(BaseCls) {
|
|
15
|
+
if (BaseCls.pbrCommonMixed) {
|
|
16
|
+
return BaseCls;
|
|
17
|
+
}
|
|
18
|
+
const S = applyMaterialMixins(BaseCls, mixinTextureProps('occlusion'), mixinTextureProps('emissive'), mixinTextureProps('sheenColor'), mixinTextureProps('sheenRoughness'), mixinTextureProps('clearcoatIntensity'), mixinTextureProps('clearcoatRoughness'), mixinTextureProps('clearcoatNormal'), mixinTextureProps('transmission'), mixinTextureProps('thickness'), mixinTextureProps('iridescence'), mixinTextureProps('iridescenceThickness'));
|
|
19
|
+
let FEATURE_SHEEN = 0;
|
|
20
|
+
let FEATURE_CLEARCOAT = 0;
|
|
21
|
+
let FEATURE_TRANSMISSION = 0;
|
|
22
|
+
let FEATURE_IRIDESCENCE = 0;
|
|
23
|
+
const EMISSIVE_COLOR_UNIFORM = S.defineInstanceUniform('emissiveColor', 'rgb');
|
|
24
|
+
const EMISSIVE_STRENGTH_UNIFORM = S.defineInstanceUniform('emissiveStrength', 'float');
|
|
25
|
+
const cls = class extends S {
|
|
26
|
+
static pbrCommonMixed = true;
|
|
27
|
+
_f0;
|
|
28
|
+
_emissiveColor;
|
|
29
|
+
_emissiveStrength;
|
|
30
|
+
_occlusionStrength;
|
|
31
|
+
_sheenFactor;
|
|
32
|
+
_clearcoatFactor;
|
|
33
|
+
_transmissionFactor;
|
|
34
|
+
_thicknessFactor;
|
|
35
|
+
_attenuationColor;
|
|
36
|
+
_attenuationDistance;
|
|
37
|
+
_iridescenceFactor;
|
|
38
|
+
constructor(){
|
|
39
|
+
super();
|
|
40
|
+
this._f0 = new Vector4(0.04, 0.04, 0.04, 1.5);
|
|
41
|
+
this._occlusionStrength = 1;
|
|
42
|
+
this._emissiveColor = new Vector3(0, 0, 0);
|
|
43
|
+
this._emissiveStrength = 1;
|
|
44
|
+
this._sheenFactor = Vector4.zero();
|
|
45
|
+
this._clearcoatFactor = new Vector4(0, 0, 1, 0);
|
|
46
|
+
this._transmissionFactor = 0;
|
|
47
|
+
this._thicknessFactor = 0;
|
|
48
|
+
this._attenuationColor = Vector3.one();
|
|
49
|
+
this._attenuationDistance = 99999;
|
|
50
|
+
this._iridescenceFactor = new Vector4(0, 1.3, 100, 400);
|
|
51
|
+
}
|
|
52
|
+
copyFrom(other) {
|
|
53
|
+
super.copyFrom(other);
|
|
54
|
+
this.ior = other.ior;
|
|
55
|
+
this.transmissionFactor = other.transmissionFactor;
|
|
56
|
+
this.thicknessFactor = other.thicknessFactor;
|
|
57
|
+
this.attenuationColor = other.attenuationColor;
|
|
58
|
+
this.attenuationDistance = other.attenuationDistance;
|
|
59
|
+
this.iridescenceFactor = other.iridescenceFactor;
|
|
60
|
+
this.iridescenceIor = other.iridescenceIor;
|
|
61
|
+
this.iridescenceThicknessMin = other.iridescenceThicknessMin;
|
|
62
|
+
this.iridescenceThicknessMax = other.iridescenceThicknessMax;
|
|
63
|
+
this.occlusionStrength = other.occlusionStrength;
|
|
64
|
+
this.emissiveColor = other.emissiveColor;
|
|
65
|
+
this.emissiveStrength = other.emissiveStrength;
|
|
66
|
+
this.transmission = other.transmission;
|
|
67
|
+
this.iridescence = other.iridescence;
|
|
68
|
+
this.clearcoat = other.clearcoat;
|
|
69
|
+
this.clearcoatIntensity = other.clearcoatIntensity;
|
|
70
|
+
this.clearcoatRoughnessFactor = other.clearcoatRoughnessFactor;
|
|
71
|
+
this.sheen = other.sheen;
|
|
72
|
+
this.sheenColorFactor = other.sheenColorFactor;
|
|
73
|
+
this.sheenRoughnessFactor = other.sheenRoughnessFactor;
|
|
74
|
+
}
|
|
75
|
+
get ior() {
|
|
76
|
+
return this._f0.w;
|
|
77
|
+
}
|
|
78
|
+
set ior(val) {
|
|
79
|
+
if (val !== this._f0.w) {
|
|
80
|
+
let k = (val - 1) / (val + 1);
|
|
81
|
+
k *= k;
|
|
82
|
+
this._f0.setXYZW(k, k, k, val);
|
|
83
|
+
this.uniformChanged();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
get transmissionFactor() {
|
|
87
|
+
return this._transmissionFactor;
|
|
88
|
+
}
|
|
89
|
+
set transmissionFactor(val) {
|
|
90
|
+
if (val !== this._transmissionFactor) {
|
|
91
|
+
this._transmissionFactor = val;
|
|
92
|
+
this.uniformChanged();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
get thicknessFactor() {
|
|
96
|
+
return this._thicknessFactor;
|
|
97
|
+
}
|
|
98
|
+
set thicknessFactor(val) {
|
|
99
|
+
if (this._thicknessFactor !== val) {
|
|
100
|
+
this._thicknessFactor = val;
|
|
101
|
+
this.uniformChanged();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
get attenuationColor() {
|
|
105
|
+
return this._attenuationColor;
|
|
106
|
+
}
|
|
107
|
+
set attenuationColor(val) {
|
|
108
|
+
if (!val.equalsTo(this._attenuationColor)) {
|
|
109
|
+
this._attenuationColor.set(val);
|
|
110
|
+
this.uniformChanged();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
get attenuationDistance() {
|
|
114
|
+
return this._attenuationDistance;
|
|
115
|
+
}
|
|
116
|
+
set attenuationDistance(val) {
|
|
117
|
+
if (val !== this._attenuationDistance) {
|
|
118
|
+
this._attenuationDistance = val;
|
|
119
|
+
this.uniformChanged();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
get iridescenceFactor() {
|
|
123
|
+
return this._iridescenceFactor.x;
|
|
124
|
+
}
|
|
125
|
+
set iridescenceFactor(val) {
|
|
126
|
+
if (this._iridescenceFactor.x !== val) {
|
|
127
|
+
this._iridescenceFactor.x = val;
|
|
128
|
+
this.uniformChanged();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
get iridescenceIor() {
|
|
132
|
+
return this._iridescenceFactor.y;
|
|
133
|
+
}
|
|
134
|
+
set iridescenceIor(val) {
|
|
135
|
+
if (this._iridescenceFactor.y !== val) {
|
|
136
|
+
this._iridescenceFactor.y = val;
|
|
137
|
+
this.uniformChanged();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
get iridescenceThicknessMin() {
|
|
141
|
+
return this._iridescenceFactor.z;
|
|
142
|
+
}
|
|
143
|
+
set iridescenceThicknessMin(val) {
|
|
144
|
+
if (this._iridescenceFactor.z !== val) {
|
|
145
|
+
this._iridescenceFactor.z = val;
|
|
146
|
+
this.uniformChanged();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
get iridescenceThicknessMax() {
|
|
150
|
+
return this._iridescenceFactor.w;
|
|
151
|
+
}
|
|
152
|
+
set iridescenceThicknessMax(val) {
|
|
153
|
+
if (this._iridescenceFactor.w !== val) {
|
|
154
|
+
this._iridescenceFactor.w = val;
|
|
155
|
+
this.uniformChanged();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
get occlusionStrength() {
|
|
159
|
+
return this._occlusionStrength;
|
|
160
|
+
}
|
|
161
|
+
set occlusionStrength(val) {
|
|
162
|
+
if (val !== this._occlusionStrength) {
|
|
163
|
+
this._occlusionStrength = val;
|
|
164
|
+
this.uniformChanged();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
get emissiveColor() {
|
|
168
|
+
return this._emissiveColor;
|
|
169
|
+
}
|
|
170
|
+
set emissiveColor(val) {
|
|
171
|
+
if (val.x !== this._emissiveColor.x || val.y !== this._emissiveColor.y || val.z !== this._emissiveColor.z) {
|
|
172
|
+
this._emissiveColor.set(val);
|
|
173
|
+
this.uniformChanged();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
get emissiveStrength() {
|
|
177
|
+
return this._emissiveStrength;
|
|
178
|
+
}
|
|
179
|
+
set emissiveStrength(val) {
|
|
180
|
+
if (this._emissiveStrength !== val) {
|
|
181
|
+
this._emissiveStrength = val;
|
|
182
|
+
this.uniformChanged();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
get transmission() {
|
|
186
|
+
return this.featureUsed(FEATURE_TRANSMISSION);
|
|
187
|
+
}
|
|
188
|
+
set transmission(val) {
|
|
189
|
+
this.useFeature(FEATURE_TRANSMISSION, !!val);
|
|
190
|
+
}
|
|
191
|
+
get iridescence() {
|
|
192
|
+
return this.featureUsed(FEATURE_IRIDESCENCE);
|
|
193
|
+
}
|
|
194
|
+
set iridescence(val) {
|
|
195
|
+
this.useFeature(FEATURE_IRIDESCENCE, !!val);
|
|
196
|
+
}
|
|
197
|
+
get clearcoat() {
|
|
198
|
+
return this.featureUsed(FEATURE_CLEARCOAT);
|
|
199
|
+
}
|
|
200
|
+
set clearcoat(val) {
|
|
201
|
+
this.useFeature(FEATURE_CLEARCOAT, !!val);
|
|
202
|
+
}
|
|
203
|
+
get clearcoatIntensity() {
|
|
204
|
+
return this._clearcoatFactor.x;
|
|
205
|
+
}
|
|
206
|
+
set clearcoatIntensity(val) {
|
|
207
|
+
if (val !== this._clearcoatFactor.x) {
|
|
208
|
+
this._clearcoatFactor.x = val;
|
|
209
|
+
this.uniformChanged();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
get clearcoatRoughnessFactor() {
|
|
213
|
+
return this._clearcoatFactor.y;
|
|
214
|
+
}
|
|
215
|
+
set clearcoatRoughnessFactor(val) {
|
|
216
|
+
if (val !== this._clearcoatFactor.y) {
|
|
217
|
+
this._clearcoatFactor.y = val;
|
|
218
|
+
this.uniformChanged();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
get sheen() {
|
|
222
|
+
return this.featureUsed(FEATURE_SHEEN);
|
|
223
|
+
}
|
|
224
|
+
set sheen(val) {
|
|
225
|
+
this.useFeature(FEATURE_SHEEN, !!val);
|
|
226
|
+
}
|
|
227
|
+
get sheenColorFactor() {
|
|
228
|
+
return this._sheenFactor.xyz();
|
|
229
|
+
}
|
|
230
|
+
set sheenColorFactor(val) {
|
|
231
|
+
if (val.x !== this._sheenFactor.x || val.y !== this._sheenFactor.y || val.z !== this._sheenFactor.z) {
|
|
232
|
+
this._sheenFactor.x = val.x;
|
|
233
|
+
this._sheenFactor.y = val.y;
|
|
234
|
+
this._sheenFactor.z = val.z;
|
|
235
|
+
this.uniformChanged();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
get sheenRoughnessFactor() {
|
|
239
|
+
return this._sheenFactor.w;
|
|
240
|
+
}
|
|
241
|
+
set sheenRoughnessFactor(val) {
|
|
242
|
+
if (val !== this._sheenFactor.w) {
|
|
243
|
+
this._sheenFactor.w = val;
|
|
244
|
+
this.uniformChanged();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
vertexShader(scope) {
|
|
248
|
+
super.vertexShader(scope);
|
|
249
|
+
if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
|
|
250
|
+
scope.$outputs.zEmissiveColor = this.getInstancedUniform(scope, EMISSIVE_COLOR_UNIFORM);
|
|
251
|
+
scope.$outputs.zEmissiveStrength = this.getInstancedUniform(scope, EMISSIVE_STRENGTH_UNIFORM);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
fragmentShader(scope) {
|
|
255
|
+
const pb = scope.$builder;
|
|
256
|
+
super.fragmentShader(scope);
|
|
257
|
+
if (this.needFragmentColor()) {
|
|
258
|
+
scope.zF0 = pb.vec4().uniform(2);
|
|
259
|
+
if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
260
|
+
scope.zEmissiveColor = pb.vec3().uniform(2);
|
|
261
|
+
scope.zEmissiveStrength = pb.float().uniform(2);
|
|
262
|
+
}
|
|
263
|
+
if (this.occlusionTexture) {
|
|
264
|
+
scope.zOcclusionStrength = pb.float().uniform(2);
|
|
265
|
+
}
|
|
266
|
+
if (this.sheen) {
|
|
267
|
+
scope.zSheenFactor = pb.vec4().uniform(2);
|
|
268
|
+
}
|
|
269
|
+
if (this.clearcoat) {
|
|
270
|
+
scope.zClearcoatFactor = pb.vec4().uniform(2);
|
|
271
|
+
}
|
|
272
|
+
if (this.transmission && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
273
|
+
scope.zTransmissionFactor = pb.float().uniform(2);
|
|
274
|
+
scope.zThicknessFactor = pb.float().uniform(2);
|
|
275
|
+
scope.zAttenuationColor = pb.vec3().uniform(2);
|
|
276
|
+
scope.zAttenuationDistance = pb.float().uniform(2);
|
|
277
|
+
}
|
|
278
|
+
if (this.iridescence) {
|
|
279
|
+
scope.zIridescenceFactor = pb.vec4().uniform(2);
|
|
280
|
+
}
|
|
281
|
+
if (this.drawContext.drawEnvLight) {
|
|
282
|
+
scope.zGGXLut = pb.tex2D().uniform(2);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
needSceneColor() {
|
|
287
|
+
return this.transmission;
|
|
288
|
+
}
|
|
289
|
+
applyUniformValues(bindGroup, ctx, pass) {
|
|
290
|
+
super.applyUniformValues(bindGroup, ctx, pass);
|
|
291
|
+
if (this.needFragmentColor(ctx)) {
|
|
292
|
+
bindGroup.setValue('zF0', this._f0);
|
|
293
|
+
if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
|
|
294
|
+
bindGroup.setValue('zEmissiveColor', this._emissiveColor);
|
|
295
|
+
bindGroup.setValue('zEmissiveStrength', this._emissiveStrength);
|
|
296
|
+
}
|
|
297
|
+
if (this.occlusionTexture) {
|
|
298
|
+
bindGroup.setValue('zOcclusionStrength', this._occlusionStrength);
|
|
299
|
+
}
|
|
300
|
+
if (this.sheen) {
|
|
301
|
+
bindGroup.setValue('zSheenFactor', this._sheenFactor);
|
|
302
|
+
}
|
|
303
|
+
if (this.clearcoat) {
|
|
304
|
+
bindGroup.setValue('zClearcoatFactor', this._clearcoatFactor);
|
|
305
|
+
}
|
|
306
|
+
if (this.transmission && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
307
|
+
bindGroup.setValue('zTransmissionFactor', this._transmissionFactor);
|
|
308
|
+
bindGroup.setValue('zThicknessFactor', this._thicknessFactor);
|
|
309
|
+
bindGroup.setValue('zAttenuationColor', this._attenuationColor);
|
|
310
|
+
bindGroup.setValue('zAttenuationDistance', this._attenuationDistance);
|
|
311
|
+
}
|
|
312
|
+
if (this.iridescence) {
|
|
313
|
+
bindGroup.setValue('zIridescenceFactor', this._iridescenceFactor);
|
|
314
|
+
}
|
|
315
|
+
if (ctx.drawEnvLight) {
|
|
316
|
+
bindGroup.setTexture('zGGXLut', getGGXLUT(1024));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
getF0(scope) {
|
|
321
|
+
return scope.zF0;
|
|
322
|
+
}
|
|
323
|
+
getCommonDatasStruct(scope) {
|
|
324
|
+
const pb = scope.$builder;
|
|
325
|
+
return pb.defineStruct([
|
|
326
|
+
pb.vec4('f0'),
|
|
327
|
+
pb.vec3('f90'),
|
|
328
|
+
pb.vec4('diffuse'),
|
|
329
|
+
pb.float('metallic'),
|
|
330
|
+
pb.float('roughness'),
|
|
331
|
+
pb.float('specularWeight'),
|
|
332
|
+
...this.sheen ? [
|
|
333
|
+
pb.float('sheenAlbedoScaling'),
|
|
334
|
+
pb.vec3('sheenColor'),
|
|
335
|
+
pb.float('sheenRoughness')
|
|
336
|
+
] : [],
|
|
337
|
+
...this.clearcoat ? [
|
|
338
|
+
pb.vec4('ccFactor'),
|
|
339
|
+
pb.vec3('ccNormal'),
|
|
340
|
+
pb.float('ccNoV'),
|
|
341
|
+
pb.float('ccFresnel')
|
|
342
|
+
] : [],
|
|
343
|
+
...this.transmission && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT ? [
|
|
344
|
+
pb.float('transmissionFactor'),
|
|
345
|
+
pb.float('thicknessFactor'),
|
|
346
|
+
pb.vec3('attenuationColor'),
|
|
347
|
+
pb.float('attenuationDistance')
|
|
348
|
+
] : [],
|
|
349
|
+
...this.iridescence ? [
|
|
350
|
+
pb.vec4('iridescenceFactor'),
|
|
351
|
+
pb.vec3('iridescenceFresnel'),
|
|
352
|
+
pb.vec3('iridescenceF0')
|
|
353
|
+
] : []
|
|
354
|
+
]);
|
|
355
|
+
}
|
|
356
|
+
getCommonData(scope, albedo, normal, viewVec, TBN) {
|
|
357
|
+
const pb = scope.$builder;
|
|
358
|
+
const that = this;
|
|
359
|
+
const funcName = 'Z_getCommonData';
|
|
360
|
+
pb.func(funcName, [
|
|
361
|
+
pb.vec4('albedo'),
|
|
362
|
+
pb.vec3('normal'),
|
|
363
|
+
pb.vec3('viewVec'),
|
|
364
|
+
pb.mat3('TBN')
|
|
365
|
+
], function() {
|
|
366
|
+
this.$l.data = that.getCommonDatasStruct(this)();
|
|
367
|
+
that.calculateCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN, this.data);
|
|
368
|
+
this.$return(this.data);
|
|
369
|
+
});
|
|
370
|
+
return scope.$g[funcName](albedo, normal, viewVec, TBN);
|
|
371
|
+
}
|
|
372
|
+
calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
|
|
373
|
+
const pb = scope.$builder;
|
|
374
|
+
if (this.sheen) {
|
|
375
|
+
if (this.sheenColorTexture) {
|
|
376
|
+
data.sheenColor = pb.mul(this.sampleSheenColorTexture(scope).rgb, scope.zSheenFactor.rgb);
|
|
377
|
+
} else {
|
|
378
|
+
data.sheenColor = scope.zSheenFactor.rgb;
|
|
379
|
+
}
|
|
380
|
+
if (this.sheenRoughnessTexture) {
|
|
381
|
+
data.sheenRoughness = pb.mul(this.sampleSheenRoughnessTexture(scope).a, scope.zSheenFactor.a);
|
|
382
|
+
} else {
|
|
383
|
+
data.sheenRoughness = scope.zSheenFactor.a;
|
|
384
|
+
}
|
|
385
|
+
scope.$l.sheenDFG = 0.157;
|
|
386
|
+
data.sheenAlbedoScaling = pb.sub(1, pb.mul(pb.max(pb.max(data.sheenColor.r, data.sheenColor.g), data.sheenColor.b), scope.sheenDFG));
|
|
387
|
+
}
|
|
388
|
+
if (this.clearcoat) {
|
|
389
|
+
if (this.clearcoatNormalTexture) {
|
|
390
|
+
const ccNormal = pb.mul(pb.sub(pb.mul(this.sampleClearcoatNormalTexture(scope).rgb, 2), pb.vec3(1)), pb.vec3(scope.zClearcoatFactor.zz, 1));
|
|
391
|
+
data.ccNormal = pb.normalize(pb.mul(TBN, ccNormal));
|
|
392
|
+
} else {
|
|
393
|
+
data.ccNormal = TBN[2];
|
|
394
|
+
}
|
|
395
|
+
data.ccNoV = pb.clamp(pb.dot(data.ccNormal, viewVec), 0.0001, 1);
|
|
396
|
+
data.ccFactor = scope.zClearcoatFactor;
|
|
397
|
+
if (this.clearcoatIntensityTexture) {
|
|
398
|
+
data.ccFactor.x = pb.mul(data.ccFactor.x, this.sampleClearcoatIntensityTexture(scope).r);
|
|
399
|
+
}
|
|
400
|
+
if (this.clearcoatRoughnessTexture) {
|
|
401
|
+
data.ccFactor.y = pb.clamp(pb.mul(data.ccFactor.y, this.sampleClearcoatRoughnessTexture(scope).g), 0, 1);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (this.transmission && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
405
|
+
if (this.transmissionTexture) {
|
|
406
|
+
data.transmissionFactor = pb.mul(this.sampleTransmissionTexture(scope).r, scope.zTransmissionFactor);
|
|
407
|
+
} else {
|
|
408
|
+
data.transmissionFactor = scope.zTransmissionFactor;
|
|
409
|
+
}
|
|
410
|
+
if (this.thicknessTexture) {
|
|
411
|
+
data.thicknessFactor = pb.mul(this.sampleThicknessTexture(scope).g, scope.zThicknessFactor);
|
|
412
|
+
} else {
|
|
413
|
+
data.thicknessFactor = scope.zThicknessFactor;
|
|
414
|
+
}
|
|
415
|
+
data.attenuationColor = scope.zAttenuationColor;
|
|
416
|
+
data.attenuationDistance = scope.zAttenuationDistance;
|
|
417
|
+
}
|
|
418
|
+
if (this.iridescence) {
|
|
419
|
+
data.iridescenceFactor = scope.zIridescenceFactor;
|
|
420
|
+
if (this.iridescenceTexture) {
|
|
421
|
+
data.iridescenceFactor.x = pb.mul(this.sampleIridescenceTexture(scope).r, data.iridescenceFactor.x);
|
|
422
|
+
}
|
|
423
|
+
if (this.iridescenceThicknessTexture) {
|
|
424
|
+
data.iridescenceFactor.w = pb.mix(data.iridescenceFactor.z, data.iridescenceFactor.w, this.sampleIridescenceThicknessTexture(scope).g);
|
|
425
|
+
}
|
|
426
|
+
data.iridescenceFresnel = this.evalIridescence(scope, 1, data.iridescenceFactor.y, pb.clamp(pb.dot(normal, viewVec), 0, 1), data.iridescenceFactor.w, data.f0.rgb);
|
|
427
|
+
data.iridescenceF0 = this.schlickToF0(scope, data.iridescenceFresnel, pb.vec3(1), pb.clamp(pb.dot(normal, viewVec), 0, 1));
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
getEmissiveColor(scope) {
|
|
431
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
432
|
+
return instancing ? scope.$inputs.zEmissiveColor : scope.zEmissiveColor;
|
|
433
|
+
}
|
|
434
|
+
getEmissiveStrength(scope) {
|
|
435
|
+
const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
|
|
436
|
+
return instancing ? scope.$inputs.zEmissiveStrength : scope.zEmissiveStrength;
|
|
437
|
+
}
|
|
438
|
+
calculateEmissiveColor(scope) {
|
|
439
|
+
const pb = scope.$builder;
|
|
440
|
+
if (this.emissiveTexture) {
|
|
441
|
+
return pb.mul(this.sampleEmissiveTexture(scope).rgb, this.getEmissiveColor(scope), this.getEmissiveStrength(scope));
|
|
442
|
+
} else {
|
|
443
|
+
return pb.mul(this.getEmissiveColor(scope), this.getEmissiveStrength(scope));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
D_Charlie(scope, NdotH, sheenRoughness) {
|
|
447
|
+
const funcNameDCharlie = 'Z_DCharlie';
|
|
448
|
+
const pb = scope.$builder;
|
|
449
|
+
pb.func(funcNameDCharlie, [
|
|
450
|
+
pb.float('NdotH'),
|
|
451
|
+
pb.float('sheenRoughness')
|
|
452
|
+
], function() {
|
|
453
|
+
this.$l.alphaG = pb.mul(this.sheenRoughness, this.sheenRoughness);
|
|
454
|
+
this.$l.invR = pb.div(1, this.alphaG);
|
|
455
|
+
this.$l.cos2h = pb.mul(this.NdotH, this.NdotH);
|
|
456
|
+
this.$l.sin2h = pb.max(pb.sub(1, this.cos2h), 0.0078125);
|
|
457
|
+
this.$return(pb.div(pb.mul(pb.add(this.invR, 2), pb.pow(this.sin2h, pb.mul(this.invR, 0.5))), 2 * Math.PI));
|
|
458
|
+
});
|
|
459
|
+
return scope.$g[funcNameDCharlie](NdotH, sheenRoughness);
|
|
460
|
+
}
|
|
461
|
+
V_Ashikhmin(scope, NdotL, NdotV) {
|
|
462
|
+
const funcNameVAshikhmin = 'Z_VAshikhmin';
|
|
463
|
+
const pb = scope.$builder;
|
|
464
|
+
pb.func(funcNameVAshikhmin, [
|
|
465
|
+
pb.float('NdotL'),
|
|
466
|
+
pb.float('NdotV')
|
|
467
|
+
], function() {
|
|
468
|
+
this.$return(pb.clamp(pb.div(1, pb.mul(pb.sub(pb.add(this.NdotL, this.NdotV), pb.mul(this.NdotL, this.NdotV)), 4)), 0, 1));
|
|
469
|
+
});
|
|
470
|
+
return scope.$g[funcNameVAshikhmin](NdotL, NdotV);
|
|
471
|
+
}
|
|
472
|
+
getVolumeTransmissionRay(scope, normal, viewVec, thickness, ior) {
|
|
473
|
+
const pb = scope.$builder;
|
|
474
|
+
const funcName = 'getVolumeTransmissionRay';
|
|
475
|
+
pb.func(funcName, [
|
|
476
|
+
pb.vec3('normal'),
|
|
477
|
+
pb.vec3('viewVec'),
|
|
478
|
+
pb.float('thickness'),
|
|
479
|
+
pb.float('ior')
|
|
480
|
+
], function() {
|
|
481
|
+
this.$l.refractionVector = pb.refract(pb.neg(this.viewVec), this.normal, pb.div(1, this.ior));
|
|
482
|
+
this.$return(pb.mul(this.refractionVector, this.$inputs.modelScale, this.thickness));
|
|
483
|
+
});
|
|
484
|
+
return pb.getGlobalScope()[funcName](normal, viewVec, thickness, ior);
|
|
485
|
+
}
|
|
486
|
+
getTransmissionSample(scope, fragCoord, roughness, ior) {
|
|
487
|
+
const pb = scope.$builder;
|
|
488
|
+
const funcName = 'getTransmissionSample';
|
|
489
|
+
pb.func(funcName, [
|
|
490
|
+
pb.vec2('fragCoord'),
|
|
491
|
+
pb.float('roughness'),
|
|
492
|
+
pb.float('ior')
|
|
493
|
+
], function() {
|
|
494
|
+
this.$l.applyIorToRoughness = pb.mul(this.roughness, pb.clamp(pb.sub(pb.mul(this.ior, 2), 2), 0.0, 1.0));
|
|
495
|
+
this.$l.framebufferLod = pb.mul(pb.log2(ShaderHelper.getSceneColorTextureSize(this).x), this.applyIorToRoughness);
|
|
496
|
+
this.$return(pb.textureSampleLevel(ShaderHelper.getSceneColorTexture(this), this.fragCoord, this.framebufferLod).rgb);
|
|
497
|
+
});
|
|
498
|
+
return pb.getGlobalScope()[funcName](fragCoord, roughness, ior);
|
|
499
|
+
}
|
|
500
|
+
getPunctualRadianceTransmission(scope, normal, viewVec, lightDir, alphaRoughness, f0, f90, baseColor, ior) {
|
|
501
|
+
const pb = scope.$builder;
|
|
502
|
+
const that = this;
|
|
503
|
+
const funcName = 'getPunctualRadianceTransmission';
|
|
504
|
+
pb.func(funcName, [
|
|
505
|
+
pb.vec3('normal'),
|
|
506
|
+
pb.vec3('viewVec'),
|
|
507
|
+
pb.vec3('L'),
|
|
508
|
+
pb.float('alphaRoughness'),
|
|
509
|
+
pb.vec3('f0'),
|
|
510
|
+
pb.vec3('f90'),
|
|
511
|
+
pb.vec3('baseColor'),
|
|
512
|
+
pb.float('ior')
|
|
513
|
+
], function() {
|
|
514
|
+
this.$l.transmissionRoughness = pb.mul(this.alphaRoughness, pb.clamp(pb.sub(pb.mul(this.ior, 2), 2), 0.0, 1.0));
|
|
515
|
+
this.$l.mirrorL = pb.normalize(pb.add(this.L, pb.mul(this.normal, pb.dot(pb.neg(this.L), this.normal), 2)));
|
|
516
|
+
this.$l.h = pb.normalize(pb.add(this.viewVec, this.mirrorL));
|
|
517
|
+
this.$l.D = that.distributionGGX(this, pb.clamp(pb.dot(this.normal, this.h), 0, 1), this.transmissionRoughness);
|
|
518
|
+
this.$l.F = that.fresnelSchlick(this, pb.clamp(pb.dot(this.viewVec, this.h), 0, 1), this.f0, this.f90);
|
|
519
|
+
this.$l.V = that.visGGX(this, pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1), pb.clamp(pb.dot(this.normal, this.mirrorL), 0, 1), this.transmissionRoughness);
|
|
520
|
+
this.$return(pb.mul(pb.sub(pb.vec3(1), this.F), this.baseColor, this.D, this.V));
|
|
521
|
+
});
|
|
522
|
+
return pb.getGlobalScope()[funcName](normal, viewVec, lightDir, alphaRoughness, f0, f90, baseColor, ior);
|
|
523
|
+
}
|
|
524
|
+
applyVolumeAttenuation(scope, radiance, transmissionDistance, attenuationColor, attenuationDistance) {
|
|
525
|
+
const pb = scope.$builder;
|
|
526
|
+
const funcName = 'applyVolumeAttenuation';
|
|
527
|
+
pb.func(funcName, [
|
|
528
|
+
pb.vec3('radiance'),
|
|
529
|
+
pb.float('transmissionDistance'),
|
|
530
|
+
pb.vec3('attenuationColor'),
|
|
531
|
+
pb.float('attenuationDistance')
|
|
532
|
+
], function() {
|
|
533
|
+
this.$if(pb.equal(this.attenuationDistance, 0), function() {
|
|
534
|
+
this.$return(this.radiance);
|
|
535
|
+
}).$else(function() {
|
|
536
|
+
this.$l.attenuationCoefficient = pb.div(pb.neg(pb.log(this.attenuationColor)), this.attenuationDistance);
|
|
537
|
+
this.$l.transmittance = pb.exp(pb.mul(pb.neg(this.attenuationCoefficient), this.transmissionDistance));
|
|
538
|
+
this.$return(pb.mul(this.radiance, this.transmittance));
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
return pb.getGlobalScope()[funcName](radiance, transmissionDistance, attenuationColor, attenuationDistance);
|
|
542
|
+
}
|
|
543
|
+
getIBLVolumnRefraction(scope, brdf, normal, viewVec, roughness, baseColor, f0, f90, position, ior, thickness, attenuationColor, attenuationDistance) {
|
|
544
|
+
const pb = scope.$builder;
|
|
545
|
+
const funcName = 'getIBLVolumeRefraction';
|
|
546
|
+
const that = this;
|
|
547
|
+
pb.func(funcName, [
|
|
548
|
+
pb.vec2('brdf'),
|
|
549
|
+
pb.vec3('normal'),
|
|
550
|
+
pb.vec3('viewVec'),
|
|
551
|
+
pb.float('roughness'),
|
|
552
|
+
pb.vec3('baseColor'),
|
|
553
|
+
pb.vec3('f0'),
|
|
554
|
+
pb.vec3('f90'),
|
|
555
|
+
pb.vec3('position'),
|
|
556
|
+
pb.float('ior'),
|
|
557
|
+
pb.float('thickness'),
|
|
558
|
+
pb.vec3('attenuationColor'),
|
|
559
|
+
pb.float('attenuationDistance')
|
|
560
|
+
], function() {
|
|
561
|
+
this.$l.transmissionRay = that.getVolumeTransmissionRay(this, this.normal, this.viewVec, this.thickness, this.ior);
|
|
562
|
+
this.$l.transmissionRayLength = pb.length(this.transmissionRay);
|
|
563
|
+
this.$l.refractedRayExit = pb.add(this.position, this.transmissionRay);
|
|
564
|
+
this.$l.ndcPos = pb.mul(ShaderHelper.getViewProjectionMatrix(this), pb.vec4(this.refractedRayExit, 1));
|
|
565
|
+
this.$l.refractionCoords = pb.add(pb.mul(pb.div(this.ndcPos.xy, this.ndcPos.w), 0.5), pb.vec2(0.5));
|
|
566
|
+
this.$l.transmittedLight = that.getTransmissionSample(this, this.refractionCoords, this.roughness, this.ior);
|
|
567
|
+
this.$l.attColor = that.applyVolumeAttenuation(this, this.transmittedLight, this.transmissionRayLength, this.attenuationColor, this.attenuationDistance);
|
|
568
|
+
this.$l.specularColor = pb.add(pb.mul(this.f0, this.brdf.x), pb.mul(this.f90, this.brdf.y));
|
|
569
|
+
this.$return(pb.mul(pb.sub(pb.vec3(1), this.specularColor), this.attColor, this.baseColor));
|
|
570
|
+
});
|
|
571
|
+
return pb.getGlobalScope()[funcName](brdf, normal, viewVec, roughness, baseColor, f0, f90, position, ior, thickness, attenuationColor, attenuationDistance);
|
|
572
|
+
}
|
|
573
|
+
directLighting(scope, lightDir, lightColor, normal, viewVec, commonData, outColor) {
|
|
574
|
+
const pb = scope.$builder;
|
|
575
|
+
const that = this;
|
|
576
|
+
const funcName = 'Z_PBRDirectLighting';
|
|
577
|
+
pb.func(funcName, [
|
|
578
|
+
pb.vec3('L'),
|
|
579
|
+
pb.vec3('lightColor'),
|
|
580
|
+
pb.vec3('normal'),
|
|
581
|
+
pb.vec3('viewVec'),
|
|
582
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
583
|
+
pb.vec3('outColor').inout()
|
|
584
|
+
], function() {
|
|
585
|
+
this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));
|
|
586
|
+
this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);
|
|
587
|
+
this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);
|
|
588
|
+
this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);
|
|
589
|
+
this.$if(pb.greaterThan(this.NoL, 0), function() {
|
|
590
|
+
this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);
|
|
591
|
+
this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);
|
|
592
|
+
if (that.iridescence) {
|
|
593
|
+
this.$l.F = pb.mix(this.schlickFresnel, this.data.iridescenceFresnel, this.data.iridescenceFactor.x);
|
|
594
|
+
} else {
|
|
595
|
+
this.$l.F = this.schlickFresnel;
|
|
596
|
+
}
|
|
597
|
+
this.$l.alphaRoughness = pb.mul(this.data.roughness, this.data.roughness);
|
|
598
|
+
this.$l.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
599
|
+
this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);
|
|
600
|
+
this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F, this.data.specularWeight);
|
|
601
|
+
if (that.sheen) {
|
|
602
|
+
this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);
|
|
603
|
+
}
|
|
604
|
+
this.outColor = pb.add(this.outColor, this.specular);
|
|
605
|
+
if (that.iridescence) {
|
|
606
|
+
this.$l.iridescenceFresnelMax = pb.vec3(pb.max(pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g), this.data.iridescenceFresnel.b));
|
|
607
|
+
this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);
|
|
608
|
+
}
|
|
609
|
+
this.$l.diffuseBRDF = pb.mul(pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)), pb.div(this.data.diffuse.rgb, Math.PI));
|
|
610
|
+
this.$l.diffuse = pb.mul(this.lightColor, pb.max(this.diffuseBRDF, pb.vec3(0)));
|
|
611
|
+
if (that.transmission && that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
612
|
+
this.$l.transmissionRay = that.getVolumeTransmissionRay(this, this.normal, this.viewVec, this.data.thicknessFactor, this.data.f0.a);
|
|
613
|
+
this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));
|
|
614
|
+
this.$l.transmittedLight = pb.mul(this.lightColor, that.getPunctualRadianceTransmission(this, this.normal, this.viewVec, this.pointToLight, this.alphaRoughness, this.data.f0.rgb, this.data.f90.rgb, this.data.diffuse.rgb, this.data.f0.a));
|
|
615
|
+
this.transmittedLight = that.applyVolumeAttenuation(this, this.transmittedLight, pb.length(this.transmissionRay), this.data.attenuationColor, this.data.attenuationDistance);
|
|
616
|
+
this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);
|
|
617
|
+
}
|
|
618
|
+
if (that.sheen) {
|
|
619
|
+
this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);
|
|
620
|
+
}
|
|
621
|
+
this.outColor = pb.add(this.outColor, this.diffuse);
|
|
622
|
+
if (that.sheen) {
|
|
623
|
+
this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);
|
|
624
|
+
this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);
|
|
625
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV));
|
|
626
|
+
}
|
|
627
|
+
if (that.clearcoat) {
|
|
628
|
+
this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);
|
|
629
|
+
this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);
|
|
630
|
+
this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);
|
|
631
|
+
this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));
|
|
632
|
+
this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));
|
|
633
|
+
this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
|
|
634
|
+
this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);
|
|
635
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
scope.$g[funcName](lightDir, lightColor, normal, viewVec, commonData, outColor);
|
|
640
|
+
}
|
|
641
|
+
fresnel0ToIor(scope, fresnel0) {
|
|
642
|
+
const pb = scope.$builder;
|
|
643
|
+
const funcName = 'Z_fresnel0ToIor';
|
|
644
|
+
pb.func(funcName, [
|
|
645
|
+
pb.vec3('fresnel0')
|
|
646
|
+
], function() {
|
|
647
|
+
this.$l.sqrtF0 = pb.sqrt(this.fresnel0);
|
|
648
|
+
this.$return(pb.div(pb.add(this.sqrtF0, pb.vec3(1)), pb.sub(pb.vec3(1), this.sqrtF0)));
|
|
649
|
+
});
|
|
650
|
+
return pb.getGlobalScope()[funcName](fresnel0);
|
|
651
|
+
}
|
|
652
|
+
iorToFresnel0v(scope, transmittedIor, incidentIor) {
|
|
653
|
+
const pb = scope.$builder;
|
|
654
|
+
const funcName = 'Z_iorToFresnel0v';
|
|
655
|
+
pb.func(funcName, [
|
|
656
|
+
pb.vec3('transmittedIor'),
|
|
657
|
+
pb.float('incidentIor')
|
|
658
|
+
], function() {
|
|
659
|
+
this.$l.t = pb.div(pb.sub(this.transmittedIor, pb.vec3(this.incidentIor)), pb.add(this.transmittedIor, pb.vec3(this.incidentIor)));
|
|
660
|
+
this.$return(pb.mul(this.t, this.t));
|
|
661
|
+
});
|
|
662
|
+
return pb.getGlobalScope()[funcName](transmittedIor, incidentIor);
|
|
663
|
+
}
|
|
664
|
+
iorToFresnel0(scope, transmittedIor, incidentIor) {
|
|
665
|
+
const pb = scope.$builder;
|
|
666
|
+
const funcName = 'Z_iorToFresnel0';
|
|
667
|
+
pb.func(funcName, [
|
|
668
|
+
pb.float('transmittedIor'),
|
|
669
|
+
pb.float('incidentIor')
|
|
670
|
+
], function() {
|
|
671
|
+
this.$l.t = pb.div(pb.sub(this.transmittedIor, this.incidentIor), pb.add(this.transmittedIor, this.incidentIor));
|
|
672
|
+
this.$return(pb.mul(this.t, this.t));
|
|
673
|
+
});
|
|
674
|
+
return pb.getGlobalScope()[funcName](transmittedIor, incidentIor);
|
|
675
|
+
}
|
|
676
|
+
evalSensitivity(scope, OPD, shift) {
|
|
677
|
+
const pb = scope.$builder;
|
|
678
|
+
const funcName = 'Z_evalSensitivity';
|
|
679
|
+
pb.func(funcName, [
|
|
680
|
+
pb.float('OPD'),
|
|
681
|
+
pb.vec3('shift')
|
|
682
|
+
], function() {
|
|
683
|
+
this.$l.phase = pb.mul(Math.PI * 2, this.OPD, 1e-9);
|
|
684
|
+
this.$l.val = pb.vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);
|
|
685
|
+
this.$l.pos = pb.vec3(1.681e6, 1.7953e6, 2.2084e6);
|
|
686
|
+
this.$l.va = pb.vec3(4.3278e9, 9.3046e9, 6.6121e9);
|
|
687
|
+
this.$l.xyz = pb.mul(this.val, pb.sqrt(pb.mul(Math.PI * 2, this.va)), pb.cos(pb.add(pb.mul(this.pos, this.phase), this.shift)), pb.exp(pb.neg(pb.mul(this.phase, this.phase, this.va))));
|
|
688
|
+
this.xyz.x = pb.add(this.xyz.x, pb.mul(9.747e-14, Math.sqrt(Math.PI * 2 * 4.5282e9), pb.cos(pb.add(pb.mul(this.phase, 2.2399e6), this.shift.x)), pb.exp(pb.mul(-45282e5, this.phase, this.phase))));
|
|
689
|
+
this.xyz = pb.div(this.xyz, 1.0685e-7);
|
|
690
|
+
this.$return(pb.mul(pb.mat3(3.2404542, -0.969266, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.041556, 1.0572252), this.xyz));
|
|
691
|
+
});
|
|
692
|
+
return pb.getGlobalScope()[funcName](OPD, shift);
|
|
693
|
+
}
|
|
694
|
+
schlickToF0(scope, f, f90, VdotH) {
|
|
695
|
+
const pb = scope.$builder;
|
|
696
|
+
const funcName = 'Z_schlickToF0';
|
|
697
|
+
pb.func(funcName, [
|
|
698
|
+
pb.vec3('f'),
|
|
699
|
+
pb.vec3('f90'),
|
|
700
|
+
pb.float('VdotH')
|
|
701
|
+
], function() {
|
|
702
|
+
this.$l.x = pb.clamp(pb.sub(1, this.VdotH), 0, 1);
|
|
703
|
+
this.$l.x2 = pb.mul(this.x, this.x);
|
|
704
|
+
this.$l.x5 = pb.clamp(pb.mul(this.x, this.x2, this.x2), 0, 0.9999);
|
|
705
|
+
this.$return(pb.div(pb.sub(this.f, pb.mul(this.f90, this.x5)), pb.sub(1, this.x5)));
|
|
706
|
+
});
|
|
707
|
+
return pb.getGlobalScope()[funcName](f, f90, VdotH);
|
|
708
|
+
}
|
|
709
|
+
evalIridescence(scope, outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0) {
|
|
710
|
+
const pb = scope.$builder;
|
|
711
|
+
const that = this;
|
|
712
|
+
const funcName = 'Z_evalIridescence';
|
|
713
|
+
pb.func(funcName, [
|
|
714
|
+
pb.float('outsideIOR'),
|
|
715
|
+
pb.float('eta2'),
|
|
716
|
+
pb.float('cosTheta1'),
|
|
717
|
+
pb.float('thinFilmThickness'),
|
|
718
|
+
pb.vec3('baseF0')
|
|
719
|
+
], function() {
|
|
720
|
+
this.$l.iridescenceIor = pb.mix(this.outsideIOR, this.eta2, pb.smoothStep(0, 0.03, this.thinFilmThickness));
|
|
721
|
+
this.$l.t = pb.div(this.outsideIOR, this.iridescenceIor);
|
|
722
|
+
this.$l.sinTheta2Sq = pb.mul(this.t, this.t, pb.sub(1, pb.mul(this.cosTheta1, this.cosTheta1)));
|
|
723
|
+
this.$l.cosTheta2Sq = pb.sub(1, this.sinTheta2Sq);
|
|
724
|
+
this.$if(pb.lessThan(this.cosTheta2Sq, 0), function() {
|
|
725
|
+
this.$return(pb.vec3(1));
|
|
726
|
+
});
|
|
727
|
+
this.$l.cosTheta2 = pb.sqrt(this.cosTheta2Sq);
|
|
728
|
+
this.$l.R0 = that.iorToFresnel0(this, this.iridescenceIor, this.outsideIOR);
|
|
729
|
+
this.$l.R12 = that.fresnelSchlick(this, this.cosTheta1, pb.vec3(this.R0), pb.vec3(1)).x;
|
|
730
|
+
this.$l.R21 = this.R12;
|
|
731
|
+
this.$l.T121 = pb.sub(1, this.R12);
|
|
732
|
+
this.$l.phi12 = pb.float(0);
|
|
733
|
+
this.$if(pb.lessThan(this.iridescenceIor, this.outsideIOR), function() {
|
|
734
|
+
this.phi12 = Math.PI;
|
|
735
|
+
});
|
|
736
|
+
this.$l.phi21 = pb.sub(Math.PI, this.phi12);
|
|
737
|
+
this.$l.baseIOR = that.fresnel0ToIor(this, pb.clamp(this.baseF0, pb.vec3(0), pb.vec3(0.9999)));
|
|
738
|
+
this.$l.R1 = that.iorToFresnel0v(this, this.baseIOR, this.iridescenceIor);
|
|
739
|
+
this.$l.R23 = that.fresnelSchlick(this, this.cosTheta2, this.R1, pb.vec3(1));
|
|
740
|
+
this.$l.phi23 = pb.vec3(0);
|
|
741
|
+
this.$if(pb.lessThan(this.baseIOR.x, this.iridescenceIor), function() {
|
|
742
|
+
this.phi23.x = Math.PI;
|
|
743
|
+
});
|
|
744
|
+
this.$if(pb.lessThan(this.baseIOR.y, this.iridescenceIor), function() {
|
|
745
|
+
this.phi23.y = Math.PI;
|
|
746
|
+
});
|
|
747
|
+
this.$if(pb.lessThan(this.baseIOR.z, this.iridescenceIor), function() {
|
|
748
|
+
this.phi23.z = Math.PI;
|
|
749
|
+
});
|
|
750
|
+
this.$l.OPD = pb.mul(this.iridescenceIor, this.thinFilmThickness, this.cosTheta2, 2);
|
|
751
|
+
this.$l.phi = pb.add(pb.vec3(this.phi21), this.phi23);
|
|
752
|
+
this.$l.R123 = pb.clamp(pb.mul(this.R12, this.R23), pb.vec3(1e-5), pb.vec3(0.9999));
|
|
753
|
+
this.$l.r123 = pb.sqrt(this.R123);
|
|
754
|
+
this.$l.Rs = pb.div(pb.mul(this.T121, this.T121, this.R23), pb.sub(pb.vec3(1), this.R123));
|
|
755
|
+
this.$l.C0 = pb.add(pb.vec3(this.R12), this.Rs);
|
|
756
|
+
this.$l.I = this.C0;
|
|
757
|
+
this.$l.Cm = pb.sub(this.Rs, pb.vec3(this.T121));
|
|
758
|
+
this.$for(pb.int('m'), 1, 3, function() {
|
|
759
|
+
this.Cm = pb.mul(this.Cm, this.r123);
|
|
760
|
+
this.$l.Sm = pb.mul(that.evalSensitivity(this, pb.mul(this.OPD, pb.float(this.m)), pb.mul(this.phi, pb.float(this.m))), 2);
|
|
761
|
+
this.I = pb.add(this.I, pb.mul(this.Cm, this.Sm));
|
|
762
|
+
});
|
|
763
|
+
this.$return(pb.max(this.I, pb.vec3(0)));
|
|
764
|
+
});
|
|
765
|
+
return pb.getGlobalScope()[funcName](outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0);
|
|
766
|
+
}
|
|
767
|
+
indirectLighting(scope, normal, viewVec, commonData, outColor, outRoughness) {
|
|
768
|
+
const pb = scope.$builder;
|
|
769
|
+
const that = this;
|
|
770
|
+
const ctx = that.drawContext;
|
|
771
|
+
const funcName = 'Z_PBRIndirectLighting';
|
|
772
|
+
pb.func(funcName, [
|
|
773
|
+
pb.vec3('normal'),
|
|
774
|
+
pb.vec3('viewVec'),
|
|
775
|
+
that.getCommonDatasStruct(scope)('data'),
|
|
776
|
+
pb.vec3('outColor').inout(),
|
|
777
|
+
...outRoughness ? [
|
|
778
|
+
pb.vec4('outRoughness').out()
|
|
779
|
+
] : []
|
|
780
|
+
], function() {
|
|
781
|
+
if (!ctx.drawEnvLight || !ctx.env.light.envLight.hasRadiance() && !ctx.env.light.envLight.hasIrradiance()) {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const envLightStrength = ShaderHelper.getEnvLightStrength(this);
|
|
785
|
+
if (that.occlusionTexture) {
|
|
786
|
+
const occlusionSample = that.sampleOcclusionTexture(this).r;
|
|
787
|
+
this.$l.occlusion = pb.mul(pb.add(pb.mul(this.zOcclusionStrength, pb.sub(occlusionSample, 1)), 1), envLightStrength);
|
|
788
|
+
} else {
|
|
789
|
+
this.$l.occlusion = envLightStrength;
|
|
790
|
+
}
|
|
791
|
+
this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0.0001, 1);
|
|
792
|
+
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));
|
|
793
|
+
this.$l.f_ab = this.ggxLutSample.rg;
|
|
794
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.data.f0.rgb), this.data.f0.rgb);
|
|
795
|
+
if (that.iridescence) {
|
|
796
|
+
this.$l.k_S = pb.mix(pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5))), this.data.iridescenceFresnel, this.data.iridescenceFactor.x);
|
|
797
|
+
} else {
|
|
798
|
+
this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
799
|
+
}
|
|
800
|
+
if (outRoughness || ctx.env.light.envLight.hasRadiance()) {
|
|
801
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
802
|
+
this.$l.specularFactor = pb.mul(this.FssEss, this.data.specularWeight, this.occlusion);
|
|
803
|
+
if (that.sheen) {
|
|
804
|
+
this.specularFactor = pb.mul(this.specularFactor, this.data.sheenAlbedoScaling);
|
|
805
|
+
}
|
|
806
|
+
if (outRoughness) {
|
|
807
|
+
this.outRoughness = pb.vec4(this.specularFactor /*this.data.f0.rgb*/ , this.data.roughness);
|
|
808
|
+
} else if (ctx.env.light.envLight.hasRadiance()) {
|
|
809
|
+
this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.normal), this.data.roughness);
|
|
810
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.radiance, this.specularFactor));
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (ctx.env.light.envLight.hasIrradiance()) {
|
|
814
|
+
this.$l.irradiance = ctx.env.light.envLight.getIrradiance(this, this.normal);
|
|
815
|
+
if (that.iridescence) {
|
|
816
|
+
this.$l.iridescenceF0Max = pb.vec3(pb.max(pb.max(this.data.iridescenceF0.r, this.data.iridescenceF0.g), this.data.iridescenceF0.b));
|
|
817
|
+
this.$l.mixedF0 = pb.mix(this.data.f0.rgb, this.iridescenceF0Max, this.data.iridescenceFactor.x);
|
|
818
|
+
this.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.mixedF0), this.mixedF0);
|
|
819
|
+
this.k_S = pb.add(this.mixedF0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
820
|
+
} else {
|
|
821
|
+
this.$l.mixedF0 = this.data.f0.rgb;
|
|
822
|
+
}
|
|
823
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x, this.data.specularWeight), pb.vec3(this.f_ab.y));
|
|
824
|
+
this.$l.Ems = pb.sub(1, pb.add(this.f_ab.x, this.f_ab.y));
|
|
825
|
+
this.$l.F_avg = pb.mul(pb.add(this.mixedF0, pb.div(pb.sub(pb.vec3(1), this.mixedF0), 21)), this.data.specularWeight);
|
|
826
|
+
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)));
|
|
827
|
+
this.$l.k_D = pb.mul(this.data.diffuse.rgb, pb.add(pb.sub(pb.vec3(1), this.FssEss), this.FmsEms));
|
|
828
|
+
this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D), this.irradiance, this.occlusion);
|
|
829
|
+
if (that.sheen) {
|
|
830
|
+
this.iblDiffuse = pb.mul(this.iblDiffuse, this.data.sheenAlbedoScaling);
|
|
831
|
+
}
|
|
832
|
+
if (that.transmission && that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
833
|
+
this.$l.iblTransmission = that.getIBLVolumnRefraction(this, this.ggxLutSample.rg, this.normal, this.viewVec, this.data.roughness, this.data.diffuse.rgb, this.data.f0.rgb, this.data.f90, this.$inputs.worldPos, this.data.f0.a, this.data.thicknessFactor, this.data.attenuationColor, this.data.attenuationDistance);
|
|
834
|
+
this.iblDiffuse = pb.mix(this.iblDiffuse, this.iblTransmission, this.data.transmissionFactor);
|
|
835
|
+
}
|
|
836
|
+
this.outColor = pb.add(this.outColor, this.iblDiffuse);
|
|
837
|
+
}
|
|
838
|
+
if (that.sheen && ctx.env.light.envLight.hasIrradiance()) {
|
|
839
|
+
this.$l.refl = pb.reflect(pb.neg(this.viewVec), this.normal);
|
|
840
|
+
this.$l.sheenBRDF = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.sheenRoughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1)).b;
|
|
841
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.data.sheenColor, this.irradiance.rgb, this.sheenBRDF));
|
|
842
|
+
}
|
|
843
|
+
if (that.clearcoat && ctx.env.light.envLight.hasRadiance()) {
|
|
844
|
+
this.$l.NoV = pb.clamp(pb.dot(this.data.ccNormal, this.viewVec), 0.0001, 1);
|
|
845
|
+
this.$l.ggxLutSample = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.ccFactor.y), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
|
|
846
|
+
this.$l.f_ab = this.ggxLutSample.rg;
|
|
847
|
+
this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.ccFactor.y)), this.data.f0.rgb), this.data.f0.rgb);
|
|
848
|
+
this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
|
|
849
|
+
this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.data.ccNormal), this.data.ccFactor.y);
|
|
850
|
+
this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
|
|
851
|
+
this.$l.ccSpecular = pb.mul(this.radiance, this.FssEss, this.data.specularWeight, this.occlusion);
|
|
852
|
+
this.outColor = pb.add(this.outColor, pb.mul(this.ccSpecular, this.data.ccFactor.x));
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
if (outRoughness) {
|
|
856
|
+
scope.$g[funcName](normal, viewVec, commonData, outColor, outRoughness);
|
|
857
|
+
} else {
|
|
858
|
+
scope.$g[funcName](normal, viewVec, commonData, outColor);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
fresnelSchlick(scope, cosTheta, F0, F90) {
|
|
862
|
+
const pb = scope.$builder;
|
|
863
|
+
const funcName = 'Z_fresnelSchlick';
|
|
864
|
+
pb.func(funcName, [
|
|
865
|
+
pb.float('cosTheta'),
|
|
866
|
+
pb.vec3('f0'),
|
|
867
|
+
pb.vec3('f90')
|
|
868
|
+
], function() {
|
|
869
|
+
this.$return(pb.add(this.f0, pb.mul(pb.sub(this.f90, this.f0), pb.pow(pb.clamp(pb.sub(1, this.cosTheta), 0, 1), 5))));
|
|
870
|
+
});
|
|
871
|
+
return scope.$g[funcName](cosTheta, F0, F90);
|
|
872
|
+
}
|
|
873
|
+
distributionGGX(scope, NdotH, alphaRoughness) {
|
|
874
|
+
const pb = scope.$builder;
|
|
875
|
+
const funcName = 'Z_distributionGGX';
|
|
876
|
+
pb.func(funcName, [
|
|
877
|
+
pb.float('NdotH'),
|
|
878
|
+
pb.float('roughness')
|
|
879
|
+
], function() {
|
|
880
|
+
this.$l.a2 = pb.mul(this.roughness, this.roughness);
|
|
881
|
+
this.$l.NdotH2 = pb.mul(this.NdotH, this.NdotH);
|
|
882
|
+
this.$l.num = this.a2;
|
|
883
|
+
this.$l.denom = pb.add(pb.mul(this.NdotH2, pb.sub(this.a2, 1)), 1);
|
|
884
|
+
this.denom = pb.mul(pb.mul(3.14159265, this.denom), this.denom);
|
|
885
|
+
this.$return(pb.div(this.num, this.denom));
|
|
886
|
+
});
|
|
887
|
+
return scope.$g[funcName](NdotH, alphaRoughness);
|
|
888
|
+
}
|
|
889
|
+
visGGX(scope, NdotV, NdotL, alphaRoughness) {
|
|
890
|
+
const pb = scope.$builder;
|
|
891
|
+
const funcName = 'Z_visGGX';
|
|
892
|
+
pb.func(funcName, [
|
|
893
|
+
pb.float('NdotV'),
|
|
894
|
+
pb.float('NdotL'),
|
|
895
|
+
pb.float('roughness')
|
|
896
|
+
], function() {
|
|
897
|
+
this.$l.a = this.roughness;
|
|
898
|
+
this.$l.ggxV = pb.mul(this.NdotL, pb.sqrt(pb.add(pb.mul(this.NdotV, this.NdotV, pb.sub(1, this.a)), this.a)));
|
|
899
|
+
this.$l.ggxL = pb.mul(this.NdotV, pb.sqrt(pb.add(pb.mul(this.NdotL, this.NdotL, pb.sub(1, this.a)), this.a)));
|
|
900
|
+
this.$l.ggx = pb.add(this.ggxV, this.ggxL, 1e-5);
|
|
901
|
+
this.$if(pb.greaterThan(this.ggx, 0), function() {
|
|
902
|
+
this.$return(pb.div(0.5, this.ggx));
|
|
903
|
+
}).$else(function() {
|
|
904
|
+
this.$return(pb.float(0));
|
|
905
|
+
});
|
|
906
|
+
});
|
|
907
|
+
return scope.$g[funcName](NdotV, NdotL, alphaRoughness);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
FEATURE_SHEEN = cls.defineFeature();
|
|
911
|
+
FEATURE_CLEARCOAT = cls.defineFeature();
|
|
912
|
+
FEATURE_TRANSMISSION = cls.defineFeature();
|
|
913
|
+
FEATURE_IRIDESCENCE = cls.defineFeature();
|
|
914
|
+
return cls;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export { mixinPBRCommon };
|
|
918
|
+
//# sourceMappingURL=common.js.map
|