flipbook shader

simple flipbook shader, refer to https://godotshaders.com/snippet/flipbook/


Shader code
shader_type canvas_item;

vec2 flipbook(vec2 uv, vec2 size, float progress){
	progress = floor(mod(progress, (size.x * size.y)));
	vec2 frame_size = vec2(1.0, 1.0) / vec2(size.x, size.y);

	float h = mod(progress, size.x);
	float v = floor(progress / size.x);
	vec2 hv = vec2(h, v);
	vec2 frame = (uv / size) + hv * frame_size;
	return frame;

void fragment()
	vec2 flip_uv = flipbook(UV, vec2(4.0, 4.0), TIME * 10.);
	vec4 flip_texture = texture(TEXTURE, flip_uv);
	COLOR = flip_texture;
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

Port of “An introduction to Shader Art Coding” by kishimisu

Distortion/Shockwave Shader

Mana Resource Orb Shader

Notify of

Inline Feedbacks
View all comments