/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../../../core/compilerUtils","../../../../../../../core/floatRGBA","./DecodeSymbolColor.glsl","../../../../core/shaderLibrary/util/RgbaFloatEncoding.glsl","../../../../core/shaderModules/Float2Uniform","../../../../core/shaderModules/Float4DrawUniform","../../../../core/shaderModules/IntegerDrawUniform","../../../../core/shaderModules/interfaces","../../../../core/shaderModules/Texture2DUniform","../../../../lib/VertexAttribute"],(function(o,e,r,n,t,a,l,d,i,c,x){"use strict";var m;o.ComponentDataType=void 0,(m=o.ComponentDataType||(o.ComponentDataType={}))[m.Uniform=0]="Uniform",m[m.Varying=1]="Varying",m[m.COUNT=2]="COUNT";const C=429496.7296;function s(o,e){r.packFloatRGBA(o/C*.5+.5,e)}function f(r,n){switch(n.componentData){case o.ComponentDataType.Varying:return u(r);case o.ComponentDataType.Uniform:return v(r);case o.ComponentDataType.COUNT:return;default:e.neverReached(n.componentData)}}function u(o){const{vertex:e,fragment:r}=o;e.include(t.RgbaFloatEncoding),e.uniforms.add([new c.Texture2DUniform("componentColorTex"),new a.Float2Uniform("componentColorTexInvDim")]),o.attributes.add(x.VertexAttribute.COMPONENTINDEX,"float"),o.varyings.add("vExternalColorMixMode","mediump float"),o.varyings.add("vExternalColor","vec4"),o.include(n.DecodeSymbolColor),e.constants.add("elevationScale","float",2*C),e.code.add(i.glsl`vec4 _readComponentColor() {
float normalizedIndex = (componentIndex * 2.0 + 0.5) * componentColorTexInvDim.x;
vec2 indexCoord = vec2(
mod(normalizedIndex, 1.0),
(floor(normalizedIndex) + 0.5) * componentColorTexInvDim.y
);
return texture2D(componentColorTex, indexCoord);
}
float readElevationOffset() {
float normalizedIndex = (componentIndex * 2.0 + 1.5) * componentColorTexInvDim.x;
vec2 indexCoord = vec2(
mod(normalizedIndex, 1.0),
(floor(normalizedIndex) + 0.5) * componentColorTexInvDim.y
);
return (rgba2float(texture2D(componentColorTex, indexCoord)) - 0.5) * elevationScale;
}
vec4 forwardExternalColor(out bool castShadows) {
vec4 componentColor = _readComponentColor() * 255.0;
float shadowFlag = mod(componentColor.b * 255.0, 2.0);
componentColor.b -= shadowFlag;
castShadows = shadowFlag >= 1.0;
int decodedColorMixMode;
vExternalColor = decodeSymbolColor(componentColor, decodedColorMixMode) * 0.003921568627451;
vExternalColorMixMode = float(decodedColorMixMode) + 0.5;
return vExternalColor;
}`),r.code.add(i.glsl`void readExternalColor(out vec4 externalColor, out int externalColorMixMode) {
externalColor = vExternalColor;
externalColorMixMode = int(vExternalColorMixMode);
}`)}function v(o){const{vertex:e,fragment:r}=o;e.uniforms.add(new l.Float4DrawUniform("externalColor",(o=>o.componentParameters.externalColor))),r.uniforms.add(new d.IntegerDrawUniform("externalColorMixMode",(o=>o.componentParameters.externalColorMixMode))),o.varyings.add("vExternalColor","vec4"),e.code.add(i.glsl`float readElevationOffset() {
return 0.0;
}
vec4 forwardExternalColor(out bool castShadows) {
vExternalColor = externalColor;
castShadows = true;
return externalColor;
}`),r.code.add(i.glsl`void readExternalColor(out vec4 color, out int colorMixMode) {
color = vExternalColor;
colorMixMode = externalColorMixMode;
}`)}o.ComponentData=f,o.MAX_ELEVATION_OFFSET=C,o.encodeElevationOffset=s,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
