Blender 3D By Example
上QQ阅读APP看书,第一时间看更新

Wood

Kitchen materials from this point require more complex procedural solutions. Wood is one such example. The advanced shader setup will require us to break things down into smaller chunks and think through how a material actually looks. For the complex shaders remaining in this chapter, it is highly recommended that you examine the final results in ch06_nodes.blend as you work, found in the wood and wood_boards materials. When in doubt, the exact replication of another user's shaders is a great start to understanding their node logic.

A close examination of wood can break its patterns down into separate problems:

  • The swirling grain usually splits into two sections, one darker than the other.
  • Within those two sections, the wood grain often has separate directions and sizes.
  • Knots gather in certain locations, even darker in color.
  • The grooved artifacts from cutting the wood can leave behind trace artifacts that can affect normals, roughness, specular, and base color, even with the most perfect polish and lacquer.
  • A larger mosaic of staining breaks up the wood's color.
  • For the wood floor, the seams between the floorboards add grooves, and no two floorboards will flow into each other.

Breaking this down into individual problems, let's tackle them in a more logical, easy digest manner:

  1. Start with the core of the wood shader: two sections that have different levels of grain. This is reminiscent of our first mess-around material, with a Wave Texture for the first grain, a Voronoi Texture for the stretched flecks in the second grain, and a Greater Than node from the first Wave Texture driving their separation. Mapping nodes change the scaling of the wood, and Reroute nodes let us use a single coordinate to drive all of their coordinates. The flowing grain and dispersed flecks are both modified with ColorRamps:

Wood grain starting patterns
  1. Use ColorRamps and Mix nodes to tweak and transform your two wood patterns.
  2. Replicate the flecks three times with varied mapping, and combine them with Multiply Math nodes.
  3. Use a starting Mapping node to drive all three Voronoi flecks' individual mapping, allowing for rotation offset. Then, avoid noodle soup with some frames.

The colored wood grain and flecks have expanded the node tree, as shown here:

Separate frames for separate wood grain operations
  1. The knots start by adding the wave texture to a new vector. Visualizing this is hard, as any value above 1 will just look white, but the added waves will "push" the coordinates using the new vector.
  2. Apply this to a Magic texture for a series of knots, and because there are too many knots, use a noise texture to add white, thereby erasing them. Note that, on the Add math node, Clamp is checked. When unclamped, new totaled values will visually output from 0 to 1, and when clamped, they'll clip the light values. This is then recolored and multiplied on top of our previous node tree.

The knots are shown here:

Adding a Wave Texture to a vector for distortion
  1. We can break the wood's monotony up even more with a larger discoloration. Add a noise texture set to 2D with a Mapping node, and then modify the scale. Duplicate the noise texture, and use the previous noise as its vector input for eddies of color.
  2. Combine this with your previous wood's rightmost node using a Mix node set to Multiply. I also used a second MixRGB node to tone the overall wood toward a specific color.
  3. Organize these in a new frame. Assign this to the wood's Principled BSDF color.

Here, the wood discoloration is multiplied by the off-screen previous wood steps:

Discoloring the wood

Specular, Roughness, and Normal come along easily after that.

  1. Add an RGB to BW node, and then use the node where you combined the discoloration and grain as its input.
  2. Use Color Ramps for Roughness and Specular; since the wood is polished, the roughness should be dark with low contrast, while the specularity should be lighter and low contrast.

As you can see in the final wood results, all of those nodes payoff:

Wood, with a complex material setup

The completed wood gives us a baseline for wooden floors. We'll start with a duplicated material, and modify the vector and color with floorboards and then add grooves:

  1. Assign a duplicate of the wood material to a new tester, and rename it wood_boards. Tweak the colors to a different wood shade.
  2. At the start of our node tree, add a Brick Texture with a Mapping node to orient the bricks with the wood grain.
  3. Use a MixRGB node set to Add to combine this with the texture coordinate that drives the whole material.

The multicolored bricks push the vectors in random amounts, making it so the wood floorboards look cut from different tree sections. This vector shift is shown here:

Adding the Generated Texture Coordinates to a Brick Texture that represents floorboards
  1. Use reroute nodes to get the brick nodes all of the way to the end of our tree, and put it in a Frame node called Brick so you don't lose track. Combine it with a Mix node set to Overlay as the last step for the Base Color, which makes the floorboards lighter and darker for more randomness and adds dark grooves between them.
  2. Specular and Roughness require the grooves as well. Run the Brick output into a color ramp that remaps it to just the black mortar. For the Specular, use a Math node to multiply the mortar over the final input, as the cracks would be less shiny (or black).
  3. For the Roughness, the cracks should be rougher (or white). Invert the mortar with an Invert node, and then use a Math node to add these white lines to the final Roughness input.

In the following, the Brick Texture from the start of the node tree has traveled via reroute nodes all of the way to the end, where it's been stored on a Frame node to affect the color, Specular, Roughness, and Normal:

The Brick texture affecting multiple BSDF properties
  1. For the Bump node, use a color ramp to lighten the wood grain and lower its contrast. Next, use a Math node to multiply the mortar on top. Use a Bump node set to .2 strength and .1 distance. Previously, we reduced the wood grain's strength with the Bump node, but since we have to combine it with the mortar, ColorRamp instead reduces it.

The final wood floorboards are very complex, but thanks to good organization, another artist could delve into your shader and make sense of things. This tidiness will pay out later when you might choose a different wood color or use that initial reroute node to map the floor with UVs:

The final wood floorboards material

The wood was a lot more complicated than the previous materials, but it has given us a chance to dive into the power of nodes. Up next, we have material for some tiles.