In this recipe, we will create an underwater environment, looking especially at a fake caustic effect projected by the water's wavy surface and at the deep "atmospheric" perspective, obtained by a per material dedicated node group, as shown here:
Let's start by preparing the scene:
0.300
(press S, followed by Z, digit .3, and hit Enter).4
.2
.20
, and Resolution to 12
.1.00
to 2.00
and press I again to set a second key.Ocean_surface
.0.010
and the Strength value to 2.500
. Set Rotation values as: X 22°, Y -7°, and Z 144°; as you already know, the location doesn't matter for a Sun lamp.1.00
and the samples to 50
for Preview and 100
for Render. Under the Light Paths tab, check the No Caustics option.-5.70000
, and go in edit mode. Scale it 30 times bigger (press A to select all the geometry, followed by S, digit 30, and hit Enter). Using the Specials menu (press W), subdivide the plane five or six times. Activate the Proportional Editing (PET) tool, randomly select vertexes, and move them up to model the dunes of the ocean bed. Next, come out of edit mode, smooth using the Tools panel, and assign a Subdivision Surface modifier at level 2. Rename it Ocean_bed
.First, the easy steps, where we'll append already made materials to re-use them:
1301OS_03_rock_procedural.blend
file, append the Rock_procedural_01
material. Select the rocks and assign the just appended material. Change the two Diffuse colors to R 0.553, G 0.576, B 0.608 and R 0.567, G 0.391, B 0.314 respectively.1301OS_03_ground.blend
file, append the ground_01
material, select the ocean bed and assign this material.Now, to the more complex steps:
1301OS_05_ocean.blend
file, append the ocean_surface
material, select the ocean surface's cube and assign this material. Rename it as ocean_surface_under
.Null
(or whatever makes sense for you), and click on the Assign button. Now the ocean cube has two materials: the transparent water surface and the opaque sides/bottom (a simple white Diffuse material). After this, go out of edit mode.caustics_tileable_low.png
texture and set the color space to Non-Color Data.What is missing now is the underwater deep atmospheric perspective effect. There are several ways to obtain this, for example, by compositing a Mist pass rendered in Blender Internal, but we are going to do it with a node group assigned to each one of the different materials:
0.030
, check the Clamp option. Connect the Multiply node output to the Fac input socket of the Mix Shader node.First of all, why a cube for the ocean surface instead of the simpler plane?
The reason is very simple: in Cycles the World emits light and the only way to avoid this is to set its color to a pitch black (or by a combination of the Light Path node with the World materials, but this is another story). In our scene, the World is set to a bright blue sky color and, with a plane, the underwater objects and the ocean bed as well would have been lit too much from the sides and from the bottom, thereby giving an unnatural result. A cube, instead, envelops all the underwater elements, limiting the lighting to the Sun lamp passing through the surface and projecting the image textured caustics—which is a more natural behavior.
The image texture that we assigned to the water material is to obtain a textured transparency effect. The water surface now is actually opaque and transparent accordingly to the black and white values of the textures, so as to allow the Sun lamp's light to pass through and project the caustics.
Thanks to the Is Camera Ray output of the Light Path node, the caustics image texture is not directly renderable on the ocean surface but still has an effect on the other materials. Because Is Camera Ray is equal to 1, the rays starting from the camera and directly hitting the ocean surface can render only the "clean" water material plugged in the second input socket of the Mix Shader node, while the transmitted caustics (plugged in the first socket equal to 0) get rendered.
Finally, the Fog_underwater node group is simply an emitter material colored as the background (in this case, a deep green) and mapped on every underwater material accordingly to the Z depth of the camera (but it works also out of camera view). The "density" of the fog is set by the Multiply node's second Value; for the ocean body, a value of 0.030
seems good enough. The camera's Z axis must not be confused with the global coordinate's Z axis, which in Blender is the vertical blue line visible in the 3D view. The camera's Z axis, instead, is the ideal line connecting the starting point of view to any visible element in the scene.
Note that we didn't expose the values of the nodes in the Fog_underwater group. This is so because we can tweak, in edit mode, the internal values of just one node to automatically update all the fog group instances assigned to the other materials, and we know that the values exposed on the group interface would overwrite the internal settings working only for that single node instance.
18.117.137.252