If you haven’t been following along, I recommend starting with part 1 and working through the parts. We’re going to pick up where we left off with the last post, and really take this wood up a level. Part 1 is here:
Procedural Wood Shaders in Cycles, the Beginning
Before we start, disconnect the Displacement output of the Diffuse BSDF node; it’s distracting as we work on the wood pattern.
Ok, the first thing we’ll add is a nice control for tweaking the intensity of the grain. Zoom in on the ‘Grain’ frame, and add a Math node. Set it to ‘Power’ and insert it between the Divide and Subtract nodes:
Try different values and you’ll see the effect it has on the grain. For example, setting the power to 0.5 will make it extremely subtle:
Setting the power to 5.0 will make it very strong:
Don’t worry about the value for now. We’ll set it later.
Also set the Subtract value to 4.0 – but since we did that, it throws off our nice 0 to 1 range for the Displacement. Click the “Clamp” checkbox on the Subtract node, which will keep it in the range we want.
Another simple thing we should’ve done a while ago is to set the Roughness value of the Diffuse BSDF node to 0.5:
It’s subtle, but it makes the wood shader hold the light a bit more since it’s acting more like a rough object vs. smooth:
Ok, that’s the simple stuff. We’re going to get a bit involved here, because we want to make the wood even more like our reference:
Note that the grain holes are surrounded by a lighter color, and there are those finger-like marks moving up from the holes. So first, let’s add that lighter color. Instead of a solid color for our holes, we need a color ramp so we can have the holes and the color around them.
Add a Color Ramp node, and place it between the Grain frame and the first Mix node. Set the left color to Hex ECC7B5 and the right color to Hex 957061 (which was the color of our holes in the Mix node). Connect the Subtract node of the Grain frame to the input of the Color Ramp, and the output of the Color Ramp into the Color2 of the Mix node:
Right now, the Subtract node Value also goes to the Fac of the Mix node. Disconnect that, and connect the output of the Power node to the Fac of the Mix node:
If you zoom in on the end grain, you’ll see we now have a lighter color around the grain holes:
The colors are a bit ugly now, but we’ll fix that once we get our pattern the way we want it. So, the pattern we want is similar to the Rays, but more random and wiggly. We’ll create it similarly to the Rays. So to start, create yet another CombineXYZ node, connect the X and Z from the beginning, and attach it to a Normalize node. We’ve done this a couple of time already so no surprise here:
We could’ve probably just taken the output from the Normalize node of the Rays, but for clarity’s sake we made new ones. Create our old friend Voronoi, and connect it to the output of the Normalize node. Set the scale value to 500. This gives us a pattern quite like what we saw with Rays:
Remember that the Normalize node is what makes it radiate out from the center line. Anyway, again we don’t really want those shades of gray, so we’ll tune it with a Color Ramp. Add one, and set the Black position to 0.250, leaving the White position at 1.0:
Our pattern is too perfect right now, so we need to wiggle it up a bit. Like we’ve done before, move the Voronoi and Color Ramp nodes to the right to make some space, and insert a SeparateXYZ and CombineXYZ node, connecting all the outputs:
Create two more Noise Texture nodes, and connect them to two Multiply nodes. Set the Noise values to Scale 1, Detail 1, Distortion 0:
Connect the X and Z outputs to the Multiply nodes, and then connect the Multiply nodes back into the CombineXYZ node:
This basically adds noise (or randomness) to the X and Z coordinates. Our pattern now looks like this:
We could’ve just used one Noise Texture for both X and Z since they have the same settings, but in case we want different controls for X and Z this gives more flexibility. Before we go on, add a Frame around those nodes and call it “Summerwood.” In fact, what we called “Grain” before is also called “Springwood” or “Earlywood.”
Ok, so what to do with this? Well, we need to use this pattern to affect our grain, so we need to do a bit of prep before we can use it. So, go back to our Rings frame. We need to tweak our Color Ramp a little, so adjust the Black position to 0.65.
Go to the Grain frame. Now add a MixRGB node (Add->Color->MixRGB), set the type to Mix, and connect the output of the Summerwood Color Ramp to Color1, and the output of the Divide node as Color2. Set Fac to 0.5. Connect the Output of the MixRGB node to the second Value input of the Power node:
That basically makes the mixed value from the Grain and the Summerwood control the density of the grain…remember that this Power node controlled how intense the grain looked? You can still tweak the Fac value of the Mix node to get different looks.
A closeup render of our end grain now looks more like our reference. It’s not exact, but it’s close to the spirit of the wood:
I’m not happy with the colors of the wood, however. I went to my local home improvement center and looked at some real red oak, and picked up some samples of red oak flooring as well. I learned something important: the end grain seems to be darker where it was cut. I was sampling the colors from end grain photos and they aren’t representative of what the wood really looks like. So, to finish off this red oak, make the following changes.
In this color ramp, change the left color to Hex E5C8B8, and the right color to Hex 986948:
In the left Mix node, set Color1 to Hex DDAA92. In the right Mix node, set Color2 to Hex 8A726B:
Rendering our final shader with Displacement off:
And with displacement reattached (remember, connect the output of the “Grain” frame to a Multiply node to tone down the displacement, and then connect to the Displacement input of the Material Output node. We originally set the Multiplication factor to 0.01, but I think it’s a bit strong. Try 0.005, which is half as much):
Now we have a really nice, relatively accurate red oak shader! I hope you learned something from this series of tutorials. If you have any questions or comments, please send them to me via the “sizzler@” link in the menu. I’ll post this completed shader on BlendSwap, and soon I’ll explore some other types of wood…or maybe something completely different!
The complete node graph:
Nice one.