molstar
Version:
A comprehensive macromolecular library.
7 lines (6 loc) • 2.03 kB
TypeScript
/**
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
export declare const text_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include common_frag_params\n#include color_frag_params\n#include common_clip\n\nuniform sampler2D tFont;\n\nuniform vec3 uBorderColor;\nuniform float uBorderWidth;\nuniform vec3 uBackgroundColor;\nuniform float uBackgroundOpacity;\n\nvarying vec2 vTexCoord;\n\nconst float smoothness = 32.0;\nconst float gamma = 2.2;\n\nvoid main2(){\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n}\n\nvoid main(){\n #include clip_pixel\n\n float fragmentDepth = gl_FragCoord.z;\n bool interior = false;\n #include assign_material_color\n\n if (vTexCoord.x > 1.0) {\n gl_FragColor = vec4(uBackgroundColor, uBackgroundOpacity * material.a);\n } else {\n // retrieve signed distance\n float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth;\n\n // perform adaptive anti-aliasing of the edges\n float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5);\n float a = smoothstep(0.5 - w, 0.5 + w, sdf);\n\n // gamma correction for linear attenuation\n a = pow(a, 1.0 / gamma);\n\n if (a < 0.5) discard;\n material.a *= a;\n\n // add border\n float t = 0.5 + uBorderWidth;\n if (uBorderWidth > 0.0 && sdf < t) {\n material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf));\n }\n\n gl_FragColor = material;\n }\n\n #if defined(dRenderVariant_pick)\n #include check_picking_alpha\n #elif defined(dRenderVariant_depth)\n gl_FragColor = material;\n #elif defined(dRenderVariant_marking)\n gl_FragColor = material;\n #elif defined(dRenderVariant_color)\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #endif\n}\n";