Procedural Textures
The checkerboard pattern started to become too basic for our fancy model. We wanted something less regular; that’s when the texture enters.
And what’s more fun than letting the computer create the textures for you? In fact one of our idea was to have the model stand on a wooden table, therefore we needed some sort of wood-ish texture. Well it turns out it’s really not difficult to generate wood using procedural noise.
Fortunately for us the glm library supports simplex noise. Here are the operations we found looked good:
- Choose one of the two coordinates and scale it by an arbitrary factor.
- Set the other coordinate to a constant value and sample a noise value at that point.
- Set the other coordinate back to its original value plus , and sample two other noise values at a various scaled displacement.
- Apply a smooth periodic function such as to with different periods, add them together and normalize the result .
- Finally blend two colors .
This function can thereafter be used a texture that’s computed on the fly (it’s not particularly expensive so we can allow it). Here we decided to stick to the checkerboard by alternating with two different types of woods. A small trick is to use a different seed for each wood type to mark the transition.