I’m trying to create a cell merging/splitting effect for when my energy balls come into close proximity with each other.
Unfortunately, the “superposition” technique I’ve implemented thus far is not reproducing the desired effect whatsoever. Because of the high attraction force/speed of the VFX particles to the SDF, switching the field location causes a jump in particles that looks nothing like a merge between spherical forces. I’ve therefore decided to abandon the superposition technique in favor of a new method: using a dynamic SDF.
The Unity Dev team created a package for dynamically updating SDFs from a mesh in real-time, and the VFX Graph docs even includes an example for generating SDFs in real-time with the SDF Bake Tool. Both techniques turn a single mesh into a single SDF, but my dynamic SDF needs to include the meshes of multiple spherical meshes. That means I need to learn how to combine several spherical meshes into a single one. How do I do that?
I found this tutorial and followed it. It enabled me to combine six different spheres into a single mesh at runtime. Playing with my combined mesh, I realized I had a new problem: I had no way to manipulate the positions of the individual spheres, and therefore, would have no way to “merge” them. In vain, I tried moving my CombineMeshes() method into Update() in an attempt to redraw the combined mesh every frame. It created graphical artifacts with a bit of flickering (see below image). Worse, I checked the stats in the game window, and FPS was down.
I need a performant way to combine meshes at every frame. According to this post, that’s what “dynamic batching” is. However, I don’t think dynamic batching actually creates any mesh filter. Something that occurred to me is that I don’t actually need the mesh renderer turned on for any of these objects. Maybe that will save performance. Either way, I think I should still pipe my combined mesh into the dynamic SDF script and see what happens. I’ll start by following this guide, which uses the SDF Bake Tool method.
Tags: unity vfx-graph sdf mesh optimization gamedev programming