Skip to content

Commit

Permalink
check lower pixel when top pixel ignores fog (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaklyy authored Aug 13, 2023
1 parent 5f9e7e1 commit f454eba
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/GPU3D_Soft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,26 +1423,27 @@ void SoftRenderer::ScanlineFinalPass(s32 y)
u32 density, srccolor, srcR, srcG, srcB, srcA;

u32 attr = AttrBuffer[pixeladdr];
if (!(attr & (1<<15))) continue;

density = CalculateFogDensity(pixeladdr);
if (attr & (1<<15))
{
density = CalculateFogDensity(pixeladdr);

srccolor = ColorBuffer[pixeladdr];
srcR = srccolor & 0x3F;
srcG = (srccolor >> 8) & 0x3F;
srcB = (srccolor >> 16) & 0x3F;
srcA = (srccolor >> 24) & 0x1F;
srccolor = ColorBuffer[pixeladdr];
srcR = srccolor & 0x3F;
srcG = (srccolor >> 8) & 0x3F;
srcB = (srccolor >> 16) & 0x3F;
srcA = (srccolor >> 24) & 0x1F;

if (fogcolor)
{
srcR = ((fogR * density) + (srcR * (128-density))) >> 7;
srcG = ((fogG * density) + (srcG * (128-density))) >> 7;
srcB = ((fogB * density) + (srcB * (128-density))) >> 7;
}
if (fogcolor)
{
srcR = ((fogR * density) + (srcR * (128-density))) >> 7;
srcG = ((fogG * density) + (srcG * (128-density))) >> 7;
srcB = ((fogB * density) + (srcB * (128-density))) >> 7;
}

srcA = ((fogA * density) + (srcA * (128-density))) >> 7;
srcA = ((fogA * density) + (srcA * (128-density))) >> 7;

ColorBuffer[pixeladdr] = srcR | (srcG << 8) | (srcB << 16) | (srcA << 24);
ColorBuffer[pixeladdr] = srcR | (srcG << 8) | (srcB << 16) | (srcA << 24);
}

// fog for lower pixel
// TODO: make this code nicer, but avoid using a loop
Expand Down

0 comments on commit f454eba

Please sign in to comment.