aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-pass1-curve-weight.glsl
blob: a489949b44f95d27c097e9c6bddaef91860d0cc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

    if( gcv_TexCoord.x == 0.0 && gcv_TexCoord.y == 0.0 ) {
        // pass-1: Lines
        color = gcu_ColorStatic.rgb;
        alpha = 1.0;
    } else {
        // pass-1: curves
        const vec2 rtex = vec2( abs(gcv_TexCoord.x), abs(gcv_TexCoord.y) - 0.1 );

        const vec2 dtx = dFdx(rtex);
        const vec2 dty = dFdy(rtex);
          
        const float w = gcu_Weight;
        const float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0;
        const float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd);

        const float aph = 2.0 - 2.0*w;
        
        const float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
        const vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));

        color = gcu_ColorStatic.rgb;
        alpha = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
    }