Making a 2D quiver plot to display Flow Motions (or alternative Ideas)

hey,
i am currently working on a project to create an interactive ocean modelling tool. The Project is nearly finished (the model is working and the user interface is set up). The model is set up as a bunch of 2d grids, where each point in the grid represents the waveheight, the velocity in x and y dimension as well as topographic boundary conditions. Theses grids are getting updated each frame when the model is running. Currently i am displaying different layers, that the user can activate / deactivate (the waveheight, the magnitude of the velocity and the waterdepth).

I am looking for an elegant and performant way to visualize the velocity more detailed (by just displaying the magnitude the important information, the direction of the velocity, is getting lost). I am thinking about a field of arrows, like the quiver plot in matlab or python matplotlib.
The only Idea i got, how to implement that, is by creating dozens of line renderers and update their scale and rotation for each frame. I can not imagine that it would be a performant solution. (I have never worked with unity before though, and dont know how it behaves when creating heaps of game objects).

Does anybody of you know a better solution for this. Or is that the way i have to go?

Kind regards,
Gordi

The fastest solution would be to use a shader of some kind.

Something like this:

That example procedurally generates an arrow per virtual grid cell.

There’s a Unity asset by a Unity employee that includes similar (but more advanced) line drawing here:
https://github.com/keijiro/KinoVision
That renders actual line geometry on a virtual grid, again all on the GPU. The benefit of this method is the lines can extend far outside the confines of the grid which is harder to do with the previous example.

2 Likes

Oh that looks fabulous, exactly what i was looking for! Thank you :slight_smile: