X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=prewarp.frag;h=baf24d1b41e0aefb8c0d1249c1d9ec5b4d7d8fd1;hb=3795723be95f2fe82f3c8b8b45b1a905b2c811fd;hp=4b2db4408ee8d9d35af8c4f72de10cafe5b05e3a;hpb=670611b5a707fb8dcebf60fcfcd0930545d14875;p=nageru diff --git a/prewarp.frag b/prewarp.frag index 4b2db44..baf24d1 100644 --- a/prewarp.frag +++ b/prewarp.frag @@ -2,21 +2,21 @@ // Warps I_1 according to the flow, then computes the mean and difference to I_0. -in vec2 tc; +in vec3 tc; out float I, I_t; out vec2 normalized_flow; -uniform sampler2D image0_tex, image1_tex, flow_tex; +uniform sampler2DArray image_tex, flow_tex; void main() { vec3 flow = texture(flow_tex, tc).xyz; flow.xy /= flow.z; // Normalize the sum coming out of the densification. - float I_0 = texture(image0_tex, tc).x; - float I_w = texture(image1_tex, tc + flow.xy).x; // NOTE: This is effectively a reverse warp since texture() is a gather operation and flow is conceptually scatter. + float I_0 = texture(image_tex, tc).x; + float I_w = texture(image_tex, vec3(tc.xy + flow.xy, 1.0f - tc.z)).x; // NOTE: This is effectively a reverse warp since texture() is a gather operation and flow is conceptually scatter. I = 0.5f * (I_0 + I_w); I_t = I_w - I_0; - normalized_flow = flow.xy * textureSize(image0_tex, 0); + normalized_flow = flow.xy * textureSize(image_tex, 0).xy; }