Книга: Mastering Blender
Назад: Part I: Fundamentals of Blender 3D
Дальше: Chapter 3: Sculpting and Retopo Workflow

Chapter 2

Working with Textures and Materials

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

Creating UV Textures with Blender and GIMP

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.

Textures and Texture Mapping

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

c02f001.tif

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.

UV Mapping

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)

c02f002.tif

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.

Texturing a Locomotive Smokestack

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

c02f003.tif

The smokestack with no materials

c02f004.tif

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.

1. To select an edge loop, hold down the Alt key while right-clicking on an edge in that edge loop. With the edge loop selected, press Ctrl+E and choose Mark Seam from the menu. In , you can see seven edge loops that have been marked as seams. Six of the edge loops are circular loops following the circumference of the pipe, and the seventh edge loop is crosswise to the other six, cutting the pipe vertically. (If you have difficulty seeing the selections in this figure, refer to the color insert in this book, where the image is reproduced in color.)
2. In the UV Maps panel of the Mesh properties area, create a new UV texture, as shown in .

Creating seams on the smokestack

c02f005.tif

Adding a UV texture

c02f006.tif
3. Open a UV/Image Editor window and create a new image by pressing Alt+N. In the dialog box that appears, enter 2048 as both the Width and Height values, and select UV Test Grid. In the 3D window, press the A key to select all vertices of the mesh, and then press the U key to bring up the UV Mapping menu. Choose Unwrap, as shown in . (This can also be done by pressing the E key in the UV/Image Editor window.)
4. Unwrap the mesh, and arrange the pieces of the mesh by selecting them with the L key and then moving them with the G key or rotating them with the R key so that they are laid out something along the lines of what’s shown in .

Preparing to unwrap

c02f007.tif

The unwrapped mesh

c02f008.tif
5. Create a guide image of your UVs by selecting the UVs menu in the UV/Image Editor window header and choosing Export UV Layout, as shown in .
6. In the Export UV Layout panel on the file browser tool shelf, set the Size value to 2048, as shown in .

Saving the UV face layout

c02f009.tif

Parameters for saving the UV face layout

c02f010.tif
7. Now it is time to turn to GIMP for the task of creating the actual 2D texture. In GIMP, open the face layout PNG file that you just exported, as shown in .
8. You will be working heavily with GIMP’s layer functionality, so it is important to have the layers document in view. Display this by choosing Dockable Dialogs > Layers from the Windows menu, as shown in .

Opening the UV face layout in GIMP

c02f011.tif

Accessing layers in GIMP

c02f012.tif

Why GIMP?
Blender’s UV/Image Editor has some limited 2D painting functionality, as you will see in Chapter 9, “Compositing with Nodes.” However, it lacks many crucial features necessary to make top-quality realistic textures. Being able to work with 2D layers as well as control fades and transparency while manipulating photographs is crucial to constructing good UV textures. For this reason, GIMP is a natural complement to Blender and an indispensable tool in any open-source 3D content-creation toolkit.

Acquiring Raw Materials for Texturing

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

c02f013.tif

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

c02f014.tif

Now it’s time to apply these textures:

1. Open the file metal_texture.jpg in GIMP. Press Ctrl+A to select the entire image and then press Ctrl+C to copy it. Return to the UV face layout file and paste the selection into the face layout file by pressing Ctrl+V. The result is shown in .

Pasting the metal texture into the face layout file

c02f015.tif
2. As you can see from the Layers window in this figure, the pasted layer is now treated as a floating selection. You must fix it to its own layer by clicking the New Layer button highlighted in .

Creating a new layer to fix the pasted selection to

c02f016.eps

Remember to do this each time you paste a selection into the window!

3. You can now select this texture with Alt+S, or with any of the selection tools in the toolbox, but be sure that you are operating on the appropriate layer when you do so. For right now, select the metallic texture with Alt+S, and rotate and scale it by using the Rotate and Scale tools in the toolbox (c02g001.tif), as shown in . Also, reduce the opacity of the texture layer so that the UV face layout layer is visible.

Arranging the new layer

c02f017.tif
4. Select the Rectangle Select tool in the toolbox, as shown in , and set it to Feather Edges with a radius of 50 pixels. This will enable you to copy selected areas with smooth, faded edges so that they can be pasted seamlessly.
5. With the texture layer active, select a rectangular area as shown in and copy it with Ctrl+C.

Setting the Rectangle Select tool to feather edges 50 pixels

c02f018.tif

Selecting a rectangular section of the metal texture

c02f019.tif
6. Paste with Ctrl+V. Once again, this will create a floating selection, as shown in .
7. Click the New Layer button again to fix this new selection to its own layer. Move the selection to cover the two rectangular portions of the UV face layout, as shown in .

Pasting the selection

c02f020.tif

The pasted selection on its own layer

c02f021.tif
8. Repeat this step to create another layer of texture to cover the upper portion of the face layout, as shown in . Note that the opacity of all layers is reduced temporarily so that the face layout is visible. Before exporting the texture, you will bring the opacity back up to 100 percent.
9. To add some grime and discoloration, open the grime texture in GIMP. Use the Lasso selection tool with Feather Edges set to 50, and then drag the mouse to select an uneven shape, as shown in .

A basic metallic texture

c02f022.tif

Selecting an area of grime

c02f023.tif
10. Press Ctrl+C to copy this selection. Return to the face layout and texture file you were working on and paste the selection with Ctrl+V. As in the previous steps, add a new layer, and then rotate and scale the new texture layer, as shown in .
11. Do this several times with differently shaped segments of grime, as shown in . Note also that the layer’s mode can be changed for different effects. In most cases, Normal mode will give the results you want, but Soft Light will also give appealing, subtle discoloration. Experiment with other modes for different effects.
12. After you are satisfied with your texture, turn the opacity of all layers up to 100 percent, and make sure all the necessary layers are set to be visible by using the small eye icon to the left of each layer’s thumbnail. From the Layer menu, select New From Visible to create a new single-composite layer from all currently visible layers, as shown in .
13. Rename this new layer color in the field to the right of the thumbnail, and set all the other layers above it to be invisible by clicking the eye icons, as shown in .

Pasting the copy of the grime texture selection

c02f024.tif

Adding more grime

c02f025.tif

Creating a composite layer

c02f026.tif

The color texture

c02f027.tif
14. Select the File menu and choose Save As. Give the file the name smokestack_color.png. Appending .png to the filename tells GIMP to merge the layers to export to a single image file. Note that the resultant PNG file will not have layer information. If you want to be able to go back later and work with the GIMP layers, you will need to save this file separately as an .xcf file.
15. You’re finished with GIMP for the time being. Return to Blender. In the UV/Image Editor, open the file smokestack_color.png and map it to the smokestack object, as shown in .

The texture mapped to the smokestack

c02f028.tif
16. Finally, create a material for the smokestack. Call the material BaseColor and set it to Shadeless. Apply smokestack_color.png as a UV-mapped image texture. The full settings for this material are shown in .

Creating a shadeless material with the color UV texture

c02f029.tif

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.

Smoothing the Seams with Texture Baking

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

c02f030.tif

Eliminating Seams
The trick to eliminating seams is to retexture the object by using a different UV unwrapping pattern, so that the areas previously showing UV unwrapping seams can be doctored in GIMP. For this, it is necessary to reseam the model and unwrap again. However, before doing this, it is a good idea to make a record of the seam patterns you used for the first unwrapping, in case it becomes necessary to revisit that unwrapping for some reason.

To eliminate the seams in this texture, follow these steps:

1. First, select all the seams in the object by entering Edge select mode, selecting a single-seamed edge, and then pressing Shift+G or selecting the Similar To Selection option in the Select menu of the 3D viewport header. When you do this, the Select Similar Edges menu will open, as shown in .
2. Select the Seam option, which will select all seams. Create a new vertex group by clicking the + icon under Vertex Groups in the Mesh properties tab, and then click Assign to assign the selected vertices to that group. Give the vertex group a meaningful name such as Seams1, as shown in .

Selecting all seams

c02f031.tif

The Seams1 vertex group

c02f032.tif
3. Using the Alt+right-click loop-selection method, select only the seams shown in . To do this quickly, clear any current selection with the A key and then select the vertices by using the Select button from the Vertex Groups panel for the vertex group you defined previously. Press Ctrl+E and select Clear Seam.
4. Then select the edge loops shown in , press Ctrl+E, and select Mark Seam. Note that it doesn’t matter much where you put the new seams, but they should be different from the previous seams.
5. In the UV Maps panel of the Mesh properties area, click the + icon to add a new UV texture, as shown in . Do not delete the previous UV texture. The new UV texture will automatically be highlighted with blue, indicating that it is now the active UV texture. The previous UV texture will still have the Render (camera) icon to its right selected, indicating that it is the texture that will be rendered.

Clearing the old seams

c02f033.tif

Marking new seams

c02f034.tif

Adding a new UV texture

c02f035.tif
6. In the UV/Image Editor, once again create a new UV Test Grid image pattern with Width and Height values of 2048. Use the A key in the 3D viewport to select the entire mesh and unwrap it in the UV/Image Editor, as shown in . As you can see, the face layout pattern is similar but not identical to the previous one.

The new unwrapping

c02f036.tif
7. Next, you have to bake your texture. Baking is a process of generating a new 2D texture from a 3D scene. This first bake will involve using your metal texture’s wrapping around the 3D object to create a new texture on the same object. Do this now by going to the Render properties area, setting the Bake Mode value in the Bake panel to Textures, and clicking the Bake button, as shown in .
8. The resulting new texture image is shown in . Save this as a PNG file called seams-color.png by selecting Save As from the Image menu in the header.

Baking the texture

c02f037.tif

The newly baked texture

c02f038.tif

Now it’s time to clean up the seams that remain in the image:

1. Open seams-color.png in GIMP. As you can see, the visible seams in the image are now separated from the edges of the UV mapping, so it is possible to doctor them directly. To do this, use the Lasso selection tool to select an area of the image that does not have a seam in it, as shown in .

Selecting an area of the texture

c02f039.tif
2. Make sure the Lasso tool has Feather Edges set to 50 pixels before making the selection. After making the selection, press Ctrl+C and then Ctrl+V to copy and paste the selection, and then click the New Layer button on the Layers window as you did previously to give the selection its own layer. Use the Move tool to move the selection over the visible seam, as shown in .
3. Use the Rotate tool to fit the selection to the new place, as shown in .

Moving the selection to conceal the seam

c02f040.tif

Rotating the selection into place

c02f041.tif
4. Do the same thing for all other spots in the texture where there are visible seams. Be careful not to modify places near the edge of the new UV layout, where modifications would create new visible seams! When you finish, you should have a completely seamless texture like the one shown in . Save the visible layer as no-seams-color.png by using Save As from the File menu.

The final color texture

c02f042.tif

Your next mission is to duplicate the layer you have created and transform it into the bump map texture for the new material:

1. Duplicate the layer by clicking the Duplicate Layer button shown in . Rename the new layer no-seam-bump. This layer will become the bump map texture for the metal material.

Duplicating the layer

c02f043.tif
2. From the Tools menu, choose Color Tools > Desaturate, as shown in .
3. Desaturate the image based on Lightness by clicking OK in the Desaturate dialog box shown in .
4. From the Colors menu, select Invert to reverse the white and black values. Then select Brightness-Contrast and adjust the brightness and contrast as shown in .

Desaturating the bump layer

c02f044.tif

Desaturate dialog box

c02f045.tif

Adjusting brightness and contrast

c02f046.tif
5. Save the visible layer as no-seams-bump.png by choosing Save As from the File menu. The resulting texture file should look like the one shown in . Remember to save the GIMP file separately as an .xcf file if you want to be able to go back and work with individual layers.
6. You now have the final texture. Return to Blender and load it into the UV/Image Editor. As you can see in , the seams have been eliminated.

The final bump texture

c02f047.tif

The seamless texture applied to the model

c02f048.tif

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.

Advanced Materials with Material Nodes

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.

Adding Soot to the Smokestack

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:

1. Open a Nodes Editor window, and click the Use Nodes check box to create a new node material. Choose Material from the drop-down menu on the Material node, as shown in . Name the material nospec, as shown in .

Making a node material

c02f049.tif

The nospec material node

c02f050.tif
2. Turn now to the Material buttons to specify the values for the nospec material. The relevant Material values are shown in . The Specular value is set low, to 0.07, and Hardness is at 108. The shaders used are Lambert and CookTorr.

The nospec material

c02f051.tif
3. Create three textures: Color, Bump, and Dark, as shown in . The Color and Bump textures are both image textures, using the UV image textures you created previously, with UV mappings.
4. Select UV in the Mapping tab. These texture settings are shown in and .

The Color, Bump, and Dark texture slots

c02f052.tif

Color texture

c02f053.tif

Bump texture

c02f054.tif
5. Set the Color texture to Color in the Influence panel. Select the Bump texture, and set its influence to Normal with a value of 1.
6. The Dark texture represents the blackening from soot. Unlike the other two textures, this texture is a blend texture rather than an image texture. The texture’s parameters are shown in . This texture uses Generated mapping, and the mapping coordinates are all Z.

The Dark texture

c02f055.tif
7. Return to the Nodes Editor. Select the nospec material node, and then press Shift+D to copy the node, as shown in .
8. In the new copy, click the number 2 next to the material name to unlink the node from nospec and create a new material. Rename this new material spec, as shown in .

Duplicating the nospec material node

c02f056.tif

Creating a new material called spec

c02f057.tif
9. The new material is the same as nospec in every respect except its specularity and hardness (Spec and Hard) values on the Shaders tab, as shown in . Change these for the new material.

Shader values for the spec material

c02f058.tif
10. Return to the Nodes Editor. Press Shift+A and add a new Material node. Once again, choose Add New from the Material drop-down menu and create a new material. Name this material blend. The parameters for the blend material are shown in .
11. This material is shadeless, so shader values have no effect. It has a single Generated-coordinate-mapped blend texture on it. The blend texture is called blend, and its values are shown in .

The blend material

c02f059.tif

The blend texture

c02f060.tif
12. The blend Material node is used to determine the values for mixing the spec and nospec Material nodes. Add a Mix node by pressing Shift+A and choosing Color > Mix. Make the following connections, as shown in :
  • Connect the Color output socket from the blend Material node to the Fac (factor) input socket in the Mix node.
  • Connect the Color output sockets from nospec and spec, respectively, to the Color1 and Color2 input sockets in the Mix node.
  • Connect the Color output socket of the Mix node to the Color input socket of the Output node.

Putting the materials together with a Mix node

c02f061.tif
13. Render the finished product. The result should look something like the render in , with the lower portion of the smokestack showing a worn metallic shininess and the upper portion sooty and dull.

Hot Lava with Nodes

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

c02f062.tif

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:

1. Delete the default cube and add a UV sphere with default values (32 segments, 32 rings, 1 radius). Set it to have an active material called Material.
2. Open a Nodes Editor window and check the Use Nodes check box, as you did in the previous example. This creates a node material. What you’re looking at are two nodes: an Input Material node and an Output node. The Output node represents the final appearance that Material will take on. At present, the Input node is not linked to any material. Click Add New to create a new Material node.
3. Add a second Material node to the node setup. Do this by pressing Shift+A while in the Nodes Editor window, choosing Input > Material, and then selecting Add New from the highlighted drop-down list on the node. Rename Material and Material.001 as Rock and Magma, respectively, and rename the main node material from Material to Lava.
4. Select the Rock Material node and set its material values by using the Material buttons as you would for any ordinary non-node material, as shown in .
5. Add three textures to the Rock material: a very small noise-size clouds texture called rough and two larger clouds textures, as shown in .

Material settings for Rock

c02f063.tif

Textures for the rock

c02f064.tif
6. The rough texture values are shown in , the soft-clouds texture values are shown in , and the hardclouds texture values are shown in . All textures use Generated coordinates for their mapping.

Material settings for the rough texture

c02f065.tif

Settings for the soft-clouds texture

c02f066.tif

Settings for the hardclouds texture

c02f067.tif
7. Then select the Magma Material node and edit the material settings as shown in , which is repeated in the color insert of the book. Note the high Emit value for the glow.
8. For the orange color texture, use a soft clouds texture with default parameter settings, shown in .

Settings for the Magma material

c02f068.tif

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.

1. Add a new Material Input node in the same way you did for the previous two Material nodes. In the drop-down menu on the node, select Add New to create a new texture, and name the texture MixTex. Make this texture a hard clouds texture with the values set as shown in . This texture will provide a pattern of black and white (that is, 0.0 and 1.0) to replace the uniform 0.50 that’s the default for the Mix node.

Orange cloud texture for the Magma material

c02f069.tif

The two materials evenly mixed

c02f070.tif

A hard clouds texture for Mix

c02f071.tif
2. Add an RGB Curves node by pressing Shift+A and choosing Color > RGB Curves. This will enable you to tweak the contrast and brightness of the factor value going into the Mix node. Connect the Mix node to the RGB Curves node, and connect the RGB Curves node to the Fac connection point on the Mix node, as shown in .
3. All that remains is to tweak the RGB curve to yield the mix pattern that looks best. To get the correct black-and-white pattern, reverse the direction of the RGB curve so that it goes from upper left to lower right, and then edit the shape of the curve itself. The gentler the curve, the smoother the transition between the two materials will be. Points can be added on the curve simply by clicking the LMB and deleted by clicking the button on the node itself marked with an X.
4. Finally, add a Displace modifier to the object with the settings shown in .
5. Type Mix in the Texture field to use the texture you just created to determine the displacement. After you’ve done this, set up your lights and take a render. The finished material should look something like , which is reproduced in the color section of the book.

Finished node setup for lava

c02f072.tif

Displace modifier

c02f073.tif

Finished render

c02f074.tif

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.

Transparency and Subsurface Scattering

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.

c02f075.tif

Mask transparency selected in the Transparency panel of Material properties

c02f076.tif

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

c02f077.tif

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

c02f078.tif

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.

Transparent Shadows

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.

c02f079.tif

Receive Transparent option for receiving transparent shadows

c02f080.tif

Subsurface Scattering

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:

Scale Scale indicates the scale of the objects that the material is applied to. It is used to calculate the size of the blurring radius for the material. To calculate the scale you should use, divide 1 by the number of millimeters you want a single Blender unit (BU) to represent. If you want a BU to represent a meter, the Scale value should be 1/1000 = 0.001. If you want a BU to represent 2 centimeters, the scale is 1/20 = 0.05. If a BU is a millimeter, the scale is 1.0. It is important to pay attention to this, because correct scale is the most important factor in getting your materials with SSS to look realistic.

The SSS panel

c02f081.tif
RGB Radius R, G, and B are the blurring radii for Red, Green, and Blue. These values determine the distance that different-colored light scatters under the surface of the material. If you’ve ever shone a flashlight through your hand in the dark, you have seen that the red in your hand scatters more than the other colors.
IOR IOR is the index of refraction, or the degree to which light is bent when it travels through the material. As mentioned in the previous section, higher IOR values indicate higher density. In the case of subsurface scattering, the effect is subtle, because no actual rays pass through the material. In most cases, you can get away with setting the IOR to approximately the value of water, 1.3.
Error Error controls the precision of sampling. Higher error values will speed up rendering but can result in visible artifacts. You can set it as low as 0.02.
Color Color determines how much the base color of the material is affected by the subsurface scattering effect.
Texture Texture controls the degree to which textures on the material are also blurred; 0 will leave the textures unaffected by the scattering.
Front Front is the weighting factor for front scattering. Front here means pointing toward the camera. Front scattering shows as diffusing of the light and blurring of the shadows on the surface of the material.
Back Back is the weighting factor for back scattering. Back scattering shows up as light passing through from behind the material.

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

c02f082.tif

Creating Convincing Real-Time Viewport Materials with Material Capture Images

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

c02f083.tif

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

c02f084.tif

Orthographic camera settings

c02f085.tif

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

c02f086.tif

Normal coordinate mapping

c02f087.tif

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

c02f088.tif

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.

The Bottom Line

Use Blender’s texturing functionality effectively. Blender has a powerful set of UV-mapping tools that rank among the best in the industry. Using these tools enables you to place 2D textures exactly as you want them on the surface of a 3D model.
Master It Find the file engine.blend among the downloadable support files for this book. Create seams, unwrap the mesh, and export a UV face-layout file for use in GIMP. Apply a UV test grid image to the mesh.
Mix textures to create almost any surface effect. By using Blender’s UV texture and texture-baking features, particularly in combination with a powerful image-manipulation application such as GIMP, you can create a wide variety of seamless texture effects.
Master It Using the metal_texture.jpg file included among the downloadable support files for this book, or other textures that you find online or create yourself, use the methods described in this chapter to create seamless color and bump map textures for the engine.blend model.
Make the most of the Blender material system to create complex materials and shaders. Creating textures is only the first part of making convincing materials. Mapping them correctly to the material and setting their parameters correctly are crucial to getting realistic material effects.
Master It Combine the two textures you created in the previous exercise into a single material with both color and bump qualities. Set the shader properties in a way that creates a convincing metallic look.
Назад: Part I: Fundamentals of Blender 3D
Дальше: Chapter 3: Sculpting and Retopo Workflow

lookforrent
Буду знать! Оцените туристический портал lookfor.rent
JbnvJinge
12 month loans cash now cash loans in winchester tn cash advance in dubai
androidinfoSa
Знать достаточно свежие публикации у сфере планшетов и наблюдать презентации планшетов Андроид пользователи смогут на разработанном сайте запись телефонных звонков , который окажет помощь для Вас находиться в теме последних выпусков мировых марок в операционке Android и продажи задекларированной устройств. Популярный ресурс выдает потребителям совершенно популярные предметы обсуждения: мнение экспертов про телефоны, оценка пользователей, обновление, апки для персональному смартфону, ОС Андроид, ответы на популярные вопросы также различные основные содержание, какими интересуются регулярно. Стоит коротко увидеть новый телефон и выделить уникальные характеристики? Вовсе не AndroidInfo.Ru преград - у основной строчке возможно кликнуть модель либо ключевое слово затем одержать с вашего задания подходящую параграф совместно с фотоотчетом плюс описанием преобладающего функций. В случае если юзер есть несомненного ценителя выпусков смарт устройств по операционке Андроид Android , здесь регистрация поможет юзерам ни разу не выпустить каждую единую добавленную новость у области умных систем. Будет изобилие всего увлекательного также развивающего для всем ценителей инноваций новой эры.
Anciwhish
buying paper custom written papers
DbgvAmurn
dissertation research research methodology dissertation