Skip to content

Instantly share code, notes, and snippets.

@SIsilicon
Last active January 3, 2020 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SIsilicon/213145bc93d8888b09acd275ae56392b to your computer and use it in GitHub Desktop.
Save SIsilicon/213145bc93d8888b09acd275ae56392b to your computer and use it in GitHub Desktop.
shader_type canvas_item;
render_mode unshaded, blend_add;
vec3 hsv2rgb(vec3 c) {
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);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void vertex() {
float time = fract(TIME / 6.28) * 6.28;
VERTEX.x += UV.x * sin(time * 15.0 + UV.y * 20.0) * 10.0;
VERTEX.x -= UV.x * cos(time * 20.0 + UV.y * 15.0) * 5.0;
}
void fragment() {
float tail_center = abs(UV.y - 0.5);
vec3 rainbow = vec3(0.0, 0.5, 2.0); // hsv
rainbow.x += tail_center - fract(TIME / 2.0) * 2.0;
rainbow = hsv2rgb(rainbow);
COLOR = vec4(rainbow, 2.0 * (0.5 - tail_center));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment