Whitecaps for RealWave
RealWave is a tool for the fast creation of huge ocean surfaces with believable waves. There are also two special emitters to get secondary effects like foam and splashes. Unfortunately, these “RW Object Splash” and “RW Crest Splash” emitters are not so easy to configure, and they are based on the slow standard particle solver. The “RW Crest Splash” emitter is also capable of producing foam maps, but they often lack detail and in fact they’re just big white spots of varying size:
Another issue with these emitters is that a good amount of particles is generated below the RealWave surface and have to be removed, e.g. through a Python script. Despite these drawbacks, RealWave is still an important tool, and wouldn’t it be nice to have a function to getter better, more realistic wave crests with whitecaps?
With “Graphs” RealFlow indeed provides a fast and easy way to create these whitecaps, but we have to solve a few issues. Anyway, the RW emitters have one advantage over graphs: emitters can be used together with interacting objects and other deformers like “Fractal”. The graph, presented here, is only suited for ocean statistical spectrum waves without interacting geometry or other deformers.
What are Graphs?
If you are not interested in the graph’s details, just download it here from Google Drive, store it in a place where it’s easy to find, and go to the “Settings” chapter below.
RealFlow Graphs is a visual, node-based programming system. Instead of writing code like in Python, you connect predefined elements, so-called nodes, to create a set of instructions. Many of these nodes provide complex, but highly optimized and ready-to-use functions. This circumstance makes graphs very fast.
We also have to differentiate between two fundamental types of graphs:
- Batch graphs are used for repetitive task like renaming, creating objects, changing parameters, etc. A batch graph is executed manually on demand.
- Simulation graphs are executed during a simulation at certain events, e.g. at the beginning of a frame or at the end of the simulation. Good examples are the introduction of forces, field extraction and manipulation, particle swapping (“foam creation”), and so on.
The “Simulation Flow” window with various scripts and graphs.
What are Whitecaps
The most obvious question is what are these whitecaps? As wave height increases, the sharpening of the wave crest may result in instability and a breaking off of the crest. This process is accelerated by the wind, and the result are the familiar whitecaps.
In terms of simulation the creation of whitecaps is, of course, based on a mathematical model. If you are interested in a more precise answer, here it is:
In order to get whitecaps you have to solve the so-called Jacobian Matrix of the ocean statistical spectrum. Since the Jacobian Matrix is a complex system we don’t want to go into details here. Just one more thing: solving this matrix can be a real bottle neck in many simulations. But, some smart and clever people found ways to accelerate the calculation of the matrix. These fast routines made their way into RealFlow’s Graphs. And therefore we, as “average” users, don’t have to deal with the Jacobian Matrix.
Connecting Graphs and RealWave
The above differentiation between batch and simulation graphs tells us that a simulation graph is certainly the right choice, because our instructions have to be executed with every simulation frame. We want to
- displace the RealWave mesh
- calculate the Jacobian Matrix to extract the whitecaps
- save the whitecaps map.
To make a long story short: a simulation graph won’t help us here, because there are some technical limitations we can’t bypass or overcome. The good news is that there’s an alternative, because of the fact that our graph should be applied per frame. A frame range is nothing more than a sequence of integers: 0, 1, 2, 3, … 200. This means that we can create a batch graph with a loop, running from 0 to a certain end frame, and perform our calculations.
This idea will work, but we’re several steps ahead already. First of all it’s necessary to create a new project with a RealWave mesh.
The “Image Ocean Statistical Spectrum” Node
In order to create a graph you need an editor. Press Ctrl/Cmd + F7 to open a batch editor, then press the Tab key. This action opens a menu with several categories. In the search field enter:
Don’t worry! You don’t have to recreate the entire graph node by node – we only want to take a look at this particular element. When you compare the node pins with the parameters of the RealWave “Ocean Statistical Spectrum” deformer you will find almost the same settings. Only “Vertical scale” is missing, but graph’s node contains an “image white caps” pin.
The ocean statistical spectrum node’s input fields (left) and the RealWave deformer’s parameters (right).
The “ImageOceanStatisticalSpectrum” graphs node is the place where you adjust the waves’ look, and this information will then be transferred to the RealWave mesh. To change the values click on the node and make your settings in the “Input” field.
The nodes below are important, because this is where you make your settings.
- If you have a batch graph open already, close it and open a new one with Ctrl/Cmd + F7.
- Still need to download the graph? Get it right here from Google Drive.
- Load the graph with the editor’s File > Open command.
Enter the exact name of the RealWave node. By default it’s “Realwave01” (don’t type the quotation marks!).
Click on the node and go to the folder icon in the “Input” section. Select the directory, where the whitecaps maps should be stored.
Here you specify the common prefix of the image map files, e.g. “whitecaps” (without quotation marks). The graph will assemble a complete file name and path, e.g. …/whitecaps_00001.exr
Now you might wonder where the main node has gone? Double-click on the “Compound01” element, and you will find the spectrum node pretty much in the middle of the graph – the node’s settings can be seen above.
- To change the size of the whitecaps image maps, increase “resolution” – the value defines a map’s size in pixels..
- The waves’ height is adjusted through the “scale” parameter. Depending on your axis setup you have to adjust the Y or Z value.
Double-click on “Compound_01” to see the “ImageOceanStatisticalSpectrum_01” node.
This node is also located under “Compound_01”. To blur the maps enter a value greater than 0.
Running the Graph
- Click on the graph editor’s “Execute graph” icon.
- Every time you want to use the graph open an editor, load the RFG file, make your settings, and run it.
- Alternatively you can attach the graph to RealFlow’s shelves permanently.
- During simulation the RealWave surface appears flat, but that’s just a temporary viewport issue.