It’s been a while since my last post, and I was thinking I really need to get back into this. Fortunately, the Universe responded with a swift kick in the pants in the form of an astute reader named Ethos. Ethos has experience in woodworking, and not only asked me some great questions about the Red Oak shader, but also pointed out some areas where it wasn’t quite realistic. One of these is the fact that the ring spacing decreases exponentially as the rings get farther from the core of the wood, but real wood rings are pretty uniformly spaced. I’d noticed the thinner and thinner rings in my shader, but didn’t realize it was unrealistic so I didn’t spend much time thinking about it. Since Ethos pointed it out to me, I decided to try to fix it. After some experimentation, I realized the cause of the error was quite simple and should’ve been obvious earlier.
If you started in the first post (Procedural Wood Shaders in Cycles, The Beginning), or read my post about a couple of other ways to make rings, you might remember that I described the rings with the equation of a circle. I stated it as , which means I left out a very important part! The full equation of a circle is , where r is the radius of the circle. I thought I could ignore the radius because we’re not really rendering just a circle, but rather a solid cylindrical shading where the radius goes from 0 to 1 (repeated over and over via the Modulo operator). However the fact that r is squared is quite important. If you recall from algebra, the equation looks like this:
I drew some blue lines on to indicate what might be the rings, and you can see that the rings get gradually closer and closer together:
So if we want the rings to be evenly-spaced, we need to get rid of that squared value, and we do that by taking the square root. There’s no “Square Root” Math function in Blender, but fortunately a square root is the same as raising a number to the power. There is a “Power” Math function that we can use. So, we need to change our into . This was the node network we ended up with at the end of part 1:
We need to insert the Power node before the Modulo node, like this:
And rendering we get this:
However, you can see that it messed up the scale. This is actually a good problem. Because our radius was exponential, the Scale of the overall shader was ramping up at a greater rate, and things like noise needed to be applied sparingly or they would quickly get out of control. Now that we’ve got uniformly-spaced rings, everything should behave better. If you bump the Scale in the Mapping node up to 5.0 instead of 2.0, you should get a similar look to what we had before.
If you’ve followed through to the end of the shader, you can insert the Power node right before the Modulo node in the Rings section:
So, yes, this was a pretty egregious mistake, but it was an awesome opportunity for me to learn and understand more. Thanks again to Ethos for pointing this out and helping to make our Red Oak shader even better!! Please, if you have comments or questions, reach out to me via the Contact form on the About page.
Another idea of Ethos’ that I hope to explore in a future post is the fact that trees get narrower towards the top, so the rings will get closer together (uniformly of course) down the length of a long board. Hopefully I’ll work on that soon so there’s not such a long time between posts. Thanks for reading!
1 thought on “IMPORTANT: I’m Still Learning Too!”