mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-28 18:34:18 +00:00
25 lines
736 B
Text
25 lines
736 B
Text
shader_type canvas_item;
|
|
|
|
uniform float hue;
|
|
|
|
vec3 hsv_to_rgb(vec3 color) {
|
|
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
vec3 p = abs(fract(color.xxx + K.xyz) * 6.0 - K.www);
|
|
return color.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), color.y);
|
|
}
|
|
|
|
vec3 rgb_to_hsv(vec3 color) {
|
|
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
vec4 p = mix(vec4(color.bg, K.wz), vec4(color.gb, K.xy), step(color.b, color.g));
|
|
vec4 q = mix(vec4(p.xyw, color.r), vec4(color.r, p.yzx), step(p.x, color.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);
|
|
}
|
|
|
|
void fragment() {
|
|
vec3 hsv = rgb_to_hsv(COLOR.rgb);
|
|
hsv.x = hue;
|
|
vec3 rgb = hsv_to_rgb(hsv);
|
|
COLOR.rgb = rgb;
|
|
}
|