summaryrefslogtreecommitdiffstats
path: root/src/graphs2d/data/LineShader.qep
blob: 456bff4fa48074e0e58ffcd3f221f9f66c37ce22 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
    "QEP": {
        "QQEM": "0.41",
        "connections": [
            {
                "fromId": 0,
                "toId": 3
            },
            {
                "fromId": 3,
                "toId": 1
            }
        ],
        "exportDirectory": ".",
        "exportFlags": 2,
        "exportName": "lineshaderhorizontal",
        "nodes": [
            {
                "fragmentCode": [
                    "void main() {",
                    "    @nodes",
                    "    fragColor = fragColor * qt_Opacity;",
                    "}"
                ],
                "name": "Main",
                "nodeId": 0,
                "type": 0,
                "vertexCode": [
                    "void main() {",
                    "    texCoord = qt_MultiTexCoord0;",
                    "    fragCoord = qt_Vertex.xy;",
                    "    vec2 vertCoord = qt_Vertex.xy;",
                    "    @nodes",
                    "    gl_Position = qt_Matrix * vec4(vertCoord, 0.0, 1.0);",
                    "}"
                ],
                "x": 140,
                "y": 35.20000076293945
            },
            {
                "name": "Output",
                "nodeId": 1,
                "type": 1,
                "x": 140,
                "y": 588.7999877929688
            },
            {
                "fragmentCode": [
                    "float createBars(float coord, float spacing, float strokeWidth) {",
                    "    float sbar = 1.0 / spacing;",
                    "    float barWidth = strokeWidth / spacing;",
                    "    float firstPos = ((barWidth + smoothing / spacing) * 1.0);",
                    "    float p = firstPos + coord * sbar;",
                    "    //float p = (coord - 0.5) * sbar;",
                    "    float bar = abs(2.0 * fract(p) - 1.0);",
                    "    float barSmoothness = smoothing / spacing;",
                    "    bar = smoothstep(1.0 - barWidth - barSmoothness, 1.0 - barWidth + barSmoothness, bar);",
                    "    return bar;",
                    "}",
                    "",
                    "@main",
                    "{",
                    "    float line = 0.0;",
                    "#if (HORIZONTAL == 1)",
                    "    float spacing = iResolution.y * 0.5 + lineWidth + smoothing;",
                    "    line += createBars(fragCoord.y, spacing, lineWidth);",
                    "#else",
                    "    float spacing = iResolution.x * 0.5 + lineWidth + smoothing;",
                    "    line += createBars(fragCoord.x, spacing, lineWidth);",
                    "#endif",
                    "    vec3 lineColor = vec3(0.0);",
                    "    float alpha = line * color.a;",
                    "    lineColor = mix(lineColor, color.rgb, alpha);",
                    "    fragColor = vec4(lineColor, alpha);",
                    "}"
                ],
                "name": "Line",
                "nodeId": 3,
                "properties": [
                    {
                        "defaultValue": "0",
                        "name": "HORIZONTAL",
                        "type": "define",
                        "value": "1"
                    },
                    {
                        "defaultValue": "1, 1, 1, 1",
                        "name": "color",
                        "type": "color",
                        "value": "1, 1, 1, 1"
                    },
                    {
                        "defaultValue": "1",
                        "maxValue": "5",
                        "minValue": "0",
                        "name": "lineWidth",
                        "type": "float",
                        "value": "1"
                    },
                    {
                        "defaultValue": "1",
                        "maxValue": "5",
                        "minValue": "0",
                        "name": "smoothing",
                        "type": "float",
                        "value": "1"
                    }
                ],
                "type": 2,
                "x": 105,
                "y": 450.6993408203125
            }
        ],
        "version": 1
    }
}