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
|
@ -987,40 +987,26 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||||
|
|
||||||
// Average all of the translation's colors
|
// Average all of the translation's colors
|
||||||
{
|
{
|
||||||
UINT16 r, g, b;
|
const UINT8 div = 6;
|
||||||
UINT8 div = 0;
|
const UINT8 start = 4;
|
||||||
|
UINT32 r, g, b;
|
||||||
|
|
||||||
blendcolor = V_GetColor(colortranslations[color][0]);
|
blendcolor = V_GetColor(colortranslations[color][start]);
|
||||||
r = (UINT16)blendcolor.s.red;
|
r = (UINT32)(blendcolor.s.red*blendcolor.s.red);
|
||||||
g = (UINT16)blendcolor.s.green;
|
g = (UINT32)(blendcolor.s.green*blendcolor.s.green);
|
||||||
b = (UINT16)blendcolor.s.blue;
|
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]);
|
RGBA_t nextcolor = V_GetColor(colortranslations[color][start+i]);
|
||||||
UINT8 mul = 1;
|
r += (UINT32)(nextcolor.s.red*nextcolor.s.red);
|
||||||
// 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
|
g += (UINT32)(nextcolor.s.green*nextcolor.s.green);
|
||||||
if (i >= 1 && i <= 9)
|
b += (UINT32)(nextcolor.s.blue*nextcolor.s.blue);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This shouldn't happen.
|
blendcolor.s.red = (UINT8)(FixedSqrt((r/div)<<FRACBITS)>>FRACBITS);
|
||||||
if (div < 1)
|
blendcolor.s.green = (UINT8)(FixedSqrt((g/div)<<FRACBITS)>>FRACBITS);
|
||||||
div = 1;
|
blendcolor.s.blue = (UINT8)(FixedSqrt((b/div)<<FRACBITS)>>FRACBITS);
|
||||||
|
|
||||||
blendcolor.s.red = (UINT8)(r/div);
|
|
||||||
blendcolor.s.green = (UINT8)(g/div);
|
|
||||||
blendcolor.s.blue = (UINT8)(b/div);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rainbow support, could theoretically support boss ones too
|
// rainbow support, could theoretically support boss ones too
|
||||||
|
|
Loading…
Reference in a new issue