Archive 17/01/2023.

What is the best way to support background repeating in 2D?

yushli

I can’t find the APIs in the document. Thanks in advance.

yushli

A little bit more specific. That is, how to support the background moves toward one direction while keep repeating? like simulating a plane flying in the dark sky with some stars. the plane is still, and the dark sky keeps moving backwards.

codingmonkey

I can’t find the APIs in the document
urho3d.github.io/documentation/H … tated.html

Bananaft

Dejavu: post6616.html?hilit=background%20repeating#p6616

yushli

Thanks for the remaining. The reason I asked again is that I managed to find a simpler way by calling StaticSprite2D::SetRectangle(deltaX,deltaY, textureWidth+deltaX,textureHeight+deltaY) and calculate the delatX and delatY by the time step in scene update. That way it works as expected to have the texture moves and repeats. But not in a smooth way. The move is sometimes slow and sometimes fast. I wonder whether calling SetRectangle is the same to using Material uv transform or in a less efficient way. I am still learning urho3d so a sample code on how to add material and perform the uv transform to staticsprite2d is highly appreciated.

1vanK

Just create textured plane (or node with child nodes if you want more than one plane) and move it in the scope of the camera. If the texture has a small size you do not need to create a lot of planes, but tuning UOffset and VOffset in material for repeating.

yushli

Do you have sample code on how to use material to animate the uv values?

Bananaft

So that’s your actual problem here?
Is this change of speed fps-dependent? Are you sure, you are using timeStep right? What happens if you turn on vsync?

1vanK

This question was asked to me? My way is not using UV animation :slight_smile: But you can see the UV animation in the Water shader