A Simple Procedural Texture Algorithm


I am playing around with generating textures and decided to post some preliminary results. The algorithm used to create these images is simple to implement, but slow. Here is how it works:

1. Generate White Noise

Start off with white noise (grayscale only – colour is much too slow).

2. Blend with random neighbourhood pixels

Generate a new image from the old one. Every pixel in the new image is a blend between the corresponding pixel in the other image, and a randomly selected pixel in a square window around that pixel. Every point in that window can be selected with a probability that is defined in a square matrix.

This matrix determines how the texture will turn out; it is unfortunately a bit hard to guess how the texture will look given the matrix, in the general case, without some mathematical analysis.

3. Repeat

Repeat the above step. The more you repeat, the smoother the result is. The images below were created by repeating the step 50 times. On my computer, generating a 128 by 128 tile takes about 10 minutes (Python implementation).

4. Convert Grayscale to RGB

Normalise the image, and map to a gradient.

texture1 texture2 texture7
texture4 texture6 texture3
texture8 texture9 texture10

Some example textures are shown above.



There are some things that I still want to investigate:

  • Is there a way to significantly speed up the algorithm?
  • Is there an intuitive way to linkthe matrix with the result?
  • What are the effects of starting with something other than white noise?


The code is currently too messy to release. I have built it on top of the code that was released for the Quadtrees article, so that is a good starting point if you do not want to wait. Otherwise, keep an eye out, I should post some code soon.