Ever since I started exploring procedural wood shaders, I’ve wanted to then use those to make wooden planked floors. As I mentioned in a previous post, a wooden log is cut into boards by slicing it along the long axis of the trunk, moving outwards from the center.
There are several ways to cut a log, but basically since I have a nice cylindrical chunk of wood I should be able to make “boards” out of it by simply moving the texture coordinates around. So, if I can get a repeated pattern across a flat plane, and move the coordinates in that pattern by random amounts, that’s a wood floor. Simple!
Well, it has eluded me for some time now. This post isn’t a detailed tutorial on creating a wood floor, but it does explain some of the process I went through to get to a shader I was happy with.
Anyway, I noticed that the Brick shader in Blender can give a nice random brick pattern with different colors in the bricks, so I thought, that’s just what I need! I can set the colors of the shader to black and white, and that will give me various shades of gray and I can use those as the offsets. Let’s see, a Brick node on a Plane:
So if we just add those gray values to the mapping vector of our wood texture, we should be in business. Since those gray values are only in the range 0 to 1, we can probably multiply it by something like 10 to get a bigger range of movement for our wood. Let’s see what happens if we use the Add node to add the output of the brick node to the Vector coming out of the main Mapping node in our Red Oak shader:
Well, that didn’t work at all. It’s hard to even see, but it looks like it’s still one big piece of wood but with parts of it moved around a little.
It occurred to me that the shader we’ve been building uses the Object mapping mode, so the texture coordinates are based on the entire object as if it were solid. Since it’s not UV-mapped across the surface you can’t really warp it any way you want like you could with UVs.
Perhaps I needed a different mode. In Generated mode, the coordinates are mapped from 0 to 1 across the surface of an object, and you can move them around just like UV coordinates, so in theory, that should give me more flexibility.
Initial results are pretty similar to before. I think what is needed is to reset the coordinates to <0, 0, 0> for every brick, and THEN add the gray value for an offset. I tried many things but couldn’t figure out how to get the coordinates to map the way I wanted.
When you are stuck on something Blender-related, a great place to go for help is Blender StackExchange. I found some similar questions but none quite what I wanted, so I posted my own question:
This is one of the images from the answer:
That looks perfect, if I can just swap out the wood for the colored Voronoi there.
To make a long story a bit shorter, I quickly realized that the problem with this solution was that the pattern repeats perfectly, so while it sort of worked, every single plank looked exactly the same. I spent a long time struggling with how to manipulate each plank so that it looked differently, when I suddenly hit on a solution: I needed to combine BOTH my original idea and this new solution. The brick pattern gave me the different values per plank, and the Blender StackExchange solution gave me the method to reset the coordinates for each plank.
So here’s the Blender StackExchange solution with a simple Voronoi pattern:
I tweaked the settings of a Brick Texture node so that it lined up perfectly with the pattern:
Then I add the values of the Brick Texture to the Z-vector of the StackExchange node:
…and it works!
Plugging in the Red Oak texture with some tweaks, and it’s actually doing the right thing:
I did a lot more tweaking of the numbers, and added a bunch of nodes so that I could use slight shader variations based on the values of the Brick Textures, and I got a result I liked:
Awesome! I won’t post the whole network as it’s a bit messy, but the full shader is available on BlendSwap here. Feel free to download it and dissect it to see this all in detail. I’ll explain how I did the variations of the planks in another post on another day, but in the meantime, here’s a room I used the shader in: