{"id":11923,"date":"2011-06-13T05:03:12","date_gmt":"2011-06-13T10:03:12","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=11923"},"modified":"2011-06-13T05:08:19","modified_gmt":"2011-06-13T10:08:19","slug":"project-frontier-4-dr-seuss-geologist","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=11923","title":{"rendered":"Project Frontier #4: Dr. Seuss, Geologist"},"content":{"rendered":"<p>As I said at the start of the project, I&#8217;m not aiming for realism. I&#8217;m looking for whimsical, retro, and fantastic.  My goal is to have something interesting, as opposed to something realistic.  <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier3_5.jpg' class='insetimage'   alt='frontier3_5.jpg' title='frontier3_5.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>I mentioned before the detail layer of the terrain.  It adds the continuous rolling hills across the world.  These hills are irregular, but for the sake of illustration let&#8217;s imagine they are perfect sine waves:<\/p>\n<p><!--more--><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_1.jpg' class='insetimage'   alt='frontier5_1.jpg' title='frontier5_1.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>These hills produce a landscape that is attractive, but lacking in variety:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_1a.jpg' class='insetimage'   alt='frontier5_1a.jpg' title='frontier5_1a.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>That&#8217;s kind of nice to look at, but seeing that stretch all the way to the horizon would be boring. We need to mix it up.  However, we can&#8217;t do anything too fancy.  Anything we do here is going to be happening while the game is running.  We don&#8217;t have time to muck around with erosion or operations that need to analyze large sections of terrain.  We need something cheap and fast which gives attractive results. <\/p>\n<p>Let&#8217;s try messing with the detail map.  If we take values above a certain height, and invert them, we can easily turn hills into craters:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_2.jpg' class='insetimage'   alt='frontier5_2.jpg' title='frontier5_2.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Which ends up looking like this:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_2a.jpg' class='insetimage'   alt='frontier5_2a.jpg' title='frontier5_2a.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>So, occasionally we can flag a region to produce craters. We have to keep them rare, obviously.  This is exceptionally &#8220;cheap&#8221; from a processing standpoint.  It&#8217;s just a filter.  As points are created, it checks if the point falls inside of a region with craters. If so, it does a couple of very simple math operations.  No need to check neighboring points or perform some sort of recursive operation.  Set a flag, do a subtract. Boom. Done. <\/p>\n<p>There are a lot of these sorts of operations we can do. We can take values above a certain point and pull them up even more.  This&#8230;<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_3.jpg' class='insetimage'   alt='frontier5_3.jpg' title='frontier5_3.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Ends up giving us landscape shaped like this:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_3a.jpg' class='insetimage'   alt='frontier5_3a.jpg' title='frontier5_3a.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>If we take values from a narrow range and pull them down&#8230;<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_4.jpg' class='insetimage'   alt='frontier5_4.jpg' title='frontier5_4.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>We can produce cracks in the earth:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_4a.jpg' class='insetimage'   alt='frontier5_4a.jpg' title='frontier5_4a.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>You get the idea.  A couple of simple flags and some basic math and we can make a huge variety of different shapes.  <\/p>\n<p>Also, if you squint at the screenshots you might notice it&#8217;s displaying information like &#8220;moisture&#8221; and &#8220;temperature&#8221;.  Those don&#8217;t DO anything yet, of course.  Those are placeholders for the climate system I have in mind.  Let&#8217;s work on that now.<\/p>\n<p>Currently the program generates only dry land.  If you keep going, you eventually end up at the edge.  (The world is only a couple of kilometers right now, although I can make it much bigger by just changing a single variable.)  <\/p>\n<p>I like the idea of making the world a single continent, so that the &#8220;edges&#8221; of the world are all ocean.  That&#8217;s so much more pleasing than the Oblivion \/ Fallout 3 \/ New Vegas approach of &#8220;invisible wall&#8221;. (Fie!)<\/p>\n<p>So, I make our island by measuring the distance from the center of the world.  Elevations fall off on a curve. I have it generate a little map of the place.  Check it out:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map1.jpg' class='insetimage'   alt='frontier5_map1.jpg' title='frontier5_map1.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Note that each pixel represents a single region, which is a large-ish area.  (I change this often as I experiment.)  Right now regions are 48 meters on a side. The green ones show what grass color is used in the given region.  The beige ones are obviously coastal areas, where points close to sea level will have sand applied.  Blue is ocean, darker = deeper.  <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_5.jpg' class='insetimage'   alt='frontier5_5.jpg' title='frontier5_5.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>This stretch of coastline represents two regions &#8211; two pixels in the map above. The water itself is a super-simple single polygon that stretches from one end of the world to the other.  I just put it there so I could see what I was doing.  I don&#8217;t know what the ocean will look like in the final product, although I&#8217;m reasonably sure it won&#8217;t look like a swimming pool.  <\/p>\n<p>Aside: In an earlier entry Tizzy <a href=\"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=11883&#038;cpage=1#comment-216226\">said<\/a> that not all coastline should be sandy beaches.  Using the detail-modifying tricks I talked about earlier, this is no problem:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_6.jpg' class='insetimage'   alt='frontier5_6.jpg' title='frontier5_6.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Anyway, I imagine you have noticed that in some cases, natural continents and islands come in shapes <em>other<\/em> than geometrically perfect circles. Well, remember that cool elevation data I created back in step one? We can use that on any scale we like.  I can just add it to our circle island and get something like&#8230;<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map2.jpg' class='insetimage'   alt='frontier5_map2.jpg' title='frontier5_map2.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>If I want a different island, I just need to draw from a different spot on the detail map.  <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map3.jpg' class='insetimage'   alt='frontier5_map3.jpg' title='frontier5_map3.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>See?<\/p>\n<p>Now we want to add some climate.  For climate, we have two goals:<\/p>\n<ol>\n<li>Variety.  We want a bit of everything.  The world should be visually diverse.\n<\/li>\n<li>Visual plausibility. We do NOT want to simulate an entire planet of tectonic plate shifts, jet steams, and ocean currents. At the same time, we don&#8217;t want to see a foggy swamp directly adjacent to a Sahara-style desert, or tundra next to a tropical beach.\n<\/li>\n<\/ol>\n<p>So what we need is a very simplistic simulation, just something to give us numbers in the right ballpark.<\/p>\n<p>We can assume the wind comes from the west, carrying moisture from the sea.  The further you move in, the drier it will be.  I average out these results (blur them) so that coastal regions can be wetter and so you don&#8217;t get overly abrupt changes in climate.  Here is a map showing the moisture.  (Green = wet.  Red = dry.) <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map5.jpg' class='insetimage'   alt='frontier5_map5.jpg' title='frontier5_map5.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>I add a few spots on the map to block rainfall.  (Eventually these will be mountains.) <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map4.jpg' class='insetimage'   alt='frontier5_map4.jpg' title='frontier5_map4.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Now we calculate temperature. Arctic at the top of the map.  Tropical at the bottom. (We&#8217;re going for variety, not realism, remember.)  The ocean has a moderating effect on temperature. <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map6.jpg' class='insetimage'   alt='frontier5_map6.jpg' title='frontier5_map6.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>In a later version I might randomize the direction of rainfall \/ temp, but this should work for now. <\/p>\n<p>The next step is to take this climate information and put it to use.  I start with making the grass color trend towards the yellows as it gets drier.  It&#8217;s not an absolute shift.  You&#8217;ll still find green in the desert, but I want reds and yellows to prevail. (At least, when it comes to grass.)  Wet areas should be deep green.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map7.jpg' class='insetimage'   alt='frontier5_map7.jpg' title='frontier5_map7.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Next up, I have things trend towards pale green \/ blue-green in colder climates.  I doubt this is strictly correct, but it seems to look right.  <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_map8.jpg' class='insetimage'   alt='frontier5_map8.jpg' title='frontier5_map8.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Now that we have our data, we can put it to use.  <\/p>\n<p>Right now, the program has some hard-coded thresholds for slopes.  Once they get too steep, it will color the ground as dirt instead of grass.  A little steeper, and it changes from dirt to rock.  If I lower this threshold as it gets drier, then arid climates will look like barren scrublands:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_7.jpg' class='insetimage'   alt='frontier5_7.jpg' title='frontier5_7.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>In hot, humid areas we can have deep greens:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_9.jpg' class='insetimage'   alt='frontier5_9.jpg' title='frontier5_9.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>I tried adding snow.  The colder it is, the more grass gets replaced with snow.  <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_10.jpg' class='insetimage'   alt='frontier5_10.jpg' title='frontier5_10.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>That still needs work.  Part of the problem is the golden yellow sunlight shining on the snow, making it feel &#8220;warm&#8221; here. I&#8217;ll need to shift the palette to blue as it gets colder. <\/p>\n<p>Unrelated, but while zipping around looking for screenshots I found this bay, which I thought was pretty cool:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/frontier5_8.jpg' class='insetimage'   alt='frontier5_8.jpg' title='frontier5_8.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>There&#8217;s a lot of work to do, but I&#8217;m happy with how it&#8217;s going so far.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I said at the start of the project, I&#8217;m not aiming for realism. I&#8217;m looking for whimsical, retro, and fantastic. My goal is to have something interesting, as opposed to something realistic. I mentioned before the detail layer of the terrain. It adds the continuous rolling hills across the world. These hills are irregular, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-11923","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/11923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11923"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/11923\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}