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
|
#version 150
#extension GL_ARB_explicit_attrib_location : enable
#extension GL_ARB_explicit_uniform_location : enable
layout(points) in ;
layout(triangle_strip, max_vertices=82) out;
layout(location = 4) uniform mat4 pjMatrix ;
layout(location = 5) uniform mat4 mvMatrix ;
out vec2 texposition;
out vec3 normal ;
out vec4 frag_position ;
void vertex( vec4 pos ) {
normal = - inverse(transpose(mat3(mvMatrix))) * vec3( pos.x, 0, pos.z ) ;
gl_Position = pjMatrix * (frag_position = gl_in[0].gl_Position + (mvMatrix * pos)) ;
EmitVertex() ;
}
void main() {
float r = 0.045 ;
float th = 0.00 ;
float h = 0.4 ;
for( ; th < 6.4 ; th += 1.0 ) {
float c = r * cos( th ) ;
float s = r * sin( th ) ;
float c2 = r * cos( th + 1.0 ) ;
float s2 = r * sin( th + 1.0 ) ;
float tex_x = th / 6.4 / 2.0;
float tex_x2 = (th+1.0) / 6.4 / 2.0 ;
texposition = vec2(tex_x, 0);
vertex( vec4(c, 0.0, s, 0) ) ;
texposition = vec2(tex_x, 1);
vertex( vec4(c, h, s, 0) ) ;
texposition = vec2(tex_x2, 0);
vertex( vec4(c2, h, s2, 0) ) ;
texposition = vec2(tex_x, 0);
vertex( vec4(c, 0.0, s, 0) ) ;
texposition = vec2(tex_x2, 0);
vertex( vec4(c2, 0, s2, 0) ) ;
texposition = vec2(tex_x2, 1);
vertex( vec4(c2, h, s2, 0) ) ;
}
for( th = 0; th < 6.4 ; th += 1.0 ) {
float c = (r*4) * cos( th ) ;
float s = (r*4) * sin( th ) ;
float tex_x = th / 6.4 / 2.0 + 0.5;
texposition = vec2(tex_x, 1);
vertex( vec4(0,h*2,0,0) ) ;
texposition = vec2(tex_x, 0);
vertex( vec4(s,h/2,c,0) ) ;
}
for( th = 0; th < 6.4 ; th += 1.0 ) {
float c = (r*6) * cos( th ) ;
float s = (r*6) * sin( th ) ;
float tex_x = th / 6.4 / 2.0 + 0.5;
texposition = vec2(tex_x, 1);
vertex( vec4(0,h,0,0) ) ;
texposition = vec2(tex_x, 0);
vertex( vec4(s,h/4,c,0) ) ;
}
EndPrimitive();
}
|