]> git.sesse.net Git - nageru/blob - futatabi/prewarp.frag
Log a warning when we kill a client that is not keeping up.
[nageru] / futatabi / 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 vec3 tc;
6 out float I, I_t;
7 out vec2 normalized_flow;
8
9 uniform sampler2DArray image_tex, flow_tex;
10
11 void main()
12 {
13         vec3 flow = texture(flow_tex, tc).xyz;
14         flow.xy /= flow.z;  // Normalize the sum coming out of the densification.
15
16         float I_0 = texture(image_tex, tc).x;
17         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.
18
19         I = 0.5f * (I_0 + I_w);
20         I_t = I_w - I_0;
21         normalized_flow = flow.xy * textureSize(image_tex, 0).xy;
22 }