/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../../chunks/_rollupPluginBabelHelpers","../../../../../../chunks/vec3f32","../attributes/VertexTextureCoordinates.glsl","../../shaderModules/Float3DrawUniform","../../shaderModules/Float3PassUniform","../../shaderModules/interfaces","../../shaderModules/Texture2DDrawUniform","../../shaderModules/Texture2DPassUniform","../../shaderTechnique/BindType","../../../lib/GLTextureMaterial"],(function(e,s,r,t,o,a,i,n,l,u,c){"use strict";const d=r.fromValues(0,.6,.2);var m;e.PBRMode=void 0,(m=e.PBRMode||(e.PBRMode={}))[m.Disabled=0]="Disabled",m[m.Normal=1]="Normal",m[m.Schematic=2]="Schematic",m[m.Water=3]="Water",m[m.WaterOnIntegratedMesh=4]="WaterOnIntegratedMesh",m[m.COUNT=5]="COUNT";let p=function(e){function r(){return e.apply(this,arguments)||this}return s._inheritsLoose(r,e),r}(c.GLTextureMaterialBindParameters);function x(s,r){const c=s.fragment,d=r.hasMetalnessAndRoughnessTexture||r.hasEmissionTexture||r.hasOcclusionTexture;if(r.pbrMode===e.PBRMode.Normal&&d&&s.include(t.VertexTextureCoordinates,r),r.pbrMode!==e.PBRMode.Schematic)if(r.pbrMode!==e.PBRMode.Disabled){if(r.pbrMode===e.PBRMode.Normal){c.code.add(i.glsl`vec3 mrr;
vec3 emission;
float occlusion;`);const e=r.supportsTextureAtlas,s=r.pbrTextureBindType;r.hasMetalnessAndRoughnessTexture&&(c.uniforms.add(s===u.BindType.Pass?l.createTexture2DPassSizeUniforms("texMetallicRoughness",(e=>e.textureMetallicRoughness),e):n.createTexture2DDrawSizeUniforms("texMetallicRoughness",(e=>e.textureMetallicRoughness),e)),c.code.add(i.glsl`void applyMetallnessAndRoughness(TextureLookupParameter params) {
vec3 metallicRoughness = textureLookup(texMetallicRoughness, params).rgb;
mrr[0] *= metallicRoughness.b;
mrr[1] *= metallicRoughness.g;
}`)),r.hasEmissionTexture&&(c.uniforms.add(s===u.BindType.Pass?l.createTexture2DPassSizeUniforms("texEmission",(e=>e.textureEmissive),e):n.createTexture2DDrawSizeUniforms("texEmission",(e=>e.textureEmissive),e)),c.code.add(i.glsl`void applyEmission(TextureLookupParameter params) {
emission *= textureLookup(texEmission, params).rgb;
}`)),r.hasOcclusionTexture?(c.uniforms.add(s===u.BindType.Pass?l.createTexture2DPassSizeUniforms("texOcclusion",(e=>e.textureOcclusion),e):n.createTexture2DDrawSizeUniforms("texOcclusion",(e=>e.textureOcclusion),e)),c.code.add(i.glsl`void applyOcclusion(TextureLookupParameter params) {
occlusion *= textureLookup(texOcclusion, params).r;
}
float getBakedOcclusion() {
return occlusion;
}`)):c.code.add(i.glsl`float getBakedOcclusion() { return 1.0; }`),c.uniforms.add(s===u.BindType.Pass?[new a.Float3PassUniform("emissionFactor",(e=>e.emissiveFactor)),new a.Float3PassUniform("mrrFactors",(e=>e.mrrFactors))]:[new o.Float3DrawUniform("emissionFactor",(e=>e.emissiveFactor)),new o.Float3DrawUniform("mrrFactors",(e=>e.mrrFactors))]),c.code.add(i.glsl`
    void applyPBRFactors() {
      mrr = mrrFactors;
      emission = emissionFactor;
      occlusion = 1.0;
      ${d?"vtc.uv = vuv0;":""}
      ${r.hasMetalnessAndRoughnessTexture?r.supportsTextureAtlas?"vtc.size = texMetallicRoughnessSize; applyMetallnessAndRoughness(vtc);":"applyMetallnessAndRoughness(vtc);":""}
      ${r.hasEmissionTexture?r.supportsTextureAtlas?"vtc.size = texEmissionSize; applyEmission(vtc);":"applyEmission(vtc);":""}
      ${r.hasOcclusionTexture?r.supportsTextureAtlas?"vtc.size = texOcclusionSize; applyOcclusion(vtc);":"applyOcclusion(vtc);":""}
    }
  `)}}else c.code.add(i.glsl`float getBakedOcclusion() { return 1.0; }`);else c.code.add(i.glsl`vec3 mrr = vec3(0.0, 0.6, 0.2);
vec3 emission = vec3(0.0);
float occlusion = 1.0;
void applyPBRFactors() {}
float getBakedOcclusion() { return 1.0; }`)}e.PBRBindParameters=p,e.PBRSchematicMRRValues=d,e.PhysicallyBasedRenderingParameters=x,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
