File: imesh_point.vert

package info (click to toggle)
solvespace 3.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 15,960 kB
  • sloc: cpp: 122,491; ansic: 11,375; javascript: 1,919; sh: 89; xml: 44; makefile: 25
file content (33 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download | duplicates (4)
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
//-----------------------------------------------------------------------------
// Point rendering shader
//
// Copyright 2016 Aleksey Egorov
//-----------------------------------------------------------------------------
const float feather = 0.5;

attribute vec3 pos;
attribute vec2 loc;

uniform mat4 modelview;
uniform mat4 projection;
uniform float width;
uniform float pixel;

void main() {
    // get camera vectors from modelview matrix
    vec3 u = vec3(modelview[0].x, modelview[1].x, modelview[2].x);
    vec3 v = vec3(modelview[0].y, modelview[1].y, modelview[2].y);

    // calculate point contour extension basis for constant width and caps

    // calculate point extension width considering antialiasing
    float ext = width + feather * pixel;

    // extend point contour
    vec3 vertex = pos;
    vertex += ext * loc.x * normalize(u);
    vertex += ext * loc.y * normalize(v);

    // transform resulting vertex with modelview and projection matrices
    gl_Position = projection * modelview * vec4(vertex, 1.0);
}