So I was looking for some good materials and I found one that I think is very impressive. It is a wood material made by Wessel van der Es. You can get the .blend file in the blender artists forum. On this page I will try to go through how this material works on a node level. This also means a lot of math as this material uses a compelx node composition to manipulate the coordinates of the material.

**How do you go about this task?**

This is a little different from my first tutorial. In this case it is about reverse engineering. To get a good start on this it is important to know how the different parameters influences the material. Thus, for each node group i start by stating how the parameters work.

When I go through the nodes I start at the output and work my way back to the parameter inputs. In this way it is more easily to understand what is influencing the output. Working from the parameter inputs to the output would require following several processes in parallel in order to understand what each parameter affects.

**Analysis**

There are four groups of nodes with parameters, one (the *Wood.Modulator*) hide inside the *Wood.Planks* node group. With this material most of the nodes are self explanatory. I will present the node groups with the last node first.

**Wood.Rings**

First, a little conclusion of the *Wood.Rings* parameters to understand what result we wish to obtain.

**Strength**: Determines the contrast between the rings. Giving less mixing of colors at the interface of the rings for higher values of the strength. Done by multiplying with the result of the cos funktion.**Density**: Determines the number of rings by multiplying with the coordinates to increase the oscillation.**Shape**: Influences how the cos funktion will generate values by changing the power of the coordinates. Some examples of how this will affect the values can be seen below in figure 3.

This node group have a lot of mathematical nodes, and will be hard to analyse if you only look at the nodes. Instead I will look at the mathematical equation which is generated by these node. The mathematical equation gives information as to how the parameters influences the color mixing.

The mathematical consequences of the node setup seen in figure 4 is an equation given by

With the round node we get in to discrete mathematics, which I am not that familiar with. For this tutorial I will just use *round* in the equations as an unknown function.

Figure 5 shows how the coordinats is split up and only Y and Z coordinats is used, to keep the pattern konstant in one direction. This will create the stripes, as Y and Z will influence the cos function and create wave pattens. Y and Z coordinate values are squared to create cirkular patterns in the Y-Z-plane.

It is important here to se the difference between the Y and Z coordinates and the value of Y and Z. With no modification the Y and Z values are the same as the coordinates.

The density parameter is used to increase the effect of the difference for the rounded value and the original value of the squared Y and Z coordinats. The density will make the value of the *cos* funktion increase faster with the coordinates and thus create more stripes (oscillation in color). The difference of the rounded value and the original value allways gives a number between -0.5 and 0.5. To create values between 0 and 2π, the 0.5 is added and the result multiplied with 2π (6.283) which is necessary for the *cos* funktion to complete one cycle.

The shape parameter influences the shape of the cos function. The strength influences how sharp the transition between the colors are.

**Wood.Gnarl, Grain & Stain**

**Gnarl strength**: Influences the degree of distortion of the stripes**Gnarl density**: Influences the degree of distortion of the stripes and the size of the stains**Grain strength**: Influences how sharp the mixing of the colors are in the stripes**Grain density**: Influences how many time the mixing pattern changes thus creating more stripes**Stain**: Create areas with a darker color

With the way the nodes have been organised, these parameters is not independent of each other. Figure 7 shows how the node has two outputs, one for the coordinates for the Wood.Rings node and one for the mixing of the colors.

In figure 8 is shown that gnarl strength and density influences the output coordinate values.

These two parameters distorts the values of the coordinates which is used for the *Wood.Rings*, making the wood rings look more noisy. How this is done, is by the noise texture which makes random values. These values is lowered by substracting a color which represents a value. Instead of sending these valuse directly to the *Wood.Rings*, they are added to the original values. This makes sure to only create a slight change to the values of the original values instead of replacing them. This influences the *cos* function in the *Wood.Rings* node.

The Grain output is affected by all the indputs as can be seen from firgure 9. The Grain output thus contains the stain which has been added to the grain in the second last step.

The Grain *strength* and *density* makes the small strips in the wood by manipulation how the colors are mixed in the wood rings. This mixing builds on the coordinate values for the *Wood.Rings*. By scaling the coordinates, a point in the next texture is stretch to small stripes which forms the grain. The grain density is used to modify the noise texture to create more stripes. The grain strength is used to make the grain clearer by multiplying with the values.

The grain strength is multiplied by 0.5 and subtracted 0.5, these two nodes seem to modify the values to finetune how the strength affect the grain. This modified grain strength is substractede from the streched noise texture.

The stain uses the first noise texture to create the stains. In this case, the gnarl density determines the size of the stain. The stain parameter determines how prominent the stain will be by multiplying with the noise texture. The stain parameter is modified, in the same way as the grain strength was, by multiplying by 0.5 and substract 0.5. This modified stain is substrated from the stain noise texture.

The Stain and Grain is added together. To avoid too many high values, this is multiplied by 0.5 and can now be used to mix the colors as a frac value.

**Wood.Modulator**

**Value**: A coordinate value or modified coordinate value**Period**: The length in coordinates before a step-change in values occurs

The idea of the *Wood.Modulator* is to create a step-change in values to give the appearance that a new wood plank is started.

The *Wood.Modulator* have two outputs, the *Frac* and *Int* value. The *Frac* value is given by the equation

The round funktion gives the integer nearest to the ratio of, value over period. Thus, the frac value will be between -0.5 and 0.5 times the period, giving coordinate values in a manner seen below.

It is this behaviour that gives the break in the texture and make it look like several planks have been put together.

The *Int* value is given by the equation:

Again the round makes sure that it is an integer times the *period,* thus the values will increase in steps with coordinates as shown below.

** Wood.Planks**

**Length**: Control the length of the planks**Width**: Control the width of the planks**Height**: Control the height of the planks**Shift 1**: Shifts the layer of planks in the x direction as they move along the Y coordinate**Shift 2**: Shifts the layer of planks in the x direction as they move along the Z coordinate**Shift 3**: Shifts the layers of planks in the y dirextion as they move along the Z coordinat**Off Centre**: Changes the value step which gives different planks.

The idea of the Wood.Planks is to shift the step-change created by the Wood.Modulator and thus the planks. As can be seen in figure 13 there is a lot of crossed connections which makes this node very complicated. Understanding the math of the Wood.Planks node group is probably the most difficult with this material. In simple therms, it splits the coordinates and utilize the Wood.Modulator on each coordinate to generat a step change in values in each direction.

In my analysis of this node, I start at the end by looking at what actions are applied to the Z coordinates for the top combiner of coordinates. For the top combiners Z coordinates, the *Wood.Modulator* have been used directly to give the *Frac* values. The input to the *Wood.Modulator*‘s value is the Z coordinates and the period is equal to the height parameter.

The values of the Z coordinates for the top combiner is thus

For the Y coordinates the *Wood.Modulator* is used but the period is the width and the value input is given by:

This means by changing the shift3 parameter, you can change how much it is shifted in the Y direction going along the Z coordinates. The value of the Y coordinates for the top combiner is thus.

This same principle is continued with the x values where the period is equal to length and the value input is:

This means that shift1 moves the planks in the X direction with the change of the Y coordinates. Shift2 moves the planks in the X direction with the change of the Z coordinates.

For the bottom coordinate combiner the indput is the int values from the Wood.Modulator. These values are used to create the noise texture which give a slight change for the background color. The values are reduced by substrating a color. The Off Centre is multiplied with the values and will change the values, creating a bigger difference between the values and thus off-set.

I hope this brings some clarity, of how this material works and that you got some insperation for you own materials.

Pingback: Reverse engineering a wood material | Material World

Keep doing this stuff is super useful and good to read!

I read this a bit early to absorb all the maths – I’m never really good at maths unless I really sit down and work it out brick-by-brick – but I do have to say that even with this cursory review, your work is exemplary. Very, very well done (over-looking the odd typo) – the effort of “reverse-engineering” the nodes to arrive at the formulas *alone* deserves considerable merit. This is precisely what I am interested in: developing materials for Blender the way I used to for Poser… using Python (which is quite maths-friendly) and formulas. I just wish I was better at it. Studying your work should help considerably!

Just a note: rounding is a simple math operation, basically if a non-integer is above or equal to n.5 then it rounds towards the larger integer, else it rounds toward the lesser, so for example 2.798 will become 3.0, 2.4999 will become 2.0.