Shining Sprite Effect

This shader has to be applied directly on a sprite. It will animate depending on the TIME and use the luminance to determine which part of the sprite to highlight.

Shader code
shader_type canvas_item;

const float PI = 3.141516;

uniform float speed = 1.;

uniform vec4 tint : hint_color = vec4(1., 1., 0., 1.);

uniform float span : hint_range(0.1, 1.) = .3;

float luminance(vec4 colour) {
	return 1.0 - sqrt(0.299*colour.r*colour.r + 0.587*colour.g*colour.g + 0.114*colour.b*colour.b);
}

void fragment() {
	vec4 colour = texture(TEXTURE, UV);
	float target = abs(sin(TIME * PI * speed) * (1. + span));
	if(colour.a > 0.) {
		float lum = luminance(colour);
		float diff = abs(lum - target);
		float mx = clamp(1. - diff / span, 0., 1.);
		colour = mix(colour, tint, mx);
	}
	
	COLOR = colour;
}
Tags
armor, color shift
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.

More from CasualGarageCoder

Swirl/Sink

Shield with impact waves

Frosty Rotative Deformation

Related shaders

Sprite progress bar

Sprite Perspective Correection

Play with Furcifer sprite deformation shader

guest

0 Comments
Inline Feedbacks
View all comments