From 668e5580e0956815e85589d6136dca1429201475 Mon Sep 17 00:00:00 2001 From: Jaklyy <102590697+Jaklyy@users.noreply.github.com> Date: Sat, 16 Mar 2024 06:51:07 -0400 Subject: [PATCH] better approximation --- src/GPU3D_Soft.h | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h index 58313800..e3e89b66 100644 --- a/src/GPU3D_Soft.h +++ b/src/GPU3D_Soft.h @@ -180,41 +180,11 @@ private: { // Z-buffering: linear interpolation // still doesn't quite match hardware... - s32 disp = 0; if (z0 < z1) - { - disp = z1 - z0; - } + return z0 + (((z1 - z0) / (xdiff << 1)) * (x<<1)); else - { - disp = z0 - z1; - } - - /*if (dir) - { - if (z0 < z1) return z0 + ((z1 - z0) * x / xdiff); - else return z1 + ((z0 - z1) - ((z0 - z1) * x / xdiff)); - }*/ - - u32 recip, recip2; - u32 shift = 0; - recip2 = recip = (x << 16) / xdiff; - while (recip2 > 0x100) - { - recip2 >>= 1; - shift++; - } - disp >>= shift; - - if (z0 < z1) - { - return z0 + ((disp * recip) >> (16 - shift)); - } - else - { - return z1 + ((z0-z1) - ((disp * recip) >> (16 - shift))); - } + return z1 + (((z0 - z1) / (xdiff << 1)) * (xdiff-x<<1)); } }