]> git.sesse.net Git - movit/blob - slice_effect.frag
.gitignore more unit tests.
[movit] / slice_effect.frag
1 uniform float PREFIX(output_coord_to_slice_num);
2 uniform float PREFIX(slice_num_to_input_coord);
3 uniform float PREFIX(slice_offset_to_input_coord);
4  
5 vec4 FUNCNAME(vec2 tc) {
6         // DIRECTION_VERTICAL will be #defined to 1 if we are expanding vertically,
7         // and 0 otherwise.
8 #if DIRECTION_VERTICAL
9         float sliced_coord = tc.y;
10 #else
11         float sliced_coord = tc.x;
12 #endif
13
14         // Find out which slice we are in, and a 0..1 coordinate for the offset within that slice.
15         float slice_num = floor(sliced_coord * PREFIX(output_coord_to_slice_num));
16         float slice_offset = fract(sliced_coord * PREFIX(output_coord_to_slice_num));
17
18         // Find out where this slice begins in the input data, and then offset from that.
19         float input_coord = slice_num * PREFIX(slice_num_to_input_coord) + slice_offset * PREFIX(slice_offset_to_input_coord);
20
21 #if DIRECTION_VERTICAL
22         return INPUT(vec2(tc.x, input_coord));
23 #else
24         return INPUT(vec2(input_coord, tc.y));
25 #endif
26 }