In this recipe we will create a worn metallic shader:
Getting ready
Start Blender and load the file 1301OS_04_start.blend.
With Suzanne selected, click on the Mode button in the Camera view header and choose Vertex Paint—Suzanne turns a shadeless white color.
Place the mouse cursor on the Paint option at the left of the Mode button, click and select Dirty Vertex Colors, then press T and in the bottom window of the Object Tools panel, set Blur Strength to 0.01, Dirt Angle to 90, and check the Dirt Only option.
Go to the Object Datawindow below the Properties panel, and in the Name slot below the Vertex Colors subpanel, rename the vertex color layer Col_vp.
Return to Object Mode and press T to get rid of the Object Tools panel. In the Properties panel go back to the Material window.
How to do it...
Now let's create the material:
From 1301OS_04_metal.blend | NodeTree, append the node group Metal.
Click on New in the Material window under the Properties panel or in the Node Editor header. Rename the material Worn_Metal.
Switch the Diffuse shader with a Mix Shader node and in the first Shader slot select, under Group, the Metal node group. Do the same for the second Shade slot; now you have two instances of the Metal node group connected to the two input sockets of the Mix Shader node:
Add an Attribute node (press Shift + A and go to Input | Attribute) and a ColorRamp (press Shift + A and go to Convertor | ColorRamp); in the Name slot of the Attribute node write the name of the vertex color layer, Col_vp, and connect the node's Color output to the Fac input socket of the ColorRamp.
Connect theColoroutput of the ColorRamp node to the Fac input socket of the Mix Shader node. Set the ColorRamp node interpolation to B-Spline and move the white color marker three-fourths to the left side of the slider.
Add a frame (press Shift + A and go to Layout | Frame), select the Attribute and ColorRamp nodes, then the frame itself and press Ctrl + P to parent them. Rename the frame VERTEX_COLOR_STENCIL.
Now go to the first Metal group and set IOR to 0.870, Color to R 0.229, G 0.307, and B 0.299, and Roughness to 0.200. In the second Metal group set IOR to 1.000, Color to R 0. 584, G 0.786, and B 0.765, Roughness to 1.000, and Aniso_Amount to 0.100.
Add a Texture Coordinate node (press Shift + A and go to Input | Texture Coordinate), then connect the Object output to the Tangent input of both the Metal group instances.
So far the shader looks really simple. Now we are going to build the bump complex to be piped in the Bump input socket of the second Metal group.
Add a Mappingnode (press Shift + A and go to Vector | Mapping), a Wave Texture node (press Shift + A and go to Texture | Wave Texture ), a Musgrave Texture node (press Shift + A and go to Texture | Musgrave Texture), a Mix node (press Shift + A and go to Color | Mix), and a ColorRamp node (press Shift + A and go to Convertor | ColorRamp).
Press Shift + D to duplicate the Mapping node, then connect the Object output of the Texture Coordinate node to the Vector input sockets of both the Mapping nodes. In the second Mapping node set the Location to 0.010 for all three axes.
In the Wave Texture set the WaveType value to Rings, Scale to 27.000, Distortion to 11.800, and Detail to 16.000. Press Shift + D to duplicate the node and move it just under the first one. Also, move the Musgrave node under this second Wave.
Connect the first Mapping node's Vector output to the first Wave Texture node's Vector input socket; connect the second Mapping node's Vector output to the Vector input sockets of the second Wave and of the Musgrave Texture node.
Set the Musgrave type to Ridged Multifractal, Scale to 27.000, Detail to 5.700, and Offset to 0.500.
Connect the input Color outputs of the two Wave Texture nodes to the Color1 and Color2 sockets of the Mix node. Set the Mix node's Fac value to 1.000 and the Blend Type to Difference. In the Active Node panel (N in the Node Editor window), in the Label slot, rename it Difference1. Connect the Difference1node's Color output to the Fac input of the ColorRamp node; move the white color marker to the middle of the slider and the black color marker one-fourths to the right.
Press Shift + D to duplicate the ColorRamp node and move it under the first one; connect the Color output of the Musgrave Texture node to the Fac input socket of the duplicated ColorRamp. Move the white color marker to the far left of the slider.
Press Shift + D to duplicate the Difference node, rename it Difference2 and connect the Color outputs of the two ColorRamp nodes to its Color1 and Color2 input sockets. Connect the Color output of the Difference2 node to the Bump input socket of the second Metal node group; set its Bump_Strength to 0.050.
Press Shift + D to duplicate the second Mapping node plus the connected Wave Texture, Musgrave Texture, and ColorRamp nodes; move them further down. Connect the Object output of the Texture Coordinate node to the Vector input of this last Mapping node, and restore its Location to 0.000 for all three axes (we could use the first Mapping node output as well, but this is just to make more readable the graphic appearance in the Node Editor window).
Press Shift + D to duplicate one of the Difference nodes, move it down aside the duplicated ColorRamp node and rename it as Difference3. Connect the ColorRamp node's Color output to the Color2 input socket and the duplicated Wave Texture node's Color output to the Color1 input socket, setting the Fac value to 0.500. In the ColorRamp node set the interpolation to B-Spline and move the black color marker a bit to the left (under the n letter of the word B-Spline, to be precise) and the white color marker to the right one-third of the total length of the slider.
In the duplicated Wave Texture node set the Scalevalue to 0.500, and in the duplicated Musgrave node set Scale to 10.000, Dimension to 1.000, Lacunarity to 0.200, and Offset to 0.600.
Add a new ColorRamp node (press Shift + A and go to Convertor | ColorRamp), set the interpolation to Ease and move the white color marker one-third to the left; change the black color marker to RGB 0.500 and click on the Add button. Set the Color of the new marker to pure black. Connect the Color output of the Difference3 node to the Fac value of the ColorRamp node.
Add a Mix node (press Shift + A | Color | Mix) and paste it between the Difference2 node and the second Metal group; connect the last ColorRamp node's Color output to the Color2 input socket of the Mix node; set the Mix node Blend Type to Add, the Fac value to 1.000 and check the Clamp option.
How it works...
As with the bronze material recipe, we used the Dirty Vertex Colors layer as stencil factor, this time to mix two instances of the same Metal node group; the first one with average metal settings and a polished surface, the second one set as a lot less reflective surface with bump scratches obtained by the texture nodes.
There's more...
Obviously, it's not just the Dirty Vertex Colors layer that can be modified and improved by vertex painting the mesh, but we could also use, instead, a gray-scale image map, painted for example in The Gimp or in Blender itself and then UV mapped on the mesh to obtain more precisely localized or peculiar worn effects.