Simulating wind flow / weather map style/ vector path

Hey all
I’m trying to find the best way to approach having the functionality of something like this:

https://www.windy.com/
windy.jpg

More precisely i’m trying to have the flow of the wind, the flow of forces represented in my prototype, so that when my “player” gets in that flow it can be affected by the direction/strength of it.
Imagine a world map with wind flow twirling around (just like windy) and you have let’s say a little boat navigating it.

What i’m interested in figuring out is how to get the same kind of “vectors all flowing in a direction” and spiraling or even merging.
How would you guys go about it?
I’m not really looking into the visuals yet, really just the functionality of it.

Let’s say I have a 3d sphere (world) and there’s wind flow all around it, creating streams, merging, spiraling etc…
For simplicity sake I’m not even looking into procedurally creating that yet, let’s just assume it’d be hand placed.

I thought about 2 potential ways to go at it:

  1. Splines: create a bunch of splines and have a BP checking the closest point and the direction to the next point, returning a vector representing the wind direction.Which sounds simple but I have no idea how to handle merge/split or even end of splines.
  2. Vector Grid: I thought about a "vector fields"ish method where my world sphere would have a grid of vectors spread all around it and they get affected by a direction… how ? i have no idea.

windysolutions.jpg

Any thoughts on this would be very helpful
Cheers

1 Like

I am also interested in this, following!

Tried the spline method and so far so good.
Did a few things:

  • Construction script automatically snaps spline points to the planet surface (so it’s easier to edit)
  • It also shows a debug arrow with the direction of the spline every x cm

Freaking love splines and blueprint, this took me 5 min and it’s already a half decent base for a system.

The forum doesn’t allow big GIF so here’s the twitter with a preview:

Multiple ways to approach this.

I highly recommend the Ryan Brucks’ Shaderbits GDC pack. It shows techniques for rewriting/multipass render target textures(which will be useful if you want to achieve the same effect as windy.com.) It also has full blown fluid simulations.

Splines are not very efficient if you want to achieve high onscreen vector density.

Here’s a multipass shader that implements a wind flow map. To get it to work in Unreal, you’ll need to translate it from GLSL to HLSL. It’s pretty much just replacing data types and function names. Don’t worry about Buffer A, it procedurally draws the world map outline, and that slows down the shader a lot.

You can easily recreate the shader with nodes, except where there are functions with loops. You can either add the code to a few external shader files, and reference their functions in a custom node. Or you can use one custom node per function with loop, per each buffer and reference the CustomExpressions produced by the HLSL compiler.Example Here: CustomExpressions are numbered, based on the order they are plugged into the Main custom node that references them. In the example EvaluateLight is CustomExpression0, ParticipatingMedia is CustomExpression1 etc.

Make a render target and a material for each buffer in the shadertoy example(Common, is not a buffer). In each material, reference the render targets corresponding to the different buffers on the shadertoy example.

Create dynamic material instances. On a fixed timestep, set their texture parameters to the appropriate render targets and draw them to their own render target.

You’ll need to use Render Target Lookup, by adding a C++ component, to read the value of the velocity buffer, in order to accurately tell your boat where to travel in response to the wind.

You can also use flow maps, with render target lookup, but it won’t look nearly as pretty unless you sample the vector field texture at multiple offsets, and blend appropriately, to create the trail effect. Though you could even paint the flowmaps at runtime, using some of the techniques in the Shaderbits GDC pack.

I’d suggest, if you were gonna make something based on splines, that was only approximating the the vector field, to base the splines on the pressure isolines(go to windy and enable the pressure overlay, and the pressure isolines) rather than attempting to replicate their paths. Then an object can be moved roughly parallel to the average of the tangents, on the two closest points, on the two closest isolines. Depending on whether or not the higher pressure region is to the left or the right, and which hemisphere it is in.

2 Likes

What platform are you aiming for?

Thanks for all that, that’s a lot of detailed info
Platform is undefined for now, though i would like to make it mobile compatible.
So I’m a bit reluctant to go too crazy with complex shaders for perf reasons.

What i’m trying to replicate right now is the functionality more than the visual effect.
I like your suggestion of the isolines, that could be a very simple way to do it.

For the visuals i’m not trying to be exactly like windy, i’d probably be fine with particle trails following the splines

I like the look of the option for the multipass shader wind flow map, but honestly i’m not experienced enough in shaders to be able to understand or replicate that in UE.

I might give isoline a shot see what i can get out of it

Thanks!

No worries.

If it’s cool with you, I think I’m gonna port the shader, and maybe make a particle or point cloud version, depending on what Niagara can do. I’ll post the project here when I’m done. The resulting material will probably be too expensive to run with a high resolution render target on mobile, but I know that my 3 year old phone can handle a 128x128 render target to drive a ~16k animated billboard point cloud in AR in Unity, so hopefully Unreal will provide similar performance.

A game concept I worked on awhile ago used a 2D interactive fluid sim to drive a height map that players would surf/glide over in VR, but it was a bit difficult to influence the height map in a strategic and predictable way. And the simulation couldn’t convincingly follow the player, limiting the game world size,. It also would have required too much bandwidth to be feasible for multiplayer. But something like this might be more manageable. I’d like to give it a shot. Lemme know if you’re OK with that.

Sure man. go crazy.
Don’t know if i’ll end up using it, but i’d definitely be curious of what you can achieve

I am wondering if this will have effect on game performance - and how are you going to visualize your efforts.how is the weather a part of your story line…?

The global whether is truly an interesting topic, but from a RPG view, perhaps only the local effect/cost is … I just raised the question here: https://www.youtube.com/watch?v=0VzY…Pjx8t0XVi409a- where we look at the effect.

Your system could make sense if you are making an world-environment simulation, say simulating wind mills or the effect of green tech. :wink:

Just a few days old, this may be interesting https://www.youtube.com/watch?v=etSfYfIIoSE - if you can “live simulate” what a drone camera “sees” … then that could perhaps be used to monitor some live weather calculation and project that to the Niagara particle system!

Hi, these information is so useful, but I can’t understand that you said that make a render target and a material for each buffer in the shadertoy, I don’t know how to make it, I mean if I create a material for bufferA how can I use it in another material. I am a beginer of UE4, the windy map is what I really needed. Thanks for your help!!