Began implementing a new idea I had a few days ago following my initial experiment with metaballs. The logic was simple: if conforming the particles to signed distance fields are what create the beautiful magnetic field look of the energy ball, then perhaps adding a second SDF to the ball would automatically simulate a merging between two fields! It was a beautiful and simple plan. The challenge has been the execution.
For the scene setup, I created three transforms, one for each hand and one for the SDF location. I wanted to be able to roughly simulate movement of the hands using only my mouse, so I used a function that converts the screen position to world coordinates that runs when the mouse is pressed down. The left mouse button controls the left hand transform and the right mouse button controls the right hand transform. I had to set the input Z position in the function to the Z distance between the transform and the camera in order to map the output properly.
VFX graph only allows the particles to conform to one SDF at a time, so I decided to try a technique I used in my Super Mushroom Broadcast visualizer, where I change an object’s position so quickly that it creates the illusion of that object being in multiple places at once. It’s superposition, but faked. I recreated my energy ball VFX graph by copying over VFX nodes from the original project, but this time only used one graph tree instead of two. I implemented the superposition technique for the two hand spawner positions using a switch node in the VFX graph and a bool that I reversed each Update call through script. That seemed to work fine.
For the SDF superposition, I wanted to use an array of transforms each bound to a VFX transform property one at a time, instead of a bool and switch within the VFX graph. This approach required more scripting and less node connecting, but potentially would allow me to merge as many energy balls together as are in the scene. VFX graph doesn’t have a built-in function for setting Transform properties via script, at least not a public one. I ended up testing two techniques I found in this thread as workarounds, but neither worked. I instead turned to the simpler but less pretty technique of setting the SDF position and scale Vector3’s separately via script. That seemed to work, however the result is nearly not as “morphy” as I’d like it to be.
Hopefully, tweaking the settings of the ‘Conform to SDF’ VFX node will allow me to make the effect into what I believe it can be. If not, I may have to look into another technique.
Tags: unity vfx-graph metaballs sdf scripting particles input