How to Clip A Texture

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

I have a texture on a flat surface, and I’m sliding the texture across that surface. I would like to clip the texture when it moves off the side of the surface to give the effect of the image scrolling off the surface, but Godot simply starts redisplaying the texture on the opposite side (repeats).

Is there a setting somewhere that will prevent the texture from repeating like that, but will instead clip the texture at the surface’s edges?

:bust_in_silhouette: Reply From: stormreaver

After much research, and an unnecessary detour into shaders, I found the simple solution: Sprite3D. Combining the region_rect and offset properties, I am able to get the effect I am after: a texture that slides off the end of a surface.

For anyone interested, here’s a video of the solution:

stormreaver | 2020-11-26 14:14

I mostly get the effect I’m after, but Sprite3D is HORRIBLY slow. On the Quest 2, one 1024x256 Sprite3D causes a noticeable slowdown, and a few more of them make my game too slow to be playable. It quickly gets to the point where the Quest 2 becomes almost entirely unresponsive (somewhere around seven or eight).

Contrast this to meshes with 1024x1024 textures, where I can have many meshes without any noticeable impact on playability.

stormreaver | 2020-11-28 22:34

:bust_in_silhouette: Reply From: qumico
:bust_in_silhouette: Reply From: scrubswithnosleeves

I do this all the time. Just use the sprite region rect and modify the params through code or an animation player.