That was my initial plan, and would have worked alright for something like the eyes since eye color is usually all one color.
But by altering the Hue in HSV color space instead, the final color of a hair style or piece of clothing can be multi-colored, and I don’t need to desaturate the image to make it white, so I could have purple hair with green highlights for example.
I believe the HSV color space was specifically intended for editing colors in a way that is more sensical to humans, since it splits a colors Hue, Saturation, and Brightness into the x, y, and z components of a vec3. So instead of having to adjust all 3 components of a blue color to shift it to orange in RGB space, you can convert your RGB color to HSV, then change only the x component to adjust the hue to any color. So If you add 0.5 to the x component of an HSV vec and convert back to RGB, you’ll essentially invert all the colors.
I don’t know if I’m explaining it as best as possible, most of my understanding of working with Hue/Saturation/Brightness editing is from using Gimp’s visual editor for editing texture’s Hue Saturation and Brightness which has always been very useful to me, and then @RiccardoBlb recently suggested this shader code when I was working on something else and I realized how easily I could make my cosmetic shaders work to adjust hsv as well
vec3 rgb2hsv(vec3 c){
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c){
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
So the command I’m calling in my video is setting the vec3 variable named m_HSVScalar that’s used by this code in my shader
vec3 colorHSV = rgb2hsv(albedo.rgb);
colorHSV.x += m_HSVScalar.x; //add hue
colorHSV.y += m_HSVScalar.y ; //likely better off multiplying S and V values by a positive value instead of adding
colorHSV.z += m_HSVScalar.z;
vec3 newColorFromHSV = hsv2rgb(colorHSV);
albedo.rgb = newColorFromHSV.xyz;