title: On-the-fly Terrain Generation Based on An Existing Terrain
body: <p>This question is very similar to that posed <a href="https://stackoverflow.com/questions/3273880/perlin-noise-detail-level-how-to-zoom-in-on-a-landscape">here</a>.</p>
  
  <p>My problem is that I have a map, something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/9ACDe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ACDe.jpg" alt="Main Map"></a></p>
  
  <p>This map is made using 2D Perlin noise, and then running through the created heightmap assigning types and color values to each element in the terrain based on the height or the slope of the corresponding element, so pretty standard. The map array is two dimensional and the exact dimensions of the screen size (pixel-per-pixel), so at 1200 by 800 generation takes about 2 seconds on my rig.</p>
  
  <p>Now zooming in on the highlighted rectangle:</p>
  
  <p><img src="https://i.stack.imgur.com/T0o4T.png" alt="http://i.stack.imgur.com/hrZnM.png"></p>
  
  <p>Obviously with increased size comes lost detail. And herein lies the problem. I want to create additional detail on the fly, and then write it to disk as the player moves around (the player would simply be a dot restricted to movement along the grid). I see two approaches for doing this, and the first one that came to mind I quickly implemented:</p>
  
  <p><img src="https://i.stack.imgur.com/Kg2Bg.png" alt="http://i.stack.imgur.com/bbLia.png"></p>
  
  <p>This is a zoomed-in view of a new biased local terrain created from a sampled element of the old terrain, which is highlighted by the yellow grid space (to the left of center) in the previous image. However this system would require a great deal of modification, as, for example, if you move one unit left and up of the yellow grid space, onto the beach tile, the terrain changes completely:</p>
  
  <p><img src="https://i.stack.imgur.com/VupAz.png" alt="http://i.stack.imgur.com/6shKz.png"></p>
  
  <p>So for that to work properly you'd need to do an excessive amount of, I guess the word would be interpolation, to create a smooth transition as the player moved the 40 or so grid-spaces in the local world required to reach the next tile over in the over world. That seems complicated and very inelegant.</p>
  
  <p>The second approach would be to break up the grid of the original map into smaller bits, maybe dividing each square by 4? I haven't implemented this and I'm not sure how I would in a way that would actually increase detail, but I think that would probably end up being the best solution.</p>
  
  <p>Any ideas on how I could approach this? Keep in mind it has to be local and on-the-fly. Just increasing the resolution of the map is something I want to avoid at all costs.</p>