A way to "offset" a 2D tiling texture in, for example, a TextureRect to create a scrolling texture.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sethseth6

Alright, so, I was designing some menus using Controls in Godot, and I had a cool idea to make an infinitely scrolling chevron on it. My guess on how to do it was to have the texture tile, and then set some sort of horizontal texture offset parameter on it to increment via script, to seemingly animate it. The issue is, I couldn’t find any options to offset only the texture, in the style of UVs. Did I do something wrong while looking, or is this not a thing? This is how I would have done it anywhere else.

:bust_in_silhouette: Reply From: eons

I can only think of a shader.

A simple example of scrolling texture shader (texture must be imported with repeat enabled):

shader_type canvas_item;

void fragment(){
	vec2 newuv = UV;
	newuv.x += TIME;
	vec4 c = texture(TEXTURE, newuv);
	COLOR = c;

It will need an uniform to control the offset correctly instead of time based as the example.

This works very well, thanks. I completely forgot UVs work like that, d’oh.

sethseth6 | 2019-04-27 23:15

1 Like