{"id":9813,"date":"2010-11-10T11:56:00","date_gmt":"2010-11-10T16:56:00","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=9813"},"modified":"2010-11-10T11:56:26","modified_gmt":"2010-11-10T16:56:26","slug":"project-hex-part-4-8-bits-is-enough","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=9813","title":{"rendered":"Project Hex Part 4 &#8211; 8 Bits is Enough"},"content":{"rendered":"<p>One of the things that ignited this project for me was when <a href=\"http:\/\/rampantgames.com\/blog\/\">Jay Barnson<\/a> linked to <a href=\"http:\/\/gas13.ru\/v3\/tutorials\/sywtbapa_almighty_grass_tile.php\">this mind-blowing series on pixel art creation<\/a>*. I read through it, then through the rest of the site.  I dabbled a bit in this sort of thing years ago, but never really produced anything I&#8217;d show to other people. These tutorials gave me the itch to try again, and this project seems like a good place to scratch that itch.  <\/p>\n<p><small>* Well, it blew <i>my<\/i> mind.  Your own brains and the blowing thereof is your problem. <\/small><\/p>\n<p>In general, the goal is to make a 3d landscape that uses that old-school style.  This doesn&#8217;t mean I&#8217;m actually going for retro technology. I plan to use high resolution, high-polygon, fancy blending tricks, and whatever else I have at my disposal. I&#8217;m thinking I want to create a contrast between the 8-bit feel of the world and the modern-ish interface.  For example, the landscape will be pixelated and blocky, while the hex outlines will be crisp and blend with the pixels underneath.  I don&#8217;t actually know how well it will work, but it&#8217;s an idea I want to try.<\/p>\n<p>Here is where we left off last week:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_hills4.jpg' class='insetimage'   alt='hex_hills4.jpg' title='hex_hills4.jpg'\/><\/td><\/tr><\/table><\/p>\n<p><!--more-->Step one is to make a &#8220;low-res&#8221; texture for the landscape. What I&#8217;m going to do is have the program draw a single texture to be stretched over the entire landscape. During loading, I&#8217;m going to render one really fancy image made especially for the topography of the world.  Grass, sand, dirt.  Everything on a single texture. (This may change later as I get a feel for how big the world needs to be, how much detail I need, and how fast the camera needs to move.  But for now, we&#8217;re doing one texture. Baby steps.)<\/p>\n<p>I cut out a small part of the map to work with.  Something with a little bit of everything: Water, dirt, sand, grass, etc. <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture2.jpg' class='insetimage'   alt='hex_texture2.jpg' title='hex_texture2.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>I&#8217;m using a very small region because I&#8217;m going to be making many experimental changes and I don&#8217;t want to have to wait for a long load every time I run the program. <\/p>\n<p>This next part is going to be tough to explain. Stay with me here. Remember, we&#8217;re drawing a <em>texture<\/em>.<\/p>\n<p>First we wipe our canvas clean, to medium gray. Then I load in a little texture, which will be used for water.  This texture:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture1.jpg' class='insetimage'   alt='hex_texture1.jpg' title='hex_texture1.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Small, I know. That&#8217;s actually the point.  The bright pink stuff is transparent, so we&#8217;ll never see that.  What we&#8217;re interested in is the grayscale blob in the middle.  Shapeless, mostly, but with a few wavy lines that I hope will look like waves. I made it after studying the tutorial above, on <a href=\"http:\/\/gas13.ru\/v3\/tutorials\/sywtbapa_de-mystifying_greats_1.php\">the part where it examines some of the tile work in Secret of Mana 3<\/a>.  The word &#8220;study&#8221; here is not hyperbole. I spent a few hours zoomed in on a little 32&#215;32 patch of pixels, trying to figure out how you give a surface depth and detail with only a few pixels and four colors. It was fun but humbling work. The pioneers that worked in this medium during its heyday were very clever folks.<\/p>\n<p>I&#8217;m going to pass over the points on the grid and throw down one of these little patches on every point that is marked as &#8220;deep water&#8221;.  For illustrative purposes, I&#8217;m going to make the blob really tiny.  <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture3.jpg' class='insetimage'   alt='hex_texture3.jpg' title='hex_texture3.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>I hope this is clear.  Each grid point gets a little patch, which I&#8217;ve tinted blue because we&#8217;re supposedly drawing water. <\/p>\n<p>Now, instead of drawing the patches tiny, I&#8217;m going to draw them so large that they overlap a bit.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture4.jpg' class='insetimage'   alt='hex_texture4.jpg' title='hex_texture4.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>After the patches for deep water are drawn, I&#8217;ll draw patches for the shallow water near the shore.  I use the same patch texture as before, but tinted slightly lighter.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture5.jpg' class='insetimage'   alt='hex_texture5.jpg' title='hex_texture5.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>I don&#8217;t like how visible the tiling is.  The pattern in the flat open ocean is very repetitive.  A little tiling is okay with this style, but if we get too much the game won&#8217;t look so much &#8220;retro&#8221; as it will &#8220;cheap&#8221;.  I might have to come back to this later.<\/p>\n<p>Now another pass, this time for sand.  And this time I&#8217;m using a slightly different texture, although the difference is probably impossible to spot in these screenshots.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture6.jpg' class='insetimage'   alt='hex_texture6.jpg' title='hex_texture6.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Now I&#8217;ll add more passes for the other surface types. One for bushy &#8220;edge&#8221; grass that borders sand, another for the more general green rolling hills, and another for the dirt slopes.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture7.jpg' class='insetimage'   alt='hex_texture7.jpg' title='hex_texture7.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Now let&#8217;s step in for a closer look.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture10.jpg' class='insetimage'   alt='hex_texture10.jpg' title='hex_texture10.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>This is actually about the right distance for this game.  This is about where the player&#8217;s camera will be.  Maybe a bit higher or at a slightly different angle, but this is pretty close.  Of course, people will likely be viewing this game full screen and not looking at it in a little 640&#215;480 window on my blog.  So let me zoom in on this image a bit so you can see what I&#8217;m seeing.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture8.jpg' class='insetimage'   alt='hex_texture8.jpg' title='hex_texture8.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Looks blurry, doesn&#8217;t it?  There is a good reason for this. The reason is that our fancy modern graphics hardware is trying like crazy to &#8220;correct&#8221; how blocky my texture is. See, for years they have been coming up with better and better filtering systems in games so that when you slam face-first into a wall you don&#8217;t see a single pixel stretched out over your entire screen. <\/p>\n<p>First they came up with bilinear filtering, which sort of blurs the edges between pixels.  But there were situations where you might look at a wall at an extreme angle and have it look <em>too<\/em> blurry. So they came up with trilinear filtering, . Then, because there were still cases where our view of a texture might not possess the correct level of blurryness, they devised anisotropic filtering.  Then came full screen anti-aliasing. Gamers have become the <a href=\"http:\/\/en.wikipedia.org\/wiki\/The_Princess_and_the_Pea\">Princess and the Pea<\/a>, so sensitive that they might lacerate their gentle eyeballs if they were ever exposed to something as dangerous as a sharp pixel edge. Everything Must Be Smooth. <\/p>\n<p>This is the way graphics work now, and if you don&#8217;t want your game to look like it&#8217;s being viewed through a Vaseline-smeared coke bottle, then you should be using gargantuan 4096&#215;4096 textures on all of your walls like a civilized person. Loading times? To hell with you and your impatience! People of quality understand that a truly fine experience is worth waiting for.  And waiting. And waiting. <\/p>\n<p>Or, maybe we can just turn off all this filtering? Let&#8217;s do that. <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture9.jpg' class='insetimage'   alt='hex_texture9.jpg' title='hex_texture9.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>That&#8217;s more like it.<\/p>\n<p>Now, I don&#8217;t like the hard, square outline of the beach.  I&#8217;d also like to do something about the tiling I mentioned earlier. <\/p>\n<p>Let me make a few changes:<br \/>\n1) I&#8217;m now rotating the patches as I place them, so they aren&#8217;t all facing the same way.<br \/>\n2) I rounded off the sand patch, which was a bit too square.<br \/>\n3) I made the patches a bit smaller, which seems to look better.<\/p>\n<p>Let&#8217;s see how it looks&#8230;<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/hex_texture11.jpg' class='insetimage'   alt='hex_texture11.jpg' title='hex_texture11.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>That&#8217;s a big improvement.  There&#8217;s a lot of work left on this, but I think we&#8217;ve reached the proof-of-concept stage.  I can look at this scene and say, &#8220;Yeah, I could play a game in this style.&#8221;  It&#8217;s interesting to look at, yet not likely to be mistaken for anything else.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the things that ignited this project for me was when Jay Barnson linked to this mind-blowing series on pixel art creation*. I read through it, then through the rest of the site. I dabbled a bit in this sort of thing years ago, but never really produced anything I&#8217;d show to other people. [&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-9813","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\/9813","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=9813"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/9813\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}