-
Notifications
You must be signed in to change notification settings - Fork 0
/
hue_shift.gdshader
35 lines (28 loc) · 930 Bytes
/
hue_shift.gdshader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
shader_type canvas_item;
render_mode unshaded;
uniform float shiftHue;
void fragment() {
vec3 input_color;
vec4 texture_color = texture(TEXTURE, UV);
input_color = texture_color.rgb;
vec3 color_hsv;
{
vec3 c = input_color;
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;
color_hsv=vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
color_hsv.x = mod((color_hsv.x + shiftHue), 1.0f);
vec3 color_rgb;
{
vec3 c = color_hsv;
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);
color_rgb=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
texture_color = vec4(color_rgb.rgb,texture_color.a);
COLOR.rgba = texture_color;
}