/nn_particles

A simple script + geometry-nodes for making a "web" from a particle system

Primary LanguagePythonMIT LicenseMIT

Web from Particles

A simple script + geometry-nodes for making a "web" from a particle system. This could be used to generate some cool effects in Blender. The inspiration came from the tutorial Recreating Hollywood VFX in Blender by Bad Normals.

How does it work?

There is a FLIP fluid simulation in the scene, which is hold by the Fluid Domain. The script connects each particle with its k closest neighbours - k=7 in the demo. The coordinates of the particles are used as vertices whereas the connections to the nearest neigbours are set as edges in the ParticleMeshObject. The ParticleMeshObject has a GeometryNode setup Geometry Nodes.001, which converts the edges into curves, shapes them and extracts some information for shading.

In principle this should work for any particle system. The name "Fluid Domain" is hard-coded in the script, but feel free to change that.

How can I reproduce it?

You first have to bake the fluid simulation in the Fluid Domain object. Then go to the Script tab and run the script. The ParticleMeshObject will then automatically update on every frame change.

What do I get.

Here is what the demo produces. Note this is just a proove of concept.

The particles of the fluid simulation

Particles0001-0250.mp4

The connecting edges (this is what the script creates)

Edges.mp4

The result from the geometry nodes and some fancy lights.

GeoNodes.mp4

Will it scale

The code takes about 40ms to run on my 10 year old PC for the example above. With geometry nodes I get about 6 fps. This will however not scale well. The KNN-algorithm is naive and has a quadratic complexity. It could be replaced with something like flann if hundred of thousands of points need to be connected quickly. Here is a video with some more particles (4sec per frame): more points. On my machine ~11k particles are the limit of what is possible (15sec per frame): 11k particles.

Limitations and Future Work

  • As mentioned before the NN-Graph generation has a quadratic computational and memory complexity, so it will get slow really quicly if many points are used.
  • Also the web mesh is re-generated in every frame. Cycles therefore does not treat it as a moving/deforming object, instead as a new static object in every frame. This essentially makes rendered motion blur impossible. It might be possible to add vector motion blur via code (not sure about that), but that is currently also msising.
  • This demo is not very usefull as it is. I might convert it into a plugin if I find the time.