Good evening!
In computer graphics, we often need ways of creating noise for clouds, water, terrain, procedural texturing, etc. I previously wrote about “Efficient Chaos” for cheaply scattering elements randomly and I wrote about Turbulence for cheaply approximating fluids and gases. Today we are looking at new cost saving technique that I sometimes use in place of 3D Value Noise, Perlin Noise and Simplex Noise algorithms. Those noise algorithms are designed to be fairly efficient, but if you’re sampling them many times per pixel (i.e. volumetric rendering), you probably can’t afford the expensive, multi-sample functions. Here’s how it works:
Gyroids
The idea started from playing with gyroids:

Gyroids are these cool wavy infinite shapes defined with a simple trig formula:
//Gyroid waves
float gyroid = dot(cos(p), sin(p.yzx));
//Gyroid waves expanded out
//float gyroid = cos(p.x)*sin(p.y) + cos(p.y)*sin(p.z) + cos(p.z)*sin(p.x);
It’s neat that such a simple combination of sine, cosine and swizzling can create this interesting pattern. The problem is it’s too perfect and repeats every Tau (with a period of 6.2831) units.
Aperiodic Gyroids
Then I wondered if pick an irrational frequency for one of the sine waves, they should never line up. Playing with the frequencies made some interesting results:
What about the golden ratio, Phi, the most irrational number? Then the sine waves should never line up perfectly. Here’s what that looks like:
That already looks pretty random and in simple cases, that may be enough, but if I zoom out, you can see that aperiodic doesn’t mean pattern-less:
There are repeating shapes that are just slightly off, but still looking clearly patterned to our brains. We can take this further with more math and the golden angle
3D Rotation
Part of the reason this looks so patterned, is because both waves are using the same axis lines. If you remember from Turbulence and Efficient Chaos, rotation can make an enormous difference in masking these patterns. What angle should we use and about what axis? Well how about the golden angle with phi and phi^2 for the axis:
//Rotating the golden angle on the vec3(1, phi, phi*phi) axis
const mat3 GOLD = mat3(
-0.571464913, +0.814921382, +0.096597072,
-0.278044873, -0.303026659, +0.911518454,
+0.772087367, +0.494042493, +0.399753815);
This orientation should be the most irrational orientation, although I can’t confirm that, it works pretty well. Here’s my blobby test:
The full function looks like this:
float dot_noise(vec3 p)
{
//The golden ratio:
//https://mini.gmshaders.com/p/phi
const float PHI = 1.618033988;
//Rotating the golden angle on the vec3(1, phi, phi*phi) axis
const mat3 GOLD = mat3(
-0.571464913, +0.814921382, +0.096597072,
-0.278044873, -0.303026659, +0.911518454,
+0.772087367, +0.494042493, +0.399753815);
//Gyroid with irrational orientations and scales
return dot(cos(GOLD * p), sin(PHI * p * GOLD));
//Ranges from [-3 to +3]
}
Uses
The ideal usecase is low-scale noise applied on natural shapes. It can work well for clouds and fluids. Here’s the twist demo I made.
For larger scenes, it can be layered as fractal noise at a fraction of the cost:
The best part is that this type of noise has fewer artifacts without a rand/hash function or interpolation.
Drawbacks
At the end of the day, it is still composed of just two layers of periodic waves. The rotation helps and the combination is not periodic, but the underlying patterns are still visible in some conditions, especially in flat, large scale scenes:
That being said, even Simplex Noise would look quite homogenous at this scale. Everything in computer graphics is about balancing trade offs and I think the simplicity and speed of this formula is worth it in many cases. If you use a lot of 3D noise, give this a shot!
Conclusion
Over the years, I keep finding and developing new tricks for recreating complexity with simple formulas. This simple modification of gyroids is about as cheap as it gets while still producing aperiodic pseudo-noise! We can skip the hash function and easing functions and blending steps, going straight for unfiltered, smooth waves.
It’s not a perfect solution for every noise problem, but it is effective for the performance cost. When layered in fractal noise, it’s a powerhouse.
Extras
Interleaved Gradient “Noise” by Alan Wolfe: a 2D alternative to white noise that is cheap to compute and easy to filter.
That’s a wrap. Thanks for reading. If you found this helpful, consider subscribing!
-Xor