Jump to content
  • Advertisement
Sign in to follow this  
zz2

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

This topic is 2139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!