Add an effect for padding.
[movit] / padding_effect.frag
1 uniform vec2 PREFIX(offset);
2 uniform vec2 PREFIX(scale);
3 uniform vec2 PREFIX(texcoord_min);
4 uniform vec2 PREFIX(texcoord_max);
5
6 vec4 FUNCNAME(vec2 tc) {
7         tc -= PREFIX(offset);
8         tc *= PREFIX(scale);
9
10 #if 1
11         if (any(lessThan(tc, PREFIX(texcoord_min))) ||
12             any(greaterThan(tc, PREFIX(texcoord_max)))) {
13                 return PREFIX(border_color);
14         }
15 #endif
16         if (any(lessThan(tc, vec2(0.0))) ||
17             any(greaterThan(tc, vec2(1.0)))) {
18                 return PREFIX(border_color);
19         } 
20 #if 0
21         // In theory, maybe we should test on the outmost textel centers
22         // (e.g. (0.5/width, 0.5/height) for the top-left) instead of the
23         // texture border. However, since we only support integer padding
24         if (any(lessThan(tc, vec2(0.0))) || any(greaterThan(tc, vec2(1.0)))) {
25                 return PREFIX(border_color);
26         }
27 #endif
28
29         return INPUT(tc);
30 }