{"id":817,"date":"2015-07-12T13:43:07","date_gmt":"2015-07-12T17:43:07","guid":{"rendered":"http:\/\/www.bootdiskrevolution.com\/?p=817"},"modified":"2015-08-23T14:24:13","modified_gmt":"2015-08-23T18:24:13","slug":"render-targets","status":"publish","type":"post","link":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/render-targets\/","title":{"rendered":"Render Targets"},"content":{"rendered":"<p>Personal life took some time from work, but I&#8217;m almost done level four &#8212; just the bosses left to touch up \/ balance. In the meantime, let&#8217;s explore render targets a bit, since I used those this week!<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-821 aligncenter\" src=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/fiery-badAVI.gif?resize=480%2C270\" alt=\"\" width=\"480\" height=\"270\" \/><\/p>\n<p>The fourth level takes place on the hull of the warship, and at some point it starts heating up as it breaks the Earth&#8217;s atmosphere (interesting scenarios trump scientific accuracy, obviously.) You&#8217;ll notice the issue I was running into &#8212; you can see this weird grid effect when the ship glows.<\/p>\n<p>So what up with that? Well, the ship is drawn using tiles, and in this case I&#8217;m using two tilesets &#8212; one where the warship looks normal, and one where it&#8217;s all fiery. The hotter the warship gets, the more opaque the fiery tileset becomes. The problem is that tiles overlap slightly &#8212; you never notice when they&#8217;re opaque, but when they&#8217;re transparent the overlapping edges blend together and cause that nasty grid effect.<\/p>\n<figure id=\"attachment_820\" aria-describedby=\"caption-attachment-820\" style=\"width: 480px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"wp-image-820 size-full\" src=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/blendingExample.png?resize=480%2C240\" alt=\"\" width=\"480\" height=\"240\" srcset=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/blendingExample.png?w=480&amp;ssl=1 480w, https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/blendingExample.png?resize=300%2C150&amp;ssl=1 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><figcaption id=\"caption-attachment-820\" class=\"wp-caption-text\">Artist&#8217;s rendition of the glitch and accompanying emotional response.<\/figcaption><\/figure>\n<p>How ya gonna fix it? I used a render target!<\/p>\n<p><!--more--><\/p>\n<p>To simply explain: usually you draw your game&#8217;s graphics right on to the screen &#8212; the screen is your game&#8217;s &#8220;render target&#8221;. But it doesn&#8217;t have to be this way! It&#8217;s totally possible to create other render targets that aren&#8217;t visible on-screen, and draw graphics there. Why would you do this&#8230;?<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-818 aligncenter\" src=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/reflectionAVI.gif?resize=480%2C270\" alt=\"\" width=\"480\" height=\"270\" \/><\/p>\n<p>Here&#8217;s an example! I take a screenshot of gameplay and save it in a render target, then flip \/ squish \/ colour it to be a reflection. It&#8217;s simple but it looks good enough to me.<\/p>\n<p>Even more relevantly, it solved my tile issues! Instead of drawing a translucent tileset on top of an opaque one in real-time, I blend them together in a render target first. This gives me a perfectly-combined &#8212; and opaque! &#8212; tileset which I use to draw the tiles of the ship.<\/p>\n<figure id=\"attachment_819\" aria-describedby=\"caption-attachment-819\" style=\"width: 480px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"wp-image-819 size-full\" src=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/tilesetsExample.png?resize=480%2C240\" alt=\"\" width=\"480\" height=\"240\" srcset=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/tilesetsExample.png?w=480&amp;ssl=1 480w, https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/tilesetsExample.png?resize=300%2C150&amp;ssl=1 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><figcaption id=\"caption-attachment-819\" class=\"wp-caption-text\">Artist&#8217;s rendition of before and after (with checkered background to make translucency easier to notice.)<\/figcaption><\/figure>\n<p>As a bonus, it&#8217;s easier for the graphics card since instead of two draws per tile (once for the normal warship and once again for the fiery version) it only needs one.<\/p>\n<figure id=\"attachment_822\" aria-describedby=\"caption-attachment-822\" style=\"width: 480px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"wp-image-822 size-full\" src=\"https:\/\/i0.wp.com\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-content\/uploads\/2015\/07\/fiery-okAVI.gif?resize=480%2C270\" alt=\"\" width=\"480\" height=\"270\" \/><figcaption id=\"caption-attachment-822\" class=\"wp-caption-text\">No more drawing errors!<\/figcaption><\/figure>\n<p>And there you have it! There&#8217;s a lot (lot) more you can do with render targets, including some cute and cool effects I have planned for later in the game (but won&#8217;t show now.)<\/p>\n<p>Hopefully the next blog is my wrapping up the fourth level with a ribbon and a bow. &#8216;Till then!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Personal life took some time from work, but I&#8217;m almost done level four &#8212; just the bosses left to touch up \/ balance. In the meantime, let&#8217;s explore render targets a bit, since I used those this week! The fourth level takes place on the hull of the warship, and at some point it starts <a class=\"read-more\" href=\"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/render-targets\/\">[&hellip;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-817","post","type-post","status-publish","format-standard","hentry","category-bleed-2"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/posts\/817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/comments?post=817"}],"version-history":[{"count":3,"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/posts\/817\/revisions"}],"predecessor-version":[{"id":825,"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/posts\/817\/revisions\/825"}],"wp:attachment":[{"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/media?parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/categories?post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bootdiskrevolution.com\/NEW_BLOG\/wp-json\/wp\/v2\/tags?post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}