UNPKG

@webviz/subsurface-viewer

Version:

3D visualization component for subsurface reservoir data

3 lines (2 loc) 1.77 kB
declare const _default: "#version 300 es\n#define SHADER_NAME grid3d-node-fragment-shader\n\nin vec3 cameraPosition;\nin vec4 position_commonspace;\nin float property;\nin vec4 vColor;\n\nflat in vec3 normal;\nflat in int vertexIndex;\n\nout vec4 fragColor;\n\nuniform sampler2D colormap;\n\nvec4 getPropertyColor (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\n\nvoid main(void) {\n if (picking.isActive > 0.5 && !(picking.isAttribute > 0.5)) {\n fragColor = encodeVertexIndexToRGB(vertexIndex); \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 = getPropertyColor(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;