48 in_corner_region = true; |
51 in_corner_region = true; |
49 break; |
52 break; |
50 } |
53 } |
51 } |
54 } |
52 |
55 |
53 #ifdef FILL |
56 #ifndef BORDER |
54 // For filled rectangle with rounded corners |
57 // For filled rectangle with rounded corners |
55 if (in_corner_region) { |
58 if (in_corner_region) { |
56 float dist = length(corner_distances[corner_idx]); |
59 float dist = length(corner_distances[corner_idx]); |
57 if (dist > radius) { |
60 if (dist > radius) { |
58 discard; // Outside the rounded corner |
61 discard; // Outside the rounded corner |
59 } |
62 } |
60 } else if (uvcoord.x < 0.0 || uvcoord.y < 0.0 || uvcoord.x > size.x || uvcoord.y > size.y) { |
63 } else if (uvcoord.x < 0.0 || uvcoord.y < 0.0 || uvcoord.x > size.x || uvcoord.y > size.y) { |
|
64 // TODO: at the moment we don't have fragments here, but we will with glow |
61 discard; // Outside the rectangle |
65 discard; // Outside the rectangle |
62 } |
66 } |
63 diffuse = color; |
67 diffuse = color; |
64 #else // no FILL |
68 #else // BORDER |
65 // For outlined rectangle with rounded corners |
69 // For outlined rectangle with rounded corners |
66 if (in_corner_region) { |
70 if (in_corner_region) { |
67 float dist = length(corner_distances[corner_idx]); |
71 float dist = length(corner_distances[corner_idx]); |
68 if (dist > radius) { |
72 if (dist > radius) { |
69 discard; // Outside the rounded corner |
73 discard; // Outside the rounded corner |
70 } else if (dist < radius - thickness) { |
74 } else if (dist < radius - thickness) { |
71 discard; // Inside the outline |
75 // Inside the outline |
|
76 #ifdef FILL |
|
77 diffuse = color; |
|
78 #else |
|
79 discard; |
|
80 #endif |
|
81 } else { |
|
82 // the corner outline |
|
83 diffuse = border_color; |
72 } |
84 } |
73 diffuse = color; |
|
74 } else if (any(lessThan(uvcoord, vec2(thickness))) || any(greaterThan(uvcoord, size - thickness))) { |
85 } else if (any(lessThan(uvcoord, vec2(thickness))) || any(greaterThan(uvcoord, size - thickness))) { |
75 // On a straight edge |
86 // On a straight edge |
76 if (uvcoord.x >= 0.0 && uvcoord.y >= 0.0 && uvcoord.x <= size.x && uvcoord.y <= size.y) { |
87 if (uvcoord.x >= 0.0 && uvcoord.y >= 0.0 && uvcoord.x <= size.x && uvcoord.y <= size.y) { |
77 diffuse = color; |
88 diffuse = border_color; |
78 } else { |
89 } else { |
79 discard; |
90 discard; |
80 } |
91 } |
81 } else { |
92 } else { |
82 discard; // Inside the outline |
93 // Inside the outline |
|
94 #ifdef FILL |
|
95 diffuse = color; |
|
96 #else |
|
97 discard; |
|
98 #endif |
83 } |
99 } |
84 #endif // FILL |
100 #endif // BORDER |
85 #else // no ROUNDED_CORNERS |
101 #else // no ROUNDED_CORNERS |
86 #ifdef FILL |
102 #ifdef BORDER |
|
103 if (any(notEqual(1.0-step(thickness, uvcoord)+step(size-thickness, uvcoord), vec2(0.0)))) { |
|
104 diffuse = border_color; |
|
105 } else { |
|
106 // Inside the outline |
|
107 #ifdef FILL |
|
108 diffuse = color; |
|
109 #else |
|
110 discard; |
|
111 #endif |
|
112 } |
|
113 #else // no BORDER |
87 diffuse = color; |
114 diffuse = color; |
88 #else // no FILL |
115 #endif // BORDER |
89 if (any(notEqual(1.0-step(thickness, uvcoord)+step(size-thickness, uvcoord), vec2(0.0)))) { |
|
90 diffuse = color; |
|
91 } else { |
|
92 discard; |
|
93 } |
|
94 #endif // FILL |
|
95 #endif // ROUNDED_CORNERS |
116 #endif // ROUNDED_CORNERS |
96 } |
117 } |