]> git.sesse.net Git - nageru/commitdiff
Fix some uniforms not getting through to the motion search vertex shader.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 23 Jul 2018 23:29:02 +0000 (01:29 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 23 Jul 2018 23:29:02 +0000 (01:29 +0200)
flow.cpp
motion_search.vert

index 85550b1f69c56647a2d339ef7f8382cc5d87023c..df6ac6df625d96586049234fc9c0e9094eca9017 100644 (file)
--- a/flow.cpp
+++ b/flow.cpp
@@ -353,7 +353,7 @@ private:
        GLuint motion_search_program;
        GLuint motion_search_vao;
 
-       GLuint uniform_image_size, uniform_inv_image_size, uniform_inv_prev_level_size;
+       GLuint uniform_image_size, uniform_inv_image_size, uniform_inv_flow_size, uniform_inv_prev_level_size;
        GLuint uniform_image0_tex, uniform_image1_tex, uniform_grad0_tex, uniform_flow_tex;
 };
 
@@ -374,6 +374,7 @@ MotionSearch::MotionSearch()
 
        uniform_image_size = glGetUniformLocation(motion_search_program, "image_size");
        uniform_inv_image_size = glGetUniformLocation(motion_search_program, "inv_image_size");
+       uniform_inv_flow_size = glGetUniformLocation(motion_search_program, "inv_flow_size");
        uniform_inv_prev_level_size = glGetUniformLocation(motion_search_program, "inv_prev_level_size");
        uniform_image0_tex = glGetUniformLocation(motion_search_program, "image0_tex");
        uniform_image1_tex = glGetUniformLocation(motion_search_program, "image1_tex");
@@ -392,6 +393,7 @@ void MotionSearch::exec(GLuint tex0_view, GLuint tex1_view, GLuint grad0_tex, GL
 
        glProgramUniform2f(motion_search_program, uniform_image_size, level_width, level_height);
        glProgramUniform2f(motion_search_program, uniform_inv_image_size, 1.0f / level_width, 1.0f / level_height);
+       glProgramUniform2f(motion_search_program, uniform_inv_flow_size, 1.0f / width_patches, 1.0f / height_patches);
        glProgramUniform2f(motion_search_program, uniform_inv_prev_level_size, 1.0f / prev_level_width, 1.0f / prev_level_height);
 
        glViewport(0, 0, width_patches, height_patches);
index e0f659ea31ecf3c5920b5895d122e06bac252538..dbb27956814ed3438b892dc9ed95256587746ebc 100644 (file)
@@ -4,8 +4,7 @@ in vec2 position;
 out vec2 flow_tc;
 out vec2 patch_bottom_left_texel;  // Center of bottom-left texel of patch.
 
-uniform float inv_flow_width, inv_flow_height;
-uniform float inv_image_width, inv_image_height;
+uniform vec2 inv_flow_size, inv_image_size;
 
 void main()
 {
@@ -18,6 +17,6 @@ void main()
        gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0);
        flow_tc = position;
 
-       vec2 patch_bottom_left = position - vec2(0.5, 0.5) * vec2(inv_flow_width, inv_flow_height);
-       patch_bottom_left_texel = patch_bottom_left + vec2(0.5, 0.5) * vec2(inv_image_width, inv_image_height);
+       vec2 patch_bottom_left = position - vec2(0.5, 0.5) * inv_flow_size;
+       patch_bottom_left_texel = patch_bottom_left + vec2(0.5, 0.5) * inv_image_size;
 }