-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbasicPointVertex.glsl
More file actions
38 lines (27 loc) · 925 Bytes
/
basicPointVertex.glsl
File metadata and controls
38 lines (27 loc) · 925 Bytes
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
#version 150
uniform mat4 transform;
uniform mat4 projection;
uniform mat4 modelview;
uniform vec4 viewport;
uniform int perspective;
in vec4 position;
in vec4 color;
out vec4 vertColor;
void main() {
gl_PointSize = 1.0;
//vec4 worldPosition = transform * position;
//gl_Position = worldPosition;
vec4 pos = modelview * position;
vec4 clip = projection * pos;
// Perspective ---
// convert from world to clip by multiplying with projection scaling factor
// invert Y, projections in Processing invert Y
vec2 perspScale = (projection * vec4(1, -1, 0, 0)).xy;
// No Perspective ---
// multiply by W (to cancel out division by W later in the pipeline) and
// convert from screen to clip (derived from clip to screen above)
vec2 noPerspScale = clip.w / (0.5 * viewport.zw);
gl_Position.xy = clip.xy + mix(noPerspScale, perspScale, float(perspective > 0));
gl_Position.zw = clip.zw;
vertColor = color;
}