Sign in to follow this  
zz2

Find nearest maximum to random location on 1D perlin noise function

Recommended Posts

Is it possible to find (approximate) nearest maximum of Perlin noise function for specific random value?

 

I draw this sketch to illustrate:

If red dot represents random offset on the Perlin noise function, is it possible to approximate where the nearest maximum is?

 

289ikp1.jpg

I would like for animation to always start at the top of the wave (so it always drops first).

 

Share this post


Link to post
Share on other sites

If you calculate the derivative of the noise function you obtain a gradient value that indicates which way the function is going at X. That is, if the function is increasing at X, then the gradient will be positive, whereas if the function is decreasing the gradient will be negative. Local maxima/minima are places where the gradient is equal to 0. At those places, the function is neither increasing nor decreasing. So you can calculate the derivative at X, then iteratively "move" in the direction indicated by this gradient value (decrease X for negative gradient, increase X for positive) until the gradient approaches near enough to 0 to be considered "close enough". That should be your nearest maximum.   

Share this post


Link to post
Share on other sites

I think the Perlin noise function works on gradients anyway.

 

There is a local minima/maxima inbetween sample points if the sign of the derivative changes between sample points (since it is continuous).

Share this post


Link to post
Share on other sites

Thank you! That would work. I have implemented Perlin noise function that calculates derivative, from Gustavson's code. Then I realized the real cause of the problem was not the starting point on Perlin's function, but a bug in my code that caused that attenuation of magnitude (of my effect) was dependent on random offset on Perlin's function. I fixed it and now animation behaves as expected.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this