]> git.sesse.net Git - nageru/blobdiff - splat.frag
Support rendering forward and backward flow in parallel.
[nageru] / splat.frag
index c06667b1b41a9c7fc67bb633607d6826efd1e403..83fd68333751a9df65b00956b920ac3ae8fb97ba 100644 (file)
@@ -4,7 +4,7 @@ in vec2 image_pos;
 flat in vec2 flow, I_0_check_offset, I_1_check_offset;
 out vec2 out_flow;
 
-uniform sampler2D image0_tex, image1_tex;
+uniform sampler2DArray image_tex;
 
 void main()
 {
@@ -13,8 +13,8 @@ void main()
        // TODO: Check if we are sampling out-of-image.
        // TODO: See whether using intensity values gives equally good results
        // as RGB, since the rest of our pipeline is intensity.
-       vec3 I_0 = texture(image0_tex, image_pos + I_0_check_offset).rgb;
-       vec3 I_1 = texture(image1_tex, image_pos + I_1_check_offset).rgb;
+       vec3 I_0 = texture(image_tex, vec3(image_pos + I_0_check_offset, 0)).rgb;
+       vec3 I_1 = texture(image_tex, vec3(image_pos + I_1_check_offset, 1)).rgb;
        vec3 diff = abs(I_1 - I_0);
-       gl_FragDepth = diff.x + diff.y + diff.z;
+       gl_FragDepth = 0.125 * (diff.x + diff.y + diff.z);  // Make sure we stay well under the 1.0 maximum.
 }