Make sure warning works for greyscale colors.

part of CURA-7262
This commit is contained in:
Remco Burema 2020-04-07 12:46:32 +02:00
parent b59d38e6c9
commit 5494a09eef
No known key found for this signature in database
GPG Key ID: 215C49431D43F98C

View File

@ -43,6 +43,13 @@ fragment =
vec3 shiftHue(vec3 color, float hue) vec3 shiftHue(vec3 color, float hue)
{ {
// Make sure colors are distinct when grey-scale is used too:
if ((max(max(color.r, color.g), color.b) - min(min(color.r, color.g), color.b)) < 0.1)
{
color = vec3(1.0, 0.0, 0.0);
}
// The actual hue shift:
const vec3 k = vec3(0.57735, 0.57735, 0.57735); const vec3 k = vec3(0.57735, 0.57735, 0.57735);
float cosAngle = cos(hue); float cosAngle = cos(hue);
return vec3(color * cosAngle + cross(k, color) * sin(hue) + k * dot(k, color) * (1.0 - cosAngle)); return vec3(color * cosAngle + cross(k, color) * sin(hue) + k * dot(k, color) * (1.0 - cosAngle));
@ -131,6 +138,13 @@ fragment41core =
vec3 shiftHue(vec3 color, float hue) vec3 shiftHue(vec3 color, float hue)
{ {
// Make sure colors are distinct when grey-scale is used too:
if ((max(max(color.r, color.g), color.b) - min(min(color.r, color.g), color.b)) < 0.1)
{
color = vec3(1.0, 0.0, 0.0);
}
// The actual hue shift:
const vec3 k = vec3(0.57735, 0.57735, 0.57735); const vec3 k = vec3(0.57735, 0.57735, 0.57735);
float cosAngle = cos(hue); float cosAngle = cos(hue);
return vec3(color * cosAngle + cross(k, color) * sin(hue) + k * dot(k, color) * (1.0 - cosAngle)); return vec3(color * cosAngle + cross(k, color) * sin(hue) + k * dot(k, color) * (1.0 - cosAngle));