bracket-lib
bracket-lib copied to clipboard
Zero octave noise
Fractal noise with zero octaves behave as if they have one. Here's the code of the Perlin fractal fbm for example (but it is the same issue with all fractal noises):
fn single_perlin_fractal_fbm(&self, mut x: f32, mut y: f32) -> f32 {
let mut sum = self.single_perlin(self.perm[0], x, y);
let mut amp = 1.0;
let mut i = 1;
while i < self.octaves {
x *= self.lacunarity;
y *= self.lacunarity;
amp *= self.gain;
sum += self.single_perlin(self.perm[i as usize], x, y) * amp;
i += 1;
}
sum * self.fractal_bounding
}
The problem comes from the fact that if you set the number of octaves to 0, fractal_bounding is not recomputed as 0 but 1, thus giving a nonzero noise with no octaves.