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

What is the amplitude of a BrownianX? #102

Closed
Binero opened this issue Mar 24, 2016 · 9 comments
Closed

What is the amplitude of a BrownianX? #102

Binero opened this issue Mar 24, 2016 · 9 comments

Comments

@Binero
Copy link

Binero commented Mar 24, 2016

How do I change the aplitude of a BrownianX noise generator. I am running a Brownian2 with a open_simplex2 noise generator. After generating 65,536 values, I found these statistics:

min: -1.0851247
avg: -0.005162108
max: 0.96951514

Am I to assume the aplitude here was 1? Is the fact that the min is slightly below -1 just a rounding error? It it always 1?

@Binero Binero changed the title How to change the aplitude of a BrownianX? What is the aplitude of a BrownianX? Mar 24, 2016
@brendanzab
Copy link
Collaborator

Could you try it with the current master branch? You can do this using:

noise = { git = "https://github.com/bjz/noise-rs.git" }

We've done some work on the algorithm, but I'm yet to publish it yet. Let me know if this fixes things!

@Binero
Copy link
Author

Binero commented Mar 25, 2016

For perlin2:

min: -1
avg: -0.00012103994
max: 1

For open_simplex2:

min: -0.54393464
avg: 0.00005978137
max: 0.5439705

For perlin2 using Brownian with 4 quads, no set wavelength:

min: -0.8027274
avg: -0.000063343985
max: 0.7899839

For open_simplex2 using Brownian with 4 quads, no set wavelength:

min: -0.51776856
avg: -0.0000017186136
max: 0.49948424

@brendanzab
Copy link
Collaborator

Is this a more expected result for you?

cc. @amaranth @Aatch

@Aatch Aatch changed the title What is the aplitude of a BrownianX? What is the amplitude of a BrownianX? Mar 26, 2016
@Aatch
Copy link
Collaborator

Aatch commented Mar 26, 2016

What do you mean by "quads" here?

@Aatch
Copy link
Collaborator

Aatch commented Mar 26, 2016

So I took a look at this and am pretty sure it's expected.

Brownian noise is generated by taking a noise function then scaling it and adding it back in. Specifically, the default doubles the frequency each step and halves the amplitude. At the end, it then scales result by the sum of the amplitudes (basically taking a weighted average of the values). Intuitively, it seems that the range for brownian noise should be the same as the input noise, since if you got the maximum for each octave you'd have 1 + 0.5 + 0.25 + 0.125... which would be divided by 1 + 0.5 + 0.25 + 0.125...

However, the way perlin noise and brownian noise work means that is never going to happen. Assuming that you're sampling a (0, 0) - (1, 1) square with the lowest frequency being 1, if that grid square contains the maximum value possible, it must be in the middle of the square, (0.5, 0.5). However, this means that the next sample will be at a grid point (1, 1), which is always 0 (or close to it). So the maximum value at that point actually tends towards 0.5 as the number of octaves increases. Instead, the maximum possible value is actually elsewhere, but figuring out where is quite difficult. Similarly figuring out what that value should be is difficult.

I think the values you have there are about right. I'd probably need a maths degree to properly understand why though.

@brendanzab
Copy link
Collaborator

Ok, I'm going to stop procrastinating and actually publish v0.2.0 now! >_>

@Binero
Copy link
Author

Binero commented Mar 26, 2016

@Aatch
I'm still confused on what the amplitude of open_simplex2 would be though. It's not a neat -1 or +1 like perlin, nor does it have the issue of multiple 'layers' Brownian has.

@amaranth
Copy link
Collaborator

The open simplex implementation is in need of a cleanup and fixing to scale the output to fit the desired -1 to 1 range like perlin does.

@Razaekel
Copy link
Owner

Razaekel commented Mar 2, 2017

Closing since it was apparently fixed in v0.2.0.

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

5 participants