forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkStickMapperGS.glsl
125 lines (92 loc) · 2.96 KB
/
vtkStickMapperGS.glsl
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
//VTK::System::Dec
/*=========================================================================
Program: Visualization Toolkit
Module: vtkStickMapperGS.glsl
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Template for the polydata mappers geometry shader
// primitiveID
//VTK::PrimID::Dec
// optional color passed in from the vertex shader, vertexColor
//VTK::Color::Dec
layout(points) in;
layout(triangle_strip, max_vertices = 6) out;
uniform int cameraParallel;
uniform mat4 VCDCMatrix;
in float radiusVCVSOutput[];
out float radiusVCGSOutput;
out vec4 vertexVCGSOutput;
in float lengthVCVSOutput[];
out float lengthVCGSOutput;
out vec3 centerVCGSOutput;
in vec3 orientVCVSOutput[];
out vec3 orientVCGSOutput;
// clipping plane vars
//VTK::Clip::Dec
//VTK::Picking::Dec
void main()
{
centerVCGSOutput = gl_in[0].gl_Position.xyz/gl_in[0].gl_Position.w;
radiusVCGSOutput = radiusVCVSOutput[0];
lengthVCGSOutput = lengthVCVSOutput[0];
orientVCGSOutput = orientVCVSOutput[0];
int i = 0;
//VTK::PrimID::Impl
//VTK::Clip::Impl
//VTK::Color::Impl
//VTK::Picking::Impl
// make the basis
vec3 xbase;
vec3 ybase;
// dir is the direction to the camera
vec3 dir = vec3(0.0,0.0,1.0);
if (cameraParallel == 0)
{
dir = normalize(-centerVCGSOutput);
}
// if dir is aligned with the cylinder orientation
if (abs(dot(dir,orientVCGSOutput)) == 1.0)
{
xbase = normalize(cross(vec3(0.0,1.0,0.0),orientVCGSOutput));
ybase = cross(xbase,orientVCGSOutput);
}
else
{
xbase = normalize(cross(orientVCGSOutput,dir));
ybase = cross(orientVCGSOutput,xbase);
}
xbase = xbase * radiusVCGSOutput;
ybase = ybase * radiusVCGSOutput;
vec3 zbase = 0.5*lengthVCGSOutput*orientVCGSOutput;
vertexVCGSOutput = vec4(0.0, 0.0, 0.0, 1.0);
vertexVCGSOutput.xyz = centerVCGSOutput
- xbase - ybase - zbase;
gl_Position = VCDCMatrix * vertexVCGSOutput;
EmitVertex();
vertexVCGSOutput.xyz = centerVCGSOutput
+ xbase - ybase - zbase;
gl_Position = VCDCMatrix * vertexVCGSOutput;
EmitVertex();
vertexVCGSOutput.xyz = centerVCGSOutput
- xbase - ybase + zbase;
gl_Position = VCDCMatrix * vertexVCGSOutput;
EmitVertex();
vertexVCGSOutput.xyz = centerVCGSOutput
+ xbase - ybase + zbase;
gl_Position = VCDCMatrix * vertexVCGSOutput;
EmitVertex();
vertexVCGSOutput.xyz = centerVCGSOutput
- xbase + ybase + zbase;
gl_Position = VCDCMatrix * vertexVCGSOutput;
EmitVertex();
vertexVCGSOutput.xyz = centerVCGSOutput
+ xbase + ybase + zbase;
gl_Position = VCDCMatrix * vertexVCGSOutput;
EmitVertex();
EndPrimitive();
}