Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero octave noise #334

Open
gwafotapa opened this issue Feb 2, 2023 · 0 comments
Open

Zero octave noise #334

gwafotapa opened this issue Feb 2, 2023 · 0 comments

Comments

@gwafotapa
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant