Fix ACZ fence texture

This commit is contained in:
Jaime Passos 2020-02-01 22:25:48 -03:00
parent 8350a8c58a
commit 4446b0d563
1 changed files with 21 additions and 15 deletions

View File

@ -230,25 +230,31 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha)
{
RGBA_t output;
INT16 fullalpha = (alpha - (0xFF - foreground.s.alpha));
if (style == AST_TRANSLUCENT)
{
if (alpha == 0)
if (fullalpha <= 0)
output.rgba = background.rgba;
else if (alpha == 0xFF)
output.rgba = foreground.rgba;
else if (alpha < 0xFF)
{
UINT8 beta = (0xFF - alpha);
output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF;
output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF;
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF;
}
// write foreground pixel alpha
// if there's no pixel in here
if (!background.rgba)
output.s.alpha = foreground.s.alpha;
else
output.s.alpha = 0xFF;
{
// don't go too high
if (fullalpha >= 0xFF)
fullalpha = 0xFF;
alpha = (UINT8)fullalpha;
// if the background pixel is empty,
// match software and don't blend anything
if (!background.s.alpha)
output.s.alpha = 0;
else
{
UINT8 beta = (0xFF - alpha);
output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF;
output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF;
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF;
output.s.alpha = 0xFF;
}
}
return output.rgba;
}
#define clamp(c) max(min(c, 0xFF), 0x00);