mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
More blend image updates
- Allow the translations that don't make use a blend image to work without requiring a blend image to be present - Fix TC_RAINBOW not working properly - TC_METALSONIC now remaps the _blend image to SKINCOLOR_COBALT, then inverts all of the blue, replicating how it works in Software (cherry picked from commit 74d7f256a7849d0c829177614b37089e2446f86b)
This commit is contained in:
parent
1871d01de6
commit
3191c365de
1 changed files with 260 additions and 242 deletions
|
|
@ -654,12 +654,12 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
UINT16 w = gpatch->width, h = gpatch->height;
|
UINT16 w = gpatch->width, h = gpatch->height;
|
||||||
UINT32 size = w*h;
|
UINT32 size = w*h;
|
||||||
RGBA_t *image, *blendimage, *cur, blendcolor;
|
RGBA_t *image, *blendimage, *cur, blendcolor;
|
||||||
UINT8 i;
|
|
||||||
|
|
||||||
UINT8 translation[16]; // First the color index
|
UINT8 translation[16]; // First the color index
|
||||||
UINT8 cutoff[16]; // Brightness cutoff before using the next color
|
UINT8 cutoff[16]; // Brightness cutoff before using the next color
|
||||||
UINT8 translen = 0;
|
UINT8 translen = 0;
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
|
blendcolor = V_GetColor(0); // initialize
|
||||||
memset(translation, 0, sizeof(translation));
|
memset(translation, 0, sizeof(translation));
|
||||||
memset(cutoff, 0, sizeof(cutoff));
|
memset(cutoff, 0, sizeof(cutoff));
|
||||||
|
|
||||||
|
|
@ -685,7 +685,10 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
|
|
||||||
image = gpatch->mipmap->grInfo.data;
|
image = gpatch->mipmap->grInfo.data;
|
||||||
blendimage = blendgpatch->mipmap->grInfo.data;
|
blendimage = blendgpatch->mipmap->grInfo.data;
|
||||||
blendcolor = V_GetColor(0); // initialize
|
|
||||||
|
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
|
||||||
|
if (skinnum == TC_METALSONIC)
|
||||||
|
color = SKINCOLOR_COBALT;
|
||||||
|
|
||||||
if (color != SKINCOLOR_NONE)
|
if (color != SKINCOLOR_NONE)
|
||||||
{
|
{
|
||||||
|
|
@ -721,7 +724,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
if (skinnum == TC_BOSS)
|
if (skinnum == TC_BOSS)
|
||||||
{
|
{
|
||||||
// Turn everything below a certain threshold white
|
// Turn everything below a certain threshold white
|
||||||
if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue <= 82)
|
if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127)
|
||||||
{
|
{
|
||||||
// Lactozilla: Invert the colors
|
// Lactozilla: Invert the colors
|
||||||
cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue);
|
cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue);
|
||||||
|
|
@ -735,23 +738,23 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
|
|
||||||
cur->s.alpha = image->s.alpha;
|
cur->s.alpha = image->s.alpha;
|
||||||
}
|
}
|
||||||
else if (skinnum == TC_METALSONIC)
|
else if (skinnum == TC_ALLWHITE)
|
||||||
{
|
{
|
||||||
// Turn everything below a certain blue threshold white
|
// Turn everything white
|
||||||
if (image->s.red == 0 && image->s.green == 0 && image->s.blue <= 82)
|
cur->s.red = cur->s.green = cur->s.blue = 255;
|
||||||
{
|
cur->s.alpha = image->s.alpha;
|
||||||
cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cur->s.red = image->s.red;
|
// Everything below requires a blend image
|
||||||
cur->s.green = image->s.green;
|
if (blendimage == NULL)
|
||||||
cur->s.blue = image->s.blue;
|
{
|
||||||
|
cur->rgba = image->rgba;
|
||||||
|
goto skippixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->s.alpha = image->s.alpha;
|
// Metal Sonic dash mode
|
||||||
}
|
if (skinnum == TC_DASHMODE)
|
||||||
else if (skinnum == TC_DASHMODE)
|
|
||||||
{
|
{
|
||||||
if (image->s.alpha == 0 && blendimage->s.alpha == 0)
|
if (image->s.alpha == 0 && blendimage->s.alpha == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -771,28 +774,29 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
bcolor.s.red = 255;
|
bcolor.s.red = 255;
|
||||||
bcolor.s.green = (blendimage->s.red + blendimage->s.green + blendimage->s.blue) / 3;
|
bcolor.s.green = (blendimage->s.red + blendimage->s.green + blendimage->s.blue) / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image->s.alpha && image->s.red > image->s.green << 1) // this is pretty arbitrary, but it works well for Metal Sonic
|
if (image->s.alpha && image->s.red > image->s.green << 1) // this is pretty arbitrary, but it works well for Metal Sonic
|
||||||
{
|
{
|
||||||
icolor.s.red = image->s.blue;
|
icolor.s.red = image->s.blue;
|
||||||
icolor.s.blue = image->s.red;
|
icolor.s.blue = image->s.red;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->s.red = (ialpha * icolor.s.red + balpha * bcolor.s.red)/255;
|
cur->s.red = (ialpha * icolor.s.red + balpha * bcolor.s.red)/255;
|
||||||
cur->s.green = (ialpha * icolor.s.green + balpha * bcolor.s.green)/255;
|
cur->s.green = (ialpha * icolor.s.green + balpha * bcolor.s.green)/255;
|
||||||
cur->s.blue = (ialpha * icolor.s.blue + balpha * bcolor.s.blue)/255;
|
cur->s.blue = (ialpha * icolor.s.blue + balpha * bcolor.s.blue)/255;
|
||||||
cur->s.alpha = image->s.alpha;
|
cur->s.alpha = image->s.alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (skinnum == TC_ALLWHITE)
|
|
||||||
{
|
|
||||||
// Turn everything white
|
|
||||||
cur->s.red = cur->s.green = cur->s.blue = 255;
|
|
||||||
cur->s.alpha = image->s.alpha;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// All settings that use skincolors!
|
||||||
UINT16 brightness;
|
UINT16 brightness;
|
||||||
|
|
||||||
I_Assert(translen > 0);
|
if (translen <= 0)
|
||||||
|
{
|
||||||
|
cur->rgba = image->rgba;
|
||||||
|
goto skippixel;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't bother with blending the pixel if the alpha of the blend pixel is 0
|
// Don't bother with blending the pixel if the alpha of the blend pixel is 0
|
||||||
if (skinnum == TC_RAINBOW)
|
if (skinnum == TC_RAINBOW)
|
||||||
|
|
@ -800,8 +804,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
if (image->s.alpha == 0 && blendimage->s.alpha == 0)
|
if (image->s.alpha == 0 && blendimage->s.alpha == 0)
|
||||||
{
|
{
|
||||||
cur->rgba = image->rgba;
|
cur->rgba = image->rgba;
|
||||||
cur++; image++; blendimage++;
|
goto skippixel;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -817,8 +820,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
if (blendimage->s.alpha == 0)
|
if (blendimage->s.alpha == 0)
|
||||||
{
|
{
|
||||||
cur->rgba = image->rgba;
|
cur->rgba = image->rgba;
|
||||||
cur++; image++; blendimage++;
|
goto skippixel; // for metal sonic blend
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -888,20 +890,14 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
if (m >= d)
|
if (m >= d)
|
||||||
m = d-1;
|
m = d-1;
|
||||||
|
|
||||||
|
mulmax = 16;
|
||||||
|
|
||||||
// calculate the "gradient" multiplier based on how close this color is to the one next in line
|
// calculate the "gradient" multiplier based on how close this color is to the one next in line
|
||||||
if (m <= 0 || d <= 0)
|
if (m <= 0 || d <= 0)
|
||||||
{
|
|
||||||
mul = 0;
|
mul = 0;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
mulmax = cutoff[firsti];
|
|
||||||
if (secondi < translen)
|
|
||||||
mulmax -= cutoff[secondi];
|
|
||||||
|
|
||||||
mul = (mulmax-1) - ((m * mulmax) / d);
|
mul = (mulmax-1) - ((m * mulmax) / d);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler
|
// Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler
|
||||||
|
|
@ -989,9 +985,29 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
cur->s.blue = (UINT8)tempcolor;
|
cur->s.blue = (UINT8)tempcolor;
|
||||||
cur->s.alpha = image->s.alpha;
|
cur->s.alpha = image->s.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skippixel:
|
||||||
|
|
||||||
|
// *Now* we can do Metal Sonic's flashing
|
||||||
|
if (skinnum == TC_METALSONIC)
|
||||||
|
{
|
||||||
|
// Blend dark blue into white
|
||||||
|
if (cur->s.alpha > 0 && cur->s.red == 0 && cur->s.green == 0 && cur->s.blue < 255 && cur->s.blue > 31)
|
||||||
|
{
|
||||||
|
// Sal: Invert non-blue
|
||||||
|
cur->s.red = cur->s.green = (255 - cur->s.blue);
|
||||||
|
cur->s.blue = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur++; image++; blendimage++;
|
cur->s.alpha = image->s.alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cur++; image++;
|
||||||
|
|
||||||
|
if (blendimage != NULL)
|
||||||
|
blendimage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
@ -1030,6 +1046,14 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||||
// If here, the blended texture has not been created
|
// If here, the blended texture has not been created
|
||||||
// So we create it
|
// So we create it
|
||||||
|
|
||||||
|
if ((blendgpatch && blendgpatch->mipmap->grInfo.format)
|
||||||
|
&& (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height))
|
||||||
|
{
|
||||||
|
// Blend image exists, but it's bad.
|
||||||
|
HWD.pfnSetTexture(gpatch->mipmap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
|
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
|
||||||
// (it have a liste of mipmap)
|
// (it have a liste of mipmap)
|
||||||
// this malloc is cleared in HWR_FreeTextureCache
|
// this malloc is cleared in HWR_FreeTextureCache
|
||||||
|
|
@ -1272,11 +1296,9 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
md2_loadBlendTexture(md2);
|
md2_loadBlendTexture(md2);
|
||||||
|
|
||||||
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
|
if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
|
||||||
{
|
|
||||||
if (md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format
|
|
||||||
&& gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height)
|
|
||||||
{
|
{
|
||||||
INT32 skinnum = INT32_MAX;
|
INT32 skinnum = INT32_MAX;
|
||||||
|
|
||||||
if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash"
|
if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash"
|
||||||
{
|
{
|
||||||
if (spr->mobj->type == MT_CYBRAKDEMON || spr->mobj->colorized)
|
if (spr->mobj->type == MT_CYBRAKDEMON || spr->mobj->colorized)
|
||||||
|
|
@ -1307,7 +1329,9 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
|
|
||||||
// Translation or skin number found
|
// Translation or skin number found
|
||||||
if (skinnum != INT32_MAX)
|
if (skinnum != INT32_MAX)
|
||||||
|
{
|
||||||
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color);
|
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Sorry nothing
|
// Sorry nothing
|
||||||
|
|
@ -1315,12 +1339,6 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// This is safe, since we know the texture has been downloaded
|
|
||||||
HWD.pfnSetTexture(gpatch->mipmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Sprite
|
// Sprite
|
||||||
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
|
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue