]> git.sesse.net Git - nageru/blob - futatabi/densify.frag
Log a warning when we kill a client that is not keeping up.
[nageru] / futatabi / densify.frag
1 #version 450 core
2
3 in vec2 image_pos;
4 flat in int image0_layer, image1_layer;
5 flat in vec2 flow_du;
6 flat in float mean_diff;
7 out vec3 flow_contribution;
8
9 uniform sampler2DArray image_tex;
10
11 void main()
12 {
13         // Equation (3) from the paper. We're using additive blending, so the
14         // sum will happen automatically for us, and normalization happens on
15         // next read.
16         //
17         // Note that equation (2) says 1 for the minimum error, but the code says 2.0.
18         // And it says L2 norm, but really, the code does absolute value even for
19         // L2 error norm (it uses a square root formula for L1 norm).
20         float diff = texture(image_tex, vec3(image_pos, image0_layer)).x - texture(image_tex, vec3(image_pos + flow_du, image1_layer)).x;
21         diff -= mean_diff;
22         float weight = 1.0 / max(abs(diff), 2.0 / 255.0);
23         flow_contribution = vec3(flow_du.x * weight, flow_du.y * weight, weight);
24 }