Swirly Vector Fields of doom

C++ and I are friends again, but to be honest UE4 makes that pretty easy.

I’ve been playing around with the Vector Fields in UE4, which are essentially a 3d grid of forces that can be applied per frame to particles.

You can’t really author them in UE4, so I wrote some plugin code that lets me randomly generate them (please excuse the crappy VFX):

Next up, I wanted to be able to change data in Vector Fields on the fly.
I have plans for a whole bunch of different “Modifiers”, including spherical impulses (explosions, etc).

For now, I have a basic motor / vortex type thing going on, that can be turned on and off through blueprints, blended in and out over the top of the random data, etc:

Places I might take this (if I can escape Civilization: Beyond Earth :)) :

  • Sample the vector field data in the Material system, so that I can have particle effects and material flow effects tied together somewhat (water on a surface follows the direction of water particles flowing near it, explosions cause materials and particles to react together, etc)
  • Run a really simple inflow/outflow pressure simulation through the grid to replace the random initialisation I have now. Kinda like what my rather clever buddy Ben Millwood did recently for 2d water flood:
    Ben Millwood’s amazing flow map tool of glory
  • Move the Modifier functionality to GPU (animated vector fields in UE4 already implement some of this).
    I’m still getting pretty decent frame rates in debug builds of the editor, so I’m not sure how much I care about it, except to tick the “yay, compute shaders in UE4” box
  • Rather than just grabbing the vector at the position in world space, interpolate between vectors using wavelet turbulence technique to add high detail flow (Wavelet turbulence). Currently well beyond my understanding, so would take me months, but you never know πŸ˜‰ At the very least, this would be a cool thing to do when sampling the Vector Field data in a material
  • Honestly, they could probably have a bunch of engineers work on this tech for years and years, and we wouldn’t see an end to the cool things that could be done with it.
    Things I would also like to see, but wouldn’t probably attempt myself:

  • The data structures don’t lend themselves to having a grid across a whole world (octrees instead of a flat array, maybe).
  • Vector Fields don’t currently work with anything but GPU particles (I think, unless I’m missing something). Would be nice to be able to use them with ribbon particles (for smoke, bullet trails, etc), make them work with dynamic objects, cloth, hair, confetti…
  • Extending them to have additional arbitrary channels added to them (pressure, temperature, etc) could be neat.
  • I could go on, but I’ll leave it there for now!

    If nothing else, this has been a relatively painless exercise in implementing custom SceneObjects and Components in UE4 πŸ™‚

    5 thoughts on “Swirly Vector Fields of doom

    1. Hey,
      Now i Can modify the VectorField’s SourceData. But i have to tweak the intensity a little bit with ui to tell the editor update resource. How do you inform the editor to update resource?

      1. Sorry, it’s been a while (can’t remember if I already replied to you)!
        I think, in editor, you can call “PostEditChangeProperty on the vector field, and in game you can call UpdateResource on the Resource of the VectorField.

        Pretty sure I copied that code from somewhere else in the vector field class, but it looks like the last time I touched the project I broke something in this area (or perhaps updating to a new UE4 version broke it).

    2. Where does one begin in order to create an extension for the engine like this? Am I making changes to the UE4 project, or would this be an addition to my own project solution? I’m currently watching a tutorial on extending the editor, but any information that points me in the right direction would be much appreciated, thanks!

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )

    Connecting to %s