From 00bab4b054427daa31563486c3a98e0d9aa02b3f Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 30 Jul 2018 23:18:43 +0200 Subject: [PATCH] Put depth in 0..1; evidently even fp32 depth is clamped in the ARB version. --- flow.cpp | 4 ++-- splat.frag | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flow.cpp b/flow.cpp index ac92387..6a9d0ee 100644 --- 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); } diff --git a/splat.frag b/splat.frag index c06667b..7b6875a 100644 --- a/splat.frag +++ b/splat.frag @@ -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. } -- 2.39.2