Hello and welcome to the Maya Learning Channel.
Today I'm going to build off the work done in part 1 of this series,
by turning this single tile into an entire ocean.
Once again, I’d like to give a quick shout out to Diego Trazzi,
on whose work these tutorials are based.
So obviously this tiny patch isn't enough to convey an entire ocean.
I could size up the tile like so...
...but then I’d lose most of the detail and definition.
And if I tried to subdivide the tile even more to make up for it,
the whole simulation would get really slow or might even crash.
So instead of making my tile huge and then subdividing it, I'm going to use Arnold to
repeat a smaller tile over and over again.
Before doing anything though, I’m going to enable the Default Material here,
just to make future changes more obvious.
This only affects my viewport, not my renders.
I’ll start by shrinking my ocean tile to 60 units, while upping its subdivisions to 1024.
You can ignore this warning for now,
since we’ll only be using these settings to generate an initial look.
In general, a larger tile will mean less overall tile duplication.
But you may need to further tweak this depending on your individual processing power
or how far you plan to place the camera (the further out, the larger the tile necessary).
Now, if I just used this same tile over and over, I'm bound to get some unnatural repetition.
That’s something I'd like to minimize as much as possible.
The key is in the solver patch sizes.
Recall that Patch Size represents the size of the water world,
as explained in the previous tutorial.
Meanwhile, each solver represents a different world,
which BOSS then combines for a final result.
If both worlds line up perfectly, then I'm guaranteed to get very noticeable tiling.
But if I offset those worlds so they rarely line up, then I'll get way more unique combinations!
Mathematically, the least number of repetitions occur when your patch sizes have a very high
"Lowest Common Multiple" or "LCM."
So for example, if I chose a patch size of 130 for the main waves...
...and 70 for the secondary waves...
...then they wouldn’t repeat for 910 meters in either direction!
There are plenty of online calculators to help you find these LCM values.
Now I’ll just change the resolution of both solvers to match my larger ocean tile.
Remember, I’ll need to disable the caches to see these changes properly.
Looks like I’ll need to lower the Wave Size to remove these artifacts.
That's better.
I think I'm also going to dampen my foam a bit more too.
Now I'll cache them out.
This is where things start to get interesting.
Despite caching it out, our simulation is still so heavy that it runs quite slow.
However, take a look at the actual cached images.
Does this look like anything to you?
It looks sort of like a displacement map!
That means if I apply it to a low resolution mesh
then Arnold can use it to fake the geometry of the high resolution one!
First, I’ll create a new plane that’s exactly the same size as the ocean tile.
However, I'll leave its subdivisions alone
and apply my existing ocean shader to it.
Now I need to apply the displacement via the Hypershade.
I'll just select the shader and show its connections.
So as you can see, my shader’s displacement is currently unused.
Let’s add one.
However, rather than just apply it as usual,
I’m going to right-click and apply it as a projection since our map is from a top view.
This creates a place3dTexture node in our scene, which I need to orient so it points down.
A value of -90 on X will do that.
As for the scale, this value should be set to half the patch size.
So 65, 65, 65.
Then I need to source the actual wave cache.
As usual, I'll turn on Use Image Sequence as well.
Finally, Maya defaults to feeding the Alpha value as displacement.
However, we actually want to use the Out Color value.
So I’m going to delete this connection
and create a new one from Out Color to Vector Displacement.
Now I’ll hide my high-resolution tile and render the scene.
As you can see, I now get all the detail of my primary waves,
despite the flat, low resolution plane!
To add my secondary waves, I'll go back to the Hypershade.
Then I'll need add a second projection to our primary one.
I can do that using a colorMath node.
First I'll redirect our primary projection into it...
...then feed that result back into the Displacement Shader.
Once that's done, I'll create another projection on Color B.
So -90 to flip it down.
And then scale to half the Patch Size, so 35.
Now I'll reference the secondary wave cache.
Use Image Sequence.
And then render again.
There, that’s not bad for a 10x10 flat plane!
Now I should be able to bump up the size of the plane to any size I want.
Pretty cool eh? Except it looks like I forgot about the foam.
Because of the tiling, I'll need to project it just like the displacements.
So I'll just get rid of these old foam nodes.
Then add them back again as a projection.
I’ll scale it to 30, but again this isn’t physically accurate
so it’s more about getting a look you like.
Then I'll load the foam cache.
There, now the foam looks better.
This is already pretty good, but I can take it a step further.
The beauty of pushing most of heavy work to render time
is that I can get Arnold to further subdivide my plane and get even more detail.
If I go to my planeShape node, I'll find this Arnold section.
Notice the subsection called Subdivision.
In here I’ll change the Type to linear.
This means that at render time, Arnold will subdivide each face again.
If I change the value to 2, Arnold will subdivide them twice.
Notice the extra undulations.
And now I'll go to 3 times...
...and 4...
Now we're getting some really fine definition.
I'm going to try once more at 8.
With each increase in subdivisions, Arnold takes longer to render.
But the results are undeniable, especially when viewed back-to-back.
It'll be up to you to decide how much performance you're willing to sacrifice for fidelity.
And since our displacement maps are all Image Sequences,
you can Batch Render the scene out to see the animated results.
That completes our basic ocean. In the next video, I’ll show you how to put something in it.