diff options
author | Jaklyy <102590697+Jaklyy@users.noreply.github.com> | 2023-08-27 07:29:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-27 13:29:12 +0200 |
commit | d69745b3a82ed75da71e93a0061581367084a6fe (patch) | |
tree | 9e1548ea37f0fc9661ca63d97e301543584f2678 /src/GPU3D_Soft.cpp | |
parent | dc8efb62b8895b88bad95d2291af402c80806f01 (diff) |
Fix Incorrect Polygon Swapping Behavior and Implement Correct Rules for Shifting Right Edges Left (#1816)
* fix polygons being swapped incorrectly
"borrowed" this from noods
needs verification that the >= and <= signs aren't actually supposed to be > and <
* proper rules for moving vertical right slopes left
* nvm most of that was actually pointless
that's on me for not checking
Diffstat (limited to 'src/GPU3D_Soft.cpp')
-rw-r--r-- | src/GPU3D_Soft.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index 10ad1d6..1323f81 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -742,6 +742,11 @@ void SoftRenderer::RenderShadowMaskScanline(RendererPolygon* rp, s32 y) s32 zl = rp->SlopeL.Interp.InterpolateZ(polygon->FinalZ[rp->CurVL], polygon->FinalZ[rp->NextVL], polygon->WBuffer); s32 zr = rp->SlopeR.Interp.InterpolateZ(polygon->FinalZ[rp->CurVR], polygon->FinalZ[rp->NextVR], polygon->WBuffer); + // right vertical edges are pushed 1px to the left as long as either: + // the left edge slope is not 0, or the span is not 0 pixels wide, and it is not at the leftmost pixel of the screen + if (rp->SlopeR.Increment==0 && (rp->SlopeL.Increment!=0 || xstart != xend) && (xend != 0)) + xend--; + // if the left and right edges are swapped, render backwards. if (xstart > xend) { @@ -955,6 +960,11 @@ void SoftRenderer::RenderPolygonScanline(RendererPolygon* rp, s32 y) s32 zl = rp->SlopeL.Interp.InterpolateZ(polygon->FinalZ[rp->CurVL], polygon->FinalZ[rp->NextVL], polygon->WBuffer); s32 zr = rp->SlopeR.Interp.InterpolateZ(polygon->FinalZ[rp->CurVR], polygon->FinalZ[rp->NextVR], polygon->WBuffer); + + // right vertical edges are pushed 1px to the left as long as either: + // the left edge slope is not 0, or the span is not 0 pixels wide, and it is not at the leftmost pixel of the screen + if (rp->SlopeR.Increment==0 && (rp->SlopeL.Increment!=0 || xstart != xend) && (xend != 0)) + xend--; // if the left and right edges are swapped, render backwards. // on hardware, swapped edges seem to break edge length calculation, |