@zephyr3d/scene 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/joint_dynamics/controller.js +92 -32
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +71 -27
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +21 -20
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/skeleton.js +7 -10
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/app/engine.js +134 -140
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +47 -16
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +3 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +346 -7
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +20 -16
- package/dist/avatar/wardrobe.js.map +1 -1
- package/dist/camera/camera.js +416 -210
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1349 -621
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +1 -1
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +23 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +178 -23
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +4 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +2 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +1 -1
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +276 -65
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +3 -3
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +2 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/mtoon.js +574 -0
- package/dist/material/mtoon.js.map +1 -0
- package/dist/material/pbrblueprint.js +499 -336
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +118 -100
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +1 -1
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +324 -294
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +812 -0
- package/dist/material/subsurfaceprofile.js.map +1 -0
- package/dist/material/unlit.js +1 -1
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/compositor.js +46 -11
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/ssr.js +422 -96
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +1053 -0
- package/dist/posteffect/sss.js.map +1 -0
- package/dist/posteffect/taa.js +61 -60
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +63 -12
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +6 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +1 -5
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +2 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +2 -1
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +2 -1
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/lightpass.js +110 -23
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/render_queue.js +51 -8
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +80 -66
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +8 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +481 -95
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +55 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +10 -4
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sky.js +31 -1
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +23 -5
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +4 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -1
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +11 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +21 -3
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +29 -14
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +5 -2
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +5 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +3 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +6 -5
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +4 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +2 -1
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -2
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +4 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +26 -393
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/esm.js +112 -12
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +2 -2
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +19 -10
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +58 -7
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +6 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +229 -0
- package/dist/shadow/shadow_region.js.map +1 -0
- package/dist/shadow/shadowmapper.js +67 -59
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +45 -19
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +8 -8
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +31 -4
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +1 -17
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +327 -359
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +5 -2
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -1
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +249 -54
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +37 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +42 -3
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1112 -646
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +7 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +31 -12
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -1
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +3 -1
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +18 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +5 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +3 -1
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -1
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +6 -0
- package/dist/utility/textures/ltcdata.js.map +1 -0
- package/dist/utility/textures/ltclut.js +61 -0
- package/dist/utility/textures/ltclut.js.map +1 -0
- package/dist/values.js +9 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrblueprint.js","sources":["../../src/material/pbrblueprint.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport { DRef, Vector2, Vector3, Vector4, type Clonable, type Immutable } from '@zephyr3d/base';\r\nimport { mixinPBRBluePrint } from './mixins/lightmodel/pbrblueprintmixin';\r\nimport type { BluePrintUniformTexture, BluePrintUniformValue } from '../utility/blueprint/material/ir';\r\nimport { MaterialBlueprintIR } from '../utility/blueprint/material/ir';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { PBRBlockNode, VertexBlockNode } from '../utility/blueprint/material/pbr';\r\nimport type { PBRReflectionMode } from './mixins/lightmodel/pbrmetallicroughness';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Physically-based rendering material driven by blueprint graphs.\r\n *\r\n * @remarks\r\n * This material extends {@link MeshMaterial} with PBR behavior via\r\n * {@link mixinPBRBluePrint}, and uses {@link MaterialBlueprintIR}\r\n * graphs for both vertex and fragment stages.\r\n *\r\n * - The **vertex blueprint IR** (`vertexIR`) controls vertex\r\n * transformations and per-vertex data.\r\n * - The **fragment blueprint IR** (`fragmentIR`) produces inputs\r\n * for the PBR shading model (albedo, roughness, metalness, etc.).\r\n *\r\n * Uniform values and textures for the blueprints are provided via\r\n * {@link PBRBluePrintMaterial.uniformValues} and\r\n * {@link PBRBluePrintMaterial.uniformTextures}.\r\n *\r\n * @public\r\n */\r\nexport class PBRBluePrintMaterial\r\n extends applyMaterialMixins(MeshMaterial, mixinPBRBluePrint)\r\n implements Clonable<PBRBluePrintMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_COLOR = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_UV = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n /** @internal */\r\n private _irFrag: MaterialBlueprintIR;\r\n /** @internal */\r\n private _irVertex: MaterialBlueprintIR;\r\n /** @internal */\r\n private _uniformValues: BluePrintUniformValue[];\r\n /** @internal */\r\n private _uniformTextures: BluePrintUniformTexture[];\r\n /** @internal */\r\n private _reflectionMode: PBRReflectionMode;\r\n /** @internal */\r\n private readonly _subsurfaceColor: Vector3;\r\n /** @internal */\r\n private _subsurfaceScale: number;\r\n /** @internal */\r\n private _subsurfacePower: number;\r\n /** @internal */\r\n private _subsurfaceIntensity: number;\r\n /** @internal */\r\n private _anisotropy: number;\r\n /** @internal */\r\n private _anisotropyDirection: number;\r\n /** @internal */\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n /**\r\n * Creates a new {@link PBRBluePrintMaterial} instance.\r\n *\r\n * @param irFrag - Optional fragment blueprint IR. If omitted, a default\r\n * IR containing a single {@link PBRBlockNode} is created.\r\n * @param irVertex - Optional vertex blueprint IR. If omitted, a default\r\n * IR containing a single {@link VertexBlockNode} is created.\r\n * @param uniformValues - Optional initial list of uniform value descriptors.\r\n * @param uniformTextures - Optional initial list of texture uniform descriptors.\r\n */\r\n constructor(\r\n irFrag?: MaterialBlueprintIR,\r\n irVertex?: MaterialBlueprintIR,\r\n uniformValues?: BluePrintUniformValue[],\r\n uniformTextures?: BluePrintUniformTexture[]\r\n ) {\r\n super();\r\n this._irFrag =\r\n irFrag ??\r\n new MaterialBlueprintIR(\r\n {\r\n nodeMap: { '1': new PBRBlockNode() },\r\n roots: [1],\r\n order: [1],\r\n graph: { incoming: {}, outgoing: {} }\r\n },\r\n '',\r\n {\r\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'PBRBlockNode', Object: '' } }],\r\n links: []\r\n }\r\n );\r\n this._irVertex =\r\n irVertex ??\r\n new MaterialBlueprintIR(\r\n {\r\n nodeMap: { '1': new VertexBlockNode() },\r\n roots: [1],\r\n order: [1],\r\n graph: { incoming: {}, outgoing: {} }\r\n },\r\n '',\r\n {\r\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'VertexBlockNode', Object: '' } }],\r\n links: []\r\n }\r\n );\r\n this._uniformValues = uniformValues ?? [];\r\n this._uniformTextures = uniformTextures ?? [];\r\n this._reflectionMode = 'ggx';\r\n this._subsurfaceColor = new Vector3(1, 0.3, 0.2);\r\n this._subsurfaceScale = 0.5;\r\n this._subsurfacePower = 1.5;\r\n this._subsurfaceIntensity = 0.5;\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR, this._irVertex.behaviors.useVertexColor);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_UV, this._irVertex.behaviors.useVertexUV);\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val: boolean) {\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n get subsurfaceColor(): Immutable<Vector3> {\r\n return this._subsurfaceColor;\r\n }\r\n set subsurfaceColor(val: Immutable<Vector3>) {\r\n if (!val.equalsTo(this._subsurfaceColor)) {\r\n this._subsurfaceColor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceScale() {\r\n return this._subsurfaceScale;\r\n }\r\n set subsurfaceScale(val: number) {\r\n if (val !== this._subsurfaceScale) {\r\n this._subsurfaceScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfacePower() {\r\n return this._subsurfacePower;\r\n }\r\n set subsurfacePower(val: number) {\r\n if (val !== this._subsurfacePower) {\r\n this._subsurfacePower = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceIntensity() {\r\n return this._subsurfaceIntensity;\r\n }\r\n set subsurfaceIntensity(val: number) {\r\n if (val !== this._subsurfaceIntensity) {\r\n this._subsurfaceIntensity = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val: number) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val: number) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Gets the fragment blueprint IR.\r\n */\r\n get fragmentIR() {\r\n return this._irFrag;\r\n }\r\n set fragmentIR(ir: MaterialBlueprintIR) {\r\n if (ir && ir !== this._irFrag) {\r\n this._irFrag = ir;\r\n this.clearCache();\r\n this.optionChanged(true);\r\n }\r\n }\r\n /**\r\n * Gets the vertex blueprint IR.\r\n */\r\n get vertexIR() {\r\n return this._irVertex;\r\n }\r\n set vertexIR(ir: MaterialBlueprintIR) {\r\n if (ir && ir !== this._irVertex) {\r\n this._irVertex = ir;\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR, this._irVertex.behaviors.useVertexColor);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_UV, this._irVertex.behaviors.useVertexUV);\r\n this.clearCache();\r\n this.optionChanged(true);\r\n }\r\n }\r\n /**\r\n * Gets the list of uniform value descriptors used by the blueprints.\r\n */\r\n get uniformValues() {\r\n return this._uniformValues;\r\n }\r\n set uniformValues(val: BluePrintUniformValue[]) {\r\n this._uniformValues = (val ?? []).map((v) => ({ ...v }));\r\n this.uniformChanged();\r\n }\r\n /**\r\n * Gets the list of texture uniform descriptors used by the blueprints.\r\n */\r\n get uniformTextures() {\r\n return this._uniformTextures;\r\n }\r\n set uniformTextures(val: BluePrintUniformTexture[]) {\r\n if (val !== this._uniformTextures) {\r\n const newUniforms = val.map((v) => ({\r\n finalTexture: new DRef(v.finalTexture!.get()),\r\n finalSampler: v.finalSampler,\r\n name: v.name,\r\n params: v.params?.clone() ?? Vector4.zero(),\r\n texture: v.texture,\r\n type: v.type,\r\n sRGB: v.sRGB,\r\n wrapS: v.wrapS,\r\n wrapT: v.wrapT,\r\n inFragmentShader: v.inFragmentShader,\r\n inVertexShader: v.inVertexShader,\r\n minFilter: v.minFilter,\r\n magFilter: v.magFilter,\r\n mipFilter: v.mipFilter\r\n }));\r\n for (const u of this._uniformTextures) {\r\n u.finalTexture!.dispose();\r\n }\r\n this._uniformTextures = newUniforms;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material.\r\n *\r\n * @remarks\r\n * The clone shares the same vertex/fragment IR references and copies\r\n * the current blueprint uniform descriptors, then calls `copyFrom`\r\n * to copy base-class and mixin state.\r\n *\r\n * @returns A new {@link PBRBluePrintMaterial} instance.\r\n */\r\n clone() {\r\n const other = new PBRBluePrintMaterial(\r\n this._irFrag,\r\n this._irVertex,\r\n this._uniformValues,\r\n this._uniformTextures\r\n );\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.reflectionMode = other.reflectionMode;\r\n this.subsurfaceScattering = other.subsurfaceScattering;\r\n this.subsurfaceColor = other.subsurfaceColor;\r\n this.subsurfaceScale = other.subsurfaceScale;\r\n this.subsurfacePower = other.subsurfacePower;\r\n this.subsurfaceIntensity = other.subsurfaceIntensity;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n /**\r\n * Builds the vertex shader for this PBR blueprint material.\r\n *\r\n * @param scope - The current vertex shader function scope.\r\n */\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$inputs.zVertexPos = pb.vec3().attrib('position');\r\n scope.$inputs.zVertexNormal = pb.vec3().attrib('normal');\r\n scope.$inputs.zVertexTangent = pb.vec4().attrib('tangent');\r\n if (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR)) {\r\n scope.$inputs.zVertexColor = pb.vec4().attrib('diffuse');\r\n }\r\n if (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_UV)) {\r\n scope.$inputs.zVertexUV = pb.vec2().attrib('texCoord0');\r\n }\r\n\r\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\r\n if (u.inVertexShader) {\r\n // @ts-ignore\r\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\r\n }\r\n }\r\n const outputs = this._irVertex.create(pb)!;\r\n scope.$l.oPos = this.getOutput(outputs, 'Position') ?? ShaderHelper.resolveVertexPosition(scope);\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;\r\n scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));\r\n ShaderHelper.setClipSpacePosition(scope, scope.csPos);\r\n scope.$outputs.zVertexColor =\r\n this.getOutput(outputs, 'Color') ??\r\n (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR) ? scope.$inputs.zVertexColor : pb.vec4(1));\r\n scope.$outputs.zVertexUV =\r\n this.getOutput(outputs, 'UV') ??\r\n (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_UV) ? scope.$inputs.zVertexUV : pb.vec2(0));\r\n scope.$l.oNorm = this.getOutput(outputs, 'Normal') ?? ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.zVertexNormal = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n scope.$l.oTangent = this.getOutput(outputs, 'Tangent') ?? ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.zVertexTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.zVertexBinormal = pb.mul(\r\n pb.cross(scope.$outputs.zVertexNormal, scope.$outputs.zVertexTangent),\r\n scope.oTangent.w\r\n );\r\n for (const outputName of ['Output1', 'Output2', 'Output3', 'Output4']) {\r\n const output = this.getOutput(outputs, outputName);\r\n if (output) {\r\n scope.$outputs[outputName] = output;\r\n }\r\n }\r\n }\r\n /**\r\n * Builds the fragment shader for this PBR blueprint material.\r\n *\r\n * @param scope - The current fragment shader function scope.\r\n */\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT\r\n ) {\r\n scope.zSubsurfaceColor = pb.vec3().uniform(2);\r\n scope.zSubsurfaceScale = pb.float().uniform(2);\r\n scope.zSubsurfacePower = pb.float().uniform(2);\r\n scope.zSubsurfaceIntensity = pb.float().uniform(2);\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\r\n if (u.inFragmentShader) {\r\n // @ts-ignore\r\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\r\n }\r\n }\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n scope.$l.commonData = this.getCommonDatasStruct(scope)();\r\n this.getCommonData(\r\n scope,\r\n scope.commonData,\r\n scope.viewVec,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.zVertexNormal,\r\n scope.$inputs.zVertexTangent,\r\n scope.$inputs.zVertexBinormal,\r\n scope.$inputs.zVertexColor,\r\n scope.$inputs.zVertexUV,\r\n this._irFrag\r\n );\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n scope.$l.outRoughness = pb.vec4();\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.viewVec,\r\n scope.commonData,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.litColor = this.applySubsurfaceScattering(\r\n scope,\r\n scope.litColor,\r\n scope.commonData.albedo.rgb,\r\n scope.commonData.normal,\r\n scope.viewVec\r\n );\r\n }\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.litColor,\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.commonData.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.viewVec, scope.commonData);\r\n if (this.subsurfaceScattering) {\r\n scope.litColor = this.applySubsurfaceScattering(\r\n scope,\r\n scope.litColor,\r\n scope.commonData.albedo.rgb,\r\n scope.commonData.normal,\r\n scope.viewVec\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.litColor);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.commonData.albedo);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n /**\r\n * Applies runtime uniform values and textures to the given bind group.\r\n *\r\n * @remarks\r\n * - Calls the base implementation first to bind standard mesh/PBR uniforms.\r\n * - If fragment color is needed for the current context, all blueprint\r\n * scalar/vector uniform values and textures are then bound by name.\r\n *\r\n * @param bindGroup - The bind group to which material resources are bound.\r\n * @param ctx - The current draw context.\r\n * @param pass - Index of the active render pass.\r\n */\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n if (this.subsurfaceScattering && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n bindGroup.setValue('zSubsurfaceColor', this._subsurfaceColor);\r\n bindGroup.setValue('zSubsurfaceScale', this._subsurfaceScale);\r\n bindGroup.setValue('zSubsurfacePower', this._subsurfacePower);\r\n bindGroup.setValue('zSubsurfaceIntensity', this._subsurfaceIntensity);\r\n }\r\n }\r\n for (const u of this._uniformValues) {\r\n if (u.inVertexShader || this.needFragmentColor(ctx)) {\r\n bindGroup.setValue(u.name, u.finalValue!);\r\n }\r\n }\r\n for (const u of this._uniformTextures) {\r\n if (u.inVertexShader || this.needFragmentColor(ctx)) {\r\n bindGroup.setTexture(u.name, u.finalTexture!.get()!, u.finalSampler);\r\n }\r\n }\r\n }\r\n /**\r\n * Creates a unique hash string used for program caching.\r\n *\r\n * @remarks\r\n * The hash includes:\r\n * - The base material hash (`super._createHash()`).\r\n * - The fragment IR hash.\r\n * - The vertex IR hash.\r\n *\r\n * Different blueprint graphs will therefore produce different programs.\r\n *\r\n * @returns A hash string that uniquely identifies this material configuration.\r\n */\r\n protected _createHash() {\r\n return `${super._createHash()}:${this._irFrag.hash}:${this._irVertex.hash}`;\r\n }\r\n /**\r\n * Creates the GPU program for this blueprint PBR material.\r\n *\r\n * @remarks\r\n * This calls the base implementation and returns its result.\r\n * Commented-out `console.log` lines are provided for debugging the\r\n * generated vertex and fragment shader sources.\r\n *\r\n * @param ctx - The current draw context.\r\n * @param pass - Index of the active render pass.\r\n * @returns The created GPU program.\r\n */\r\n protected createProgram(ctx: DrawContext, pass: number) {\r\n const program = super.createProgram(ctx, pass);\r\n //console.log(program.getShaderSource('vertex'));\r\n //console.log(program.getShaderSource('fragment'));\r\n return program;\r\n }\r\n /**\r\n * Disposes resources associated with this material.\r\n *\r\n * @remarks\r\n * - Calls the base `onDispose` to clean up inherited resources.\r\n * - Disposes all `finalTexture` references from the blueprint\r\n * texture uniform descriptors.\r\n *\r\n * This method is intended to be called by the engine's resource\r\n * management system rather than directly by user code.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n for (const u of this._uniformTextures) {\r\n u.finalTexture!.dispose();\r\n }\r\n }\r\n /**\r\n * Retrieves a named output expression from a blueprint output list.\r\n *\r\n * @param outputs - The list of outputs generated by a blueprint graph.\r\n * @param name - The desired output name (e.g. `\"Position\"`, `\"Color\"`, `\"UV\"`).\r\n * @returns The expression associated with the given name, or `undefined` if not found.\r\n */\r\n private getOutput(\r\n outputs: {\r\n name: string;\r\n exp: number | boolean | PBShaderExp;\r\n }[],\r\n name: string\r\n ) {\r\n return outputs.find((output) => output.name === name)?.exp;\r\n }\r\n private applySubsurfaceScattering(\r\n scope: PBInsideFunctionScope,\r\n litColor: PBShaderExp,\r\n albedoRGB: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n scope.$l.NoV = pb.clamp(pb.dot(normal, viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(pb.add(pb.sub(1, scope.NoV), scope.zSubsurfaceScale), pb.add(1, scope.zSubsurfaceScale)),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(pb.pow(scope.wrapNdotV, scope.zSubsurfacePower), scope.zSubsurfaceIntensity);\r\n return pb.vec4(\r\n pb.add(litColor.rgb, pb.mul(albedoRGB, scope.zSubsurfaceColor, scope.sssFactor)),\r\n litColor.a\r\n );\r\n }\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","PBRBluePrintMaterial","applyMaterialMixins","MeshMaterial","mixinPBRBluePrint","FEATURE_VERTEX_COLOR","defineFeature","FEATURE_VERTEX_UV","FEATURE_SUBSURFACE_SCATTERING","irFrag","irVertex","uniformValues","uniformTextures","_irFrag","MaterialBlueprintIR","nodeMap","PBRBlockNode","roots","order","graph","incoming","outgoing","nodes","id","title","locked","node","ClassName","Object","links","_irVertex","VertexBlockNode","_uniformValues","_uniformTextures","_reflectionMode","_subsurfaceColor","Vector3","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector2","useFeature","behaviors","useVertexColor","useVertexUV","reflectionMode","val","uniformChanged","subsurfaceScattering","featureUsed","subsurfaceColor","equalsTo","set","subsurfaceScale","subsurfacePower","subsurfaceIntensity","anisotropy","clamped","Math","max","min","anisotropyDirection","anisotropyDirectionScaleBias","fragmentIR","ir","clearCache","optionChanged","vertexIR","map","v","newUniforms","finalTexture","DRef","get","finalSampler","name","params","clone","Vector4","zero","texture","type","sRGB","wrapS","wrapT","inFragmentShader","inVertexShader","minFilter","magFilter","mipFilter","u","dispose","other","copyFrom","vertexShader","scope","pb","$builder","$inputs","zVertexPos","vec3","attrib","zVertexNormal","zVertexTangent","vec4","zVertexColor","zVertexUV","vec2","getGlobalScope","uniform","outputs","create","$l","oPos","getOutput","ShaderHelper","resolveVertexPosition","worldMatrix","getWorldMatrix","$outputs","worldPos","mul","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","oNorm","resolveVertexNormal","getNormalMatrix","oTangent","resolveVertexTangent","zVertexBinormal","cross","w","outputName","output","fragmentShader","needFragmentColor","drawContext","renderPass","RENDER_PASS_TYPE_LIGHT","zSubsurfaceColor","zSubsurfaceScale","float","zSubsurfacePower","zSubsurfaceIntensity","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","viewVec","calculateViewVector","commonData","getCommonDatasStruct","getCommonData","materialFlags","MaterialVaryingFlags","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","applySubsurfaceScattering","albedo","rgb","normal","outputFragmentColor","add","applyUniformValues","bindGroup","ctx","pass","setValue","finalValue","setTexture","_createHash","hash","createProgram","program","onDispose","find","exp","albedoRGB","NoV","clamp","dot","wrapNdotV","div","sub","sssFactor","pow","a"],"mappings":";;;;;;;;AAYA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AAEA;;;;;;;;;;;;;;;;;;AAkBC,IACM,MAAMC,oBACHC,SAAAA,mBAAAA,CAAoBC,YAAcC,EAAAA,iBAAAA,CAAAA,CAAAA;AAG1C,qBACA,OAAwBC,oBAAAA,GAAuB,IAAI,CAACC,aAAa,EAAG;AACpE,qBACA,OAAwBC,iBAAAA,GAAoB,IAAI,CAACD,aAAa,EAAG;AACjE,qBACA,OAAwBE,6BAAAA,GAAgC,IAAI,CAACF,aAAa,EAAG;qBAE7E,OAAqC;qBAErC,SAAuC;qBAEvC,cAAgD;qBAEhD,gBAAoD;qBAEpD,eAA2C;qBAE3C,gBAA2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EAAU,CAAG,EAAA,CAAA,CAAA;AACpDtD,QAAAA,KAAAA,CAAMiB,EAAE,CAACwE,SAAS,GAAGxF,EAAGsF,CAAAA,KAAK,CAC3BtF,EAAAA,CAAGyF,GAAG,CAACzF,EAAGqE,CAAAA,GAAG,CAACrE,EAAG0F,CAAAA,GAAG,CAAC,CAAA,EAAG3F,KAAMsF,CAAAA,GAAG,CAAGtF,EAAAA,KAAAA,CAAM+C,gBAAgB,CAAA,EAAG9C,EAAGqE,CAAAA,GAAG,CAAC,CAAA,EAAGtE,KAAM+C,CAAAA,gBAAgB,IAC7F,CACA,EAAA,CAAA,CAAA;AAEF/C,QAAAA,KAAAA,CAAMiB,EAAE,CAAC2E,SAAS,GAAG3F,EAAAA,CAAGyB,GAAG,CAACzB,EAAAA,CAAG4F,GAAG,CAAC7F,MAAMyF,SAAS,EAAEzF,MAAMiD,gBAAgB,CAAA,EAAGjD,MAAMkD,oBAAoB,CAAA;QACvG,OAAOjD,EAAAA,CAAGQ,IAAI,CACZR,EAAAA,CAAGqE,GAAG,CAACP,QAAAA,CAASI,GAAG,EAAElE,EAAAA,CAAGyB,GAAG,CAAC2D,SAAAA,EAAWrF,MAAM8C,gBAAgB,EAAE9C,MAAM4F,SAAS,CAAA,CAAA,EAC9E7B,SAAS+B,CAAC,CAAA;AAEd;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"pbrblueprint.js","sources":["../../src/material/pbrblueprint.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\nimport { DRef, Vector4, type Clonable } from '@zephyr3d/base';\nimport { ShaderHelper } from './shader/helper';\nimport type { BluePrintUniformTexture, BluePrintUniformValue } from '../utility/blueprint/material/ir';\nimport { MaterialBlueprintIR } from '../utility/blueprint/material/ir';\nimport type { IGraphNode } from '../utility/blueprint/node';\nimport { PBRBlockNode, VertexBlockNode } from '../utility/blueprint/material/pbr';\nimport { PBRMetallicRoughnessMaterial } from './pbrmr';\nimport type { DrawContext } from '../render/drawable';\n\ntype BlueprintOutputMap = Partial<Record<PBRBlueprintOutputName, number | boolean | PBShaderExp>>;\ntype VertexBlueprintOutputName = 'Position' | 'Normal' | 'Tangent' | 'Color' | 'UV';\ntype VertexBlueprintOutputMap = Partial<Record<VertexBlueprintOutputName, number | boolean | PBShaderExp>>;\n\n/**\n * Physically-based rendering material driven by blueprint graphs, but shaded by the\n * @public\n */\nexport type PBRBlueprintOutputName =\n | 'BaseColor'\n | 'Metallic'\n | 'Roughness'\n | 'Specular'\n | 'Emissive'\n | 'Normal'\n | 'Tangent'\n | 'Opacity'\n | 'SpecularWeight'\n | 'AO';\n\nconst DEFAULT_OUTPUT_NAMES: readonly PBRBlueprintOutputName[] = [\n 'BaseColor',\n 'Metallic',\n 'Roughness',\n 'Specular',\n 'Emissive',\n 'Normal',\n 'Tangent',\n 'Opacity',\n 'SpecularWeight',\n 'AO'\n] as const;\n\n/**\n * Physically-based rendering material driven by blueprint graphs, but shaded by the\n * same PBR metallic/roughness backend used by {@link PBRMetallicRoughnessMaterial}.\n *\n * @remarks\n * The blueprint graph only produces surface inputs. Final direct/indirect lighting,\n * transmission, clearcoat, sheen, iridescence and anisotropic reflection still run\n * through the standard PBRM backend so imported GLTF materials and blueprint materials\n * stay on the same shading path.\n *\n * @public\n */\nexport class PBRBluePrintMaterial\n extends PBRMetallicRoughnessMaterial\n implements Clonable<PBRBluePrintMaterial>\n{\n /** @internal */\n private static readonly FEATURE_BLUEPRINT_VERTEX_COLOR = this.defineFeature();\n /** @internal */\n private static readonly FEATURE_BLUEPRINT_VERTEX_UV = this.defineFeature();\n /** @internal */\n private _irFrag: MaterialBlueprintIR;\n /** @internal */\n private _irVertex: MaterialBlueprintIR;\n /** @internal */\n private _uniformValues: BluePrintUniformValue[];\n /** @internal */\n private _uniformTextures: BluePrintUniformTexture[];\n /** @internal */\n private _connectedOutputs: Set<PBRBlueprintOutputName>;\n /** @internal */\n private _vertexUsesColor: boolean;\n /** @internal */\n private _vertexUsesUV: boolean;\n\n constructor(\n irFrag?: MaterialBlueprintIR,\n irVertex?: MaterialBlueprintIR,\n uniformValues?: BluePrintUniformValue[],\n uniformTextures?: BluePrintUniformTexture[]\n ) {\n super();\n this._irFrag =\n irFrag ??\n new MaterialBlueprintIR(\n {\n nodeMap: { '1': new PBRBlockNode() },\n roots: [1],\n order: [1],\n graph: { incoming: {}, outgoing: {} }\n },\n '',\n {\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'PBRBlockNode', Object: '' } }],\n links: []\n }\n );\n this._irVertex =\n irVertex ??\n new MaterialBlueprintIR(\n {\n nodeMap: { '1': new VertexBlockNode() },\n roots: [1],\n order: [1],\n graph: { incoming: {}, outgoing: {} }\n },\n '',\n {\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'VertexBlockNode', Object: '' } }],\n links: []\n }\n );\n this._uniformValues = uniformValues ?? [];\n this._uniformTextures = uniformTextures ?? [];\n this._connectedOutputs = new Set();\n this._vertexUsesColor = false;\n this._vertexUsesUV = false;\n this.syncBlueprintMetadata();\n }\n\n get fragmentIR() {\n return this._irFrag;\n }\n set fragmentIR(ir: MaterialBlueprintIR) {\n if (ir && ir !== this._irFrag) {\n this._irFrag = ir;\n this.syncBlueprintMetadata();\n this.clearCache();\n this.optionChanged(true);\n }\n }\n\n get vertexIR() {\n return this._irVertex;\n }\n set vertexIR(ir: MaterialBlueprintIR) {\n if (ir && ir !== this._irVertex) {\n this._irVertex = ir;\n this.syncBlueprintMetadata();\n this.clearCache();\n this.optionChanged(true);\n }\n }\n\n get uniformValues() {\n return this._uniformValues;\n }\n set uniformValues(val: BluePrintUniformValue[]) {\n this._uniformValues = (val ?? []).map((v) => ({ ...v }));\n this.uniformChanged();\n }\n\n get uniformTextures() {\n return this._uniformTextures;\n }\n set uniformTextures(val: BluePrintUniformTexture[]) {\n if (val !== this._uniformTextures) {\n const newUniforms = (val ?? []).map((v) => ({\n finalTexture: new DRef(v.finalTexture?.get() ?? null),\n finalSampler: v.finalSampler,\n inFragmentShader: v.inFragmentShader,\n inVertexShader: v.inVertexShader,\n magFilter: v.magFilter,\n minFilter: v.minFilter,\n mipFilter: v.mipFilter,\n name: v.name,\n params: v.params?.clone() ?? Vector4.zero(),\n sRGB: v.sRGB,\n texture: v.texture,\n type: v.type,\n wrapS: v.wrapS,\n wrapT: v.wrapT\n }));\n for (const u of this._uniformTextures) {\n u.finalTexture?.dispose();\n }\n this._uniformTextures = newUniforms;\n this.uniformChanged();\n }\n }\n\n hasConnectedOutput(name: PBRBlueprintOutputName) {\n return this._connectedOutputs.has(name);\n }\n\n clone() {\n const other = new PBRBluePrintMaterial(\n this._irFrag,\n this._irVertex,\n this._uniformValues,\n this._uniformTextures\n );\n other.copyFrom(this);\n return other;\n }\n\n copyFrom(other: this) {\n super.copyFrom(other);\n if (other instanceof PBRBluePrintMaterial) {\n this.fragmentIR = other.fragmentIR;\n this.vertexIR = other.vertexIR;\n this.uniformValues = other.uniformValues;\n this.uniformTextures = other.uniformTextures;\n }\n }\n\n vertexShader(scope: PBFunctionScope) {\n super.vertexShader(scope);\n const pb = scope.$builder;\n\n scope.zVertexColor = this.getBlueprintVertexColor(scope);\n scope.zVertexUV = this.getBlueprintVertexUV(scope);\n scope.zVertexNormal = (scope.$outputs.wNorm ?? pb.vec3(0, 0, 1)) as PBShaderExp;\n scope.zVertexTangent = (scope.$outputs.wTangent ?? pb.vec3(1, 0, 0)) as PBShaderExp;\n scope.zVertexBinormal = (scope.$outputs.wBinormal ?? pb.vec3(0, 1, 0)) as PBShaderExp;\n scope.zWorldPos = scope.$outputs.worldPos as PBShaderExp;\n if (this._vertexUsesColor && !scope.$outputs.zOutDiffuse) {\n scope.$outputs.zOutDiffuse = scope.zVertexColor;\n }\n if (this._vertexUsesUV) {\n scope.$outputs.zVertexUV = scope.zVertexUV;\n }\n\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\n if (u.inVertexShader) {\n // @ts-ignore dynamic shader type constructor\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\n }\n }\n\n const outputs = this._irVertex.create(pb);\n if (!outputs) {\n return;\n }\n const vertexOut = this.toVertexOutputMap(outputs);\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\n\n if (vertexOut.Position) {\n scope.$l.oPos = vertexOut.Position as PBShaderExp;\n scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;\n scope.zWorldPos = scope.$outputs.worldPos as PBShaderExp;\n scope.$l.csPos = pb.mul(\n ShaderHelper.getViewProjectionMatrix(scope),\n pb.vec4(scope.$outputs.worldPos, 1)\n );\n ShaderHelper.setClipSpacePosition(scope, scope.csPos);\n }\n if (vertexOut.Color) {\n scope.zVertexColor = this.toVec4(scope as unknown as PBInsideFunctionScope, vertexOut.Color, 1);\n if (scope.$outputs.zOutDiffuse) {\n scope.$outputs.zOutDiffuse = scope.zVertexColor;\n }\n }\n if (vertexOut.UV) {\n scope.zVertexUV = this.toVec2(scope as unknown as PBInsideFunctionScope, vertexOut.UV);\n if (this._vertexUsesUV) {\n scope.$outputs.zVertexUV = scope.zVertexUV;\n }\n }\n if (vertexOut.Normal) {\n scope.$l.oNorm = this.toVec3(scope as unknown as PBInsideFunctionScope, vertexOut.Normal);\n scope.$outputs.wNorm = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\n scope.zVertexNormal = scope.$outputs.wNorm as PBShaderExp;\n }\n if (vertexOut.Tangent) {\n const tangent = vertexOut.Tangent as PBShaderExp;\n scope.$l.oTangent =\n tangent.getTypeName() === 'vec4'\n ? tangent\n : pb.vec4(this.toVec3(scope as unknown as PBInsideFunctionScope, tangent), 1);\n scope.$outputs.wTangent = pb.mul(\n ShaderHelper.getNormalMatrix(scope),\n pb.vec4(scope.oTangent.xyz, 0)\n ).xyz;\n scope.$outputs.wBinormal = pb.mul(\n pb.cross(scope.$outputs.wNorm as PBShaderExp, scope.$outputs.wTangent as PBShaderExp),\n scope.oTangent.w\n );\n scope.zVertexTangent = scope.$outputs.wTangent as PBShaderExp;\n scope.zVertexBinormal = scope.$outputs.wBinormal as PBShaderExp;\n }\n for (const outputName of ['Output1', 'Output2', 'Output3', 'Output4']) {\n const output = outputs.find((output) => output.name === outputName)?.exp;\n if (output) {\n scope.$outputs[outputName] = output;\n }\n }\n }\n\n fragmentShader(scope: PBFunctionScope) {\n const pb = scope.$builder;\n if (this.needFragmentColorInput()) {\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\n if (u.inFragmentShader) {\n // @ts-ignore dynamic shader type constructor\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\n }\n }\n scope.zVertexColor = scope.$inputs.zOutDiffuse ?? pb.vec4(1);\n scope.zVertexUV = scope.$inputs.zVertexUV ?? pb.vec2(0);\n scope.zVertexNormal = scope.$inputs.wNorm ?? pb.vec3(0, 0, 1);\n scope.zVertexTangent = scope.$inputs.wTangent ?? pb.vec3(1, 0, 0);\n scope.zVertexBinormal = scope.$inputs.wBinormal ?? pb.vec3(0, 1, 0);\n scope.zWorldPos = scope.$inputs.worldPos as PBShaderExp;\n }\n super.fragmentShader(scope);\n }\n\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\n super.applyUniformValues(bindGroup, ctx, pass);\n if (this.needFragmentColorInput(ctx)) {\n for (const u of this._uniformValues) {\n bindGroup.setValue(u.name, u.finalValue!);\n }\n for (const u of this._uniformTextures) {\n const texture = u.finalTexture?.get();\n if (texture) {\n bindGroup.setTexture(u.name, texture, u.finalSampler);\n }\n }\n }\n }\n\n protected createProgram(ctx: DrawContext, pass: number) {\n return super.createProgram(ctx, pass);\n }\n\n protected _createHash() {\n return `${super._createHash()}:${this._irFrag.hash}:${this._irVertex.hash}:${this._connectedOutputHash()}`;\n }\n\n protected onDispose() {\n super.onDispose();\n for (const u of this._uniformTextures) {\n u.finalTexture?.dispose();\n }\n }\n\n calculateAlbedoColor(scope: PBInsideFunctionScope, uv?: PBShaderExp) {\n const baseColor = this.getBlueprintOutput(scope, 'BaseColor');\n const opacity = this.getBlueprintOutput(scope, 'Opacity');\n if (baseColor !== undefined) {\n const pb = scope.$builder;\n return pb.vec4(this.toVec3(scope, baseColor), (opacity as PBShaderExp | number) ?? 1);\n }\n const albedo = super.calculateAlbedoColor(scope, uv);\n if (opacity !== undefined) {\n const pb = scope.$builder;\n return pb.vec4(albedo.rgb, opacity as PBShaderExp | number);\n }\n return albedo;\n }\n\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp) {\n const value = this.getBlueprintOutput(scope, 'Metallic');\n if (value !== undefined) {\n return this.toFloat(scope, value);\n }\n return super.calculateMetallic(scope, albedo, normal);\n }\n\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp) {\n const value = this.getBlueprintOutput(scope, 'Roughness');\n if (value !== undefined) {\n return this.toFloat(scope, value);\n }\n return super.calculateRoughness(scope, albedo, normal);\n }\n\n calculateSpecularFactor(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp) {\n const pb = scope.$builder;\n const base = super.calculateSpecularFactor(scope, albedo, normal);\n const specular = this.getBlueprintOutput(scope, 'Specular');\n const weight = this.getBlueprintOutput(scope, 'SpecularWeight');\n if (specular !== undefined || weight !== undefined) {\n return pb.vec4(\n specular !== undefined ? this.toVec3(scope, specular) : base.rgb,\n (weight as PBShaderExp | number | undefined) ?? base.a\n );\n }\n return base;\n }\n\n calculateEmissiveColor(scope: PBInsideFunctionScope) {\n const emissive = this.getBlueprintOutput(scope, 'Emissive');\n if (emissive !== undefined) {\n return this.toVec3(scope, emissive);\n }\n return super.calculateEmissiveColor(scope);\n }\n\n calculateNormalAndTBN(\n scope: PBInsideFunctionScope,\n worldPos: PBShaderExp,\n worldNormal?: PBShaderExp,\n worldTangent?: PBShaderExp,\n worldBinormal?: PBShaderExp\n ) {\n const outputNormal = this.getBlueprintOutput(scope, 'Normal');\n const outputTangent = this.getBlueprintOutput(scope, 'Tangent');\n if (outputNormal === undefined && outputTangent === undefined) {\n return super.calculateNormalAndTBN(scope, worldPos, worldNormal, worldTangent, worldBinormal);\n }\n const pb = scope.$builder;\n const NormalStruct = pb.defineStruct([pb.mat3('TBN'), pb.vec3('normal')]);\n const funcName = 'Z_calculateBlueprintNormalAndTBN';\n const that = this;\n pb.func(\n funcName,\n [\n pb.vec3('worldPos'),\n pb.vec3('worldNormal'),\n pb.vec3('worldTangent'),\n pb.vec3('worldBinormal'),\n pb.vec3('surfaceNormal'),\n pb.vec3('surfaceTangent')\n ],\n function () {\n this.$l.TBN = that.calculateTBN(\n this,\n this.worldPos,\n this.worldNormal,\n this.worldTangent,\n this.worldBinormal\n );\n this.$l.ng = this.TBN[2];\n this.$l.t = this.TBN[0];\n this.$l.b = this.TBN[1];\n this.$if(pb.greaterThan(pb.length(this.surfaceTangent), 0.0001), function () {\n this.$l.t_ = pb.normalize(this.surfaceTangent);\n this.t = pb.normalize(pb.sub(this.t_, pb.mul(this.ng, pb.dot(this.ng, this.t_))));\n this.b = pb.normalize(pb.cross(this.ng, this.t));\n });\n this.TBN = pb.mat3(this.t, this.b, this.ng);\n this.$l.surfaceNormalTS = this.surfaceNormal;\n this.$if(pb.lessThanEqual(pb.length(this.surfaceNormalTS), 0.0001), function () {\n this.surfaceNormalTS = pb.vec3(0, 0, 1);\n });\n this.$l.surfaceNormalWS = pb.normalize(pb.mul(this.TBN, this.surfaceNormalTS));\n this.$return(NormalStruct(this.TBN, this.surfaceNormalWS));\n }\n );\n return pb\n .getGlobalScope()\n [\n funcName\n ](worldPos, (worldNormal ?? scope.zVertexNormal) as PBShaderExp, (worldTangent ?? scope.zVertexTangent) as PBShaderExp, (worldBinormal ?? scope.zVertexBinormal) as PBShaderExp, outputNormal !== undefined ? this.toVec3(scope, outputNormal) : pb.vec3(0, 0, 1), outputTangent !== undefined ? this.toVec3(scope, outputTangent) : pb.vec3(0)) as PBShaderExp;\n }\n\n indirectLighting(\n scope: PBInsideFunctionScope,\n normal: PBShaderExp,\n viewVec: PBShaderExp,\n commonData: PBShaderExp,\n outColor: PBShaderExp,\n outRoughness?: PBShaderExp,\n outDiffuseColor?: PBShaderExp\n ) {\n const ao = this.getBlueprintOutput(scope, 'AO');\n if (ao === undefined) {\n super.indirectLighting(scope, normal, viewVec, commonData, outColor, outRoughness, outDiffuseColor);\n return;\n }\n const pb = scope.$builder;\n const funcName = `Z_applyBlueprintAO${outDiffuseColor ? '_D' : ''}`;\n pb.func(\n funcName,\n [\n pb.vec3('outColor').inout(),\n ...(outDiffuseColor ? [pb.vec3('outDiffuseColor').inout()] : []),\n pb.float('ao')\n ],\n function () {\n this.outColor = pb.mul(this.outColor, this.ao);\n if (outDiffuseColor) {\n this.outDiffuseColor = pb.mul(this.outDiffuseColor, this.ao);\n }\n }\n );\n super.indirectLighting(scope, normal, viewVec, commonData, outColor, outRoughness, outDiffuseColor);\n if (outDiffuseColor) {\n pb.getGlobalScope()[funcName](outColor, outDiffuseColor, ao as PBShaderExp | number);\n } else {\n pb.getGlobalScope()[funcName](outColor, ao as PBShaderExp | number);\n }\n }\n\n private syncBlueprintMetadata() {\n this._connectedOutputs = this.collectConnectedOutputs(this._irFrag, PBRBlockNode);\n const fragmentUsesColor = this._irFrag.behaviors.useVertexColor;\n const fragmentUsesUV = this._irFrag.behaviors.useVertexUV;\n const vertexUsesColor = this._irVertex.behaviors.useVertexColor;\n const vertexUsesUV = this._irVertex.behaviors.useVertexUV;\n this._vertexUsesColor = fragmentUsesColor || vertexUsesColor;\n this._vertexUsesUV = fragmentUsesUV || vertexUsesUV;\n this.useFeature(PBRBluePrintMaterial.FEATURE_BLUEPRINT_VERTEX_COLOR, this._vertexUsesColor);\n this.useFeature(PBRBluePrintMaterial.FEATURE_BLUEPRINT_VERTEX_UV, this._vertexUsesUV);\n }\n\n private collectConnectedOutputs<T extends IGraphNode>(\n ir: MaterialBlueprintIR,\n rootCtor: new (...args: any[]) => T\n ): Set<PBRBlueprintOutputName> {\n const outputs = new Set<PBRBlueprintOutputName>();\n for (const rootId of ir.DAG.roots) {\n const rootNode = ir.DAG.nodeMap[rootId];\n if (!(rootNode instanceof rootCtor)) {\n continue;\n }\n for (const input of rootNode.inputs) {\n if (input.inputNode) {\n outputs.add(input.name as PBRBlueprintOutputName);\n }\n }\n }\n return outputs;\n }\n\n private getBlueprintVertexColor(scope: PBFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n if (this.vertexColor) {\n return this.getVertexColor(scope as unknown as PBInsideFunctionScope);\n }\n if (this._vertexUsesColor) {\n if (scope.$inputs.zDiffuse) {\n return scope.$inputs.zDiffuse as PBShaderExp;\n }\n if (scope.$getVertexAttrib('diffuse')) {\n return scope.$getVertexAttrib('diffuse') as PBShaderExp;\n }\n scope.$inputs.zDiffuse = pb.vec4().attrib('diffuse');\n return scope.$inputs.zDiffuse as PBShaderExp;\n }\n return pb.vec4(1);\n }\n\n private getBlueprintVertexUV(scope: PBFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n if (this._vertexUsesUV) {\n if (scope.$inputs.zVertexUV) {\n return scope.$inputs.zVertexUV as PBShaderExp;\n }\n if (scope.$getVertexAttrib('texCoord0')) {\n return scope.$getVertexAttrib('texCoord0') as PBShaderExp;\n }\n scope.$inputs.zVertexUV = pb.vec2().attrib('texCoord0');\n return scope.$inputs.zVertexUV as PBShaderExp;\n }\n if (this.albedoTexture) {\n return (this.getAlbedoTexCoord(scope as unknown as PBInsideFunctionScope) ?? pb.vec2(0)) as PBShaderExp;\n }\n return pb.vec2(0);\n }\n\n private getBlueprintOutput(\n scope: PBInsideFunctionScope,\n name: PBRBlueprintOutputName\n ): number | boolean | PBShaderExp | undefined {\n if (!this._connectedOutputs.has(name)) {\n return undefined;\n }\n return this.getBlueprintOutputMap(scope)[name];\n }\n\n private getBlueprintOutputMap(scope: PBInsideFunctionScope): BlueprintOutputMap {\n const pb = scope.$builder;\n const funcName = 'Z_GetPBRBlueprintOutputs';\n const that = this;\n const outputsStruct = pb.defineStruct(\n DEFAULT_OUTPUT_NAMES.map((name) => {\n switch (name) {\n case 'BaseColor':\n return pb.vec3(name);\n case 'Specular':\n case 'Emissive':\n case 'Normal':\n case 'Tangent':\n return pb.vec3(name);\n default:\n return pb.float(name);\n }\n })\n );\n if (!pb.getGlobalScope()[funcName]) {\n pb.func(\n funcName,\n [\n pb.vec3('worldPos'),\n pb.vec4('vertexColor'),\n pb.vec2('vertexUV'),\n pb.vec3('vertexNormal'),\n pb.vec3('vertexTangent'),\n pb.vec3('vertexBinormal')\n ],\n function () {\n this.zWorldPos = this.worldPos;\n this.zVertexColor = this.vertexColor;\n this.zVertexUV = this.vertexUV;\n this.zVertexNormal = this.vertexNormal;\n this.zVertexTangent = this.vertexTangent;\n this.zVertexBinormal = this.vertexBinormal;\n const outputs = that._irFrag.create(pb);\n let baseColor: number | PBShaderExp = pb.vec3(1);\n let metallic: number | PBShaderExp = 0;\n let roughness: number | PBShaderExp = 1;\n let specular: number | PBShaderExp = pb.vec3(1);\n let emissive: number | PBShaderExp = pb.vec3(0);\n let normal: number | PBShaderExp = pb.vec3(0);\n let tangent: number | PBShaderExp = pb.vec3(0);\n let opacity: number | PBShaderExp = 1;\n let specularWeight: number | PBShaderExp = 1;\n let ao: number | PBShaderExp = 1;\n if (outputs) {\n const map = that.toOutputMap(outputs);\n if (map.BaseColor !== undefined) {\n baseColor = that.toVec3(scope, map.BaseColor);\n }\n if (map.Metallic !== undefined) {\n metallic = map.Metallic as PBShaderExp | number;\n }\n if (map.Roughness !== undefined) {\n roughness = map.Roughness as PBShaderExp | number;\n }\n if (map.Specular !== undefined) {\n specular = that.toVec3(scope, map.Specular);\n }\n if (map.Emissive !== undefined) {\n emissive = that.toVec3(scope, map.Emissive);\n }\n if (map.Normal !== undefined) {\n normal = that.toVec3(scope, map.Normal);\n }\n if (map.Tangent !== undefined) {\n tangent = that.toVec3(scope, map.Tangent);\n }\n if (map.Opacity !== undefined) {\n opacity = map.Opacity as PBShaderExp | number;\n }\n if (map.SpecularWeight !== undefined) {\n specularWeight = map.SpecularWeight as PBShaderExp | number;\n }\n if (map.AO !== undefined) {\n ao = map.AO as PBShaderExp | number;\n }\n }\n this.$return(\n outputsStruct(\n baseColor,\n metallic,\n roughness,\n specular,\n emissive,\n normal,\n tangent,\n opacity,\n specularWeight,\n ao\n )\n );\n }\n );\n }\n const result = pb\n .getGlobalScope()\n [\n funcName\n ](this.getBlueprintWorldPos(scope), this.getBlueprintFragmentVertexColor(scope), this.getBlueprintFragmentVertexUV(scope), this.getBlueprintFragmentVertexNormal(scope), this.getBlueprintFragmentVertexTangent(scope), this.getBlueprintFragmentVertexBinormal(scope)) as PBShaderExp;\n const map: BlueprintOutputMap = {};\n for (const name of DEFAULT_OUTPUT_NAMES) {\n map[name] = result[name] as PBShaderExp;\n }\n return map;\n }\n\n private getBlueprintWorldPos(scope: PBInsideFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n return (scope.$inputs.worldPos ?? scope.zWorldPos ?? pb.vec3(0)) as PBShaderExp;\n }\n\n private getBlueprintFragmentVertexColor(scope: PBInsideFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n return (scope.$inputs.zOutDiffuse ?? scope.zVertexColor ?? pb.vec4(1)) as PBShaderExp;\n }\n\n private getBlueprintFragmentVertexUV(scope: PBInsideFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n return (scope.$inputs.zVertexUV ?? scope.zVertexUV ?? pb.vec2(0)) as PBShaderExp;\n }\n\n private getBlueprintFragmentVertexNormal(scope: PBInsideFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n return (scope.$inputs.wNorm ?? scope.zVertexNormal ?? pb.vec3(0, 0, 1)) as PBShaderExp;\n }\n\n private getBlueprintFragmentVertexTangent(scope: PBInsideFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n return (scope.$inputs.wTangent ?? scope.zVertexTangent ?? pb.vec3(1, 0, 0)) as PBShaderExp;\n }\n\n private getBlueprintFragmentVertexBinormal(scope: PBInsideFunctionScope): PBShaderExp {\n const pb = scope.$builder;\n return (scope.$inputs.wBinormal ?? scope.zVertexBinormal ?? pb.vec3(0, 1, 0)) as PBShaderExp;\n }\n\n private toOutputMap(\n outputs: {\n name: string;\n exp: number | boolean | PBShaderExp;\n }[]\n ): BlueprintOutputMap {\n const map: BlueprintOutputMap = {};\n for (const output of outputs) {\n map[output.name as PBRBlueprintOutputName] = output.exp;\n }\n return map;\n }\n\n private toVertexOutputMap(\n outputs: {\n name: string;\n exp: number | boolean | PBShaderExp;\n }[]\n ): VertexBlueprintOutputMap {\n const map: VertexBlueprintOutputMap = {};\n for (const output of outputs) {\n map[output.name as VertexBlueprintOutputName] = output.exp;\n }\n return map;\n }\n\n private toFloat(scope: PBInsideFunctionScope, value: number | boolean | PBShaderExp): PBShaderExp {\n const pb = scope.$builder;\n if (typeof value === 'number') {\n return pb.float(value);\n }\n const exp = value as PBShaderExp;\n return exp.getTypeName() === 'float' ? exp : exp.x;\n }\n\n private toVec2(scope: PBInsideFunctionScope, value: number | boolean | PBShaderExp): PBShaderExp {\n const pb = scope.$builder;\n if (typeof value === 'number') {\n return pb.vec2(value);\n }\n const exp = value as PBShaderExp;\n const type = exp.getTypeName();\n if (type === 'float') {\n return pb.vec2(exp);\n }\n if (type === 'vec3' || type === 'vec4') {\n return exp.xy;\n }\n return exp;\n }\n\n private toVec3(scope: PBInsideFunctionScope, value: number | boolean | PBShaderExp): PBShaderExp {\n const pb = scope.$builder;\n if (typeof value === 'number') {\n return pb.vec3(value);\n }\n const exp = value as PBShaderExp;\n const type = exp.getTypeName();\n if (type === 'float') {\n return pb.vec3(exp);\n }\n if (type === 'vec2') {\n return pb.vec3(exp, 0);\n }\n if (type === 'vec4') {\n return exp.xyz;\n }\n return exp;\n }\n\n private toVec4(\n scope: PBInsideFunctionScope,\n value: number | boolean | PBShaderExp,\n alpha: number | PBShaderExp\n ): PBShaderExp {\n const pb = scope.$builder;\n if (typeof value === 'number') {\n return pb.vec4(value, value, value, alpha);\n }\n const exp = value as PBShaderExp;\n const type = exp.getTypeName();\n if (type === 'float') {\n return pb.vec4(pb.vec3(exp), alpha);\n }\n if (type === 'vec2') {\n return pb.vec4(exp, 0, alpha);\n }\n if (type === 'vec3') {\n return pb.vec4(exp, alpha);\n }\n return exp;\n }\n\n private _connectedOutputHash() {\n return DEFAULT_OUTPUT_NAMES.map((name) => (this._connectedOutputs.has(name) ? '1' : '0')).join('');\n }\n}\n"],"names":["DEFAULT_OUTPUT_NAMES","PBRBluePrintMaterial","PBRMetallicRoughnessMaterial","FEATURE_BLUEPRINT_VERTEX_COLOR","defineFeature","FEATURE_BLUEPRINT_VERTEX_UV","irFrag","irVertex","uniformValues","uniformTextures","_irFrag","MaterialBlueprintIR","nodeMap","PBRBlockNode","roots","order","graph","incoming","outgoing","nodes","id","title","locked","node","ClassName","Object","links","_irVertex","VertexBlockNode","_uniformValues","_uniformTextures","_connectedOutputs","Set","_vertexUsesColor","_vertexUsesUV","syncBlueprintMetadata","fragmentIR","ir","clearCache","optionChanged","vertexIR","val","map","v","uniformChanged","newUniforms","finalTexture","DRef","get","finalSampler","inFragmentShader","inVertexShader","magFilter","minFilter","mipFilter","name","params","clone","Vector4","zero","sRGB","texture","type","wrapS","wrapT","u","dispose","hasConnectedOutput","has","other","copyFrom","vertexShader","scope","pb","$builder","zVertexColor","getBlueprintVertexColor","zVertexUV","getBlueprintVertexUV","zVertexNormal","$outputs","wNorm","vec3","zVertexTangent","wTangent","zVertexBinormal","wBinormal","zWorldPos","worldPos","zOutDiffuse","getGlobalScope","uniform","outputs","create","vertexOut","toVertexOutputMap","worldMatrix","ShaderHelper","getWorldMatrix","Position","$l","oPos","mul","vec4","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","Color","toVec4","UV","toVec2","Normal","oNorm","toVec3","getNormalMatrix","Tangent","tangent","oTangent","getTypeName","cross","w","outputName","output","find","exp","fragmentShader","needFragmentColorInput","$inputs","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","finalValue","setTexture","createProgram","_createHash","hash","_connectedOutputHash","onDispose","calculateAlbedoColor","uv","baseColor","getBlueprintOutput","opacity","undefined","albedo","rgb","calculateMetallic","normal","value","toFloat","calculateRoughness","calculateSpecularFactor","base","specular","weight","a","calculateEmissiveColor","emissive","calculateNormalAndTBN","worldNormal","worldTangent","worldBinormal","outputNormal","outputTangent","NormalStruct","defineStruct","mat3","funcName","that","func","TBN","calculateTBN","ng","t","b","$if","greaterThan","length","surfaceTangent","t_","normalize","sub","dot","surfaceNormalTS","surfaceNormal","lessThanEqual","surfaceNormalWS","$return","indirectLighting","viewVec","commonData","outColor","outRoughness","outDiffuseColor","ao","inout","float","collectConnectedOutputs","fragmentUsesColor","behaviors","useVertexColor","fragmentUsesUV","useVertexUV","vertexUsesColor","vertexUsesUV","useFeature","rootCtor","rootId","DAG","rootNode","input","inputs","inputNode","add","vertexColor","getVertexColor","zDiffuse","$getVertexAttrib","attrib","albedoTexture","getAlbedoTexCoord","getBlueprintOutputMap","outputsStruct","vertexUV","vertexNormal","vertexTangent","vertexBinormal","metallic","roughness","specularWeight","toOutputMap","BaseColor","Metallic","Roughness","Specular","Emissive","Opacity","SpecularWeight","AO","result","getBlueprintWorldPos","getBlueprintFragmentVertexColor","getBlueprintFragmentVertexUV","getBlueprintFragmentVertexNormal","getBlueprintFragmentVertexTangent","getBlueprintFragmentVertexBinormal","x","xy","alpha","join"],"mappings":";;;;;;AA8BA,MAAMA,oBAA0D,GAAA;AAC9D,IAAA,WAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,SAAA;AACA,IAAA,SAAA;AACA,IAAA,gBAAA;AACA,IAAA;AACD,CAAA;AAED;;;;;;;;;;;IAYO,MAAMC,oBACHC,SAAAA,4BAAAA,CAAAA;AAGR,qBACA,OAAwBC,8BAAAA,GAAiC,IAAI,CAACC,aAAa,EAAG;AAC9E,qBACA,O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,oBAAqB0C,CAAAA,GAAG,CAAC,CAACa,OAAU,IAAI,CAACxB,iBAAiB,CAACqC,GAAG,CAACb,IAAAA,CAAAA,GAAQ,GAAM,GAAA,GAAA,CAAA,CAAMsM,IAAI,CAAC,EAAA,CAAA;AACjG;AACF;;;;"}
|
package/dist/material/pbrmr.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mixinVertexColor } from './mixins/vertexcolor.js';
|
|
|
3
3
|
import { mixinPBRMetallicRoughness } from './mixins/lightmodel/pbrmetallicroughness.js';
|
|
4
4
|
import { mixinTextureProps } from './mixins/texture.js';
|
|
5
5
|
import { ShaderHelper } from './shader/helper.js';
|
|
6
|
-
import {
|
|
6
|
+
import { RENDER_PASS_TYPE_LIGHT, MaterialVaryingFlags } from '../values.js';
|
|
7
7
|
import { Vector3 } from '@zephyr3d/base';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -12,21 +12,15 @@ import { Vector3 } from '@zephyr3d/base';
|
|
|
12
12
|
*/ class PBRMetallicRoughnessMaterial extends applyMaterialMixins(MeshMaterial, mixinPBRMetallicRoughness, mixinVertexColor, mixinTextureProps('subsurface')) {
|
|
13
13
|
/** @internal */ static FEATURE_VERTEX_NORMAL = this.defineFeature();
|
|
14
14
|
/** @internal */ static FEATURE_VERTEX_TANGENT = this.defineFeature();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_subsurfaceScale;
|
|
18
|
-
_subsurfacePower;
|
|
19
|
-
_subsurfaceIntensity;
|
|
15
|
+
_subsurfaceProfileChanged;
|
|
16
|
+
_subsurfaceProfile;
|
|
20
17
|
/**
|
|
21
18
|
* Creates an instance of PBRMetallicRoughnessMaterial class
|
|
22
19
|
*/ constructor(){
|
|
23
20
|
super();
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this._subsurfacePower = 1.5;
|
|
27
|
-
this._subsurfaceIntensity = 0.5;
|
|
21
|
+
this._subsurfaceProfileChanged = ()=>this.uniformChanged();
|
|
22
|
+
this._subsurfaceProfile = null;
|
|
28
23
|
this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, true);
|
|
29
|
-
this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, false);
|
|
30
24
|
this.transmission = false;
|
|
31
25
|
this.transmissionFactor = 0.2;
|
|
32
26
|
this.thicknessFactor = 0.35;
|
|
@@ -42,11 +36,7 @@ import { Vector3 } from '@zephyr3d/base';
|
|
|
42
36
|
super.copyFrom(other);
|
|
43
37
|
this.vertexNormal = other.vertexNormal;
|
|
44
38
|
this.vertexTangent = other.vertexTangent;
|
|
45
|
-
this.
|
|
46
|
-
this.subsurfaceColor = other.subsurfaceColor;
|
|
47
|
-
this.subsurfaceScale = other.subsurfaceScale;
|
|
48
|
-
this.subsurfacePower = other.subsurfacePower;
|
|
49
|
-
this.subsurfaceIntensity = other.subsurfaceIntensity;
|
|
39
|
+
this.subsurfaceProfile = other.subsurfaceProfile;
|
|
50
40
|
}
|
|
51
41
|
/** true if vertex normal attribute presents */ get vertexNormal() {
|
|
52
42
|
return this.featureUsed(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL);
|
|
@@ -60,63 +50,28 @@ import { Vector3 } from '@zephyr3d/base';
|
|
|
60
50
|
set vertexTangent(val) {
|
|
61
51
|
this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT, !!val);
|
|
62
52
|
}
|
|
63
|
-
/**
|
|
64
|
-
return this.
|
|
53
|
+
/** shared profile asset driving channel radius/falloff */ get subsurfaceProfile() {
|
|
54
|
+
return this._subsurfaceProfile;
|
|
65
55
|
}
|
|
66
|
-
set
|
|
67
|
-
this.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
set subsurfaceColor(val) {
|
|
73
|
-
if (!val.equalsTo(this._subsurfaceColor)) {
|
|
74
|
-
this._subsurfaceColor.set(val);
|
|
75
|
-
this.uniformChanged();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/** wrap factor for the scattering profile */ get subsurfaceScale() {
|
|
79
|
-
return this._subsurfaceScale;
|
|
80
|
-
}
|
|
81
|
-
set subsurfaceScale(val) {
|
|
82
|
-
if (val !== this._subsurfaceScale) {
|
|
83
|
-
this._subsurfaceScale = val;
|
|
84
|
-
this.uniformChanged();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/** profile exponent for the scattering profile */ get subsurfacePower() {
|
|
88
|
-
return this._subsurfacePower;
|
|
89
|
-
}
|
|
90
|
-
set subsurfacePower(val) {
|
|
91
|
-
if (val !== this._subsurfacePower) {
|
|
92
|
-
this._subsurfacePower = val;
|
|
93
|
-
this.uniformChanged();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/** final intensity of scattering contribution */ get subsurfaceIntensity() {
|
|
97
|
-
return this._subsurfaceIntensity;
|
|
98
|
-
}
|
|
99
|
-
set subsurfaceIntensity(val) {
|
|
100
|
-
if (val !== this._subsurfaceIntensity) {
|
|
101
|
-
this._subsurfaceIntensity = val;
|
|
102
|
-
this.uniformChanged();
|
|
56
|
+
set subsurfaceProfile(val) {
|
|
57
|
+
if (val !== this._subsurfaceProfile) {
|
|
58
|
+
this._subsurfaceProfile?.removeChangeListener(this._subsurfaceProfileChanged);
|
|
59
|
+
this._subsurfaceProfile = val ?? null;
|
|
60
|
+
this._subsurfaceProfile?.addChangeListener(this._subsurfaceProfileChanged);
|
|
61
|
+
this.optionChanged(true);
|
|
103
62
|
}
|
|
104
63
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return instancing ? scope.$inputs.zSubsurfaceColor : scope.zSubsurfaceColor;
|
|
64
|
+
getSubsurfaceProfileId(scope) {
|
|
65
|
+
return scope.zSubsurfaceProfileId;
|
|
108
66
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return instancing ? scope.$inputs.zSubsurfaceScale : scope.zSubsurfaceScale;
|
|
67
|
+
getSubsurfaceProfileScale(scope) {
|
|
68
|
+
return scope.zSubsurfaceProfileScale;
|
|
112
69
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return instancing ? scope.$inputs.zSubsurfacePower : scope.zSubsurfacePower;
|
|
70
|
+
getSubsurfaceProfileStrength(scope) {
|
|
71
|
+
return scope.zSubsurfaceProfileStrength;
|
|
116
72
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return instancing ? scope.$inputs.zSubsurfaceIntensity : scope.zSubsurfaceIntensity;
|
|
73
|
+
getSubsurfaceProfilePreset(scope) {
|
|
74
|
+
return scope.zSubsurfaceProfilePreset;
|
|
120
75
|
}
|
|
121
76
|
vertexShader(scope) {
|
|
122
77
|
super.vertexShader(scope);
|
|
@@ -126,7 +81,8 @@ import { Vector3 } from '@zephyr3d/base';
|
|
|
126
81
|
scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;
|
|
127
82
|
scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));
|
|
128
83
|
ShaderHelper.setClipSpacePosition(scope, scope.csPos);
|
|
129
|
-
|
|
84
|
+
const needsVolumeTransmissionRay = this.transmission || !!this._subsurfaceProfile && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_TRANSMISSION);
|
|
85
|
+
if (needsVolumeTransmissionRay) {
|
|
130
86
|
scope.$outputs.screenUV = pb.add(pb.mul(pb.div(scope.csPos.xy, scope.csPos.w), 0.5), pb.vec2(0.5));
|
|
131
87
|
scope.$outputs.modelScale = pb.vec3(pb.length(worldMatrix[0].xyz), pb.length(worldMatrix[1].xyz), pb.length(worldMatrix[2].xyz));
|
|
132
88
|
}
|
|
@@ -143,50 +99,71 @@ import { Vector3 } from '@zephyr3d/base';
|
|
|
143
99
|
fragmentShader(scope) {
|
|
144
100
|
super.fragmentShader(scope);
|
|
145
101
|
const pb = scope.$builder;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
scope.
|
|
149
|
-
scope.
|
|
150
|
-
scope.
|
|
102
|
+
const renderPassType = this.drawContext.renderPass.type;
|
|
103
|
+
if (!!this._subsurfaceProfile && this.needFragmentColor() && renderPassType === RENDER_PASS_TYPE_LIGHT) {
|
|
104
|
+
scope.zSubsurfaceProfileId = pb.float().uniform(2);
|
|
105
|
+
scope.zSubsurfaceProfileScale = pb.float().uniform(2);
|
|
106
|
+
scope.zSubsurfaceProfileStrength = pb.float().uniform(2);
|
|
107
|
+
scope.zSubsurfaceProfilePreset = pb.float().uniform(2);
|
|
151
108
|
}
|
|
152
|
-
if (this.
|
|
109
|
+
if (this.needFragmentColorInput()) {
|
|
153
110
|
scope.$l.albedo = this.calculateAlbedoColor(scope);
|
|
154
111
|
if (this.vertexColor) {
|
|
155
112
|
scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));
|
|
156
113
|
}
|
|
157
|
-
if (
|
|
114
|
+
if (renderPassType === RENDER_PASS_TYPE_LIGHT) {
|
|
158
115
|
scope.$l.normalInfo = this.calculateNormalAndTBN(scope, scope.$inputs.worldPos, scope.$inputs.wNorm, scope.$inputs.wTangent, scope.$inputs.wBinormal);
|
|
159
116
|
scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);
|
|
160
117
|
if (this.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {
|
|
161
118
|
scope.$l.outRoughness = pb.vec4();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
scope.$l.
|
|
166
|
-
scope.$l.sssFactor = pb.mul(pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)), this.getSubsurfaceIntensity(scope));
|
|
167
|
-
if (this.subsurfaceTexture) {
|
|
168
|
-
scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);
|
|
169
|
-
}
|
|
170
|
-
scope.litColor = pb.add(scope.litColor, pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor));
|
|
119
|
+
const writeSSSDiffuse = !!this._subsurfaceProfile && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_DIFFUSE);
|
|
120
|
+
const writeSSSTransmission = !!this._subsurfaceProfile && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_TRANSMISSION);
|
|
121
|
+
if (writeSSSDiffuse) {
|
|
122
|
+
scope.$l.sssDiffuse = pb.vec4();
|
|
171
123
|
}
|
|
124
|
+
if (writeSSSTransmission) {
|
|
125
|
+
scope.$l.sssTransmission = pb.vec4();
|
|
126
|
+
}
|
|
127
|
+
if (writeSSSDiffuse && writeSSSTransmission) {
|
|
128
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, scope.outRoughness, scope.sssDiffuse, scope.sssTransmission);
|
|
129
|
+
} else if (writeSSSDiffuse) {
|
|
130
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, scope.outRoughness, scope.sssDiffuse);
|
|
131
|
+
} else if (writeSSSTransmission) {
|
|
132
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, scope.outRoughness, undefined, scope.sssTransmission);
|
|
133
|
+
} else {
|
|
134
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, scope.outRoughness);
|
|
135
|
+
}
|
|
136
|
+
const writeSSSProfile = !!this._subsurfaceProfile && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_PROFILE);
|
|
137
|
+
scope.$l.sssProfile = writeSSSProfile ? this.buildSubsurfaceProfile(scope) : pb.vec4(0);
|
|
138
|
+
scope.$l.sssParams = writeSSSProfile ? scope.sssParams ?? pb.vec4(0) : pb.vec4(0);
|
|
172
139
|
/*
|
|
173
140
|
scope.outRoughness = pb.vec4(
|
|
174
141
|
pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)),
|
|
175
142
|
scope.outRoughness.a
|
|
176
143
|
);
|
|
177
|
-
*/ this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a), scope.outRoughness, pb.vec4(pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)), 1));
|
|
144
|
+
*/ this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a), scope.outRoughness, pb.vec4(pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)), 1), scope.sssProfile, scope.sssParams, writeSSSDiffuse ? scope.sssDiffuse : undefined, writeSSSTransmission ? scope.sssTransmission : undefined, writeSSSProfile);
|
|
178
145
|
} else {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
scope.$l.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
scope.litColor = pb.add(scope.litColor, pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor));
|
|
146
|
+
const writeSSSDiffuse = !!this._subsurfaceProfile && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_DIFFUSE);
|
|
147
|
+
const writeSSSTransmission = !!this._subsurfaceProfile && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_TRANSMISSION);
|
|
148
|
+
if (writeSSSDiffuse) {
|
|
149
|
+
scope.$l.sssDiffuse = pb.vec4();
|
|
150
|
+
}
|
|
151
|
+
if (writeSSSTransmission) {
|
|
152
|
+
scope.$l.sssTransmission = pb.vec4();
|
|
188
153
|
}
|
|
189
|
-
|
|
154
|
+
if (writeSSSDiffuse && writeSSSTransmission) {
|
|
155
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, undefined, scope.sssDiffuse, scope.sssTransmission);
|
|
156
|
+
} else if (writeSSSDiffuse) {
|
|
157
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, undefined, scope.sssDiffuse);
|
|
158
|
+
} else if (writeSSSTransmission) {
|
|
159
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN, undefined, undefined, scope.sssTransmission);
|
|
160
|
+
} else {
|
|
161
|
+
scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.normalInfo.normal, scope.viewVec, scope.albedo, scope.normalInfo.TBN);
|
|
162
|
+
}
|
|
163
|
+
const writeSSSProfile = !!this._subsurfaceProfile && !!(this.drawContext.materialFlags & MaterialVaryingFlags.SSS_STORE_PROFILE);
|
|
164
|
+
scope.$l.sssProfile = writeSSSProfile ? this.buildSubsurfaceProfile(scope) : pb.vec4(0);
|
|
165
|
+
scope.$l.sssParams = writeSSSProfile ? scope.sssParams ?? pb.vec4(0) : pb.vec4(0);
|
|
166
|
+
this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a), undefined, undefined, scope.sssProfile, scope.sssParams, writeSSSDiffuse ? scope.sssDiffuse : undefined, writeSSSTransmission ? scope.sssTransmission : undefined, writeSSSProfile);
|
|
190
167
|
}
|
|
191
168
|
} else {
|
|
192
169
|
this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);
|
|
@@ -197,12 +174,53 @@ import { Vector3 } from '@zephyr3d/base';
|
|
|
197
174
|
}
|
|
198
175
|
applyUniformValues(bindGroup, ctx, pass) {
|
|
199
176
|
super.applyUniformValues(bindGroup, ctx, pass);
|
|
200
|
-
if (this.
|
|
201
|
-
|
|
202
|
-
bindGroup.setValue('
|
|
203
|
-
bindGroup.setValue('
|
|
204
|
-
bindGroup.setValue('
|
|
177
|
+
if (!!this._subsurfaceProfile && this.needFragmentColor(ctx) && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
|
|
178
|
+
const profile = this._subsurfaceProfile;
|
|
179
|
+
bindGroup.setValue('zSubsurfaceProfileId', profile?.slot ?? 0);
|
|
180
|
+
bindGroup.setValue('zSubsurfaceProfileScale', profile?.scale ?? 0);
|
|
181
|
+
bindGroup.setValue('zSubsurfaceProfileStrength', profile?.strength ?? 0);
|
|
182
|
+
bindGroup.setValue('zSubsurfaceProfilePreset', profile?.presetIndex ?? 0);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
_createHash() {
|
|
186
|
+
return `${super._createHash()}:${this._subsurfaceProfile ? 1 : 0}`;
|
|
187
|
+
}
|
|
188
|
+
buildSubsurfaceProfile(scope) {
|
|
189
|
+
const pb = scope.$builder;
|
|
190
|
+
const hasExplicitTransmissionAuthoring = !!(this.transmissionTexture || this.thicknessTexture);
|
|
191
|
+
scope.$l.sssMask = pb.float(1);
|
|
192
|
+
scope.$l.sssScatterSoftness = pb.float(0);
|
|
193
|
+
scope.$l.sssTransmissionMask = pb.float(0);
|
|
194
|
+
scope.$l.sssTransmissionAuthor = pb.float(1);
|
|
195
|
+
scope.$l.sssThicknessScale = pb.clamp(pb.div(scope.zThicknessFactor ?? 0, pb.add(scope.zThicknessFactor ?? 0, 1)), 0, 1);
|
|
196
|
+
scope.$l.sssThinAuthorMask = pb.sub(1, scope.sssThicknessScale);
|
|
197
|
+
if (this.subsurfaceTexture) {
|
|
198
|
+
scope.$l.sssTexel = this.sampleSubsurfaceTexture(scope);
|
|
199
|
+
scope.sssMask = pb.clamp(scope.sssTexel.r, 0, 1);
|
|
200
|
+
scope.sssScatterSoftness = pb.clamp(scope.sssTexel.g, 0, 1);
|
|
201
|
+
}
|
|
202
|
+
if (this.transmissionTexture) {
|
|
203
|
+
scope.sssTransmissionAuthor = pb.mul(scope.sssTransmissionAuthor, pb.clamp(this.sampleTransmissionTexture(scope).r, 0, 1));
|
|
204
|
+
}
|
|
205
|
+
if (this.thicknessTexture) {
|
|
206
|
+
scope.$l.sssThicknessSample = pb.clamp(this.sampleThicknessTexture(scope).g, 0, 1);
|
|
207
|
+
scope.sssThinAuthorMask = pb.clamp(pb.mix(pb.sub(1, scope.sssThicknessSample), pb.sub(1, pb.mul(scope.sssThicknessSample, scope.sssThicknessScale)), pb.add(0.35, pb.mul(scope.sssThicknessScale, 0.65))), 0, 1);
|
|
208
|
+
}
|
|
209
|
+
scope.$l.sssAuthoredTransmissionMask = pb.clamp(pb.mul(scope.sssTransmissionAuthor, scope.sssThinAuthorMask), 0, 1);
|
|
210
|
+
scope.sssTransmissionMask = pb.clamp(pb.max(scope.sssTransmissionMask, scope.sssAuthoredTransmissionMask), 0, 1);
|
|
211
|
+
scope.$l.sssScatterStrengthMask = pb.clamp(pb.add(pb.mul(scope.sssMask, 0.82), pb.mul(scope.sssScatterSoftness, 0.38)), 0, 1);
|
|
212
|
+
scope.$l.sssScatterWidthMask = pb.clamp(pb.max(scope.sssMask, pb.mul(scope.sssScatterSoftness, 0.9)), 0, 1);
|
|
213
|
+
scope.$l.sssStrength = pb.mul(this.getSubsurfaceProfileStrength(scope), scope.sssScatterStrengthMask);
|
|
214
|
+
scope.$l.sssWidthBase = pb.mul(this.getSubsurfaceProfileScale(scope), scope.sssScatterWidthMask);
|
|
215
|
+
scope.$l.sssWidth = pb.clamp(pb.div(scope.sssWidthBase, pb.add(scope.sssWidthBase, 1)), 0, 0.999);
|
|
216
|
+
if (!hasExplicitTransmissionAuthoring) {
|
|
217
|
+
scope.$l.sssProfileFallbackMask = pb.clamp(pb.add(pb.mul(scope.sssMask, 0.12), pb.add(pb.mul(scope.sssStrength, 0.18), pb.mul(scope.sssWidth, 0.24))), 0, 0.42);
|
|
218
|
+
scope.sssTransmissionMask = pb.max(scope.sssTransmissionMask, scope.sssProfileFallbackMask);
|
|
205
219
|
}
|
|
220
|
+
scope.$l.sssSlotEncoded = pb.div(this.getSubsurfaceProfileId(scope), 255);
|
|
221
|
+
scope.$l.sssPresetEncoded = pb.div(this.getSubsurfaceProfilePreset(scope), 255);
|
|
222
|
+
scope.$l.sssParams = pb.vec4(scope.sssSlotEncoded, scope.sssWidth, scope.sssPresetEncoded, pb.add(0.75, pb.mul(scope.sssScatterSoftness, 0.25)));
|
|
223
|
+
return pb.vec4(scope.sssStrength, scope.sssStrength, scope.sssStrength, scope.sssTransmissionMask);
|
|
206
224
|
}
|
|
207
225
|
}
|
|
208
226
|
|