RealFlow Expert Tutorial: Using Hybrido to Create Realistic Fluid Systems
Note: If you'd like to follow along with this tutorial, you can download the starting scene files here.
When considering how your scene is going to be solved in your 3D package, the first step should be to set up your overall scene. This isn't a task you only need to do when working with RealFlow. Most 3D software programs keep a relationship between the software and their own solvers to calculate the process. For example, the scale, polygons, number of elements, are factors to be considered for the majority of simulation softwares. Depending on these variables, the simulation can vary greatly, so it's important to bear them in mind.
Before importing geometry inside of RealFlow
For this tutorial, we're going to be working with Hybrido particles in RealFlow, so the first thing we'll need to do is to export out the geometry from our 3D software. We'll be using 3ds Max for this tutorial, but you can use other 3D packages such as Maya, Houdini or CINEMA 4D simply by installing the necessary RealFlow connectivity plug-in.
The geometry we want RealFlow to interact with should be built with a logical structure inside your 3D program. In this way, we can consider if it's advisable to make the geometry open or closed as shown in the image above.
The Hybrido solver interacts with the geometry by first converting that geometry into distance fields. There are several methods of building the distance fields depending on the volume mode. They are: “Shell”, “Volume inside” or “Volume outside”.
“Volume outside” will always be considered if we want to keep the particles inside a geometry and for this tutorial we want particles inside of our geometry. The other two options will help us to decide between “closed” or “opened geometry” when talking about how the fluid is going to collide against any geometry.
The choice between “Shell” or “Solid inside” is easy. You should use “Shell” mode when the geometry is not closed because it means the geometry is not watertight. An example of this would be a simple plane.
In this way, “Solid inside” will be used for the other cases. It's advisable to use “Solid inside” as it won’t allow particles inside the geometry, but if we see artifacts when displaying the isosurface for that geometry, as shown in the image above, the “Shell” mode could fix these artifacts.
Bear in mind, though, that the “Shell” will create a mesh collision with thickness and could have particles inside. Particles inside a geometry such as “Shell” can be due to a fluid’s velocity, or if the geometry is animated and it is moving fast.
Once we've chosen the closed geometry, we need to make sure that the geometry won’t have coplanar faces, isolated vertex, self-intersecting faces, etc. as this will be the cause of a bad computation of the distance field in RealFlow.
We need to avoid “ill-defined” geometry or intersections between the geometry itself. For that reason, it's advisable to work with a proxy of your geometry collision and not with the high res geometry, to collide with RealFlow fluids.
If the geometry is loaded inside RealFlow and its isosurface is showing some artifact, this will mean that the geometry is not properly built in the 3D program and the simulation could be calculated incorrectly.
Still, there's a couple of things we can do to try and see if the artifacts can be solved by RealFlow without modifying the mesh in the 3D program. Try playing with the “Cell Size” and “Surface offset” parameters values to see if this helps solve any artifacts.
Keep in mind that this isn't always a very reliable fix as you're fixing the artifacts for one single frame, but the artifacts could appear in other frames. So even though this may work for some situations, the best solution is always to avoid bringing an “ill-defined” mesh from your 3D program into RealFlow.
To make sure our mesh is fully compatible to work in a Hybrido simulation, it's advisable to show the isosurface and make a preview. It'll take short amount of time to simulate and it'll allow us to see if the mesh is going to work inside RealFlow.
All of these rules must apply to any objects we're going to export from our 3D platform. Although RealFlow is always improving the detection for “ill-defined” geometries to avoid a bad simulation, it's important to take care of the geometries with which we’ll work.
Note: For RealFlow 2015, there will a better way to compute the distance fields. This will make RealFlow more efficient and robust against non “ill-defined” meshes.
If we have several objects to be exported, we need to know something about them. As I said, the distance field is calculated for geometries so the fluid can collide against the geometry with no problem. The geometry can be intersecting between them, of course, but they must be separate objects and not a merged object because this would have the same problem mentioned before, with reference to “ill-defined” geometry.
When we have several geometries to be exported out of a 3D program that are a mixture of static and animated geometry, it's recommended to do it in separate SD files. This helps decrease the file size because it avoids having to export out all of the frames for the static geometry. As another option, if the 3D program we're using supports exporting Alembic format, we won’t have this problem and RealFlow will read it without any problem and keep objects separate.
In order to export the geometry we'll click on the export icon in the RealFlow connectivity plugin toolbar. In this case, let’s export three SD files: “terrain.sd”, “rocks.sd” and “horse.sd”. Don’t forget to change the export “Selected Objects” option to export only the selected objects, and Current frame” if they are static geometries.
Importing geometry inside of RealFlow
Once the geometry has been exported, let’s import it into RealFlow. What do we need to know? Easy. If the geometry to import is static, it's advisable to import it as a Multibody as it is more comfortable to work with its transformations and number of geometries and it will be imported as only one node in RealFlow, regardless of the number of objects that the SD file has. In this case, we'll want to import “rocks.sd” as a Multibody.
If the geometry to import is animated, it needs to be imported with the “Import...” option in RealFlow, in the case of our other SD files. It's worth noting that Multibodies won’t accept animation if we're importing SD files in RealFlow.
In the case that we're working with the Alembic format, it doesn’t matter if it's imported as a Multibody or not. Unlike the SD files such as Multibodies, Alembic accepts animation if it's imported as Multibody or single object.
For our scene, let’s import the “rocks.sd” and “terrain.sd” as Multibodies, and the “horse.sd” as a single object by using the “Import…” option. Note all these commands can be called from the Relationship Editor by pressing the TAB key and typing “Multibody” or “Import”, depending what we want to import.
As mentioned before, once the geometry is imported, we’ll want to do a preview of all frames showing each isosurface to make sure that the distance field is created correctly and no geometry has an artifact which could be affecting the simulation. Of course the exact simulation time depends on your system, but it shouldn't take long, in my case only about five minutes, and it'll avoid futures resimulations. Believe me. :)
Creating the setup for the Hybrido scene
Now we're ready to create the setup and add Hybrido particles to our scene. Hybrido particles are based on a FLIP solver which has many advantages over the SPH solver. Hybrido is faster than SPH.
Also, we'll be able to get more particles for Hybrido than SPH as the SPH process is costly to the machine. For that reason, Hybrido is advisable for large-scale, whereas SPH has better detail for working on small scale, with more or less the same number of particles. For example, SPH particles are ideal when working in advertising.
Back to our scene, let’s create an “Open Domain” and adjust its scale to the “terrain” geometry like in the image above. Although it's not really necessary to adjust the scale for the Hybrido domain, in this case we want to do it because the exported textures for Hybrido, which will be a displacement, will be adjusted depending on the Hybrido projection plane. Also, the mesh could be affected if we're working with “open boundaries” in the mesh parameters.
Once we've created the Hybrido domain, we need to distinguish between two concepts: Particles inside or outside of the objects. Each object has the “Volume mode” parameter, to decide if we want particles inside or outside. It's important to make a conscious choice about this parameter because depending which we choose, the particles will affect the geometry in a different way.
So, “Volume mode” set as “Solid Outside” means that particles will be kept inside the geometry. This is similar to building a closed room and filling that room with fluid so the fluid collides against walls. On the other hand, “Volume mode” as “Solid Inside” means there won’t be particles inside the geometry.
There's another “Volume mode” method and it is “Shell”. This one is useful when our geometry is not watertight and is considered as opened geometry, creating a wrapper around the object. Closed geometry can be used with this method as well, but depending on whether the geometry is animated or not, and its velocity, the fluid could be passing through the geometry in the simulation, which would affect the simulation.
For this scene, we don't need to set the geometry's “Volume mode” to “Solid Outside”, because we’ll kill the particles before particles leave the geometry. Instead, we'll create a k Volume to kill particles. The k Volume will be adjusted to something a bit smaller than the terrain geometry to ensure we're going to remove the particles properly.
Once we know the space where the fluid is going to be created, let’s create a couple of emitters to emit the Hybrido particles. Emitters will be based on closed geometry, although it's possible to use open geometry as well.
So, we're going to add a couple of boxes and adjust them to be the emitters. What we want to achieve is that the fluid falls down the terrain, filling the hole where the horse is. For that reason we need to create at least a couple of emitters, or even more if it's necessary. The final number of emitters you use is your choice.
Finally, we’ll select each box separately to create the Hybrido emitters. Why do we need to create the boxes before the Hybrido emitters? Well, it's not really necessary, but once you've created the boxes and a Hybrido emitter with a geometry which is selected, the geometry will be added to the Hybrido emitter automatically. So, it's just easier to work this way. Of course we can create the Hybrido emitters first, but don’t forget to add the geometry to the emitters so they are able to emit.
Because we want to generate an initial state for our fluid, the new Hybrido emitters that we just have created must be set to “Stream: Yes”, “Initial velocity: Constant”, and set a “@speed” value for the velocity’s fluid.
This way we're ensuring the emitters will be emitting constantly. Once we've set the emitter to “Constant”, an arrow will appear to indicate the direction the fluid is going to emit. It's important to check out the arrow so the fluid will be emitting properly.
A very important concept when working with Hybrido particles is to know what "Cell size" means. For each Hybrido projection plane corner, you’ll see four small boxes indicating the "Cell size" for our Hybrido domain.
Actually, there are small boxes filling the whole fluid scene which is known as Voxelization. This means subdivide the scene into small boxes to know what part is fluid and what part is solid or air. By default, in a Hybrido domain there are 8 particles per cell.
If you take a look at the Hybrido emitter, you’ll see there's a parameter called “Core particle sampling” with a value of 2. This parameter is indicating how many particles are going to be created per cell. It's 8 by default because this parameter is value ^ 3, or 2x2x2 = 8 particles per cell. If we increase this value to 4, for example, we’ll be creating 4x4x4 = 64 particles per cell.
It'll mean more particles for the simulation but it won’t mean the fluid will be adjusted like a charm.
Why not, if there are a lot of particles? Because the fluid will be adjusted depending on the cell size. If the cell size box is very big, it won’t be able to be adjusted properly with the fluid, even if there are millions of particles.
You might've noticed that the geometry has its own "Cell size" too. As we said above, the cell size for geometry will help us to understand how the fluid is going to collide with the geometry.
What if I want to increase the number of particles for the simulation? Well, we’ll need to decrease the "Cell size" value for the Hybrido domain. But, in the same way we had before, if the cell size for the object is very big, the fluid won’t collide properly with the geometry either.
Ultimately, we need to set a balance between both cell sizes for fluid and geometry. The best way to do it will be to use the global cell size multiplier. In this way, we are ensuring that all nodes with the "Cell size" parameter is going to be affected by this value.
Before simulating the scene, we need to set the connections between the different nodes in the Relationship Editor. This relationship between nodes will allow us to indicate which nodes are affecting other nodes so we can create, for instance, collisions between fluid and geometry, or forces affecting the fluid, etc.
In order to connect a node with another one, we have several methods of doing this. The first way we can connect nodes in the Relationship Editor is by pressing the Ctrl key and drag and drop from a node to another node. Another option we have is to drag and drop from the colored external circle in the node to another node in the Relationship Editor to create the connection between them.
On top of those two options, we also have the ability to create a Hub node in the Relationship Editor. The Hub node indicates that all nodes connected to it will be interacting without creating a direct connection between nodes. If you've used older versions of RealFlow, this is similar to creating a global link.
Once you have nodes connected to a Hub node, you can click the “Show implicit links” icon, to see the connections between nodes.
Note in the image above that the emitter geometry is not linked to Hybrido. This is because the emitter geometry will only be a reference. Even if the geometry is linked to the Hybrido node, the solver will indicate that there won’t be a connection between them as they are considered by RealFlow to be emitters and not like other geometry.
Nodes can be created directly in the Relationship Editor by pressing the Tab key and choosing or typing the node we need to create. So, let’s use this method to add a Gravity daemon and connect it to the HUB so the fluid has gravity.
Also, we need to check if the format in which the domain is going to be exported is checked properly in the Export Central. We have the option to export to several formats in RealFlow. By default, the RPC format is checked and it stores the particle information.
If we show the RPC properties, we see which channels are going to be exported. The vorticity and normal channels aren't checked by default, so if we want to export the vorticity texture, we need to check them in the RPC properties and we need to set the vorticity channel to be exported in the “Particle Channels” in the Domain’s parameters.
There's other formats which can be exported besides the RPC. Your choice. On the other hand, the fluid simulation is based on fields. GFC, VDB of F3D are field formats and at least one of them must be checked if we want to create the secondaries such as splash, foam, etc, after the Hybrido simulation is finished.
Next, let’s check the parameters for Hybrido in the simulation.
Once all of our nodes have been connected and the export formats have been properly checked, the next step we'll want to do is to create an initial state for our fluid. The first thing we need to think about when generating an initial state for fluids is to think about how long will it take to simulate.
It can be difficult to estimate how long something may take to simulate precisely since it'll depend on the scene, but I'd advise you to create the initial state saving the cache to disk instead using the “lock” mode. Lock mode won’t save any information about the simulation so, if the system collapses, RealFlow might lose the fluid data.
However, with the simulation data being exported, we’ll be able to choose the frame we wish to make the initial state. Using the lock mode we have the option to indicate a “frame countdown”. In this way, RealFlow will simulate a number of frames, and then start to save it.
Another reason for saving data instead of using lock mode is that the lock mode won’t simulate properly in command line unless the countdown option is enabled. Keeping in mind that the command line is, more or less, 33% faster than simulating with the GUI, it's always a good option to consider. Of course, another option is to disable the viewport and simulate in GUI if we wish.
If we haven't saved the scene yet, it's time to do so before simulating.
If we are happy with a frame to make it the initial state, we’ll stop the simulation and go to the “Initial State” tab. Next, click on the “Make Initial State”. The Hybrido particles will be saved as initial state in the “initialstate” folder of our project where the scene is saved.
In addition, if we wish to create secondaries for our simulation, a field format, GFC or VDB, must be exported as initial state as well. If not, the secondaries won’t be created.
We also need to ensure we check the “Use Initial State” to "Yes", as shown in the image above. To complete the process to use an initial state we’ll check the “Reset” button to “Reset to Initial State”, which you can see in the above image.
Keep in mind when we want to get an initial state, it's not necessary to have any interaction between fluids and animated geometry because we only want to create the initial state for that fluid. Of course, if it needs the interaction to make the initial state, feel free to connect the nodes in the Relationship Editor.
Another very important thing with Hybrido will be checking the solver parameters. Depending on these values we can speed up the simulation. The most important parameters to take a look at in simulations options for Hybrido, will be the Min and Max Substeps. Min and Max substeps indicate how many steps the solver needs to solve the simulation.
So, when is it good to increase steps? Usually, increasing the steps is necessary when there's geometry moving fast through fluid, or even if the fluid itself is moving very fast to collide against static or animated geometry.
In that case, we’ll increase the Max substeps value. If we set Min substeps as 1 and Max Substeps as 20, we're not forcing to the solver to do 20 steps. Instead, the solver will only use up to 20 steps if it's necessary, but it could be using just 4 or 5 steps and nothing more.
How do we know when to increase the substeps? Easy.
If we have fluid inside the geometry, this means that the substeps need to be increased so the solver can manage the simulation. Another symptom which tells you it's necessary to increase the substeps is if the fluid loses volume. Most of simulations without animated geometry work fine with the Min and Max substeps value set to 1 and 1. Because of this low value, the simulation will be very fast.
Usually, we'll want simulate in command line so, if we set a fluid as initial state, we’ll need to configure the command line options so the initial state can be properly read. Leaving the “Reset to Initial State” parameter as checked, we’ll click on the command line options in the arrow button close the “Simulate” button.
The command line options will allow us to set which parameters and frames are going to be simulated in command line. So, as we want to simulate with a reset to initial state, we need to click on “Reset” to force to RealFlow to reset the scene when it is going to start the simulation. And, because the “Reset to Initial State” has been checked as well, RealFlow will do the reset to initial state once the simulation has been sent to command line by pressing the Simulation button.
If we want to visualize the particles in RealFlow just we need to update the timeline cache by pressing Alt+U or the button close the timeline, and go to any frame which has been already simulated.
Creating the setup for secondaries
Adding secondary emitters such as splash and foam is easy in RealFlow. But, it can be difficult to know which parameters are necessary to use without simulating. We can easily waste time simulating scenes with a lot of particles doing small variations of parameter values to get a good result.
In RealFlow, there's a way to know which parameters we're going to use even before simulating, and it's very useful when configuring secondary parameters as foam and splashes. I’m talking about the display property known as “Splash/Foam emission” which can be found in the Hybrido domain. You can see what it looks like and it's location in the image above.
This kind of visualization will allow us to configure the splashes and foam even before simulating, which will help to save time when simulating. Once we have set the parameters for the property “Splash/Foam emission” in the Display tab for Hybrido, let’s add the Splash emitter to the scene.
The Splash emitter can be added from the "Liquid - Hybrido" tab in RealFlow's shelf or directly in the Relationship Editor using the Tab method we talked about earlier.
For all secondary emitters, the only condition it needs to work is that it must be connected to the Hybrido domain so they can emit. This is the case for all Hybrido emitters except for the Mist emitter, which will need to be connected to the Splash emitter, besides the Hybrido domain, as Mist emitter needs a Splash emitter to emit.
So, once we have added the Splash emitter created, we'll need to connect it to the Hybrido domain in the Relationship Editor, beside the gravity and k Volume daemons. To do this, let’s create a Hub and connect the gravity, k Volume and splash so they can interact.
Bear in mind that the Splash, Splash & Foam, Wet and Wet & Foam emitters are all splash emitters that can be connected to any force daemon. Other emitters such as Foam, Bubbles and Waterline are a kind of foam, and only the kill daemons must be connected to them.
This way the foam is placed over the Hybrido surface. If we're pushing the foam particles, for instance with gravity, the daemons would send the particles downwards, and the Hybrido surface upwards. This might cause a problem with the simulation.
Finally, we’ll set the same parameters we used for the "SplashFoam emission" display in Hybrido, for our Splash emitter. Other parameters such as Emission rate, Position, Angle and Velocity variation will help us to indicate how many and where we want to create more particles increasing or decreasing their values.
For this scene, the position variation will be set to 0.07 avoiding the generation a lot of particles around a point. Also, the “Splash min and max lifetime” will be changed to 0.25 and 0.35 respectively. It's worth noting that these parameters are indicated in seconds.
Now, before simulating, the Hybrido domain should be set to Cache mode to avoid being simulated again and the command line options, if we're going to simulate in command line, should be set to “None” as Argument. This is because we want to use the full sequence to generate splashes. Also, we'll need to adjust the splash’s bounding box to the area where we want to generate the splashes.
The last thing to do before simulating is to check the Export Central (F12) to see if the format we want to export is checked properly. RPC is the default format to be exported when working with secondaries. Once verifying our export settings, let’s simulate again.
Like we did with Hybrido options in the simulation options, the secondaries emitters have their own Min and Max substeps in the Liquid - Particle group in the Simulation Options. The concept is the same we had for the Hybrido domain.
Increasing the substeps the simulation will be calculated in greater detail but RealFlow will take more time to simulate. On the other hand, low values will do the simulation faster but might have explosions.
A trick to simulate the Foam emitter very fast is set the Min and Max substeps to 1, as the particles are created over the main fluid surface and they will be moving with the main fluid, so the foam simulation will be much faster.
Note you might be seeing little spots of splash or foam particles appearing everywhere in the main fluid. If it happens, try to increase the Curvature threshold to fix it.
Let’s repeat the same process, more or less, to generate the foam. We have several foam emitters and they are: Foam, Bubbles and Waterline. Of course we can mix them, but for this scene, let’s just take the Bubbles emitter.
The Bubbles emitter adds particles following the same criteria as Splash and Foam emitters, the “threshold”. Once they're on the Hybrido surface, the bubbles will be converted into foam. I like this method because it adds detailed bubble/foam particles to the main fluid.
Usually, there are bubbles in the vorticity areas for fluids like rivers, sea, etc. If we take a look at the vorticity display for the Hybrido domain, we’ll see we can create very good particles there.
Unfortunately, bubbles have an inconvenience due to the fact we can’t create foam based on splash particles from them. In that case, we would add another Foam emitter by choosing only the foam generation per splash if we wish.
Don’t forget to set the Splash emitter to Cache mode.
So, once the Bubble emitter has been added, we need to link it to the Hybrido domain in the Relationship Editor. If you remember we said above that no force daemons can be applied to these kind of foam emitters. Only kill daemons are allowed.
Note that secondary emitters can be linked to the Hub where the Hybrido domain is connected, or directly to the Hybrido domain node, so the secondaries can be created.
Let’s simulate the bubbles but remember that the RPC format is also checked by default to save the bubble particles in the Export Central. Let’s display only the bubble simulation by hiding the other nodes.
Once the bubbles have been simulated, we're going to display the Hybrido fluid, splash and bubbles together.
Now we have the full simulation particles, let’s create the mesh for the main fluid. Splash and bubbles particles can be rendered directly by using the RealFlow RenderKit, which is now free, or even using KRAKATOA so that RealFlow has the ability to export to PRT to work with it directly.
The mesh can also be created in render time by using the RealFlow RenderKit, but we're going to see how to build the mesh directly in RealFlow. So, we're going to hide all the nodes except terrain geometry.
From the Mesh tab, we’ll create a Hybrido Mesh node. The Hybrido mesh will be linked automatically to the Hybrido domain in the Relationship Editor, if the Hybrido domain exists. Bear in mind that we only need the RPC files to mesh so we can uncheck the other file information to load if we wish.
For this scene, we're going to mesh all emitters, Splash and Bubbles, and the Hybrido domain with the Hybrido mesh together. So, we need to be sure that the Splash and Bubbles emitter information are checked in the Export Central.
Next, in the node list, click on the HY_Mesh node with right mouse button (RMB) and we'll choose the “Insert all emitters” option. Now, the Hybrido, Splash and Bubbles are added to Hybrido mesh. Before meshing, take a look at the Hybrido mesh parameters.
If we select the Hybrido domain, in the viewport we’ll see it says: Cell size: 0.150. This is the result of “global cell size x hybrido local cell size”. So, in the Hybrido mesh, the “Auto polygon size” and “Auto particle radius” is set to cell size/2 by default.
Select the HY_Mesh node and click on the build button to build the mesh as seen in the image above. Each time we select the HY_Mesh node, the mesh will be selected, showing green.
With the green mesh, it can be hard to see the changes in our mesh when we adjust parameters. To avoid this, we are going to uncheck the “Selection Highlighting” mode from “View>Show>Selection Highlighting”. Once we have unchecked this option, the selected node won’t be displayed as in the viewport.
Now, we're going to uncheck the filters for the mesh and build the mesh again. Filter parameters will make the mesh process slower, so we are going to turn off the filters for now and build the mesh again.
Also, we're going to set the “Auto polygon size” and “Auto particle radius” to "No" to indicate the values manually. Next, we're going to change the values for “@polygon size” and “@particle radius”. The new value will be 0.03 for both.
Setting the same lower value for both parameters will create more polygons adding more details to the mesh. Of course we can set different values for them depending what we need. So let’s build the mesh again.
Now the mesh is better, but there is a roughness which is giving the mesh a weird aspect as you can see in the above image. Let’s touch the filters to fix that.
First, set the Global Filter to "Yes" and then change the parameters values for “@ thinning” to 0.5, “@ relaxation” to 2, and “@ steps” also to 2. Then build the mesh again.
Now it's better.
A new feature in RealFlow 2014 is an interactive mode for the mesh. With it, you can build the mesh and make changes to the filters, for instance, without building the mesh again. But be careful. For example, if you reduce the polygon size, the mesh will need to be calculated again and it will be done automatically. This can put a lot of strain on your system, depending on the complexity of your mesh.
Also we see there's a lot of small balls due to the radius we set for the “@ particle radius” parameter. So, let’s set a lower radius value for the “@particle radius” parameter, for instance: 0.025. Then we’ll build the mesh again.
The displacement maps can be calculated after the Hybrido domain simulation has been done. It's helpful as it won’t take more time than the main fluid simulation, which would be the case if RealFlow was simulating the main fluid and the displacement maps at the same time. So, with the Hybrido domain selected in Cache mode, let’s go to the Ocean Statistical Spectrum tab and set the “Calculate displacement” to "Always".
Also, we need to be sure we are exporting the Displacement map to TIF format in the Export Central for the Hybrido domain. Once we have checked that, we’ll right-click on the HY_Domain node and select Export > Export Now. That option will export the selected and all its properties like the displacement map as it is in “Always”.
Obviously, only the map is going to be exported because the HY_Domain is in cache mode. In this case, the Export Now will export the displacement map for the actual frame. Bear in mind that the displacement maps will be calculated depending on the Hybrido domain projection plane.
Now the displacement map for the actual frame is exported, we need to check that the parameters are good or not.They are not. So, let’s select the HY_Mesh again and in the “Shader”, we’ll choose “Displacement” for the “Shader Type”.
Now, the displacement map will be applied to the mesh in the viewport as a shader to configure it. We’ll select the HY_Domain node again, and now, we can change the Ocean Statistical Spectrum parameters and all changes will be displayed automatically in the viewport.
Next, we need to export the full sequence for the displacement maps. We need to disable the mesh because we don’t want to export it yet. With the Hybrido domain set to cache and the Calculate Displacement to Always, we'll click on the Simulate button again.
This won’t take much time as RealFlow is reading the RPC files info and writing the displacement maps. Once the maps have been calculated, we’ll set the “Calculate Displacement” parameter to Cache. In this way, we ensure we're not overwriting the displacement maps already calculated.
If you're activating the “White caps channel”, we’ll need to export them activating the checkbox in the Export Central. Also, the UVs Mapping Mode should be set to “Top projection (Average velocity)” so the displacement can move with the fluid movement. If not, the displacement will keep static.
Displacement maps can be applied in two ways to affect the mesh. They can be applied as maps in your 3D package or they can be applied directly to the mesh when building it in RealFlow. This last option will increase the time for the mesh calculation, but let’s check out how it works.
Selecting the HY_Mesh node, we’ll set the “Use Displacement” in the Displacement tab to "Yes", and before calculating the mesh, make sure the “Auto edge length” parameter is set to "No".
After that, we need to change the “@ edge length” parameter to 10. Why 10? Our mesh has a very high resolution, and if we apply the displacement directly to the mesh, the “Auto edge length” parameter would subdivide the mesh even more. So, we need to set the “@ edge length” with a high value to be sure the mesh is not subdividing for now.
If the displacement is set to Cache, once the mesh is calculated you will be able to see the displacement applied to it. Don’t forget to change the “Shader Type” to NONE for the mesh to see the mesh again in blue. Build the mesh. Of course, if you need to subdivide the mesh to apply the displacement, feel free to do that.
In order to simulate the full mesh sequence we can select the “Build sequence” button in the Mesh toolbar, or directly simulate the scene with only the mesh process by command line. I prefer the last method, but the mesh result won’t change independently if we simulate the mesh in GUI or command line. The only difference is the command line process could speed up the mesh generation process.
Once the mesh is done, the last thing to do will be to make a beautiful render of the scene. Check out the Maxwell Render preview in RealFlow by pressing F6.