Skip to content

Instantly share code, notes, and snippets.

@Capital-EX
Last active February 1, 2019 08:16
Show Gist options
  • Save Capital-EX/1565525a7a3e0a038de9dc9a4e8836f8 to your computer and use it in GitHub Desktop.
Save Capital-EX/1565525a7a3e0a038de9dc9a4e8836f8 to your computer and use it in GitHub Desktop.
Simple little shader to animate tiles in Godot
// Sprite sheet
uniform texture sprites;
// Distance to travel for next sprite
uniform vec2 offset_xy;
// Size of sprite sheet
uniform vec2 texture_wh;
// Number of frames
uniform float frames;
// Frames per second
uniform float speed = 1.0;
float time = TIME * speed;
vec2 offset = offset_xy / texture_wh;
offset *= mod(floor(time), frames);
COLOR = tex(sprites, UV + offset);
@doums
Copy link

doums commented Feb 1, 2019

thank dude!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment