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