shown in other instead.
Learn how to create ocean with waves that looks and feels amazingly realistic. In shallow waters along the shore, we are going to create dynamic caustics and foam. But that is not even the half of it. Water in your project will also have reflections on its surface, refraction for submerged object, underwater fog effect, subsurface scattering for additional play of colors — you name it and try it out!
Step 1. Add Water
Due to its reflectance properties, the water is usually set up after or parallel to the light scattering.
- On the editor panel, click Add an object button, and then Water in the rollout.
- Choose Water for an infinite ocean. Click Ok.
Here's water that is colorless with default settings. Only light scattering attenuates it at horizon with a blue tint.
- Press N to open Nodes settings and rename the node, if necessary.
Step 2. Assign Water Material
Create the custom water material so it can be tweaked.
- Press M to open Material settings. For further steps, there should be present a custom library associated with the world (see how to add material library).
- Select water_base in the list of materials and click inherit the material.
- Choose material library where to save a new material and specify its name.
- While we're in Material settings, go to States tab and check Dynamical reflection so that reflection is not baked into a static map, but generated in run-time.
- After creating the material, it need to be assigned to our object water. Press N to go the Nodes settings -> Surfaces tab.
Holding SHIFT or CTRL, select surface and volume surfaces and load new material for them.
- Select the created water material in the list:
The sky and palms start to be reflected by the water surface:
Step 3. Set Environment Lighting
Environment lighting contributes a very important part into the resulting water color, so it should be set prior to actually adjusting the water. Otherwise, without environment light, the water mass will appear black with colored specular highlights.
- The environment texture is tiny in size, so it is reasonable to disable all small and unessential objects before grabbing it.
In our case, that will be the palms.
- Choose the camera position somewhere in the middle, so that main components of the scene (the sky, water and ground) are visible. We will choose the position above the island:
- Press T to go to Tools settings -> Grabber. In the Mode rollout, select Cube and press the Grab button.
- Save the environment texture in .dds format:
- Enable all the disabled nodes.
- Press R to go to Render settings and load Environment texture.
- Select path to the texture.
The water became brighter - too bright, in fact. HDR reacted to the added environment ambient lighting, darkening the sky:
- Slightly decrease the environment light Exposure down to 0.75.
That will be the base for tweaking water colors:
- Even with decreased exposure, some objects appear too bright. For example, the sand became too bluish and dark sunset shadows has lost their intensity.
Go to Materials settings -> Parameters tab -> Ambient options -> Environment and decrease it down to 0.1. In the result, we get such a view:
Step 4. Tune Water Color and Reflectivity
Now we can get down to tuning our water material.
- Go to Parameters tab -> Shading and set Glossiness to 180 to decrease the highlighted areas on the water surface.
The highlighting has narrowed to the sun path and we can get a better view of the colors to tweak.
- Scroll up and click on the Surface Color field.
- Select black color so that the water surface will be transparent. Other colors can be used if creating muddy water or dense liquids like milk or oil.
- Click on the Volume Color field to determine the basic underwater color.
- Select dark blue, as water color darkens by the sunset.
- Go to States tab and enable Subsurface option to allow additional subsurface scattering layer.
Subsurface color, which is white is by default, is added to volume color
- Return to Parameters tab and find subsurface parameters appeared. Click on the Subsurface Color field.
- Select green color. In combination with blue it will bring nice turquoise tinge.
- Focus on the shore line. We see that the water looks too shallow:
Volume Density up to 0.2:
It will redistribute the volume layer closer to the shore:
- Increase the Volume Power up to 1.5:
It will concentrate the volume spread line, giving the effect of deeper waters:
- Tweak subsurface parameters as well:
- Set Subsurface Density to 0.15, so that subscattering layer is bigger and hence spread closer to the shore.
- Set Subsurface Power to 1.5, so that the subscattering color will grow intense and prominent faster. It should approximate to the volume power for the balance.
Now the subscattering color finely compensates the volume color:
- Let's move the subsurface layer a bit further from the shore. Set Subsurface Falloff to 0.25:
- The Surface which is responsible for reflections also has a spread line. Set Surface Density to 0.25, so that reflections on the water appear closer the shore.
- After all manipulations, let's return to shading and adjust the Fresnel effect: increase Fresnel power up to 7.
After that, the water will appear a little bit less reflective and bottom-exposing when looking from above, than if compared to water near horizon:
- The water is still overly reflective. To compensate for that, set Fresnel bias to 0.05.
With that, we set the minimum level for reflections, so that there are fewer of them.
- Increase the Specular component up to 1.2 for brighter and broader sun path.
- Now tune reflections from the water surface. Click on the Near Color field in the Reflections group. This option changes the reflection color close to the camera.
- Select light gray to ensure that reflections won't be brighter than environment colors.
- Click on the Far Color field. This option allows to set reflections in the distance, far from the camera. Choose light gray as well. The highlights became less prominent:
- Reflections are almost done with, except that palms above the water are basically mirrored in water which is no good.
To blur the reflection of objects, go to States tab and set Reflection Filter to One pass.
Palm reflection becomes vague and hazy:
- At last, setup refraction for underwater objects and surfaces. By default, refraction is not intense enough:
Refraction Scale up to 2 for more distortion.
The bottom and underwater objects are now rippled with the current:
Step 5. Tune Waves
There are two types of waves: rippling according to normal maps (present by default) and big geometrical waves. We'll tune them in the mentioned order.
- First of all, go to Textures tab and load normal maps (Normal 01 and Normal 23) that create two layers of waves.
We will use a default texture.
- Now we'll tune the rippling animation starting with the 1st layer of waves. It is created by the texture Normal 01 being transformed twice, using set expressions:
To see it clearly, let's disable the second layer:
Go to Parameters tab and inset vec4(0.0,0.0,0.0,0.0) in the Normal 2 and Normal 3 fields:
Here's what the first layer of waves looks like. The idea is to make the texture go in two circles that differ basically only with rotation direction and thus compensate each other. (See information on circular motion transformation.)
- The movement is fine, however, the water is not rippled enough. Double click on the Normal 1 field to edit transformation expression.
- The texture coordinate transformation window opens. Here, increase Scale X and Scale Y to 0.02 to add detail.
- Enable the 2nd layer of waves again by clicking Set to parent button for the following fields:
Normal 23 texture according to set expressions and create the 2nd layer of rippling waves.
Two layers together:
- Double click on the Normal 2 field to edit it.
- Increase the Scale X and Scale Y up to 0.04 to add still more ripples.
- Double click on the Normal 3 field to edit it.
- Increase the Scale X and Scale Y up to 0.06.
The resulting rippling looks like that:
- Now we can add bigger geometrical waves that look like being wind generated.
Press N to go to Nodes tab -> Water. Here up to four waves can be set. Let's adjust the parameters of the first wave that will be the biggest:
- Set Amplitude to 0.27 to define the wave height.
- Set Speed to 0.25 to define the speed with which the wave will move.
- Set Length to 11 to define the distance between waves following each other in the same direction.
- Add the second wave:
- Set Amplitude to 0.2 to make the wave a little lower.
- Set Speed to 0.3 so it would move faster.
- Set Length to 9 so that wave follow each other more frequently.
- Set Direction to 45 to make it move at an angle of 45 degrees relative to the first wave.
- Add the third wave that will be even smaller and faster.
- Set Amplitude to 0.16.
- Set Speed to 0.35.
- Set Length to 7.
- Set Direction to -60 so that the waves will follow at an angle of 60 degrees counting clockwise. Its direction balances the direction of the fist two waves.
- Add the fourth wave, the smallest, the fastest, as well as most recurring.
- With the added waves the area closer to horizon looks somehow stirred and creased.
To correct that, go back to Materials settings -> Parameters tab -> Animation parameters. Set Wave radius to 60 units, so that the waves will not spread so far.
Now the waves fade closer and thus more smoothly:
Step 6. Add Caustics
Let's add caustics to the bottom of the sea that will be seen in the shallow waters near the shore.
- Go to States tab and enable Caustics effect.
That's what we've got by default:
- Go to Parameters tab, where options to tweak caustics will appear. There are two expressions that transform caustics animation:
Caustic 0 field to edit it.
- Change Scale X and Scale Y to 0.02 so that caustics pattern becomes denser and finer.
- Click on Caustic 1 field to edit the second animation transformation.
- Increase Scale X and Scale Y up to 0.035 for caustics pattern to become even more detailed.
- Scroll down for Caustics parameters and click on the Color field.
- We'll choose aqua green to match with seashore color.
- Caustics pattern is too thin and not clear enough. Decrease Threshold down to 0.35 so it will be more revealed.
- Let's make the caustics spread line softer and move it away from the shore: for that, set Density to 0.34.
- To limit the spread of caustics in the deep waters, increase Falloff up to 3.5.
- The caustics became barely seen. Set Multiplier to 3 to increase its brightness.
Here's how the result looks like:
Step 7. Add Foam
Let's add one more effect to the water: foam that is is generated near the shore where the waves break.
- Go to States tab and enable Foam effect.
The foam will appear (though hardly visible):
- Go to Textures tab and load foam texture if necessary.
We will use a default texture.
- Go back to Parameters tab, where options to tweak foam show up. Decrease Falloff down to 0.3 and the foam will spread wider from the shore.
- Increasing Threshold to 1.1 allows to sightly move the foam back from the shore and soften the breaking waves line.
- Set Multiplier to 2, which will make the foam brighter and more distinct.
- Now let's animate the foam properly. Scroll up to Transform parameters. Foam texture is transformed twice using set expressions:
Click on the Foam 0 field to edit the first transformation:
- The texture coordinate transformation window opens. Here, increase Scale X and Scale Y to 0.11 so that the foam looks finer.
- Click on the Foam 1 field to edit the second transformation:
- Set Scale X and Scale Y to 0.2 for more sprayed look.
And here comes the final result: