mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-03-25 04:11:05 +00:00
Changed MD2 coloring again
Squares the colors to get nicer looking results (https://www.youtube.com/watch?v=LKnqECcg6Gw), as well as only blending a small chunk of the skincolor to prevent desaturation from the brightest/darkest values.
This commit is contained in:
parent
ac2f81e423
commit
c9994c6ad8
1 changed files with 15 additions and 29 deletions
|
@ -987,40 +987,26 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
|||
|
||||
// Average all of the translation's colors
|
||||
{
|
||||
UINT16 r, g, b;
|
||||
UINT8 div = 0;
|
||||
const UINT8 div = 6;
|
||||
const UINT8 start = 4;
|
||||
UINT32 r, g, b;
|
||||
|
||||
blendcolor = V_GetColor(colortranslations[color][0]);
|
||||
r = (UINT16)blendcolor.s.red;
|
||||
g = (UINT16)blendcolor.s.green;
|
||||
b = (UINT16)blendcolor.s.blue;
|
||||
blendcolor = V_GetColor(colortranslations[color][start]);
|
||||
r = (UINT32)(blendcolor.s.red*blendcolor.s.red);
|
||||
g = (UINT32)(blendcolor.s.green*blendcolor.s.green);
|
||||
b = (UINT32)(blendcolor.s.blue*blendcolor.s.blue);
|
||||
|
||||
for (i = 1; i < 16; i++)
|
||||
for (i = 1; i < div; i++)
|
||||
{
|
||||
RGBA_t nextcolor = V_GetColor(colortranslations[color][i]);
|
||||
UINT8 mul = 1;
|
||||
// Weight these shades more. Indices 1-9 weren't randomly picked, they are commonly used on sprites and are generally what the colors "look" like
|
||||
if (i >= 1 && i <= 9)
|
||||
mul++;
|
||||
// The mid & dark tons on the minimap icons get weighted even harder
|
||||
if (i == 4 || i == 6)
|
||||
mul += 2;
|
||||
// And the shade between them, why not
|
||||
if (i == 5)
|
||||
mul++;
|
||||
r += (UINT16)(nextcolor.s.red)*mul;
|
||||
g += (UINT16)(nextcolor.s.green)*mul;
|
||||
b += (UINT16)(nextcolor.s.blue)*mul;
|
||||
div += mul;
|
||||
RGBA_t nextcolor = V_GetColor(colortranslations[color][start+i]);
|
||||
r += (UINT32)(nextcolor.s.red*nextcolor.s.red);
|
||||
g += (UINT32)(nextcolor.s.green*nextcolor.s.green);
|
||||
b += (UINT32)(nextcolor.s.blue*nextcolor.s.blue);
|
||||
}
|
||||
|
||||
// This shouldn't happen.
|
||||
if (div < 1)
|
||||
div = 1;
|
||||
|
||||
blendcolor.s.red = (UINT8)(r/div);
|
||||
blendcolor.s.green = (UINT8)(g/div);
|
||||
blendcolor.s.blue = (UINT8)(b/div);
|
||||
blendcolor.s.red = (UINT8)(FixedSqrt((r/div)<<FRACBITS)>>FRACBITS);
|
||||
blendcolor.s.green = (UINT8)(FixedSqrt((g/div)<<FRACBITS)>>FRACBITS);
|
||||
blendcolor.s.blue = (UINT8)(FixedSqrt((b/div)<<FRACBITS)>>FRACBITS);
|
||||
}
|
||||
|
||||
// rainbow support, could theoretically support boss ones too
|
||||
|
|
Loading…
Reference in a new issue