]> git.sesse.net Git - nageru/blob - prewarp.frag
In the variational refinement, change the flow unit from normalized coordinates to...
[nageru] / prewarp.frag
1 #version 450 core
2
3 // Warps I_1 according to the flow, then computes the mean and difference to I_0.
4
5 in vec2 tc;
6 out float I, I_t;
7 out vec2 normalized_flow;
8
9 uniform sampler2D image0_tex, image1_tex, flow_tex;
10 uniform vec2 image_size;
11
12 void main()
13 {
14         vec3 flow = texture(flow_tex, tc).xyz;
15         flow.xy /= flow.z;  // Normalize the sum coming out of the densification.
16
17         float I_0 = texture(image0_tex, tc).x;
18         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.
19
20         I = 0.5f * (I_0 + I_w);
21         I_t = I_w - I_0;
22         normalized_flow = flow.xy * image_size;
23 }