Basic Shimmer

Change th hue on the fly when a canvas item is drawn.

Shader code
shader_type canvas_item;
// A Shimmer's colours: every pixel takes the species' shimmer hue and saturation and keeps its own
// brightness and alpha.
// amount 0 leaves the art as it is. white fades the result to white (the evolution flash).

uniform float hue : hint_range(0.0, 1.0) = 0.0;
uniform float sat : hint_range(0.0, 1.0) = 0.0;
uniform float amount : hint_range(0.0, 1.0) = 1.0;
uniform float white : hint_range(0.0, 1.0) = 0.0;

varying vec4 tint;

vec3 hsv2rgb(vec3 c) {
	vec3 p = abs(fract(c.xxx + vec3(0.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - 3.0);
	return c.z * mix(vec3(1.0), clamp(p - 1.0, 0.0, 1.0), c.y);
}

void vertex() {
	tint = COLOR;
}

void fragment() {
	vec4 t = texture(TEXTURE, UV);
	float v = max(t.r, max(t.g, t.b));
	vec3 rgb = mix(t.rgb, hsv2rgb(vec3(hue, sat, v)), amount);
	rgb = mix(rgb, vec3(1.0), white);
	COLOR = vec4(rgb, t.a) * tint;
}
Live Preview
Tags
Compositor Effect, Dynamic, hue, shader, shimmer
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Comments 0

No comments yet.