Simple tiled texture scroll

Applies simple vertex-based UV scrolling for any canvasitem. When used on a textured node, creates a scrolling texture effect. Can be used with sprites or texturerects to create scrolling texture rectangles. Can be used with a meshinstance2d to create free-form cutouts of scrolling texture. May have other uses if you’re clever. Tiles in both dimensions.

NOTE: if using with a texture, texture must have repeat enabled.

Motion: controls scrolling, in pixels.
Offset: fixed texture offset, also in pixels.
Scale: scale multiplier for the texture. 1.0 means 1 texture pixel is mapped to 1 pixel of local space. Must not be zero.

Shader code
shader_type canvas_item;

uniform vec2 motion = vec2(0.0);
uniform float scale = 1.0;
uniform vec2 offset = vec2(0.0);

void vertex(){
	UV = (VERTEX + offset + TIME * motion) * TEXTURE_PIXEL_SIZE * (1.0/scale);
scrolling, simple, tiling
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

Tiled texture inside of mask

Brick/tiled wall

Squishy scroll

Notify of

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

ultra thanks!!!!!!!