eyelids / blinking

make a ColorRect that fills the whole screen and apply this shader to the material in the CanvasItem section

Shader code
shader_type canvas_item;

uniform float open_amount : hint_range(0.0, 1.0, 0.01);
uniform float edge_blur_amount : hint_range(0.0, 1.0, 0.01);
uniform vec3 color : source_color;

void fragment() {
	float blur = edge_blur_amount * 0.5;
	float v = open_amount + edge_blur_amount * open_amount;
	float d1 = (2.0 * v * pow(UV.x - 0.5, 2.0) - v/2.0 + 0.5) - (UV.y+v/(2.0));
	float d2 = -(-2.0 * v * pow(UV.x - 0.5, 2.0) + v/2.0 + 0.5) + (UV.y-v/(2.0));
	float d = max(d1, d2);

	if (d > -blur){
		COLOR = vec4(color, (-d-blur)/-blur);
	} else {
		COLOR = vec4(0.0);
	}
}
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

Blinking Bomb Countdown

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments