Variable Wind Vector driving a World Aligned Texture results in increasingly fast texture panning

The game I’m working on has a dynamic wind system. A blueprint outputs a vector for the wind, which I’m using to pan a texture on various geometries. Whenever I’ve done something like this before, I multiplied the incoming vector by time, and then added that to the Absolute World Position, which then goes into the “WorldPosition” input on a WorldAlignedTexture. So far, so good.

However, this only seems to work for static vectors. If the vector is dynamic- like a changing wind- I start to see discrepancies in the movement of the texture. It looks fine at first- the texture pans through the geometry in the direction of the wind, and it accurately changes direction when the wind changes. But over time it starts to diverge from the wind- it accelerates, eventually (within a few minutes) strobing because it’s moving so quickly.

I’ve got a debug node hooked up and displaying in the material, so I can verify that the incoming numbers are correct- the wind vector is working exactly the way it should. It just seems to accumulate errors when it pans the texture.

I’m getting the same result with a 2D implementation of this, as well. If the panning vector is static (as in, it doesn’t change over time), the panning works correctly. But as soon as the incoming vector changes over time, the texture pan increasingly diverges from what it should be doing.

I’m kind of at my wit’s end, here. This seems like a fairly simple implementation of panning a texture, but as it is right now I can’t have wind drive a texture pan. Here’s the graph I’m currently using:

Any ideas?

I don’t know what’s wrong, but you could try to ‘normalize’ the wind vector and see if that helps.
I don’t quite remember what time outputs I usually put a frac after it just so I know it’s not going over 1.

Flow maps might be a better fit as it pans the texture twice at different phases (offset by half by default) then lerps between them so it can reset so you don’t get crazy high offsets where you will get floating point precision issues.

So, the problem you are discribing is common.
If you are multiplying by time, and you change the multiplied value at runtime, you are essentially going back/forth in time. Meaning you will not have a ‘smooth’ blend between different values.
A way of preventing this is to create your own time. E.g. in Blueprints (or Niagara).

This custom time is essentially using Delta time and multiplying it with your (wind speed) value, then adding itself ontop of the existing custom time.
You then feed your custom time into your material. Like so:

If you adjust your WindSpeed now, it will only affect the rate of change, not the actual time, hence you don’t get the wild panning of your texture.

I have not found a way of doing this inside the material editor only. You could probably do it with the help of a coder. Or I was just a bit stupid :slight_smile:

Thanks, all. My gut instinct- once I wrapped my brain around the problem- was to use the flowmap sin/lerp system. I’m still working on the timing on it. It’s a shame, 'cause it’s not as elegant as just doing it directly.