 # noiseDetail in openFrameworks

#1

Hey gang,

How would you recreate the effects of noiseDetail for graphics in processing, but using openFrameworks?

Any help appreciated.

Thanks,
James

#2

Hi RaCompTeur,

Your question interest me so I’ve just done some researches and tries that I can share.

First I’ve read the ofNoise code. The comments says:

This implementation is “Simplex Noise” as presented by Ken Perlin […]

I’ve read that Simplex noise is an improved version of Perlin noise, and that they are gradient smooth functions. To create a more fractal noise, a common practice is to layer multiple perlin (or simplex) noise at different amplitudes and frequencies, which are the “octaves” you’re looking for. Here is a nice article about this.

It seems a little bit strange to me that I’ve found nothing about fractal noise in the OF core nor in the OF addons. Perhaps I’m missing something. A research about this topic in the forum lead to shader implementations, and this is probably a common use case, because CPU computation can be too slow in many cases.

Anyway, I made a CPU function that compute octaves noise (I just had to port the code from this neat page to OF):

``````float octavePerlin( float x, float y, float z, int octaves, float persistence )
{
float total = 0 ;
float frequency = 1 ;
float amplitude = 1 ;
float maxValue = 0 ;
for( int i = 0 ; i < octaves ; i++ )
{
total += ofNoise( x * frequency, y * frequency, z * frequency ) * amplitude ;
maxValue += amplitude ;
amplitude *= persistence ;
frequency *= 2 ;
}
return total / maxValue ;
}
`````` Here’s a demo application: octave-noise.zip (2,2 Ko)

I think the `octave` and `persistence` parameters have got the same effect that the `lod` and `falloff` parameters for the processing `noiseDetail()` function.

The zip also contains a class that can be used like that:

``````OctaveNoise noise ;
noise.setup( 8, 0.5f ) ; // p5 noiseDetail() like
float value = noise.get( 140.f, 20.f ); // 2D noise
``````
3 Likes