Tuesday, January 6, 2015

Fast Moisture Simulation


In the previous post I described my attempt to model average precipitation (moisture) in my fractal world generator.  While the end result was acceptable, the amount of processing time needed to complete hundreds of cycles of simulated air circulation was too much.  I needed a faster approach.


Rather than slavishly attempt to model every pixel of air movement, I decided to try a randomized approximation that would hopefully yield similar results.  My new moisture simulation performs 10 cycles of the following steps:

  1. Adds a small amount of moisture to each point on the map.
  2. Determine a random offset to the left/right and up/down.  Rather than 1 pixel shifts like in my previous model, the maximum offset is 20% of the map size, and the minimum 5%.
  3. Take an image of the elevation map, shift it by the offset amount, and use the elevation values to modify the moisture map.  Low elevations will add to the moisture map, and higher elevations will subtract from it.

Approximated Moisture Map

Here are the results applied to the same fractal world as the previous example.  On the plus side, this method resulted in more amorphous moisture blobs, which I think will work better once this data is used to map to terrain hexes.  We still have low moisture areas (blue) which will translate to deserts, but they aren't as precisely defined as the previous method.  Bottom line, I think this approach will yield a result just as usable as the more intensive method, at about one hundredth of the processing time required, so it's a win!

No comments:

Post a Comment