dabbb4a321a514cc04f339ae7f15fa00bfb46070
[blender.git] / source / blender / draw / modes / shaders / edit_mesh_overlay_common_lib.glsl
1 #define EDGE_EXISTS     (1 << 0)
2 #define EDGE_ACTIVE     (1 << 1)
3 #define EDGE_SELECTED   (1 << 2)
4 #define EDGE_SEAM       (1 << 3)
5 #define EDGE_SHARP      (1 << 4)
6 #define EDGE_VERTEX_ACTIVE   (1 << (0 + 8))
7 #define EDGE_VERTEX_SELECTED (1 << (1 + 8))
8
9 #define VERTEX_ACTIVE   (1 << 0)
10 #define VERTEX_SELECTED (1 << 1)
11
12
13 vec4 EDIT_MESH_edge_color_outer(int edge_flag, bool face_active, float crease, float bweight)
14 {
15         vec4 color = vec4(0.0);
16         color = ((edge_flag & EDGE_SHARP) != 0) ? colorEdgeSharp : color;
17         color = (crease > 0.0) ? vec4(colorEdgeCrease.rgb, crease) : color;
18         color = (bweight > 0.0) ? vec4(colorEdgeBWeight.rgb, bweight) : color;
19         color = ((edge_flag & EDGE_SEAM) != 0) ? colorEdgeSeam : color;
20
21         if (face_active)
22         {
23                 color = colorEditMeshActive;
24         }
25         return color;
26 }
27
28 vec4 EDIT_MESH_edge_color_inner(int edge_flag, bool face_active)
29 {
30 #ifdef EDGE_SELECTION
31         vec4 color = colorWireEdit;
32         color = ((edge_flag & EDGE_SELECTED) != 0) ? colorEdgeSelect : color;
33         color = ((edge_flag & EDGE_ACTIVE) != 0) ? colorEditMeshActive : color;
34
35 #else
36         vec4 color = colorWireEdit;
37         color = ((edge_flag & EDGE_SELECTED) != 0) ? colorEdgeSelect : color;
38 #endif
39         return color;
40 }
41
42 vec4 EDIT_MESH_vertex_color(int vertex_flag)
43 {
44         if ((vertex_flag & (VERTEX_ACTIVE | VERTEX_SELECTED)) != 0)
45         {
46                 return colorEdgeSelect;
47         }
48         else {
49                 return colorWireEdit;
50         }
51 }