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

fbm can be a lot faster #299

Closed
fmrl-island opened this issue Dec 3, 2022 · 0 comments · Fixed by #310
Closed

fbm can be a lot faster #299

fmrl-island opened this issue Dec 3, 2022 · 0 comments · Fixed by #310

Comments

@fmrl-island
Copy link

Hi,
I noticed that in fbm.rs (2d, 3d, 4d), the signal is multiplied by self.persistence.powi(x as i32); each time through the loop. My code runs in only 45% of the time if I change that to instead by a local variable that is updated each octave. I think it is still correct. Thanks!

   fn get(&self, point: [f64; 2]) -> f64 {
        ...

        let mut temp = 1.0;

        for x in 0..self.octaves {
             ...

            // Scale the amplitude appropriately for this frequency.
            signal *= temp;
            temp *= self.persistence;
            ...
        }
         ...
    }
    ```
PrinceOfBorgo added a commit to PrinceOfBorgo/noise-rs that referenced this issue Jan 11, 2024
…he value in the loop (as suggested for fbm in Razaekel#299). Fixed calc_scale_factor in fbm constructor.
Razaekel pushed a commit that referenced this issue Mar 17, 2024
…he value in the loop (as suggested for fbm in #299). Fixed calc_scale_factor in fbm constructor.
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

Successfully merging a pull request may close this issue.

1 participant