Skip to content
Snippets Groups Projects
Select Git revision
  • 49cfaa6140bfa70714d27ea63285f2c2268e6485
  • master default protected
  • rednatco-v2
  • base-pairs-ladder
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

intra-unit-link-cylinder.ts

Blame
  • text.frag 1.83 KiB
    /**
     * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    precision highp float;
    precision highp int;
    
    #pragma glslify: import('./chunks/common-frag-params.glsl')
    #pragma glslify: import('./chunks/color-frag-params.glsl')
    
    uniform sampler2D tFont;
    
    uniform vec3 uBorderColor;
    uniform float uBorderWidth;
    uniform vec3 uBackgroundColor;
    uniform float uBackgroundOpacity;
    
    varying vec2 vTexCoord;
    
    const float smoothness = 32.0;
    const float gamma = 2.2;
    
    void main2(){
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    }
    
    void main(){
        #pragma glslify: import('./chunks/assign-material-color.glsl')
    
        if (vTexCoord.x > 1.0) {
            gl_FragColor = vec4(uBackgroundColor, uBackgroundOpacity);
        } else {
            // retrieve signed distance
            float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth;
    
            // perform adaptive anti-aliasing of the edges
            float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5);
            float a = smoothstep(0.5 - w, 0.5 + w, sdf);
    
            // gamma correction for linear attenuation
            a = pow(a, 1.0 / gamma);
    
            if (a < 0.5) discard;
            material.a *= a;
    
            // add border
            float t = 0.5 + uBorderWidth;
            if (uBorderWidth > 0.0 && sdf < t) {
                material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf));
            }
    
            gl_FragColor = material;
        }
    
        #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
            if (uAlpha < uPickingAlphaThreshold)
                discard; // ignore so the element below can be picked
        #else
            #pragma glslify: import('./chunks/apply-marker-color.glsl')
            #pragma glslify: import('./chunks/apply-fog.glsl')
        #endif
    }