duderino > learn > knowledge > snippets > color

getSaturation

float getSaturation(vec3 color){ // from gpt-4, no idea if this makes sense
    float maxColor = max(max(color.r, color.g), color.b);
    float minColor = min(min(color.r, color.g), color.b);
    if (maxColor == 0.0) return 0.0;
    return 1.0 - (minColor / maxColor);
}