@webviz/subsurface-viewer
Version:
3D visualization component for subsurface reservoir data
3 lines (2 loc) • 2.59 kB
TypeScript
declare const _default: "#version 300 es\n#define SHADER_NAME map-fragment-shader\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nin vec3 worldPos;\nin float property;\nflat in int vertexIndex;\n\n// Uniforms\nuniform sampler2D colormap;\n\nout vec4 fragColor;\n\n\nvoid main(void) { \n geometry.uv = vTexCoord;\n\n vec3 normal = normals_commonspace;\n\n if(!map.smoothShading || (normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0)) {\n normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n }\n\n //Picking pass.\n if (picking.isActive > 0.5 && !(picking.isAttribute > 0.5)) {\n fragColor = encodeVertexIndexToRGB(vertexIndex);\n return;\n }\n\n vec4 color = vec4(1.0, 1.0, 1.0, 1.0);\n float propertyValue = property;\n\n // This may happen due to GPU interpolation precision causing color artifacts.\n propertyValue = clamp(propertyValue, map.valueRangeMin, map.valueRangeMax);\n\n float x = (propertyValue - map.colormapRangeMin) / (map.colormapRangeMax - map.colormapRangeMin);\n if (x < 0.0 || x > 1.0) {\n // Out of range. Use clampcolor.\n if (map.isClampColor) {\n color = vec4(map.colormapClampColor.rgb, 1.0);\n }\n else if (map.isColormapClampColorTransparent) {\n discard;\n return;\n }\n else {\n // Use min/max color to clamp.\n x = max(0.0, x);\n x = min(1.0, x);\n\n color = texture(colormap, vec2(x, 0.5));\n }\n }\n else {\n color = texture(colormap, vec2(x, 0.5));\n }\n\n bool is_contours = map.contourReferencePoint != -1.0 && map.contourInterval != -1.0;\n if (is_contours) {\n float val = map.isContoursDepth ? (abs(worldPos.z) - map.contourReferencePoint) / map.contourInterval\n : (propertyValue - map.contourReferencePoint) / map.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 from 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 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\n fragColor = vec4(lightColor, vColor.a);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n";
export default _default;