How to control wave parameters in real time with water plug-in

I was following these instructions to create my own wave generator:

However, it doesn’t really override the wave values properly (tested by setting the values to extreme ranges) but also there’s no error. The water just looks the same when I set the customized one to be the Gerstner Wave Generator.
Has anybody tried this? My end goal is to use sensors to control the tides via OSC data.

I am not sure if this is what you are looking for and there may be another way. For me when I wanted to dynamically change the values of a gerstner wave I had to call a c++ function called recompute waves. Here is an example blueprint for changing the properties. UE Change built in water gerstner wave property posted by delebash | blueprintUE | PasteBin For Unreal Engine. You can see I am overriding some properties but in order for those changes to take effect I have to call a custom bp function called Recalc Wave. This BP function just exposes the c++ function GerstnerWaterWaves->RecomputeWaves(true); You can see my custom function here WaterBlueprintFunctionLibrary/Source/WaterBlueprintFunctionLibrary/Private/WaterBlueprintFunctionLibraryBPLibrary.cpp at main · delebash/WaterBlueprintFunctionLibrary (github.com). This is part of my Global Environmental System for UE here delebash/UE_GlobalEnvironmentalSystem: Make your landscape interact with weather, wind,water,foliage and your player like the real world. (github.com) hope that helps.

Also, you may want to consider the marketplace asset Oceanology as it is very good and much easier to control via BP. Oceanology 6 will be coming out soon with a new FFT system and significant enhancements, but OC 5 is still very good if you want it now. UE water is still experimental since UE 4.6, and I haven’t seen anything about it getting any love or attention. There have been some bug fixes, but I haven’t heard anything about enhancements or moving it to production. Another good asset is Fluid Flux but it is pretty expensive

Thanks for the code. I’m not very familiar with C++, current goal is to stream OSC data from Arduino sensors / Max MSP to control the tides. I created a GerstnerWaveGeneratorBase blueprint class and realized that my regular OSC message receiver blueprint nodes are not allowed in there.
Does Oceanology have an underwater post process component and does its blueprint class controlling the waves allow OSC nodes?

It does have underwater post processing. I have no idea about OSC nodes. They have a discord channel so you can ask there.

And why on earth do you want that to be a visual only effect?
Shpuld you not be moving the water sheet(s) up and down physically so that collisions with it, distance to nearest surface, etc. Match up?

Really. Dump the engine s*it and make your own.

At a base level, 1c++ class called ocean manager that handles the wave.
It, will have a blueprint accessible function that returns the Z value at x/y for Gametime.
Taking into account the tide level that offsets the overall Z plane ofc.
This function probbaly also has to be in its own thread.
Simplistic math as it may be, you can easily clog up a CPU by queriing too many times.
I wouldnt necessarily go Async because you need the value returned in the correct frame for that gametime or for gametime + a frame to get the position of the next frame and make it so that the correct height is applied.
Anyway, these are details. Start with the basic class, and the functions.

Then, and once you wrote the grstner yourself in c++ probbaly off the old GPU gem articles youll have an easier time with this, you create the same grstner function in a material function.

Then, you add the function to a singlelayerwater material (or you make your own water material which may provide brtter results. Single layer water is faster and does some things you wouldnt have to do yourself).

Then, you will likely botice that the waves are causing display issues and look like they have holes on a single tile where they possibly couldnt.
Thats due to Z sorting and the engine generally sucking at depth detection when its offset by a shader. Theres various fixes for it. If you run into it i probably posted solutions 3 or 4 years ago on this forum.
OR, you can grab the community ocean project and look at some of their materials to see how they handle the sorting. Theres several ways, some look better some perfrom better.
You use whatever you think your project can deal with.

At this point you have a material and a function which both return the same value (provided the function is aware of the Z location of the water sheet).

You can start to do actual sruff with other components… like creating a component which when placed on an object keeps its Z in sync with the wave.

And you can start having a great xmas with figuring out the correct way to handle bouyancy with multiple points of contact - so that a floating doughbut can incline on the wave.
(Or you can just get the wave normal of the impact point and rotate the ■■■■ thing incorrectly at 1/16th of the processing cost? Probably a better idea…)

You better get familiar with C++/C#/ other .net trash.
Arduino has an entierly different way of thinking programmatically - its sequential.
Everything else is not.

Particularly if the need is to get some sort of physics simulation, you better start with being aware that the result is probably not going to be as accurate as a mathematical model of it.
Particularly not in Unreal. Particularly not using Chaos.
If the need is mostly visual, youll have no big issues.

After you get done with creating the water shader, read up on flow maps, and start to implement that so you can provide interactivity - ripples and such, at runtime.

I already have a plugin built for UE 5.3 that exposes the recalc wave so you can change gerstner wave properties dynamically via blueprints. Just put this in your plugins folder and now you have that function for blueprints and you can see how I use it from the blueprint in my previous post. delebash/UnrealWaterLibrary: expose recalc gerstner wave to blueprints (github.com). I have never used OSC data but this looks like a nice blueprint library you could use videofeedback/Unreal_Engine_SerialCOM_Plugin: Serial Com Port Library for Unreal Engine 4 and Unreal Engine 5 (github.com)

Thanks. I’m using a different OSC plugin and it works in other situations, just that the wave bp class does not allow any OSC nodes. btw the github link is broken.

Try now. The repo was set to private by accident. It is now public. Just curious when you say the wave bp does not allow OSC nodes, how so. What bp are you trying to add osc nodes to?

In the BP class “GerstnerWaterWaveGeneratorBase”

Im not sure thats possible in engine.

If a blueprint node is created, and you are using a bleprint, then the node can be called anywhere.

There isnt a blueprint that has no bleprintcallable functions or a way to put restrictions on blueprint callable afaik.

What could be going on is that the particular function you are trying to use is not accessible from any blueprint of a different class, because it only exists within the class.

In c# c++ you would normally do something like…

OSCClass instancetouse = new OSCClass()
And then youd get function access by
Instancetouse->functiontocall()

In BP you can do the very same.
Create a variable of the correct class type. Then onbeginplay or onconstruction run the class initializer on that variable.
The initializer may not be blueprint callable, so that would be an issue.

From then on assuming it initialized, you can probably drag from the variable pin to pull out the executable node though.

So do you need to modify this bp directly? If not like I showed you how to change wave parameters in just a regular bp you could put your osc nodes in a reqular bp, get an instance of your gerstner wave and change the properties according to your osc node values

1 Like

Thanks, I’ll try that