Skip to content

Instantly share code, notes, and snippets.

@xsellier
Forked from MrBSmith/Repeated pattern shader
Created February 19, 2024 15:13
Show Gist options
  • Save xsellier/063842c2f53be1c3c8bc40ade3e157f5 to your computer and use it in GitHub Desktop.
Save xsellier/063842c2f53be1c3c8bc40ade3e157f5 to your computer and use it in GitHub Desktop.
shader_type canvas_item;
uniform float row_offset : hint_range(0.0, 1.0, 0.01);
uniform vec2 direction = vec2(0.77, 0.77);
uniform float speed = 10.0;
uniform float skew_amount : hint_range(-1.0, 1.0, 0.01) = 0.5;
uniform float perspective_amount = -0.5;
void fragment() {
float scale = 1.0;
vec2 move_uv = UV + direction * TIME * speed;
vec2 pick_uv = vec2(move_uv.x, move_uv.y + (move_uv.x * skew_amount)) / vec2(scale + ((UV.x - 0.5) * perspective_amount));
int row_id = int(pick_uv.y);
if (row_id % 2 != 0) {
pick_uv += vec2(row_offset, 0.0);
}
vec4 texture_color = texture(TEXTURE, pick_uv);
COLOR = texture_color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment