declare const _default: "#version 300 es\n#define SHADER_NAME grid3d-cell-fragment-shader\n\nin vec3 cameraPosition;\nin vec4 position_commonspace;\nin vec4 vColor;\n\nflat in vec3 normal;\nflat in int vertexIndex;\nflat in float property;\n\nout vec4 fragColor;\n\nuniform sampler2D colormap;\n\n// Calculate color from propertyValue using discrete colormap.\nvec4 getDiscretePropertyColor (float propertyValue) {\n   vec4 color = vec4(1.0, 1.0, 1.0, 1.0);\n   // On some machines (like in docker container), float comparison and texture lookup may fail due to precision.\n   // Use this tolerance for comparison and to shift the lookup position.\n   float tolerance = (1.0 / grid.colormapSize) * 0.5;\n\n   if (propertyValue < grid.colormapRangeMin - tolerance || propertyValue > grid.colormapRangeMax + tolerance) {\n      // Out of range. Use clampcolor.\n      if (grid.isClampColor) {\n         color = grid.colormapClampColor;\n         if( color[3] == 0.0 ) {\n            discard;\n         }\n      }\n      else {\n         // Use min/max color to clamp.\n         float p = clamp (propertyValue, grid.colormapRangeMin, grid.colormapRangeMax);\n         float x = p / grid.colormapSize;\n         color = texture(colormap, vec2(x + tolerance, 0.5));\n      }\n   }\n   else {\n      float x = propertyValue / grid.colormapSize;\n      color = texture(colormap, vec2(x + tolerance, 0.5));\n   }\n      \n   return color;\n}\n\nvec4 getContinuousPropertyColor (float propertyValue) {\n   vec4 color = vec4(1.0, 1.0, 1.0, 1.0);\n   float normalizedValue = (propertyValue - grid.colormapRangeMin) / (grid.colormapRangeMax - grid.colormapRangeMin);\n   if (normalizedValue < 0.0 || normalizedValue > 1.0) {\n      // Out of range. Use clampcolor.\n      if (grid.isClampColor) {\n         color = grid.colormapClampColor;\n         if( color[3] == 0.0 ) {\n            discard;\n         }\n      }\n      else {\n         // Use min/max color to clamp.\n         normalizedValue = clamp (normalizedValue, 0.0, 1.0);         \n         color = texture(colormap, vec2(normalizedValue, 0.5));\n      }\n   }\n   else {\n      color = texture(colormap, vec2(normalizedValue, 0.5));\n   }\n   return color;\n}\n\nvoid main(void) {\n\n   if (picking.isActive > 0.5 && !(picking.isAttribute > 0.5)) {\n      fragColor = encodeIndexToRGB(vertexIndex);      \n      return;\n   }\n\n   if (isnan(property)) {\n      vec3 lightColor = lighting_getLightColor(grid.undefinedPropertyColor.rgb, cameraPosition, position_commonspace.xyz, normal);\n      fragColor = vec4(lightColor, vColor.a);\n      DECKGL_FILTER_COLOR(fragColor, geometry);\n      return;\n   }\n\n   // This may happen due to GPU interpolation precision causing color artifacts.\n   float propertyValue = clamp(property, grid.valueRangeMin, grid.valueRangeMax);\n      \n   vec4 color = grid.isColoringDiscrete ? getDiscretePropertyColor(round(propertyValue)) : getContinuousPropertyColor(propertyValue);\n\n   // Use two sided phong lighting. This has no effect if \"material\" property is not set.\n   vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n   fragColor = vec4(lightColor, vColor.a);\n   DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n";
export default _default;
