{"id":3059,"date":"2009-04-20T08:26:32","date_gmt":"2009-04-20T12:26:32","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3059"},"modified":"2010-10-24T08:05:57","modified_gmt":"2010-10-24T13:05:57","slug":"procedural-city-part-5-fixes","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3059","title":{"rendered":"Procedural City, Part 5: Fixes"},"content":{"rendered":"<p><a href=\"?p=3047\">The time spent contemplating the program<\/a> did not go to waste.  I was able to correct several things that had been bothering me.  <\/p>\n<p><span class=\"date\">Building Textures<\/span><\/p>\n<p><a href=\"?p=2954\">I mentioned before<\/a> that I had two approaches to making the building textures:  One would light windows completely scattershot.  Each window had a fixed chance to be lit or unlit.  The other approach was to light them in horizontal groups, so that the lit windows would always be grouped together.  <\/p>\n<p>Stepping back and looking at what I&#8217;m trying to simulate, I can see the scattershot doesn&#8217;t make much sense, and doesn&#8217;t seem to match what we see in cityscapes.  Worse, all buildings had the same percentage of lit windows, which made the view even more monotonous. <\/p>\n<p>All buildings should exhibit <em>some<\/em> level of lit-window grouping. The only difference from one building to the next is in how big each office \/ apartment is.  Also, not all buildings have the same ratio of lit windows to dim ones.  <\/p>\n<p>So I replaced the old window-generating code with a new one.  It randomly decides at the outset how big the interior spaces are, and what percent of the windows should be lit.  <\/p>\n<p>Now different buildings have different window shapes <em>and<\/em> different densities of lit windows <em>and<\/em> different group sizes.  The city lights now look less like uniform noise and more like chaos that springs from complex ordered systems. <\/p>\n<p><span class=\"date\">Tower Buildings<\/span><\/p>\n<p><a href=\"?p=2968\">As I mentioned in the post on building shapes<\/a>, my classic tower-style buildings weren&#8217;t going to cut it.  I was supposedly making these buildings with elaborate stonework.  My goal was to present the outline of such a building and allow the viewer&#8217;s imagination and prior experience to fill in the blanks with engravings and such.  But I didn&#8217;t leave any blanks for them to fill in! Every building was all windows, edge-to-edge, top-to-bottom.  I tore out the old code and replaced it with a new building generator:<\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pixelcity_building5.jpg' class='insetimage' width='600' alt='pixelcity_building5.jpg' title='pixelcity_building5.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>These new buildings are very rarely covered in windows.  They have vertical stripes or windowless areas running down the face of the building.  The buildings are broken into tiers, and there are a few blank floors between each tier.  It begins at the bottom, drops a tier into place, then puts a lid on that tier, then builds a new tier on top of the lid, onward until it reaches the planned building height.<\/p>\n<p>I love the new one because it has a ton of parameters that govern the shape of the building:<\/p>\n<ol>\n<li>How tall each tier is. (More accurately, how much of the remaining height is given to the current tier.  One-half, one-third, one-forth, etc.)\n<\/li>\n<li>How much (if any) the lid sticks out from the side, forming a ledge.\n<\/li>\n<li>How tall the lid is, in stories.\n<\/li>\n<li>If the corners of the building are explicitly windowless.\n<\/li>\n<li>The grouping of the windows and blank areas on the face of the building.\n<\/li>\n<li>If the tower gets narrower towards the top.\n<\/li>\n<li>The window texture used.\n<\/li>\n<li>The tint of the window texture, from a handful of various types of light sources.\n<\/li>\n<\/ol>\n<p>These values allow for a huge number of meaningful changes to the shape of the structure, giving the world a ton of visual variety. Also, the vertical blank areas seem very subtle, but it&#8217;s shocking how the eye can instantly spot the break in the pattern:<\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pixelcity_building6.jpg' class='insetimage' width='600' alt='pixelcity_building6.jpg' title='pixelcity_building6.jpg'\/><\/td><\/tr><\/table><\/p>\n<p><span class=\"date\">Modern Buildings<\/span><\/p>\n<p>These buildings looked fine to begin with, but they didn&#8217;t have a lot of variety.  A slight change brought about compelling results.  <\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pixelcity_building7.jpg' class='insetimage' width='600' alt='pixelcity_building7.jpg' title='pixelcity_building7.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Instead of just randomly cutting off sections of a cylinder, it chooses to do so at regular intervals.  And it can make cuts in 45 degree sections as well as 90.  And as with the other buildings, I added some vertical window gaps. Although, it doesn&#8217;t really make the buildings that much more interesting.  <\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/pixelcity_building8.jpg' class='insetimage' width='600' alt='pixelcity_building8.jpg' title='pixelcity_building8.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>They look interesting in wireframe, but without the lines one deformed cylinder looks much like another.<\/p>\n<p><span class=\"date\">Other Changes<\/span><\/p>\n<p>As you&#8217;ve probably noticed in the screenshots, I&#8217;ve added a few polygons of roof clutter to hint at HVAC systems and whatnot.  The building colors are now limited to a handful of hues that match common lights.  And I put larger gaps between buildings, which gives their silhouettes more opportunities to stand out.<\/p>\n<p>A few improvements to the existing systems made a big difference to the overall appearance. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The time spent contemplating the program did not go to waste. I was able to correct several things that had been bothering me. Building Textures I mentioned before that I had two approaches to making the building textures: One would light windows completely scattershot. Each window had a fixed chance to be lit or unlit. [&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,10],"tags":[],"class_list":["post-3059","post","type-post","status-publish","format-standard","hentry","category-programming","category-projects"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/3059","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=3059"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/3059\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}