/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{clamp as e}from"../../../../../../core/mathUtils.js";import{isColor as s}from"../ShaderOutput.js";import{VertexTextureCoordinates as i}from"../attributes/VertexTextureCoordinates.glsl.js";import{Gamma as o}from"../shading/Gamma.glsl.js";import{Float3DrawUniform as r}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as m}from"../../shaderModules/Float3PassUniform.js";import{FloatDrawUniform as t}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as n}from"../../shaderModules/FloatPassUniform.js";import{If as a,glsl as v}from"../../shaderModules/glsl.js";import{Texture2DDrawUniform as l}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as u}from"../../shaderModules/Texture2DPassUniform.js";import{maxEmissiveStrength as f}from"../../../shaders/oitResolution.glsl.js";const c=1,d=1;function g(c,g){if(!s(g.output))return;c.fragment.include(o);const{emissionSource:x,hasEmissiveTextureTransform:p,bindType:h}=g,j=3===x||4===x||5===x;j&&(c.include(i,g),c.fragment.uniforms.add(1===h?new u("texEmission",e=>e.textureEmissive):new l("texEmission",e=>e.textureEmissive)));const T=2===x||j;T&&c.fragment.uniforms.add(1===h?new m("emissiveBaseColor",e=>e.emissiveBaseColor):new r("emissiveBaseColor",e=>e.emissiveBaseColor));const C=0!==x;if(C&&!(7===x||6===x||4===x||5===x)){const s=s=>e(s??0,0,f);c.fragment.uniforms.add(1===h?new n("emissiveStrength",e=>s(e.emissiveStrength)):new t("emissiveStrength",e=>s(e.emissiveStrength)))}const b=7===x,F=5===x,S=1===x||6===x||b;c.fragment.code.add(v`
    vec4 getEmissions(vec3 symbolColor) {
      vec4 emissions = ${T?F?"emissiveSource == 0 ? vec4(emissiveBaseColor, 1.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(emissiveBaseColor, 1.0)":S?b?"emissiveSource == 0 ? vec4(0.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(linearizeGamma(symbolColor), 1.0)":"vec4(0.0)"};
      ${a(j,`${a(F,`if(emissiveSource == 0) {\n              vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n              emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);\n           }`,`vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n           emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);`)}\n        emissions.a = emissions.rgb == vec3(0.0) ? 0.0: emissions.a;`)}
      ${a(C,`emissions.rgb *= emissiveStrength * ${v.float(d)};`)}
      return emissions;
    }
  `)}export{g as Emissions,d as emissiveStrengthBoost,c as emissiveStrengthDefault};
