CG:Skeelogy
FEATURED
ARCHIVES
 
 
CURRENTLY VIEWING
SOLID TEXTURES
Generating a wood solid texture in OpenGL
DATE
TYPE
EFFORT
Mar 2007
Texturing
Individual
Solid Textures
@ programming > computer graphics
SECTION MENU

The wood texture that I have created is simply an offset to a cosine noise function. For any 3D point P(x,y,z), the wood texture is obtained by using cos(P.x + turbulence(P))/2+0.5. The last two numbers are used to clamp the result to [0, 1]. The final color produced by this wood function is modulated with a brown RGB color value.

The turbulence() function above is created by adding up the values of noise with different octaves. Each successive noise added should have twice the previous frequency (thus an octave) and half the amplitude. For noise i, the frequency is 2i and the amplitude is pi, where p is the persistence of the noise. Each successive addition of an octave will include noisier details to the result.

Turbulence render with: Octaves = 3, Persistence = 4
Turbulence render with: Octaves = 3, Persistence = 4

Turbulence render with: Octaves = 1, Persistence = 1
Turbulence render with: Octaves = 1, Persistence = 1

Turbulence render with: Octaves = 5, Persistence = 2
Turbulence render with: Octaves = 5, Persistence = 2 (Doesn’t look like wood anymore but I just wanted to show various settings)

Since wood textures normally stretch in a certain direction, I stretched the wood texture by multiplying a texture vector T(tx, ty, tz) where each element is the texture repeat factor for that axis e.g. T(2, 0.5, 1) will repeat texture in X-axis twice, stretch texture in Y-axis by 2 times, and no change texture in Z-axis. We obtain the result R by multiplying this vector T with the point P(x,y,z) as such: R = (tx*x, ty*y, tz*z).

So then how do we obtain the noise function? I used the gradient noise method to generate the pseudo-random noise values, similar to what Ken Perlin has suggested in his 1985 paper. A 3D grid with vertices at integer values is defined. Each vertex on the grid has a value of 0 and has an associated pseudo-random gradient vector. To obtain a value of any point within the grid, a trilinear interpolation (total of 7 linear interpolations) is applied on the 8 grid vertices surrounding the given point. Basically, given any point in the 3D space of the grid, I am now able to return the noise value associated with the point. An important characteristic of this noise function is that it must be pseudo-random and not really random i.e. it must return the same “random” noise value when the same (x,y,z) values are supplied.

Note: As this is part of a group project, this 3D wood texture is created by modifying a distributed raytracer done by my groupmate Neo Jiet Shern.


 
ABOUT ME
Skeel Lee Skeel Lee
skeel@skeelogy.com
Facebook Google+ Twitter Tumblr
YouTube Vimeo Flickr Pinterest
Worked at Wētā FX, Digital Domain 3.0, Sony Pictures Imageworks, MPC, Industrial Light & Magic (ILM), Double Negative
LinkedIn IMDb GitHub Stack Overflow
I am a Technical Director with strong interests in both tech and art. My life evolves round VFX, photography, software engineering, tools programming and generally anything that looks / sounds cool.
I have done a variety of CG programming, including fluid sims, muscles, soft/rigid bodies, raytracing etc. These knowledge complement the visual works that I do as a TD in VFX.
I was interviewed by The Straits Times in May 2014 for my VFX work in X-Men: Days of Future Past.