mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Merge pull request #1606 from LordSk/feature/team_colors
Tuned down custom skin saturation/luminosity influence on team colors
This commit is contained in:
commit
e6634cc6bd
|
@ -152,7 +152,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
const json_value &rPart = rStart[(const char *)ms_apSkinPartNames[PartIndex]];
|
||||
if(rPart.type != json_object)
|
||||
continue;
|
||||
|
||||
|
||||
// filename
|
||||
const json_value &rFilename = rPart["filename"];
|
||||
if(rFilename.type == json_string)
|
||||
|
@ -174,7 +174,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|||
// color components
|
||||
if(!UseCustomColors)
|
||||
continue;
|
||||
|
||||
|
||||
for(int i = 0; i < NUM_COLOR_COMPONENTS; i++)
|
||||
{
|
||||
if(PartIndex != SKINPART_MARKING && i == 3)
|
||||
|
@ -354,46 +354,29 @@ vec4 CSkins::GetColorV4(int v, bool UseAlpha) const
|
|||
|
||||
int CSkins::GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const
|
||||
{
|
||||
static const int s_aTeamColors[3] = {12895054, 65387, 10223467};
|
||||
static const int s_aTeamColors[3] = {0xC4C34E, 0x00FF6B, 0x9BFF6B};
|
||||
|
||||
int TeamHue = (s_aTeamColors[Team+1]>>16)&0xff;
|
||||
int TeamSat = (s_aTeamColors[Team+1]>>8)&0xff;
|
||||
int TeamLgt = s_aTeamColors[Team+1]&0xff;
|
||||
int PartSat = (PartColor>>8)&0xff;
|
||||
int PartLgt = PartColor&0xff;
|
||||
|
||||
if(!UseCustomColors)
|
||||
{
|
||||
int ColorVal = s_aTeamColors[Team+1];
|
||||
if(Part == SKINPART_MARKING)
|
||||
ColorVal |= 0xff000000;
|
||||
return ColorVal;
|
||||
PartSat = 255;
|
||||
PartLgt = 255;
|
||||
}
|
||||
|
||||
/*blue128: 128/PI*ARCSIN(COS((PI*(x+10)/128)))+182 // (decoration, marking, hands)
|
||||
blue64: 64/PI*ARCSIN(COS((PI*(x-76)/64)))+172 // (body, feet, eyes)
|
||||
red128: Mod((128/PI*ARCSIN(COS((PI*(x-105)/128)))+297),256)
|
||||
red64: Mod((64/PI*ARCSIN(COS((PI*(x-56)/64)))+280),256)*/
|
||||
|
||||
int MinSat = 160;
|
||||
int MaxSat = 255;
|
||||
float Dark = DARKEST_COLOR_LGT/255.0f;
|
||||
int MinLgt = Dark + 64*(1.0f-Dark);
|
||||
int MaxLgt = Dark + 191*(1.0f-Dark);
|
||||
|
||||
int Hue = 0;
|
||||
int Sat = (PartColor>>8)&0xff;
|
||||
int Lgt = PartColor&0xff;
|
||||
int h = TeamHue;
|
||||
int s = clamp(mix(TeamSat, PartSat, 0.2), MinSat, MaxSat);
|
||||
int l = clamp(mix(TeamLgt, PartLgt, 0.2), (int)DARKEST_COLOR_LGT, 200);
|
||||
|
||||
int NewHue;
|
||||
if(Team == TEAM_RED)
|
||||
{
|
||||
if(Part == SKINPART_MARKING || Part == SKINPART_DECORATION || Part == SKINPART_HANDS)
|
||||
NewHue = (int)(128.0f/pi*asinf(cosf(pi/128.0f*(Hue-105.0f))) + 297.0f) % 256;
|
||||
else
|
||||
NewHue = (int)(64.0f/pi*asinf(cosf(pi/64.0f*(Hue-56.0f))) + 280.0f) % 256;
|
||||
}
|
||||
else
|
||||
NewHue = 64.0f/pi*asinf(cosf(pi/64.0f*(Hue-76.0f))) + 172.0f;
|
||||
|
||||
int NewSat = clamp(Sat, MinSat, MaxSat);
|
||||
int NewLgt = clamp(Lgt, MinLgt, MaxLgt);
|
||||
int ColorVal = (NewHue<<16) + (NewSat<<8) + NewLgt;
|
||||
|
||||
if(Part == SKINPART_MARKING)
|
||||
int ColorVal = (h<<16) + (s<<8) + l;
|
||||
if(Part == SKINPART_MARKING) // keep alpha
|
||||
ColorVal += PartColor&0xff000000;
|
||||
|
||||
return ColorVal;
|
||||
|
|
Loading…
Reference in a new issue