Random fields

Just a quick update on the random functionality I implemented for the Vector Fields in the last post:


The random data I was generating was previously overwriting the values imported for the vector field.
I’ve refactored it so that “Random” is a new “Modifier” component, which means it can be blended in with existing vector field data, e.g flow data baked out of Maya, other Modifier components I’ve implemented.

I’ve also set up a really basic blending between two random data seeds, to have a simple animated random vector field (rather than the previous approach).

Less words, more video!!

Towards the end of the video, I turn on the original Motor component, which starts blending with the randomness.

Probably worth mentioning that all components by default can be controlled by blueprints (because UE4 is awesome), so it would probably only take a few hours of a non-programmers time to:

  • Make a gun that shoots grenades that generate vortices in vector fields
  • A button that randomises particle movement in rooms
  • Fans that blow particles around that turn on and off with player interaction
  • players that generate swirling particles around as they move
  • Etc.

    Oh, also, I bumped the number of particles up to 48 000, for giggles.
    I can actually push it up to about 100 000 before it struggles, which is pretty neat for a 4 year old graphics card (560 ti)! šŸ™‚


    Tags: , , , ,

    11 Responses to “Random fields”

    1. John Fesenko Says:

      Hey Geoff,
      Thanks so much for sharing your work in UE4 with vector fields. This is exactly the sort of thing I was looking to implement myself for an art project, and it would be great to get a leg up on the process by checking out the source of your plugin. Are you open to sharing that code?

    2. geofflester Says:

      Heya! I’ll send you an email about it.
      I generally don’t share source code for a few reasons.

    3. Beer van Geer Says:

      Hi there,

      Is there any plugin or example code available to start generating these dynamic vector fields?
      Iā€™m surprised its still so static in unreal, would love to create my own fields.

      Beer van Geer

      • geofflester Says:

        Although I’m not posting any of the code up, or planning on releasing a plugin myself, I hope Epic go further with this tech.

        There’s actually some code in the VectorField.cpp to do animated vector fields driven by textures somehow. Haven’t looked into it much, I don’t think it’s exposed in the UI at all.
        On top of that, there’s no support inside of UE4 to generate them, which is what started me down this path, I’d really hope to have the ability to randomize them in the editor, groom them somehow using brushes (like hair plugins in dcc tools), etc, etc.

        I recently discovered that I can’t get my plugin to work without engine changes, because in the editor I was calling PostEditChangeProperty which is not usable in a standalone build. And also I should be able to just call “Update”, none of the stuff I need to call is in the header file, and I’ve had zero luck working out how to get around this because forward declaring the classes doesn’t help me…

        Annnnnnnnnyway, I got so annoyed with it, I’ve temporarily abandoned the idea of doing this as a plugin, but maybe one day I’ll make the engine changes to expose the classes I need, put it up on gitHub, and see if I can convince someone to put it in the engine.

    4. Lorenzo Says:

      Hey Geoff,
      this looks amazing.
      I know you are not sharing the code, however I was wondering if you could point me in the right direction as I’m pretty new to Unreal.


      best regards

      • geofflester Says:

        Thank you šŸ™‚

        If you are / have access to a programmer, definitely check out some of the code in VectorField.cpp. Basically, if you search through all the engine code for UVectorField, there’s only a handful of source files involved in loading them, updating them, etc.

        If you have any specific questions, feel free to email them through, and I’ll try to answer them when I have time šŸ™‚

    5. tangshengchao Says:

      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?

    6. tangshengchao Says:

      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?

    7. geofflester Says:

      Ok, so this is one of the areas I was having issues, as per the other comment šŸ™‚

      But I could get it to update in the editor, by firing PostEditChangeProperty.

      #if WITH_EDITOR
      UProperty* VFStaticProperty = FindField(UVectorFieldComponent::StaticClass(), GET_MEMBER_NAME_CHECKED(UVectorFieldComponent, VectorField));
      FPropertyChangedEvent PropertyChangedEvent(VFStaticProperty);
      #endif // WITH_EDITOR

      Can’t remember why that second part wasn’t working for me in game, but I kind of ran out of steam on this when I decided I’d probably need to make engine changes to get a bunch of stuff working šŸ™‚

    8. black_H Says:

      I really want this solution.
      I read comment all and engine source code but I can’t how to do it.

      Excuse me, but can you give me the source code?

      • geofflester Says:

        Sent you an email, hopefully I can help with any questions.

        If anything interesting comes up, I’ll post it back here or do a new post.
        I haven’t touched particle stuff much in the last few years, but there’s some cool tools I plan to try out at *some* point, like some of the tools these guys are making:


    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 )

    Google+ photo

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

    Connecting to %s

    %d bloggers like this: