Particle-Based Meshing
If you went through the fluid tutorials you might have been missing one thing: mesh creation. In this workshop you will learn how to mesh the results from the “Foam with SPH Fluids” and “Shattered Glass” lessons.
A mesh with particles from the "Foam with SPH Fluids" tutorial.
Here is the nodes list:
1 “Particle mesh” node (not the “legacy” engine)
All scene elements can be added from RealFlow's “Edit” menu:
Add > Mesh
RealFlow nodes can be moved, scaled, and rotated with the W, R, and E keys.
Viewport perspective is changed with the 1, 2, 3, and 4 keys.
Shading modes are toggled with the 7, 8, 9, and 0 keys.
Foam with SPH Fluids – Overview
This scene contains two emitters, but only the “Square01” node will be meshed, while the fluid from “Container01” should be rendered as particles. Choose a frame with lots of details, and follow these instructions:
Edit > Add > Mesh > Particle mesh
Nodes > ParticleMesh01 > right-click > Insert emitters > choose “Square01”
The mesh node now has an alias of “Square01” attached.
A click on the mesh node itself reveals a wide variety of settings under “Node Params”, but not all of them are relevant for a good mesh. The most important settings are located under “Mesh”.
Now click on the emitter alias and you will find two more panels: when you create a mesh, the engine puts small spheres at the particles' positions and blends them to create a coherent surface. The radius of these spheres is adjusted with the emitter-related settings:
Click on the mesh node's “Square01” alias.
Go to Field > Radius
If “Radius” is too small then the spheres might not interpenetrate and you will see a torn fluid with holes. If it is too big the fluid's borders become thick and you will lose detail.
Foam with SPH Fluids – Settings
A very good and reliable way to start with RealFlow's “Particle mesh” is to use very similar settings for “Polygon size” and “Radius”:
Mesh > Polygon size > 0.02
Field > Radius > 0.03
Now, make one more adjustment to get a better representation of the particle cloud
Mesh > Weight normalization > Yes
Click on the “Build Mesh” button from the “Mesh” shelf to create the mesh for the current frame. As you can see, the result is already very good. If you need a higher level of detail just decrease “Polygon size”.
The mesh's borders are a little too round, and this is something that can be fixed with the entries from “Filters”:
Filters > Filter > Yes
@ Relaxation > 0.1
@ Steps > 16
Recreate the mesh
“Steps” tells the engine how often the relaxation filter will be applied. With higher settings the borders become sharper. With settings greater than 100 you can often observe the look of liquid metal which completely destroys the impression of a watery or milky fluid. Always start with moderate values between 8 and 32. In this case, "Steps" should not be too high, because otherwise the mesh will shrink, and you might lose the connection between the mesh and the foam particles. This results in visible gaps in the final render (see "Foam with SPH Particles" for more information about the simulation's foam pass).
Foam with SPH Fluids - Channels
Channels are essential for realistic rendering and they help you to visualize changes in speed, age, or density – to name but a few. With a velocity channel, for example, it is possible to create the whitening effect of a rapidly moving fluid. RealFlow's “Particle mesh” engine provides a wide variety of attributes to save with the mesh:
Open “Particle Channels”.
Enable/disable the appropriate channels with “Yes” and “No”.
For the second step, the channels have to be exported with the mesh files:
Export > Export Central
Open the “PARTICLE MESHES” branch. There you will find several file formats to choose from.
BIN is the standard format and supports only a few basic channels.
ABC (Alembic) can store the entire range of channels.
MD provides the most sophisticated method, because here you can also decide which channels you want to include. Of course the channels have to be activated under “Particle Channels” before – otherwise they remain empty.
Enable “Mesh sequence (.md)” and leave “Mesh cache (.bin)” activated, because it is required by RealFlow.
Uncheck the unused channels, but leave “normal” and “texture” active in any case.
Click on “Done”.
Foam with SPH – Build Mesh Sequence
Now, the mesh sequence can be created:
Select the “ParticleMesh01” node.
Shelves > Mesh > Build Mesh Sequence
This action can be stopped with the Esc key, but it might take a short while until the process is interrupted, because the current mesh will be finished first. All files will be written to the project's “mesh” folder.
Shattered Glass – Workflow
The steps for preparing the mesh node and its settings are almost the same as described before. Only the final parameters are slightly different. This time you will also be using RealFlow's “Interactive Meshing” feature:
Again, start with Polygon size = 0.02, Radius = 0.03, Weight normalization = Yes
Shelves > Mesh > Mesh interactive mode
The mesh is created automatically every time you change one of its parameters.
Since it is hard to see and evaluate the live changes when the mesh is selected go to View > Show > Selection highlighting. With this action you will have a better view of the mesh.
When you alter parameters like “Polygon size”, “Field”, or “Weight normalization” it takes longer to update the mesh, because the entire geometry has to be rebuilt. Filtering and optimization, on the other hand, is performed very fast.
If the mesh does not represent all the fine drops decrease “Polygon size”, e.g. to 0.015. “Radius” can also be slightly decreased.
Once you are happy it is time to work on the fluid's borders:
Filters > Filter > Yes
Adjust the “Steps” parameter to taper the borders, but avoid high values. With each new value the mesh will be updated.
In order to get thinner splashes, activate “@ Thinning”. This parameter is not influenced by the “Steps” parameter. A value between 0.2 and 0.3 should produce good results.
At the moment all settings are temporary due to the interactive mode. In the last step, bake the mesh:
Shelves > Mesh > disable “Mesh interactive mode”.
Shelves > Mesh > Build mesh
Now, the channels and export formats can be specified. Create the mesh sequence for the entire simulation.