4
\$\begingroup\$

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?

\$\endgroup\$
9
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ That sounds like a good solution. Just to clarify, what exactly do you mean when you say "add another layer of noise"? Another noise function that controls the amplitude of the original one? \$\endgroup\$ – radioprotector Sep 2 '13 at 20:55
  • 1
    \$\begingroup\$ Correct. The new layer sits above the current noise and its output feeds into the input of your existing noise algorithm, supplying the amplitude. \$\endgroup\$ – MichaelHouse Sep 2 '13 at 21:00
  • \$\begingroup\$ Agreed! A single Noise field is almost never used alone because it's nothing more than a mildly grumpy sampling over space. You get the most interesting results by using one noise source to modify another, just like @Byte56 is talking about. \$\endgroup\$ – Patrick Hughes Sep 2 '13 at 22:22
  • 1
    \$\begingroup\$ Nearly there. Scale the amplitude noise along the X axis to make the transitions more gradual. I should have been a little more specific in my original description that I was talking about the X axis. You do this by scaling the inputs to this noise function down. \$\endgroup\$ – MichaelHouse Sep 2 '13 at 23:57
  • 1
    \$\begingroup\$ Ramping up the power should increase the amplitude, making the trenches lower. At this point I think you have the functions you need, and it's just a tweaking the numbers game. I've found in situations like this, it's interesting to put sliders in your game and change these values on-the-fly. See part of this answer about mixing noise for some other options. \$\endgroup\$ – MichaelHouse Sep 3 '13 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.