]> git.sesse.net Git - nageru/commitdiff
Put depth in 0..1; evidently even fp32 depth is clamped in the ARB version.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 30 Jul 2018 21:18:43 +0000 (23:18 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 30 Jul 2018 22:35:45 +0000 (00:35 +0200)
flow.cpp
splat.frag

index ac9238759054939ee91345dda2206968691321ca..6a9d0eeb74ce551455e2392fb963e211759aaab3 100644 (file)
--- a/flow.cpp
+++ b/flow.cpp
@@ -1390,7 +1390,7 @@ void Splat::exec(GLuint tex0, GLuint tex1, GLuint forward_flow_tex, GLuint backw
        glViewport(0, 0, width, height);
        glDisable(GL_BLEND);
        glEnable(GL_DEPTH_TEST);
-       glDepthFunc(GL_LESS);  // We store the difference between I_0 and I_1, where less difference is good. (Default is effectively +inf, which always loses.)
+       glDepthFunc(GL_LESS);  // We store the difference between I_0 and I_1, where less difference is good. (Default 1.0 is effectively +inf, which always loses.)
        glBindVertexArray(splat_vao);
 
        // FIXME: Get this into FBOSet, so we can reuse FBOs across frames.
@@ -1513,7 +1513,7 @@ GLuint Interpolate::exec(GLuint tex0, GLuint tex1, GLuint forward_flow_tex, GLui
        {
                ScopedTimer timer("Clear", &total_timer);
                glClearTexImage(flow_tex, 0, GL_RG, GL_FLOAT, nullptr);
-               float infinity = 1000000.0f;
+               float infinity = 1.0f;
                glClearTexImage(depth_tex, 0, GL_DEPTH_COMPONENT, GL_FLOAT, &infinity);
        }
 
index c06667b1b41a9c7fc67bb633607d6826efd1e403..7b6875a131164f89d159b8417b4aa98bbd52e657 100644 (file)
@@ -16,5 +16,5 @@ void main()
        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 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.
 }