Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gpu_shader_2D_edituvs_points_vert.glsl « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3f3bfa5410c334cbd738519b2ed278b22ba42901 (plain)
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

uniform mat4 ModelViewProjectionMatrix;
uniform vec4 vertColor;
uniform vec4 selectColor;
uniform vec4 pinnedColor;
uniform float pointSize;
uniform float outlineWidth;

in vec2 pos;
in int flag;

out vec4 fillColor;
out vec4 outlineColor;
out vec4 radii;

/* TODO: Port drawing to draw manager and
 * remove constants duplications. */
#define VERT_UV_SELECT (1 << 3)
#define VERT_UV_PINNED (1 << 4)

void main()
{
  gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
  gl_PointSize = pointSize;

  bool is_selected = (flag & VERT_UV_SELECT) != 0;
  bool is_pinned = (flag & VERT_UV_PINNED) != 0;

  vec4 deselect_col = (is_pinned) ? pinnedColor : vertColor;
  fillColor = (is_selected) ? selectColor : deselect_col;
  outlineColor = (is_pinned) ? pinnedColor : vec4(fillColor.rgb, 0.0);

  // calculate concentric radii in pixels
  float radius = 0.5 * pointSize;

  // start at the outside and progress toward the center
  radii[0] = radius;
  radii[1] = radius - 1.0;
  radii[2] = radius - outlineWidth;
  radii[3] = radius - outlineWidth - 1.0;

  // convert to PointCoord units
  radii /= pointSize;
}