Source Code

For the determined experimenter, I have provided the C source code for the 4D noise function.

This is supplied in two text files:

4noise.c contains the generic code including my Pseudo random number generator. It includes a generated table from tables.c

This code seems to be robust. It generates a plain vanilla noise function of four variables based on a tightly packed grid whose geometric size is 500 x 500 x 500 x 250 units. Because of the way the 3D layers pack in 4D, this is indexed as 500 x 500 x 500 x 500 so the fourth (time) dimension is not treated quite uniformly with the others. If you need this uniformity, seek the true noise at x, y, z, 2*t.

The block of noise repeats itself outside these dimensions. The pseudo random numbers are calculated on-the-fly. You don't need to store the 62,500,000,000 values. The code handles negative numbers cleanly and there are no known bugs.

The generation of the table uses a lot more theory that I will publish later. I am working on an optimisation that will make this code 4 to 5 times faster.

Please use this code for making cool pictures. E-mail me with your progress. Good luck.

Latest news... The optimisation didn't work. My 1999 code is probably as good as it is going to get without a major breakthrough in theory.

Page updated 23 May 2001
Geoff Wyvill <>