2 // uniform vec2 PREFIX(offset);
3 // uniform vec2 PREFIX(scale);
5 // uniform vec2 PREFIX(normalized_coords_to_texels);
6 // uniform vec2 PREFIX(offset_bottomleft);
7 // uniform vec2 PREFIX(offset_topright);
9 vec4 FUNCNAME(vec2 tc) {
13 vec2 tc_texels = tc * PREFIX(normalized_coords_to_texels);
14 vec2 coverage_bottomleft = clamp(tc_texels + PREFIX(offset_bottomleft), 0.0f, 1.0f);
15 vec2 coverage_topright = clamp(PREFIX(offset_topright) - tc_texels, 0.0f, 1.0f);
16 vec2 coverage_both = coverage_bottomleft * coverage_topright;
17 float coverage = coverage_both.x * coverage_both.y;
19 if (coverage <= 0.0f) {
20 // Short-circuit in case the underlying function is expensive to call.
21 return PREFIX(border_color);
23 return mix(PREFIX(border_color), INPUT(tc), coverage);