#Correctly adjust color's brightness
1 messages · Page 1 of 1 (latest)
Color.RGBToHSV(_initialColor, out float h, out float s, out float v);
float percent = value / 100f;
v *= 1 + percent;
s *= 1 - percent;
_color = Color.HSVToRGB(h, s, v);
The solution is to also multiply the HSV's saturation (s).
This works on all colors but full black, since there is nothing to multiply ((0, 0, 0))
What is also to note is that the color's alpha is to be set to the initial one's, since it's overriden to 1 on convention
Since this approach creates a larger color difference for the colors with greater RGB values, which makes it impossible to change pure black and only works perfectly for pure white, it's much better to add the percent instead.
float percent = value / 100f;
v += percent;
s -= percent;
Writing this if someone faces the same issue in the future. In this case, write me for the source code.