declare const fsShader = "#version 300 es\n#define SHADER_NAME terrainmap-shader\n\nprecision highp float;\n\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\n\nuniform bool isReadoutDepth;\nuniform bool isContoursDepth;\n\nuniform float contourReferencePoint;\nuniform float contourInterval;\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nin vec4 positions;\n\nout vec4 fragColor;\n\nin vec3 worldPos; // we export this from vertex shader (by injecting into it).\n\n\nvoid main(void) {\n   geometry.uv = vTexCoord;\n\n   vec3 normal;\n   if (flatShading) {\n#ifdef DERIVATIVES_AVAILABLE\n      normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n#else\n      normal = vec3(0.0, 0.0, 1.0);\n#endif\n   } else {\n      normal = normals_commonspace;\n   }\n\n   vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\n\n   float propertyValue = 0.0; // XXX this must be fixed.\n\n   // Discard transparent pixels.\n   if (!picking_uActive && color.w < 0.99) {\n         discard;\n         return;\n   }\n\n   // Picking pass.\n   if (picking_uActive) {\n      if (isReadoutDepth) {\n         // Readout should not be surface height (z value).\n         float depth = abs(worldPos.z);\n         \n         // Express in 255 system.\n         float r = 0.0;\n         float g = 0.0;\n         float b = 0.0;\n\n         if (depth >= (256.0 * 256.0) - 1.0) {\n            r = floor(depth / (256.0 * 256.0));\n            depth -= r * (256.0 * 256.0);\n         }\n\n         if (depth >= 256.0 - 1.0) {\n            g = floor(depth / 256.0);\n            depth -= g * 256.0;\n         }\n\n         b = floor(depth);\n\n         fragColor = vec4(r / 255.0, g / 255.0, b / 255.0,  1.0);\n      }\n      else {\n         // Readout should be surface property.\n         // Send texture coordinates.\n         float s = vTexCoord.x;\n         float t = vTexCoord.y;\n\n         fragColor = vec4(s, t, 0.0, 1.0);\n      }\n\n      return;\n   }\n\n   bool is_contours = contourReferencePoint != -1.0 && contourInterval != -1.0;\n   if (is_contours) {\n      // Contours are made of either depths or properties.\n      float val = isContoursDepth ? (abs(worldPos.z) - contourReferencePoint) / contourInterval\n                                  : (propertyValue - contourReferencePoint) / contourInterval;\n\n      float f  = fract(val);\n      float df = fwidth(val);\n\n      // keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smootstep from/to no of pixels distance fronm contour line.\n      float c = smoothstep(0.0, df * 2.0, f);\n\n      color = color * vec4(c, c, c, 1.0);\n   }\n\n   // Use normal lighting.\n   vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n   fragColor = vec4(lightColor, color.a * opacity);\n\n   DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n";
export default fsShader;
