Results 1 to 10 of 26

Thread: Heightmap Generator for a City Generator

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #18
    Administrator waldronate's Avatar
    Join Date
    Mar 2007
    Location
    The High Desert
    Posts
    3,576

    Default

    CONREC - A Contouring Subroutine is a classic, but any code that will generate contours on a raster will work. The idea is that you run a line along pixels of equal intensity. The cheap way to handle edges so that they are connected to other contours is to accept a surface that's one pixel smaller all around and set the outermost pixel on each edge to a value that's less than all of the rest. Assume that your heightfield surface is ranging from 0 to 255: a contour at 1 will be outside of contours at 5, which will be outside contours at 10, which will be outside of contours at 50, and so on.

    It occurs to me that you might be concerned about purely interior basins (i.e. lakes with no outlet). My lazy technique is to do all of the regular land contours from low to high and then do contours on water from high. Land contours from low to high get progressively smaller, as do water contours from high to low. For your convenience it may be simpler to make a "water surface" where the shoreline of each lake is at 0 altitude and the depth of the lake goes down from there. That way all water is referenced to the same 0 point. With the water surface and the land surface, it's also just two contouring passes (one for land and one for water) to get all of the contours.

    If you don't care about filled contours, it doesn't really matter what order you do things in.
    Last edited by waldronate; 08-02-2014 at 02:40 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •