X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=motion_search.vert;h=d0232767fbcef03434d18ad532ffbc0e0bbf870d;hb=3795723be95f2fe82f3c8b8b45b1a905b2c811fd;hp=0e782aa8c2fcab55267b9cf67608768bce01f39e;hpb=b21b2d8045035a08dd3a3eeabfe1c9457cc5cf61;p=nageru diff --git a/motion_search.vert b/motion_search.vert index 0e782aa..d023276 100644 --- a/motion_search.vert +++ b/motion_search.vert @@ -1,10 +1,13 @@ #version 450 core +#extension GL_ARB_shader_viewport_layer_array : require layout(location=0) in vec2 position; -out vec2 flow_tc; +out vec3 flow_tc; out vec2 patch_center; +flat out int ref_layer, search_layer; -uniform sampler2D flow_tex; +uniform sampler2DArray flow_tex; +uniform vec2 out_flow_size; void main() { @@ -23,9 +26,8 @@ void main() // // a = 1 / (w - 1) // b = w / 2 (w - 1) - vec2 flow_size = textureSize(flow_tex, 0); - vec2 a = flow_size / (flow_size - 1); - vec2 b = -1.0 / (2 * (flow_size - 1.0)); + vec2 a = out_flow_size / (out_flow_size - 1); + vec2 b = -1.0 / (2 * (out_flow_size - 1.0)); patch_center = a * position + b; // The result of glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0) is: @@ -35,5 +37,11 @@ void main() // 0.000 0.000 -2.000 -1.000 // 0.000 0.000 0.000 1.000 gl_Position = vec4(2.0 * position.x - 1.0, 2.0 * position.y - 1.0, -1.0, 1.0); - flow_tc = position; + flow_tc = vec3(position, gl_InstanceID); + + gl_Layer = gl_InstanceID; + + // Forward flow (0) goes from 0 to 1. Backward flow (1) goes from 1 to 0. + ref_layer = gl_InstanceID; + search_layer = 1 - gl_InstanceID; }