Thursday, August 19, 2010

Texture a Terrain in Cinema 4D

This tutorial examines how to texture a terrain with horizontal striations in addition to a rocky material.  We'll use Cinema 4D for this tutorial, but the principles used are standard and will apply to nearly any 3D environment.

The trick is to apply two textures to the model, each projected from a different direction.  The striations are projected sideways along the terrain, causing them to follow the shape of the ground.  The rocky texture is projected flat against the terrain in the usual manner.

The two textures are mixed together for the final result.

Step 1

Let's start by using Genetica to create the rocky material.  Genetica can be downloaded from here.

Genetica comes with a good number of terrain texture presets that can be used directly.  In the Start tab, select the Terrain, Desert & Barren category, and then select the Hunting Grounds preset.

Next render and export the texture using the two buttons indicated below.

Step 2

Now it's time to create the striations.  Still in Genetica, begin by creating a new document, and then insert a Gradient node and a Colorize node as shown below.  Nodes can be inserted into a document by dragging them from the Library panel.  For help with this, see our earlier tutorials.

Double-click the Colorize node and give the gradient a number of control points with earthy tones, as shown below.  We've used dark colors in this example because that seems to work best with the texture blending offered by Cinema 4D.  You should experiment with what colors work best with your 3D app.

When finished, close the dialog by clicking OK.

Step 3

Genetica's node-based interface allows us to additionally tweak the gradient without actually needing to spend time shuffling countless gradient control points around.  This can be a big timesaver.

For example, you may wish to soften the striations a little by inserting a Gaussian Blur node at the end of the tree, and setting its Radius property to 0.005.

You can also add more details to the striations by fractalizing them, as shown below.

Finally render and export the texture as we did at the end of Step 1.

Step 4

Create a terrain model in your 3D application.  This can be accomplished by creating a plane and then elevating various points within it, but in our example we simply made use of the terrain generation feature offered by Cinema 4D (found in the main menu by clicking Objects > Primitive > Landscape).  Our terrain was customized with the attributes shown below.

Step 5

Still in Cinema 4D, create a new material using the menu found within the materials panel.

Click the button shown below to load the rocky texture that we had exported from Genetica in Step 1.

Apply the material onto the landscape object by dragging the material from the materials panel and dropping it onto the landscape within the main viewport.  The terrain should now resemble the example shown below.

Step 6

To make the texture repeat more often on the model, select the texture tag shown below and then increase the Tiles X and Tiles Y values.

Step 7

Repeat Step 5, creating a second material in Cinema 4D, except this time you should import the striations texture that we had exported from Genetica in Step 2.

Again drag the new material onto the model.  As shown below, the striations will be applied, but they'll be oriented the wrong way.

As we saw in Step 6, the texture tag can be used to modify how a texture is applied to an object.  Now that we've dragged two materials onto the landscape object, it will have two texture tags.  Select the texture tag corresponding to the striations (it should be the second one), and then change the Projection mode to Flat.

The striations may not initially be lined up with the model as desired.  To move and scale them, select the Coordinates section and then adjust the values found within.

Step 8

All that remains is to mix the textures together.  With the striations texture tag still selected, switch back to the Tag section and then check the Mix Textures box.

Here's the final terrain!