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