Flowing Lava


            This project revisited the foundation of viscosity fluid meshing techniques as well as shader customize. The reference video is an excellent demonstration of lava elements since it displayed the whole process of merging and flowing movement. It also brings the challenge for this project because the lava simulation with temperature variation is an effect that I have never encountered before. It seems that this effect is complicated at a glance.


  • Scene Optimization & Flip collision setup

            In this project, the primary scene geometry is imported from Megascans in high resolution, which brings lots of surface details even without texture displacement. However, this could result in slower computing progress if the hi-res geometry is converted directly to VDB format. The remesh node provides an "affordable" geometry proxy to avoid this issue but still maintains the overall shape. Then, instead of putting the DOP network's geometry as a static object collision type, it has been converted to the collision VDB with a zero-collision velocity field so that the whole VDB proxy can be loaded as a volume for faster collision purpose.

            Inside the flip DOP network, the collision VDB proxy is imported using the Volume Source node. The preset for the "Collision" type is ready for use since it provides necessary vector fields for the collision. Notice that the "Source Volume" name for collision velocity is set to "v" by default, so the custom VDB that created in the SOP level should also be named "v" in order to match the input. Do not worry about the collision velocity scale since the geometry is not moving at all.

  • The viscosity source setup

            The particle source is generated from two different overlapped polygons. In the reference video, the surface is cooler than other parts of the lava, and there is a significant temperature variation existing in fast-moving areas. Also, the emission source is not entirely connected as there seem many "gaps" in the heavy surface. As a result, the top source that I use has a much lower temperature than the bottom one, so the high-temperature source could provide sufficient velocity for the simulation movement, carrying the top part with low temperature flowing from the beginning. For temperature variation, noises with different frequencies are introduced to ensure both sources have initial randomness for emitting particles.    

            Inside the attribute VOP for temperature variation, two partitions consist of the final output. Basically, the turbulence noise can provide noise patterns for general usage. However, the result lacks accurate control, and the influence on fluid dynamic status is limited. To have more control on the amount of emission, two ramp parameters based on the bounding box are added, so users can manipulate which part of the source should emit more particles or less but still has noise patterns while emitting.

  • Flipsolver in viscosity solving

            As for the basic lava simulation workflow, the lava shelf tools provide basic guidelines for essential steps. Inside the DOP network, after bringing particle sources, the node named" gas temperature update" is merged into the solver to control viscosity based on temperature. It offers controls over cooling temperature as well as mapping min/max viscosity and solidifying threshold. In my example, I started with viscosity from 25 to 100000 to achieve a "heavy" look and slightly lower the solidify threshold from 0.15 to 0.12 since the high value of the solidify threshold would result in earlier static status for the lava. Users can also enable the "remap" function for more accurate control of the viscosity change rate. Under the fluid object tab, I slightly lower the "Particle Radius Scale" from 2 to 1.2 to ensure more dynamic details to the fluid as this value controls smoothness over the surface. For the flip solver parameters, the Swirly kernel is required by default as it can bring more vorticity compared to Splashy kernel in simulating high viscosity fluid. The crucial attribute for shader displacement in the solver is the "dual rest." Flipsolver would store position attribute for each point in the "rest" value based on timing, so the displacement can stick to the surface without floating. Just to make sure, the value "Frames Between Reset" should be twice the length of the final output frames as this float value controls the noise blending ratio in the shader.

  • Tips for viscosity meshing

            After caching out the flip particles, the "rest2_ratio" attribute is stored in detail class by default, and it should be promoted to point level for shader displacement usage. In my case, I am not very satisfied with the time factor since I found the beginning of lava flowing is much faster than the end, so I have decided to remap the timing using the "Retime" node to scale the time factor by half. In the meshing step, instead of choosing the average position method, I switched to the "Spherical" one with zero polygon adaptivity to avoid possible mesh flickering issue. I also added a little filtering based on the vorticity range to give fast-moving areas more smoothness. One thing is that the dual rest attributes need to be transferred on the mesh as well.

            In lava shader, the emit color attribute is definitive as it provides emissive information on the surface for geometry lighting purposes. Usually, after the meshing step, the setup from lava shelf tools copies color attribute from particles to the surface and create the emit color attribute. But unfortunately, this color ramp is uniform and not interesting at all. So the purpose is to override this attribute with a custom pyro blackbody ramp parameter to add more randomness to the color itself.

            How? Since the temperature is well- calculated by the solver, this could be an attribute for the color source. The pyro blackbody reads those field parameters and provides tone mapping function as well as temperature control. Since this node deals with XYZ space data, it needs to be converted to RGB information for emitting colors.

  • Lava Shader tips

            For the lava shader, the cooling area's overall surface displacement will bring significant change to the final look. The reference video shows that the trend of cooling influencing displacement strength. To achieve this similar look, the procedural noise introduced by the mantra principle shader is useful. The users need to import the rest attribute to the shader and let it decide the object space for displacement. Besides, we can have more advanced control using emit color attribute controlling highlight roughness and displacement amplitude rather than uniform displacement applied.

Results and further improvements

            The general purpose of this project is to practice viscosity fluid simulation with shader look development. By combining several dynamic simulation techniques, plenty of elements in the reference video are presented successfully. However, there are still many improvements needed for further revision, such as the more aggressive "overlapping" effect in the reference video when the lava flows to the bottom part. This kind of status needs more combination tweaks, not only the flip source but also the collision geometry.

Share on facebook
Share on twitter
Share on linkedin

2 thoughts on “Flowing Lava”

Leave a Reply

Your email address will not be published. Required fields are marked *