Fix software renderer ignoring texture in transparent render path

The transparent code path skipped texture sampling entirely, producing
a solid colored rectangle instead of the textured shape. Move texture
sampling before the opaque/transparent branch so both paths get texel
color modulation, and use texel alpha for per-pixel transparency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Semmler 2026-03-16 12:54:17 -07:00
parent 09ed6edb3e
commit 176aef1d90
No known key found for this signature in database
GPG Key ID: 086DAA1360BEEE5C

View File

@ -465,8 +465,7 @@ void Direct3DRMSoftwareRenderer::DrawTriangleProjected(
Uint8* pixelAddr = pixels + y * pitch + x * m_bytesPerPixel;
Uint32 finalColor;
if (appearance.color.a == 255) {
zref = z;
Uint8 alpha = appearance.color.a;
if (texels) {
// Perspective correct interpolate texture coords
@ -507,12 +506,21 @@ void Direct3DRMSoftwareRenderer::DrawTriangleProjected(
r = (r * tr + 127) / 255;
g = (g * tg + 127) / 255;
b = (b * tb + 127) / 255;
// Use texel alpha for per-pixel transparency
alpha = ta;
}
if (alpha == 0) {
continue;
}
if (alpha == 255) {
zref = z;
finalColor = SDL_MapRGBA(m_format, m_palette, r, g, b, 255);
}
else {
finalColor = BlendPixel(pixelAddr, r, g, b, appearance.color.a);
finalColor = BlendPixel(pixelAddr, r, g, b, alpha);
}
switch (m_bytesPerPixel) {