Creating a rock material using image maps

In this recipe, we will create a realistic rock material that looks like the samples shown in the following screenshot, using an image map. We'll see a material made with procedurals in the this recipe.

Creating a rock material using image maps

The image-based rock material as it appears in the final rendering

Image maps are particularly useful for several reasons: they already have the necessary color information of a natural surface ready to be used; they can be easily edited in any image editor to obtain different kinds of information, for example, high levels for the bump maps; and they are processed faster than procedurals by the software (procedural textures must be calculated every time). Moreover, they can nowadays be found easily on the Web for free, in several sizes and resolutions.

For our recipe, we'll use the rockcolor_tileable_low.png image map, which you can find in the textures folder provided with this cookbook. This is just a low-resolution texture image provided for the sake of this exercise. Obviously, you can use any other different image with a bigger resolution. Here is a screenshot of the tileable rock image texture for your reference:

Creating a rock material using image maps

The tileable rock image texture provided with this cookbook

In any case, for any image you are going to use, just remember to make it tileable in your preferred image editor. In GIMP, this task can be automatically done by a plugin that can be found by navigating to Filter | Map | Make Tileable.

Getting ready

Start Blender and load the 9931OS_02_interface.blend file, which saw in the previous chapter. Remember that all the blend files and the textures needed for the exercises of this module can be downloaded from the support page on the Packt Publishing website.

Now, we'll create a new file named 9931OS_start.blend, and we'll be using it as the starting point for the most of our recipes. To do so, perform the following steps:

  1. Select the Spheroid and (just for the purpose of this exercise) delete it by pressing X.
  2. Ensure that the 3D cursor is at the center of the scene (Shift + C), and with the mouse pointer in the 3D window, press Shift + A to pop up the Add menu. Then add a new Cube primitive (press Shift + A and navigate to Mesh | Cube).
  3. Press Tab to go out of Edit Mode if needed (this depends on whether you are using Blender with the factory settings or not), and move the cube 2 units up on the z axis.
  4. Go to the Outliner and select the Lamp item, in the Object data window under the Properties panel, switch the Type of Lamp to Sun. Then set the Strength to 2.000 and the color values to 1.000 for R, 0.872 for G, and 0.737 for B.
  5. Reselect the Cube, go to the Material window under the Properties panel, and save the file as 9931OS_start.blend.

How to do it...

Now carry out the following steps to create the rock material:

  1. Click on the New button in the Material window under the Properties panel, or in the toolbar of the Node Editor window.
  2. Rename Material.001 as Rock_01 (the numbering is because I assume that you are going to experiment with several values, especially colors, producing more and different kind of rock materials) and save the file as 9931OS_03_Rock_imagemap.blend.
  3. Put the mouse on the Node Editor window and add an Image Texture node (press Shift + A and navigate to Texture | Image Texture). Then add a Mapping node (press Shift + A and navigate to Vector | Mapping), and a Texture Coordinate node (press Shift + A and navigate to Input | Texture Coordinate).
  4. Connect the Generated output socket of the Texture Coordinate node to the Vector input socket of the Mapping node, and its Vector output to the Vector input of the Image Texture node. Also connect the Color output of the Image Texture node to the Color input of the Diffuse BSDF shader node.
  5. Set the Viewport Shading mode of the Camera view to Rendered by pressing Shift + Z with the mouse cursor in the 3D window. The rendered Cube turns pink because there is no image texture loaded yet, as shown in the following screenshot:
    How to do it...

    The overall view of Blender's customized Default screen with the rendered preview of the pink Cube

  6. Click on the Open button in the Image Texture node, browse to the textures folder, and select the rockcolor_tileable_low.png image.
  7. As we selected Generated as the mapping mode, the image is mapped flat on the Cube from the z axis and appears stretched on the sides. Disconnect the Generated output of the Texture Coordinate node and connect the Object node instead. Then click on the Flat button on the Image Texture node to select the Box item. The texture looks now correctly mapped on each face of the Cube, as shown in this screenshot:
    How to do it...

    The rock image texture loaded in the Image Texture node

  8. Go to the Object modifiers window and assign a Subdivision Surface modifier to the Cube. Set the Subdivisions levels to 4 both for View and Render. Then check the Optimal Display item.
  9. Press Shift + Z to go out of the viewport's Rendered mode. Then press Tab to go to Edit Mode and scale all the vertices to double (press Tab, then press S, enter the digit 2, and finally, press Enter). Now, go out of Edit Mode.
  10. Press T to make the Tool Shelf panel appear in the Camera view, and click on the Smooth button under the Tools tab. Press T again.
  11. Go to the Mapping node in the Node Editor window and set the Scale values for X, Y, and Z to 0.250.
  12. Although the image map we used is tileable, there are visible seams at the corners of the subdivided Cube. In the Image Texture node, set Blend factor to 0.200 to soften the seams (this factor is used to blend the edges of the faces of the Cube that, remember, is still a six-faced solid at its lower level, though looks like a Spheroid as of now). The output of blurring effect of the Blend factor is shown in the following screenshot:
    How to do it...

    The edges seams visible on the surface of the subdivided Cube, and the blurring effect of the Blend factor

  13. Now add a ColorRamp node (press Shift + A and navigate to Converter | ColorRamp) between the Image Texture node and the Diffuse BSDF shader. Set the interpolation to B-Spline, move the marker of the black color to position (Pos:) 0.495 and the white marker to position 0.235, as shown in this screenshot:
    How to do it...

    The ColorRamp node pasted between the Image Texture and the Diffuse BSDF nodes

  14. Add a Bump node (press Shift + A and navigate to Vector | Bump). Connect the Color output of the ColorRamp to the Height input of the Bump node, and the Normal output of the latter to the Normal input of the Diffuse BSDF shader. Detach the Color link from the Color input of the Diffuse BSDF node and leave the Bump node's Strength value to 1.000, as shown in the following screenshot:
    How to do it...

    The Bump node pasted between the ColorRamp and Diffuse BSDF nodes

  15. Add a Mix Shader node and a Glossy BSDF shader, and connect them to be mixed with the Diffuse BSDF shader. Set the Glossy BSDF node's Roughness value to 0.150 and the Mix Shader node's Fac value to 0.300. Connect the Normal output of the Bump node to the Normal input socket of the Glossy BSDF shader, as shown in this screenshot:
    How to do it...

    Adding the Mix Shader and the Glossy BSDF nodes

  16. Add an RGB node (press Shift + A and navigate to Input | RGB) and a MixRGB node (press Shift + A and navigate to Color | MixRGB). Connect both the Color outputs of the RGB and Image Texture nodes to the Color1 and Color2 input sockets of the MixRGB node. Connect the Color output of the MixRGB node to the Color input sockets of the Diffuse BSDF and Glossy BSDF shaders.
  17. Set the Fac value of the MixRGB node to 0.800. Click on the color slider of the RGB node and set the values to 0.407 for R, 0.323 for G, and 0.293 for B, as shown in the following screenshot:
    How to do it...

    Setting the color for the material

  18. Add a new MixRGB node (press Shift + A and navigate to Color | MixRGB). Drag it to be pasted between the first MixRGB node and the Diffuse BSDF shader, and set Blend Type to Add.
  19. Connect the Color output of the second MixRGB node (which we can call the Add-MixRGB node) to the Color input socket of the Glossy BSDF shader node, and set its Fac value to 1.000.
  20. Connect the Color output of the Image Texture node to the Color1 input socket of the Add-MixRGB node so that the preceding connection coming from the first MixRGB node (which we can call Mix-MixRGB) switches automatically to the Color2 input socket of the Add-MixRGB node, as shown in this screenshot:
    How to do it...

    Adding more variations to the rock color

  21. If you wish, model a very quick rock mesh by sculpting or deforming the subdivided Cube in proportional Edit Mode, and assign to it the Rock_01 material as shown in the following screenshot:
    How to do it...

How it works...

We mapped a colored image of a rock with the Box option available in the Image Texture node (developed by the Project Mango team for open movie production of Tears of Steel to quickly map objects without the need to unwrap them), and set the Blend factor to 0.200 to have smooth transitions at the corners. Although we had a tileable image texture, this has been necessary because we set the Scale values for the three axes in the Mapping node to 0.250.

First, by connecting the MixRGB node's Color output directly to the Color input of the Diffuse BSDF shader node, we had a quick visual feedback of the image mapping, and thanks to the ColorRamp node, we achieved the following goals:

  • We converted the colored image to a gray-scale image to be used for the bump.
  • By moving the color markers, we remapped the values of the ColorRamp node's position values to reverse and increase the contrast (we could have obtained the same result by processing the color map in GIMP, for example, by desaturating it and playing with the curve tool). In any case, it's possible to visualize the ColorRamp node itself on the object by temporarily connecting it to the Color input socket of the Diffuse BSDF shader or an Emission shader node connected to the Material Output node.

This contrasted result has been applied as a bump map to both the Diffuse BSDF and Glossy BSDF shaders.

Then we mixed a brownish color (the RGB node) with the Color output of the image of the rock, and the result was added to the Image Texture node's output.

There's more...

We can improve the rocky effect by adding displacement to the geometry. Unlike bump or normal effects on the mesh surface, which are just optical illusions giving an impression of perturbing the mesh surface, displacement is an actual deformation of the mesh based on the gray-scale values of a texture.

At least in this case, there is no need for precise correspondence between the already textured surface and the displacement because it would be barely noticeable. Therefore, we can use object modifiers to obtain a fast but effective result, by performing the following steps:

  1. Starting from the Rock_imagemap.blend file we just created, select the Cube and go to the Object modifiers window under the Properties panel. In the Subdivision Surface modifier already assigned, lower the Subdivisions levels for both View and Render to 3.
  2. Add a new Subdivision Surface modifier and set the levels to 4.
  3. Now add a Displace modifier. Click on the Show textures in texture tab button, the last button on the right of the Texture slot. This switches to the Texture window, where we can click on the New button and then change the default Clouds texture to a Voronoi texture node. Set the Size value to 2.00 and leave the rest of the values unchanged. Go back to the Object modifiers window and set the modifier's Strength value to 0.800.
  4. Add a new Displace modifier. Switch to the Texture window and assign a new Voronoi Texture node. Change the Size value to 1.20. Back in the modifier, set the Strength value to 0.300.
  5. Add one more Displace modifier. This time, we are going to use the default Clouds texture as it is. Just go to the Object modifiers window and set the Strength value to 0.150, as shown in this screenshot:
    There's more...

    A different rock model, thanks to displacement

Of course, these are just basic values. You can change them and also play with different kinds of procedural textures to obtain several rock shapes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.34.208