DS GX: Fix z-fighting and transparent colors

This commit is contained in:
Vicki Pfau 2017-03-01 18:12:47 -08:00
parent 4320669d21
commit 560e928d58
1 changed files with 13 additions and 8 deletions

View File

@ -100,6 +100,9 @@ static color_t _lookupColor(struct DSGXSoftwareEndpoint* ep, struct DSGXSoftware
case 7:
return _finishColor(0x3F, 0x3F, 0x3F);
}
if (DSGXTexParamsIs0Transparent(poly->poly->texParams) && !texel) {
return FLAG_UNWRITTEN;
}
uint8_t r, g, b;
texel = poly->palBase[texel];
_expandColor(texel, &r, &g, &b);
@ -392,6 +395,7 @@ static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int
struct DSGXSoftwareSpan* span = NULL;
struct DSGXSoftwareEndpoint ep;
int32_t depth = INT32_MIN;
scanline[i] = FLAG_UNWRITTEN;
if (i >= nextSpanX) {
size_t nextSpanId = DSGXSoftwareSpanListSize(&softwareRenderer->activeSpans);
span = DSGXSoftwareSpanListGetPointer(&softwareRenderer->activeSpans, nextSpanId - 1);
@ -412,10 +416,17 @@ static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int
struct DSGXSoftwareSpan* testSpan = DSGXSoftwareSpanListGetPointer(&softwareRenderer->activeSpans, nextSpanId - 1);
while (i > (testSpan->ep[0].x >> 12)) {
if (i <= (testSpan->ep[1].x >> 12)) {
_lerpEndpoint(testSpan, &ep, i);
if (ep.w > depth) {
_lerpEndpoint(testSpan, &ep, i);
color_t color = _lookupColor(&ep, testSpan->poly);
if (scanline[i] == FLAG_UNWRITTEN) {
scanline[i] = color;
}
if (ep.w >= depth) {
depth = ep.w;
span = testSpan;
if (color != FLAG_UNWRITTEN) {
scanline[i] = color;
}
}
}
--nextSpanId;
@ -426,12 +437,6 @@ static void DSGXSoftwareRendererDrawScanline(struct DSGXRenderer* renderer, int
}
}
}
if (span) {
_lerpEndpoint(span, &ep, i);
scanline[i] = _lookupColor(&ep, span->poly);
} else {
scanline[i] = FLAG_UNWRITTEN; // TODO
}
}
}