-
Notifications
You must be signed in to change notification settings - Fork 0
/
point-geometry.glsl
51 lines (40 loc) · 1.08 KB
/
point-geometry.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
#version 400
// take in a point and output a triangle strip with 4 vertices (aka a "quad")
//
layout(points) in;
layout(triangle_strip, max_vertices = 4) out;
uniform mat4 al_ProjectionMatrix;
uniform float pointSize;
in Vertex {
vec4 color;
float size;
}
vertex[];
out Fragment {
vec4 color;
vec2 mapping;
}
fragment;
void main() {
mat4 m = al_ProjectionMatrix; // rename to make lines shorter
vec4 v = gl_in[0].gl_Position; // al_ModelViewMatrix * gl_Position
float r = pointSize;
r *= vertex[0].size;
gl_Position = m * (v + vec4(-r, -r, 0.0, 0.0));
fragment.color = vertex[0].color;
fragment.mapping = vec2(-1.0, -1.0);
EmitVertex();
gl_Position = m * (v + vec4(r, -r, 0.0, 0.0));
fragment.color = vertex[0].color;
fragment.mapping = vec2(1.0, -1.0);
EmitVertex();
gl_Position = m * (v + vec4(-r, r, 0.0, 0.0));
fragment.color = vertex[0].color;
fragment.mapping = vec2(-1.0, 1.0);
EmitVertex();
gl_Position = m * (v + vec4(r, r, 0.0, 0.0));
fragment.color = vertex[0].color;
fragment.mapping = vec2(1.0, 1.0);
EmitVertex();
EndPrimitive();
}