Representing the surface properties of objects and the way the light behaves when it strikes them is vitally important to creating realistic images in Blender. To do this well, you must understand how to create textures and materials that look convincing. Furthermore, you have to master a few crucial tricks of 2D image manipulation when using the most powerful texture-creation tools. Blender has several impressive features that enable you to quickly and easily create seamless UV textures and to combine them in convincing, realistic materials, but for the 2D images themselves, you will turn to another open-source application: GIMP.
In this chapter, you will learn to
Anyone who tries to create even simple images with any degree of realism in Blender will quickly realize the limitations of materials on their own. Blender’s material and shader system enables you to have a great deal of control over a material’s innate properties such as specularity, reflectivity, transparency, and even subsurface scattering. Nevertheless, the uniformity of an untextured material is immediately recognizable. Real objects in the real world are not perfectly even in their color, shininess, or other properties—they have bumps, scratches, pores, indentations, and a host of other imperfections that testify to their physical interaction with the world around them. In Blender, such qualities of the surfaces of objects are represented by textures. Learning to create textures and have them interact with each other in the context of materials is a crucial aspect of learning to create truly convincing models and images.
All textures are represented as 2D patterns that influence the material of the surface of a mesh. Broadly speaking, there are two kinds of textures used in Blender: procedural textures and image-based textures. These two types of patterns have different effects and are used in different ways.
In the case of procedural textures, the patterns are determined by a mathematical formula or algorithm. Working with procedural textures involves manipulating the parameters to the formula and adjusting how the resulting pattern will affect the material. In many cases, the formula for the procedural texture’s pattern in fact results in a three-dimensional pattern, and that pattern’s cross-section at the plane where it intersects the mesh surface is treated as its 2D manifestation. Blender’s clouds texture is a good example of this.
Image-based textures use a 2D image such as a photograph, a hand-drawn image, or an image generated in some other way. With both procedural and image textures, a mapping is a correspondence between 2D points on the image and points on the 2D surface of the textured mesh. There are several set ways to map a rectangular image to a 3D surface. In Blender, the built-in mappings are a plane, a cube, a tube, and a sphere, as shown in . Note that the image texture and the mesh are the same in all four cases. The only difference is the mapping—that is to say, the way that the 2D coordinates of the texture are translated onto the 2D coordinates of the surface of the mesh.
Plane, cube, tube, and sphere texture mappings
These built-in mappings are very useful for appropriate tasks. For example, a rectangular image of the surface of the earth can easily be mapped onto a sphere by using Blender’s sphere mapping. Nevertheless, it should be obvious that these set mappings have their own limitations. For shapes that are not easily analogous to simple planes, cubes, tubes, or spheres, these mappings do not offer sufficient control over where the texture is applied to the mesh.
For the kind of texturing you see in (a color version of this image is included in the book’s color insert), it is necessary to have complete control over where every texture is applied to every part of the mesh. For this, a special kind of texture mapping exists, called UV mapping.
A UV-textured model (background skymap by M@dcow from BlenderArtists.org)
UV mapping derives its name from the 2D coordinate system describing the surface of the mesh. In traditional 2D environments, coordinates are described in terms of X and Y. However, in a 3D environment, X, Y, and Z are used to describe the 3D space. Another set of coordinates is required to describe the surface of the mesh, so the letters U and V are used. Logically, the third dimension in this coordinate system, W, would extend along the vertex normals of the mesh; however, this coordinate name is not used in Blender.
The idea behind UV mapping is to create the mapping between the 2D UV surface of the mesh and the 2D image by hand, albeit with a number of powerful tools at your disposal. Indeed, Blender’s UV-mapping tools are among the best in the industry. The process at its simplest involves three steps: unwrapping the mesh, creating the texture, and applying the texture to the mesh. The unwrapping step is the key to the mapping, and it requires that the mesh be correctly prepared in advance with seams to indicate where cuts will be made in order to flatten the surface with minimal distortion. The process of creating the texture is typically done outside Blender, in a 2D image-manipulation application such as GIMP. In this chapter, you will follow the steps to do all of these things but with an added twist that will involve using Blender’s powerful texture-baking features to reprocess the images and remove all visible seams left from the initial mapping process.
In the next few sections, you’ll focus on texturing a specific object, the smokestack from the locomotive model shown highlighted in . The locomotive model itself is made up of several 3D objects, and the unadorned smokestack shown in can be found on its own in the file smokestack_no_mats.blend on the web page for this book: .
The smokestack object
The smokestack with no materials
To complete the following tutorial for creating a basic UV texture, you will use both Blender and GIMP. An installation of GIMP can be downloaded from or from for Mac OS X installations. After you have installed the software, open the smokestack.blend file and follow these steps:
To create a flat UV mapping, you need to define places on the 3D mesh where the geometry will be “cut.” This is done by adding seams. In this case, it will be quickest just to use the default Loop selection to select the edge loops and add seams manually.
Creating seams on the smokestack
Adding a UV texture
Preparing to unwrap
The unwrapped mesh
Saving the UV face layout
Parameters for saving the UV face layout
Opening the UV face layout in GIMP
Accessing layers in GIMP
To create realistic, photo-based textures, you must start with raw photographic materials. Numerous resources are available on the Web for free or as inexpensive stock textures. One of my favorites websites for this is , where you can find a truly dizzying variety of high-quality textures, most of which are released freely for most uses. The two textures used in this tutorial are from that website. The first is Wojciech Sadlej’s metallic texture shown in , which is also included on the website for this book in the file metal_texture.jpg. This texture and other excellent textures like it can be downloaded from Wojciech’s deviantART page at .
Metallic texture
The second texture, shown in , is by deviantART-user Dazzle—it provides further weathering but is not crucial for following the main points of the tutorial. This texture can be downloaded at Dazzle’s deviantART page at .
A grimy, discolored metal texture
Now it’s time to apply these textures:
Pasting the metal texture into the face layout file
Creating a new layer to fix the pasted selection to
Arranging the new layer
Setting the Rectangle Select tool to feather edges 50 pixels
Selecting a rectangular section of the metal texture
Pasting the selection
The pasted selection on its own layer
A basic metallic texture
Selecting an area of grime
Pasting the copy of the grime texture selection
Adding more grime
Creating a composite layer
The color texture
The texture mapped to the smokestack
Creating a shadeless material with the color UV texture
This is the end of the first stage in creating the finished material, but you’re not quite there yet. The material you’ve created here is not the final material you will use to render the image but rather a sort of interim material that will be used to create the final seamless textures, as you will see in the next section.
The 2D-to-3D mapping shown in looks pretty good, but there are some obvious problems. The biggest problem is the visibility of seams, where the 2D texture meets itself and does not match. In this section, you will see how to eliminate such seams. Astute readers might point out that actual sheet-metal smokestacks are generally not composed of seamless whole surfaces. In fact, this is true, and in many cases, seams can and should be hidden by matching them with real-world seams or hiding them out of view. However, real-world seams do not always match up perfectly with the best places to cut your meshes for UV mapping, so it is important to understand how to create seamless textures when necessary. In this example, ironic as it may be, I ignore the existence of real-world sheet-metal seams and concentrate on explaining the methodology of creating seamless textures.
Unsightly seams
To eliminate the seams in this texture, follow these steps:
Selecting all seams
The Seams1 vertex group
Clearing the old seams
Marking new seams
Adding a new UV texture
The new unwrapping
Baking the texture
The newly baked texture
Now it’s time to clean up the seams that remain in the image:
Selecting an area of the texture
Moving the selection to conceal the seam
Rotating the selection into place
The final color texture
Your next mission is to duplicate the layer you have created and transform it into the bump map texture for the new material:
Duplicating the layer
Desaturating the bump layer
Desaturate dialog box
Adjusting brightness and contrast
The final bump texture
The seamless texture applied to the model
Now you have created the seamless color and bump UV textures that will be the basis of the final material. At this point, you can delete both the old UV texture and the previous BaseColor material. The next section tells you how to construct the new material by using the Blender material nodes system.
Textures are an important first step to creating materials. The textures you have created so far will determine the base color of the metal smokestack as well as the pattern of scratches and pocks as represented by the seamless bump map you created from the color texture. Another important aspect of materials is the shader parameters that determine how light behaves when it strikes the surface of the material. Specularity, hardness, reflectivity, and other real-world qualities depend on these parameters for their representation in Blender.
In the example of the smokestack, it would be nice to represent the accumulation of soot on the upper portion of the smokestack with a blackening-in color and with a diminishing of specularity, because soot-covered metal is less shiny than relatively clean metal. There are various ways to do this. In this section, you will see how to do it by combining several materials with different specularities into a single node-based material.
To create the material, follow these steps:
Making a node material
The nospec material node
The nospec material
The Color, Bump, and Dark texture slots
Color texture
Bump texture
The Dark texture
Duplicating the nospec material node
Creating a new material called spec
Shader values for the spec material
The blend material
The blend texture
Putting the materials together with a Mix node
The nodes system greatly increases Blender’s power and flexibility in creating materials. By using nodes, it is possible to mix materials with different qualities in a wide variety of ways. In this section you’ll see another example of combining materials to achieve a simple but convincing lava effect.
The finished smokestack
A notable feature of flowing lava is that it is composed of two very different main “materials.” (In reality, the material is the same, but its states are different.) The material consists of the flowing, molten part of the lava, which is liquid and glows from heat, and the portion of the lava that has been exposed to cold air and hardened, forming a dark-colored rocky crust. In Blender, it is possible to create these two states separately and then combine them by using nodes. To create this material, follow these steps:
Material settings for Rock
Textures for the rock
Material settings for the rough texture
Settings for the soft-clouds texture
Settings for the hardclouds texture
Settings for the Magma material
You now have the two basic materials completed in your node setup. What remains is to mix them. To do this, add a Mix node by pressing Shift+A while in the Node Editor and choosing Color > Mix. Create connections between nodes by LMB-dragging your mouse from one node’s socket to another socket. You can also connect two nodes by selecting both of them and then hitting F to fill, similar to filling between two edges. Hitting F multiple times toggles through optional sockets. To mix the two materials, draw a connection between Rock and the Color1 socket on the Mix node and a connection between Magma and the Color2 socket. Draw a connection between the Color sockets on the Mix node and the Output node, as shown in . As you can see, the output material is now a mixture of the two input materials. The Mix factor of the Mix node is 0.50, which means that the two materials are mixed at a uniform level of 50/50 across the entire object. You need to input a Mix factor that will give a more appropriate mix effect.
Orange cloud texture for the Magma material
The two materials evenly mixed
A hard clouds texture for Mix
Finished node setup for lava
Displace modifier
Finished render
If you have trouble getting the object lit the way you see it here, check the file lava.blend among the downloadable support files for the book to see how I’ve done the lighting.
You’ve now seen how to create realistic textures by using Blender and GIMP and how to incorporate them into a convincing node-based material. The next section touches on some more important aspects of materials.
In Blender, there are three kinds of transparency: Mask transparency, Z transparency, and Raytrace transparency. In , you can see an example of the three types of transparency together.
The knight piece on the left has the Mask option selected, as shown in , and the area defined by its outline is alpha 0, with the world background visible in the render. Note that things that are in front of the object are not cut out, such as the middle horse’s nose in the image, but the checkerboard wall and floor behind the piece are cut out to show the sky background. This option is useful for compositing.
The knight piece on the left has Mask transparency selected. The piece in the middle has Z transparency selected, and the one on the right has Raytrace transparency.
Mask transparency selected in the Transparency panel of Material properties
The middle knight uses Z transparency, with the settings shown in . Z transparency takes two values into consideration: the material’s alpha value and the Z values of the points in the scene. The alpha value of a material is a measure of how opaque the material is. A 0 (zero) alpha means the material is completely invisible; a 1 alpha means that the material is entirely opaque. The Z value is the distance of a point in space along the camera’s local z-axis; that is, the distance from the camera. Z transparency works very much like layer transparency in a 2D image-manipulation program, using the Z value to determine the ordering of the layers. In the image, the middle knight’s alpha value is set to 0.2.
Z transparency values
The knight on the right also has an alpha value of 0.2, but with Raytrace transparency and the values shown in . As you can see, the effect is very different from that of the middle knight. Whereas the middle knight looks ghostly, the third knight looks like it is made of a real-world transparent material.
Raytrace transparency values
The difference, as you can see, is mainly in the way the light from the background is distorted as it passes through the object, as it would be in real life. This distortion depends on the index of refraction (IOR) of the material. Denser materials have higher IORs. Air has an IOR of approximately 1 (1 is the IOR of a perfect vacuum); water has an IOR of about 1.3; glass has an IOR somewhat higher, between 1.5 and 1.8; and diamond has an IOR of about 2.4.
To represent a material’s IOR, it is necessary to use raytracing to follow the path of the light. Using raytracing will make render times longer, but in cases like these it is necessary. The Depth value on the Raytrace Transparency panel is set at 2 by default. This means that the raytrace calculation will pass through two surfaces. If there are more than two transparent surfaces for the light to pass through, the subsequent surfaces will appear black. To calculate raytrace information passing through more surfaces than this, you must raise the Depth value. Again, this will increase render times, so it should be done only when necessary.
Ray shadows cast by transparent objects are transparent. However, in order for them to appear as they should, the material on which they are cast needs to be set to receive transparent shadows. You can see how this affects the shadow that falls on the checkerboard material in . This setting is found on the Shadow panel of the Material properties area, as shown in .
In the first image, the black-and-white checkerboard materials are set to receive transparent shadows; in the second, they are not.
Receive Transparent option for receiving transparent shadows
When light strikes an object, it can be reflected in a variety of ways. Mostly, the way it reflects depends on qualities of the surface of the object. In Blender, the diffuse and specular shader settings determine how a material reflects light (other settings, such as ray mirroring, may also play a part). With some materials, however, calculating only how light behaves on the surface is not enough. For materials such as wax, skin, most vegetation, jade, milk, and many others, a small amount of surface translucency influences the way light reflects. Although most of the light reflects back from the surface, some of the light penetrates the surface of the material and is reflected back through the material in a scattered state, diffusing some of the light. Although this effect is subtle, it is present on many of the things that humans are best at recognizing, such as food, animals, and other people. For this reason, a lack of subsurface scattering can be a dead giveaway that an image is CG. When used well, it can enable you to achieve extremely realistic organic materials.
To enable subsurface scattering, click the Subsurface Scattering check box on the Subsurface Scattering (SSS) tab in the material’s Properties area, shown in . There are a handful of preset materials: skin (two different ones), marble, whole milk, skim milk, potato, ketchup, cream, apple, and chicken. (I guess the developer who set up the presets was eager to get to lunch!) You can select one of these and then modify the values to create a custom setup.
The settings for subsurface scattering are as follows:
The SSS panel
shows three objects with materials that differ only in their subsurface scattering. The image is reproduced in the color insert of the book. The knight on the left has no SSS, the knight in the middle has strong front SSS with weaker back SSS, and the knight on the right has strong back SSS with weak front SSS. Of course, for more-convincing materials, you would also want to adjust the shader values appropriately; wax has a different specularity than jade, for instance. This example is mainly to highlight the differences in the subsurface scattering effect itself.
Three materials: no SSS, strong front SSS, strong back SSS
Up until now, this chapter has been concerned with materials and textures intended to be rendered to images using Blender’s Internal renderer. In this section, you’ll see a simple technique that can be used to get convincing-looking material and reflection effects in real time in Blender’s own 3D viewport. This is especially useful when doing sculpting, which you’ll read about in the next chapter.
The trick here is to render out a material capture image consisting of a shaded, lit sphere with the desired material settings. The image is then used as a texture for another object, using Normal coordinate mapping. As a result, the reflective properties of the original material are applied to the new object and viewable in the 3D viewport when the GLSL texture shading option is selected.
To create a material capture image, first add a smooth-shaded, subdivision-surfaced Icosphere. shows a simple scene set up with three-point lighting and some white planes for reflections. This setup is based on descriptions on Ben Simonds’s blog at , where you can find some other material capture images and a discussion of the process.
A simple scene for creating a material capture image
The Material settings I used for the sphere are shown in . You can use any settings you like, but including some mirror reflectivity to reflect the white planes creates a nice effect. I turned the Gloss level down a little bit on the Mirror panel.
In the Render properties area, set the dimensions of the camera to 512 by 512. In the Camera properties area, set the camera to Orthographic mode and adjust the Orthographic scale so that the ball fits snugly into the square, as shown in .
Material settings for the sphere
Orthographic camera settings
Render the image so that the output looks something like . This is your material capture image.
To use this material capture image on an object you’re sculpting, simply add a shadeless material to the object, and add an image texture to that material with the material capture image mapped to Normal coordinates, as shown in .
A material capture image
Normal coordinate mapping
The only other thing you need to do is to make sure your viewport shading is set to GLSL in the 3D viewport properties shelf, which you can toggle by pressing the N key while your cursor is over the 3D viewport, and that the viewport shading mode in the 3D viewport header is set to Textured, as shown in .
Shading mode set to Textured in the 3D Viewport
This technique makes a wide variety of shading and reflection attributes possible in real time. This approach is especially nice to use when sculpting, because it allows Blender to ignore lamps during GLSL shading. You can try out your material captures in the next chapter when you explore Blender’s sculpting tools.