From 672e6d03faa93b38eca455da4d1bb00e39ee5b1d Mon Sep 17 00:00:00 2001 From: Jaklyy <102590697+Jaklyy@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:09:47 -0400 Subject: [PATCH] betterer approximation --- src/GPU3D_Soft.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h index e3e89b66..06d132b0 100644 --- a/src/GPU3D_Soft.h +++ b/src/GPU3D_Soft.h @@ -181,10 +181,22 @@ private: // Z-buffering: linear interpolation // still doesn't quite match hardware... - if (z0 < z1) - return z0 + (((z1 - z0) / (xdiff << 1)) * (x<<1)); + if (dir) + { + // seems like y dir does different interpolation? + // this probably isn't right... + if (z0 < z1) + return z0 + (z1-z0) * x / xdiff; + else + return z1 + (z0-z1) * (xdiff-x) / xdiff; + } else - return z1 + (((z0 - z1) / (xdiff << 1)) * (xdiff-x<<1)); + { + if (z0 < z1) + return z0 + (((z1-z0) / xdiff & ~0x1) * x); + else + return z1 + (((z0-z1) / xdiff & ~0x1) * (xdiff-x) + ((z0-z1) & 0xFF)); + } } }