{"id":2031,"date":"2015-02-04T21:11:00","date_gmt":"2015-02-04T21:11:00","guid":{"rendered":"http:\/\/www.spellcasterstudios.com\/?p=2031"},"modified":"2015-01-30T15:20:35","modified_gmt":"2015-01-30T15:20:35","slug":"started-with-decals","status":"publish","type":"post","link":"https:\/\/www.spellcasterstudios.com\/?p=2031","title":{"rendered":"Started with decals"},"content":{"rendered":"<p align=\"justify\">One of the effects I would like to use extensively in the game is \u201cdecals\u201d\u2026<\/p>\n<p align=\"justify\">A decal is just a kind of painting you put on top of the geometry.<\/p>\n<p align=\"justify\">Decals used to be done by intersecting the world geometry with the decal shape and drawing those polygons, but since I now have the normal\/depth of each point on screen available, I can probably get away with using screen-space decals\u2026 I got the idea first from this presentation: <a href=\"http:\/\/www.slideshare.net\/blindrenderer\/screen-space-decals-in-warhammer-40000-space-marine-14699854?qid=a6625ece-4349-443c-ab19-837f87c11eb0&amp;v=qf1&amp;b=&amp;from_search=1\">Screen Space Decals in Warhammer 40K: Space Marine<\/a>.<\/p>\n<p align=\"justify\">As the rest of my rendering engine, I\u2019m betting a lot of batching, which introduces some complications: since I can\u2019t pass the decal property as a constant to the shader, I need to find another way to pass it in. For now, I\u2019m using the texture coordinates of the box itself, which is a bit wasteful. I could use an array and just pass an index, but that would be more complex and would have other limitations, like the number of decals on a single batch.<\/p>\n<p align=\"justify\">So, to be able to add this kind of \u201ccustom data\u201d to each vertex, I had to code in a new vertex declaration system, but that was quite fast (I had to do most of the groundwork before for the OpenGL port anyway).<\/p>\n<p align=\"justify\">So, the current state of this is:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/01\/screen422.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen422\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"screen422\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/01\/screen422_thumb.jpg\" width=\"830\" height=\"483\" \/><\/a><\/p>\n<p>\u201cWhat am I looking at?!\u201d, I hear you say\u2026<\/p>\n<p>Basically, you\u2019re looking at the rendered decal volume, in which every point is colored with the normal extracted from the Normal+Depth buffer\u2026<\/p>\n<p>Tomorrow I\u2019ll work on actually generating UVs from that and discard the points that don\u2019t belong inside the decal box\u2026 Just look at the tree below:<\/p>\n<p><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/01\/screen423.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen423\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px\" border=\"0\" alt=\"screen423\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/01\/screen423_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p>Most of the code on the decal shader is to prevent that from happening\u2026 <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-smile\" style=\"border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none\" alt=\"Smile\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/01\/wlEmoticon-smile8.png\" \/><\/p>\n<p><em>Now listening to \u201cThe Burning Halo\u201d by \u201cDraconian\u201d<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the effects I would like to use extensively in the game is \u201cdecals\u201d\u2026 A decal is just a kind of painting you put on top of the geometry. Decals used to be done by intersecting the world geometry with the decal shape and drawing those polygons, but since I now have the normal\/depth [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,147,8],"tags":[256,242],"class_list":["post-2031","post","type-post","status-publish","format-standard","hentry","category-development","category-chrome-hunter","category-technology","tag-decals","tag-polish"],"_links":{"self":[{"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts\/2031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2031"}],"version-history":[{"count":1,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts\/2031\/revisions"}],"predecessor-version":[{"id":2032,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts\/2031\/revisions\/2032"}],"wp:attachment":[{"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}