Using Hooke's Law to Create Visual Effects

A VFX artist Andy Moorer talked about using physics to create visual effects and discussed PopcornFX, a multi-platform particle system.

Introduction

As a VFX artist, exploring all kinds of tools becomes a way of life. Recently a project had me dive into PopcornFX, a particle system that as middleware can be embedded into game engines and applications. For example, PKFX has plugins for Unreal, Unity and After Effects and is embedded into iClone and Substance Painter, among others.

I was aware of it from its early days but had assumed it to be only a rudimentary script-based tool more of interest to engineers than artists. I couldn't have been more wrong.

I have been pleased to discover that despite its universal, works-anywhere nature this particle system is quite sophisticated. In particular, I appreciate its node-based visual scripting, the well-made stand-alone editor with its advanced toolsets for monitoring performance and data flow, and PKFX's overall deep functionality.

Using Hooke's Law in the Workflow

Being a Houdini and former ICE user I felt right at home and was frankly surprised at how quickly I could create complex effects. The latest release demonstrates techniques such as 6-way lightmapping, parallax raymarching, advancing GPU support, and more. And SPH fluids may even be on the horizon.

Remember, this is in real-time. In a form that is pipeline and platform agnostic.

To share with the community some of my explorations, let's create a custom spring force based on Hooke's Law. Plainly put, Hooke's law states that as spring is extended, a force countering it increases. As such, it is a restitution force, one which seeks an equilibrium or resting state.

Written out in its simplest form as it pertains to us: F = -kx, where F and x are vectors and k, is a scalar value representing the spring coefficient (or degree of elasticity).

The vector x is the displacement of the spring from its resting state: xrest - xcurrent.

Illustrated as nodes, the graph is pretty minimal:

Yes, it really is just 3 nodes. PopcornFX's physics node handles all the integration so custom forces really just require the artist to translate their idea or formula into nodes and plug them into the physics "acceleration" input.

(Note that below the nodes is a running tally of how long each node takes to calculate. PKFX constantly provides information on the efficiency of effects as they run in real-time, and has various displays to give feedback on the performance and function of each effect.)

I chose Hooke's law for illustration because it is to my mind the most elegant of forces – so very simple yet capable of producing beautiful motions:

Here's a look at the entire graph used for this effect:

The top left arranges spawned particles into a line. Those spawn positions (the points drawn inside boxes) are then moved around by the blue node on the bottom left (the blue indicates it is a template, a graph I made before and saved as a preset tool). The spring force is computed, gravity added to it, and the result is fed into the blue physics node. The results are then drawn with the brown nodes – boxes around the initial positions and the computed spring result is a big dot, with a line drawn between the two.

The thick yellow line represents the area of the graph in which evolving data is stored as a new value every frame. In this case, the prior frame's resulting position.

Hooke's law is of course handy for VFX artists in a myriad of ways and can be used to build complex elastic structures and dynamic systems. But even in its most basic form here it's useful and easy to implement. For example here is an equivalent implementation of a basic spring force effect in Unity, using the VFX graph:

And similar graphs can just as easily be implemented in Niagara etc.

PopcornFX

So why should real-time VFX artists be keeping an eye on PopcornFX? A few reasons.

First, it's evolving into a very powerful tool on its own. PopcornFX handles spatial queries and retrieving data such as closest point attributes, it scales to millions of particles (with more efficiency coming as GPU implementation is further refined) and is written in a way that is very accessible and efficient for the common VFX tasks, yet it gives users the ability to manage a level of complexity which approaches best-in-class DCC tools like Houdini.

Second, as middleware, its capability to be embedded into custom pipelines and applications means it's already turning up in interesting places. The idea of being able to author tools and templates which can be used in a myriad of different projects and pipelines irrespective of differences in core engines is very appealing.

And finally, PopcornFX has that elusive "fun" factor which makes it a joy to use. It's always worth noting any tool which lets the user focus more on the task at hand and less on the tool itself. PKFX in its version 2 form is just enjoyable to learn and use.

Andy Moorer, VFX Artist

Join discussion

Comments 0

    You might also like

    We need your consent

    We use cookies on this website to make your browsing experience better. By using the site you agree to our use of cookies.Learn more