bab03db47810b33e70b196cb8d1efcd40ac852909d38314797f6335f03315c73.json 15 KB

1
  1. {"ast":null,"code":"import { __decorate } from \"../../tslib.es6.js\";\n/* eslint-disable @typescript-eslint/naming-convention */\n\nimport { serialize, expandToProperty } from \"../../Misc/decorators.js\";\nimport { MaterialDefines } from \"../materialDefines.js\";\nimport { MaterialPluginBase } from \"../materialPluginBase.js\";\n/**\n * @internal\n */\nexport class MaterialBRDFDefines extends MaterialDefines {\n constructor() {\n super(...arguments);\n this.BRDF_V_HEIGHT_CORRELATED = false;\n this.MS_BRDF_ENERGY_CONSERVATION = false;\n this.SPHERICAL_HARMONICS = false;\n this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = false;\n }\n}\n/**\n * Plugin that implements the BRDF component of the PBR material\n */\nexport class PBRBRDFConfiguration extends MaterialPluginBase {\n /** @internal */\n _markAllSubMeshesAsMiscDirty() {\n this._internalMarkAllSubMeshesAsMiscDirty();\n }\n /**\n * Gets a boolean indicating that the plugin is compatible with a given shader language.\n * @returns true if the plugin is compatible with the shader language\n */\n isCompatible() {\n return true;\n }\n constructor(material, addToPluginList = true) {\n super(material, \"PBRBRDF\", 90, new MaterialBRDFDefines(), addToPluginList);\n this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;\n /**\n * Defines if the material uses energy conservation.\n */\n this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;\n this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;\n /**\n * LEGACY Mode set to false\n * Defines if the material uses height smith correlated visibility term.\n * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR\n * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png\n * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision\n * Not relying on height correlated will also disable energy conservation.\n */\n this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;\n this._useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;\n /**\n * LEGACY Mode set to false\n * Defines if the material uses spherical harmonics vs spherical polynomials for the\n * diffuse part of the IBL.\n * The harmonics despite a tiny bigger cost has been proven to provide closer results\n * to the ground truth.\n */\n this.useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;\n this._useSpecularGlossinessInputEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION;\n /**\n * Defines if the material uses energy conservation, when the specular workflow is active.\n * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).\n * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.\n * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.\n */\n this.useSpecularGlossinessInputEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION;\n this._internalMarkAllSubMeshesAsMiscDirty = material._dirtyCallbacks[16];\n this._enable(true);\n }\n prepareDefines(defines) {\n defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;\n defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;\n defines.SPHERICAL_HARMONICS = this._useSphericalHarmonics;\n defines.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation;\n }\n getClassName() {\n return \"PBRBRDFConfiguration\";\n }\n}\n/**\n * Default value used for the energy conservation.\n * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.\n */\nPBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;\n/**\n * Default value used for the Smith Visibility Height Correlated mode.\n * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.\n */\nPBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;\n/**\n * Default value used for the IBL diffuse part.\n * This can help switching back to the polynomials mode globally which is a tiny bit\n * less GPU intensive at the drawback of a lower quality.\n */\nPBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS = true;\n/**\n * Default value used for activating energy conservation for the specular workflow.\n * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).\n * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.\n */\nPBRBRDFConfiguration.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = true;\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsMiscDirty\")], PBRBRDFConfiguration.prototype, \"useEnergyConservation\", void 0);\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsMiscDirty\")], PBRBRDFConfiguration.prototype, \"useSmithVisibilityHeightCorrelated\", void 0);\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsMiscDirty\")], PBRBRDFConfiguration.prototype, \"useSphericalHarmonics\", void 0);\n__decorate([serialize(), expandToProperty(\"_markAllSubMeshesAsMiscDirty\")], PBRBRDFConfiguration.prototype, \"useSpecularGlossinessInputEnergyConservation\", void 0);","map":{"version":3,"names":["__decorate","serialize","expandToProperty","MaterialDefines","MaterialPluginBase","MaterialBRDFDefines","constructor","arguments","BRDF_V_HEIGHT_CORRELATED","MS_BRDF_ENERGY_CONSERVATION","SPHERICAL_HARMONICS","SPECULAR_GLOSSINESS_ENERGY_CONSERVATION","PBRBRDFConfiguration","_markAllSubMeshesAsMiscDirty","_internalMarkAllSubMeshesAsMiscDirty","isCompatible","material","addToPluginList","_useEnergyConservation","DEFAULT_USE_ENERGY_CONSERVATION","useEnergyConservation","_useSmithVisibilityHeightCorrelated","DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED","useSmithVisibilityHeightCorrelated","_useSphericalHarmonics","DEFAULT_USE_SPHERICAL_HARMONICS","useSphericalHarmonics","_useSpecularGlossinessInputEnergyConservation","DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION","useSpecularGlossinessInputEnergyConservation","_dirtyCallbacks","_enable","prepareDefines","defines","getClassName","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Materials/PBR/pbrBRDFConfiguration.js"],"sourcesContent":["import { __decorate } from \"../../tslib.es6.js\";\n/* eslint-disable @typescript-eslint/naming-convention */\n\nimport { serialize, expandToProperty } from \"../../Misc/decorators.js\";\nimport { MaterialDefines } from \"../materialDefines.js\";\nimport { MaterialPluginBase } from \"../materialPluginBase.js\";\n/**\n * @internal\n */\nexport class MaterialBRDFDefines extends MaterialDefines {\n constructor() {\n super(...arguments);\n this.BRDF_V_HEIGHT_CORRELATED = false;\n this.MS_BRDF_ENERGY_CONSERVATION = false;\n this.SPHERICAL_HARMONICS = false;\n this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = false;\n }\n}\n/**\n * Plugin that implements the BRDF component of the PBR material\n */\nexport class PBRBRDFConfiguration extends MaterialPluginBase {\n /** @internal */\n _markAllSubMeshesAsMiscDirty() {\n this._internalMarkAllSubMeshesAsMiscDirty();\n }\n /**\n * Gets a boolean indicating that the plugin is compatible with a given shader language.\n * @returns true if the plugin is compatible with the shader language\n */\n isCompatible() {\n return true;\n }\n constructor(material, addToPluginList = true) {\n super(material, \"PBRBRDF\", 90, new MaterialBRDFDefines(), addToPluginList);\n this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;\n /**\n * Defines if the material uses energy conservation.\n */\n this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;\n this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;\n /**\n * LEGACY Mode set to false\n * Defines if the material uses height smith correlated visibility term.\n * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR\n * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png\n * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision\n * Not relying on height correlated will also disable energy conservation.\n */\n this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;\n this._useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;\n /**\n * LEGACY Mode set to false\n * Defines if the material uses spherical harmonics vs spherical polynomials for the\n * diffuse part of the IBL.\n * The harmonics despite a tiny bigger cost has been proven to provide closer results\n * to the ground truth.\n */\n this.useSphericalHarmonics = PBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS;\n this._useSpecularGlossinessInputEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION;\n /**\n * Defines if the material uses energy conservation, when the specular workflow is active.\n * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).\n * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.\n * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.\n */\n this.useSpecularGlossinessInputEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION;\n this._internalMarkAllSubMeshesAsMiscDirty = material._dirtyCallbacks[16];\n this._enable(true);\n }\n prepareDefines(defines) {\n defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;\n defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;\n defines.SPHERICAL_HARMONICS = this._useSphericalHarmonics;\n defines.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation;\n }\n getClassName() {\n return \"PBRBRDFConfiguration\";\n }\n}\n/**\n * Default value used for the energy conservation.\n * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.\n */\nPBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;\n/**\n * Default value used for the Smith Visibility Height Correlated mode.\n * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.\n */\nPBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;\n/**\n * Default value used for the IBL diffuse part.\n * This can help switching back to the polynomials mode globally which is a tiny bit\n * less GPU intensive at the drawback of a lower quality.\n */\nPBRBRDFConfiguration.DEFAULT_USE_SPHERICAL_HARMONICS = true;\n/**\n * Default value used for activating energy conservation for the specular workflow.\n * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).\n * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.\n */\nPBRBRDFConfiguration.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = true;\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsMiscDirty\")\n], PBRBRDFConfiguration.prototype, \"useEnergyConservation\", void 0);\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsMiscDirty\")\n], PBRBRDFConfiguration.prototype, \"useSmithVisibilityHeightCorrelated\", void 0);\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsMiscDirty\")\n], PBRBRDFConfiguration.prototype, \"useSphericalHarmonics\", void 0);\n__decorate([\n serialize(),\n expandToProperty(\"_markAllSubMeshesAsMiscDirty\")\n], PBRBRDFConfiguration.prototype, \"useSpecularGlossinessInputEnergyConservation\", void 0);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C;;AAEA,SAASC,SAAS,EAAEC,gBAAgB,QAAQ,0BAA0B;AACtE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,SAASF,eAAe,CAAC;EACrDG,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC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AC,CAAC","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}