Thursday, April 25, 2019

procedural generation - Perlin Noise for generating terrain in a 2D side-scrolling game. Is there a way to make variations in noise's amplitude?


For example if my generated levels look roughly like this:


enter image description here


But once in a while I would like to have the "amplitude" rise say 10 times than the rest of the level, so that it would look something like:


enter image description here



That is, once in a while there are deep "trenches" in the level. Now I know that my terrain's Y values are always between for example 200 and 1000 pixels. I there a way for them to mostly be in that range, but once in a while there is a drop to for example 10000 pixels?



Answer



Add another layer of noise to control the amplitude. Scale the noise up (on the X axis) to make the changes in amplitude gradual. Further, you can apply the amplitude changes in a exponential fashion. By applying them in this way, the difference in the noise values of .3 to .4 are not nearly as significant as the difference in the values .9 to 1. This strategy ensures that you do get some deep trenches, but you don't get them frequently.


Note that this method can easily be applied to also cause high mountains if desired.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...