From 605dad2c0221c88ee7a57e06ab4648857688af68 Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Fri, 27 Dec 2019 21:36:46 +0000 Subject: [PATCH] Fix the sky in harley in first person mode where pixels in the sky are culled when they shouldn't be with the quad renderer. Basically we were running out of precision in a rare corner case. Doing the maths with double precision and casting back to float was enough to fix the issue. --- Src/Graphics/New3D/R3DShaderQuads.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Src/Graphics/New3D/R3DShaderQuads.h b/Src/Graphics/New3D/R3DShaderQuads.h index 24f7cb4..44541fd 100644 --- a/Src/Graphics/New3D/R3DShaderQuads.h +++ b/Src/Graphics/New3D/R3DShaderQuads.h @@ -82,7 +82,7 @@ out GS_OUT flat vec4 color; } gs_out; -float area(vec2 a, vec2 b) +double area(dvec2 a, dvec2 b) { return a.x*b.y - a.y*b.x; } @@ -124,13 +124,15 @@ void main(void) // int reorder[4] = int[]( 1, 0, 2, 3 ); int ii = reorder[i]; + dvec2 vector[4]; for (j=0; j<4; j++) { - gs_out.v[j] = v[j] - v[ii]; + vector[j] = dvec2(v[j]) - dvec2(v[ii]); + gs_out.v[j] = vec2(vector[j]); } for (j=0; j<4; j++) { j_next = (j+1) % 4; - gs_out.area[j] = area(gs_out.v[j], gs_out.v[j_next]); + gs_out.area[j] = float(area(vector[j], vector[j_next])); } gl_Position = gl_in[ii].gl_Position; @@ -276,9 +278,9 @@ void QuadraticInterpolation() } } } - if (abs(lambdaSignCount) != 4) { + if (lambdaSignCount != 4) { if(!gl_HelperInvocation) { - discard; // need to revisit this + discard; } }