Wood

How to 3D

Chapter 11: Noise

Wood

Perturb a linear oscillation with noise, and we get a marble effect. Perturb a circular oscillation with noise, and we get a wood grain effect. To produce a circular oscillation, we measure how far a fragment is from the center of its xy-plane with this calculation:

GLSL
float d = distance(mixTexPosition.xy, vec2(0.5, 0.5));
float d = distance(mixTexPosition.xy, vec2(0.5, 0.5));

We feed this distance into the sine function to get circular ripples and then blend between two shades of brown to produce tree rings:

GLSL
float noise = texture(noiseTexture, mixTexPosition).r;
float shift = noise * strength;
float strataness = sin(d + shift) * 0.5 + 0.5;
vec3 albedo = mix(vec3(0.8, 0.6, 0.2), vec3(0.6, 0.3, 0.0), strataness);
float noise = texture(noiseTexture, mixTexPosition).r;
float shift = noise * strength;
float strataness = sin(d + shift) * 0.5 + 0.5;
vec3 albedo = mix(vec3(0.8, 0.6, 0.2), vec3(0.6, 0.3, 0.0), strataness);

Adjust the frequency of the ripples and the strength of the noise perturbation in this renderer:

If the strength is too high, the effect is lost.

← MarbleWater →