summaryrefslogtreecommitdiffstats
path: root/src/graphs2d/data/GridShader.qep
blob: 6f17e9a1369e83ebaca62468467ed25789ec3eda (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
{
    "QEP": {
        "QQEM": "0.43",
        "connections": [
            {
                "fromId": 0,
                "toId": 3
            },
            {
                "fromId": 3,
                "toId": 1
            }
        ],
        "exportDirectory": ".",
        "exportFlags": 2,
        "exportName": "gridshader",
        "nodes": [
            {
                "fragmentCode": [
                    "void main() {",
                    "    @nodes",
                    "    fragColor = fragColor * qt_Opacity;",
                    "}"
                ],
                "name": "Main",
                "nodeId": 0,
                "type": 0,
                "vertexCode": [
                    "void main() {",
                    "    texCoord = qt_MultiTexCoord0;",
                    "    if (origo == 0)",
                    "        fragCoord = vec2(qt_Vertex.x, iResolution.y - qt_Vertex.y);",
                    "    else if (origo == 1)",
                    "        fragCoord = qt_Vertex.xy;",
                    "    else if (origo == 2)",
                    "        fragCoord = vec2(iResolution.x - qt_Vertex.x, qt_Vertex.y);",
                    "    else",
                    "        fragCoord = vec2(iResolution.x - qt_Vertex.x, iResolution.y - qt_Vertex.y);",
                    "    fragCoord += gridMovement;",
                    "    vec2 vertCoord = qt_Vertex.xy;",
                    "    @nodes",
                    "    gl_Position = qt_Matrix * vec4(vertCoord, 0.0, 1.0);",
                    "}"
                ],
                "x": 140,
                "y": 35.400001525878906
            },
            {
                "name": "Output",
                "nodeId": 1,
                "type": 1,
                "x": 140,
                "y": 592.5999755859375
            },
            {
                "description": "This is an empty node for creating custom effects.",
                "fragmentCode": [
                    "float createBars(float coord, float spacing, float strokeWidth) {",
                    "    float sbar = 1.0 / spacing;// * 0.5;",
                    "    float barWidth = strokeWidth / spacing;// * 0.5;",
                    "    float firstPos = -((gridLineWidth / spacing) * 0.5);",
                    "    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",
                    "{",
                    "    // sublines",
                    "    float subLines = 0.0;",
                    "    if (gridVisibility.z > 0)",
                    "        subLines += createBars(fragCoord.x, gridWidth * horizontalSubGridScale, subGridLineWidth);",
                    "    if (gridVisibility.w > 0)",
                    "        subLines += createBars(fragCoord.y, gridHeight * verticalSubGridScale, subGridLineWidth) * (1.0 - subLines);",
                    "    // Major lines",
                    "    float lines = 0.0;",
                    "    if (gridVisibility.x > 0)",
                    "        lines += createBars(fragCoord.x, gridWidth, gridLineWidth);",
                    "    if (gridVisibility.y > 0)",
                    "        lines += createBars(fragCoord.y, gridHeight, gridLineWidth) * (1.0 - lines);",
                    "    // Combine lines, sublines below",
                    "    vec3 barColor = plotAreaBackgroundColor.rgb;",
                    "    float gridColorAlpha = lines * gridColor.a;",
                    "    float subGridColorAlpha = subLines * subGridColor.a;",
                    "    barColor = mix(barColor, subGridColor.rgb, subGridColorAlpha);",
                    "    barColor = mix(barColor, gridColor.rgb, gridColorAlpha);",
                    "    fragColor = vec4(barColor, min(1.0, subGridColorAlpha + gridColorAlpha + plotAreaBackgroundColor.a));",
                    "}"
                ],
                "name": "Grids",
                "nodeId": 3,
                "properties": [
                    {
                        "defaultValue": "0",
                        "maxValue": "3",
                        "minValue": "0",
                        "name": "origo",
                        "type": "int",
                        "value": "0"
                    },
                    {
                        "defaultValue": "1, 1, 1, 1",
                        "maxValue": "1, 1, 1, 1",
                        "minValue": "0, 0, 0, 0",
                        "name": "gridVisibility",
                        "type": "vec4",
                        "value": "1, 1, 1, 1"
                    },
                    {
                        "defaultValue": "50",
                        "maxValue": "100",
                        "minValue": "10",
                        "name": "gridWidth",
                        "type": "float",
                        "value": "50"
                    },
                    {
                        "defaultValue": "50",
                        "maxValue": "100",
                        "minValue": "10",
                        "name": "gridHeight",
                        "type": "float",
                        "value": "50"
                    },
                    {
                        "defaultValue": "0, 0",
                        "maxValue": "500, 500",
                        "minValue": "-500, -500",
                        "name": "gridMovement",
                        "type": "vec2",
                        "value": "0, 0"
                    },
                    {
                        "defaultValue": "0.5, 0.5, 0.5, 1",
                        "name": "subGridColor",
                        "type": "color",
                        "value": "0.5, 0.5, 0.5, 1"
                    },
                    {
                        "defaultValue": "1, 1, 1, 1",
                        "name": "gridColor",
                        "type": "color",
                        "value": "1, 1, 1, 1"
                    },
                    {
                        "defaultValue": "1",
                        "maxValue": "5",
                        "minValue": "0",
                        "name": "subGridLineWidth",
                        "type": "float",
                        "value": "1"
                    },
                    {
                        "defaultValue": "2",
                        "maxValue": "5",
                        "minValue": "0",
                        "name": "gridLineWidth",
                        "type": "float",
                        "value": "2"
                    },
                    {
                        "defaultValue": "1",
                        "maxValue": "5",
                        "minValue": "0",
                        "name": "smoothing",
                        "type": "float",
                        "value": "1"
                    },
                    {
                        "defaultValue": "0.2",
                        "maxValue": "1",
                        "minValue": "0",
                        "name": "verticalSubGridScale",
                        "type": "float",
                        "value": "0.2"
                    },
                    {
                        "defaultValue": "0.2",
                        "maxValue": "1",
                        "minValue": "0",
                        "name": "horizontalSubGridScale",
                        "type": "float",
                        "value": "0.2"
                    },
                    {
                        "defaultValue": "0, 0, 0, 0",
                        "name": "plotAreaBackgroundColor",
                        "type": "color",
                        "value": "0, 0, 0, 0"
                    }
                ],
                "type": 2,
                "x": 105,
                "y": 129.55999755859375
            }
        ],
        "version": 1
    }
}