From 74ac64b2e402247edf61271a4862e657da7fe135 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 15 Mar 2014 21:53:10 +0100 Subject: [PATCH] Make SliceEffect slice from the top, not the bottom. This is more consistent with the rest of Movit, and makes the rest of the FFT implementation easier. --- slice_effect.frag | 4 ++-- slice_effect.h | 4 ++-- slice_effect_test.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/slice_effect.frag b/slice_effect.frag index 8416515..1598cb0 100644 --- a/slice_effect.frag +++ b/slice_effect.frag @@ -6,7 +6,7 @@ vec4 FUNCNAME(vec2 tc) { // DIRECTION_VERTICAL will be #defined to 1 if we are expanding vertically, // and 0 otherwise. #if DIRECTION_VERTICAL - float sliced_coord = tc.y; + float sliced_coord = 1.0 - tc.y; #else float sliced_coord = tc.x; #endif @@ -19,7 +19,7 @@ vec4 FUNCNAME(vec2 tc) { float input_coord = slice_num * PREFIX(slice_num_to_input_coord) + slice_offset * PREFIX(slice_offset_to_input_coord); #if DIRECTION_VERTICAL - return INPUT(vec2(tc.x, input_coord)); + return INPUT(vec2(tc.x, 1.0 - input_coord)); #else return INPUT(vec2(input_coord, tc.y)); #endif diff --git a/slice_effect.h b/slice_effect.h index 17202d7..31a13fd 100644 --- a/slice_effect.h +++ b/slice_effect.h @@ -7,8 +7,8 @@ // discard roles, where one does convolutions by means of many small FFTs, but // could also work as a (relatively boring) video effect on its own. // -// Note that vertical slices happen from the bottom, not the top, due to the -// OpenGL coordinate system. +// Note that vertical slices happen from the top, consistent with the rest of +// Movit. #include #include diff --git a/slice_effect_test.cpp b/slice_effect_test.cpp index efa6803..88b77a2 100644 --- a/slice_effect_test.cpp +++ b/slice_effect_test.cpp @@ -84,21 +84,21 @@ TEST(SliceEffectTest, HorizontalDiscard) { expect_equal(expected_data, out_data, 4, 2); } -TEST(SliceEffectTest, VerticalOverlapSlicesFromBottom) { +TEST(SliceEffectTest, VerticalOverlapSlicesFromTop) { float data[2 * 3] = { 0.0f, 0.1f, - 0.4f, 0.3f, + 0.6f, 0.2f, }; float expected_data[2 * 6] = { - 0.0f, 0.1f, - 0.0f, 0.1f, - 0.0f, 0.1f, - 0.0f, 0.1f, 0.4f, 0.3f, 0.6f, 0.2f, + + 0.6f, 0.2f, + 0.6f, 0.2f, + 0.6f, 0.2f, }; float out_data[2 * 6]; -- 2.39.2