Seamless transition between different wave speed FX/Water

Hello,

I want to visualize a liquid-simulation. The simulation calculates periodically values for the speed of the liquid. I’m using these values to set some properties in the FX/Water shader (in this case the Wave speed map). This method works greatly for constant values. But if I change the values more often the visualization becomes bad. For example if the value decreases, the liquid seems to flow backwards (but the value remains positive). Is there someone with an idea, how to change the water-shader or water-script to achieve my goal? To gain a seamless transition from one wave speed to another wave speed.

Thanks in advance,
Philipp

If you’re using _Time in your formula for the scroll you’re effectively rewinding toward start time when you change your rate or whatever. You’ll need to track and manage a global variable that stands in as _Time.

Thank you for your answer! The _Time variable wasn’t the issue here. I have read several scroll texture scripts and came up with this code:

float waveScale = mat.GetFloat("_WaveScale");
Vector4 waveScale4 = new Vector4(waveScale, waveScale, waveScale * 0.4f, waveScale * 0.45f);
myOffset -= Time.deltaTime * 0.5f * liquidSpeed;
mat.SetVector("_WaveOffset", new Vector4(10, waveScale4.y * myOffset, 10, waveScale4.w*myOffset / 2));
mat.SetVector("_WaveScale4", waveScale4);

In the Update()-Function of the water script. LiquidSpeed is my external parameter.

1 Like

I bumped here while Google searching for my problem, for anyone else who finds this for same reason, here is working solution with any direction: