/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{FloatPassUniform as o}from"../../shaderModules/FloatPassUniform.js";import{glsl as e}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as r}from"../../shaderModules/Texture2DPassUniform.js";function l(l){l.fragment.uniforms.add(new r("u_colormap",o=>o.u_colormap),new o("u_colormapOffset",o=>o.colormap.u_colormapOffset),new o("u_colormapMaxIndex",o=>o.colormap.u_colormapMaxIndex),new o("u_opacity",o=>o.common.u_opacity)),l.fragment.code.add(e`vec4 colormap(vec4 currentPixel, bool isFloat) {
float colorIndex = isFloat ? currentPixel.r - u_colormapOffset : currentPixel.r * 255.0 - u_colormapOffset;
vec4 result;
if (currentPixel.a == 0.0 || colorIndex > u_colormapMaxIndex) {
result = vec4(0.0, 0.0, 0.0, 0.0);
} else {
vec2 texelCoordinates = vec2((colorIndex + 0.5), 0.5);
result = texelFetch(u_colormap, ivec2(texelCoordinates), 0);
}
return result;
}`)}export{l as Colormap};
