shaders: Small optimization in rgb2hsl. (#3831)

This commit is contained in:
Dickby 2023-11-11 18:20:18 +01:00 committed by GitHub
parent ae46fbafe5
commit 6eb2abcb20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -238,14 +238,13 @@ vec3 rgb2hsl(vec3 col) {
vec3 adds = vec3(((green - blue) / delta), 2.0 + ((blue - red) / delta), 4.0 + ((red - green) / delta)); vec3 adds = vec3(((green - blue) / delta), 2.0 + ((blue - red) / delta), 4.0 + ((red - green) / delta));
float deltaGtz = (delta > 0.0) ? 1.0 : 0.0; if (delta > 0.0) {
hue += dot(adds, masks); hue += dot(adds, masks);
hue *= deltaGtz;
hue /= 6.0; hue /= 6.0;
if (hue < 0.0) if (hue < 0.0)
hue += 1.0; hue += 1.0;
}
return vec3(hue, sat, lum); return vec3(hue, sat, lum);
} }