Debian Codegraph @

shaders/symmaxe.geom

raw
1 #version 330
2
3 layout(lines) in;
4 layout(triangle_strip, max_vertices = 103) out;
5 //layout(line_strip, max_vertices = 80) out;
6
7 uniform mat4 pmv;
8 uniform mat3 normalMatrix;
9 uniform int dontshowSymElement[200];
10 uniform int dontshowSymOperation[200];
11 uniform int dssesize=0;
12 uniform int dssosize=0;
13 uniform float axisThickness=0.04;
14
15 in float coli[];
16 in float oprn[];
17 out vec3 Normal;
18 out float col;
19
20 const int segments = 5;
21 const float PI = 3.14159265359f;
22
23 out gl_PerVertex{
24 vec4 gl_Position;
25 };
26
27
28
29
30 void main() {
31 for (int i=0; i<dssesize; i++) if ((dontshowSymElement[i]==coli[0])||(dontshowSymElement[i]==coli[1])) return;
32 for (int i=0; i<dssosize; i++) if ((dontshowSymOperation[i]==oprn[0])||(dontshowSymOperation[i]==oprn[1])) return;
33 /*
34 gl_Position = pmv*gl_in[0].gl_Position;
35 col = coli[0];
36 Normal = normalMatrix*vec3(1,0,0);
37 EmitVertex();
38 gl_Position = pmv*gl_in[1].gl_Position;
39 col = coli[1];
40 Normal = normalMatrix*vec3(1,0,0);
41 EmitVertex();
42 EndPrimitive();
43 */
44 vec4 start = gl_in[0].gl_Position;
45 vec4 end = gl_in[1].gl_Position;
46 start.w = 1.0;
47 end.w = 1.0;
48 vec3 direction = normalize(end.xyz - start.xyz);
49 float l = length(end.xyz - start.xyz);
50 vec3 lot = (abs(dot(direction, vec3(1, 0, 0))) > 0.8)?
51 (abs(dot(direction, vec3(0, 1, 0))) > 0.8)?
52 normalize(cross(direction, vec3(0, 0, 1))):
53 normalize(cross(direction, vec3(0, 1, 0))):
54 normalize(cross(direction, vec3(1, 0, 0)));
55 vec3 lot2 = normalize(cross(direction,lot));
56 vec3 r = vec3(0,0,0);
57 float rad = axisThickness;
58 vec3 vert=vec3(0,0,0);
59 for (int i = 0; i <= 2*segments; i++){
60 r = sin(PI * i / segments) * lot + cos(PI * i / segments) * lot2;
61
62 vert = start.xyz + rad * r;
63 gl_Position = pmv* vec4(vert, 1);
64 Normal = normalize(normalMatrix * r);
65 col = coli[0];
66 EmitVertex();
67
68 vert = end.xyz + rad * r;
69 gl_Position = pmv* vec4(vert , 1);
70 Normal = normalize(normalMatrix * r);
71 col = coli[1];
72 EmitVertex();
73 }
74 EndPrimitive();
75
76 }
77
78
79 /*
80 for (int i = 0; i <= 2*segments; i++){
81 r = sin(PI * i / segments) * lot + cos(PI * i / segments) * lot2;
82 vert = start.xyz + rad * r;
83 gl_Position = pmv* vec4(vert, 1);
84 Normal = normalMatrix * r;
85 bondlength = l;
86 _an = toan;
87 _style = tostyle;//abs(styleI[0]-styleI[1]);
88 distance_from_start = 0.0;
89 EmitVertex();
90 vert = end.xyz + rad * r;
91 gl_Position = pmv* vec4(vert , 1);
92 Normal = normalMatrix * r;
93 distance_from_start = 1.0;
94 bondlength = l;
95 _an = toan;
96 _style = tostyle;//abs(styleI[0]-styleI[1]);
97 EmitVertex();
98 }
99 EndPrimitive();
100 */