{"id":2057,"date":"2015-02-06T21:23:00","date_gmt":"2015-02-06T21:23:00","guid":{"rendered":"http:\/\/www.spellcasterstudios.com\/?p=2057"},"modified":"2015-02-01T16:42:20","modified_gmt":"2015-02-01T16:42:20","slug":"more-issues-with-decals","status":"publish","type":"post","link":"https:\/\/www.spellcasterstudios.com\/?p=2057","title":{"rendered":"More issues with decals&hellip;"},"content":{"rendered":"<p align=\"justify\">Unfortunately, my initial idea that screen-space decals was some sort of magic bullet was completely wrong\u2026<\/p>\n<p align=\"justify\">They work great a lot of the time, easy to implement, fast\u2026 but (there\u2019s always a but) they have some small details which break it down\u2026<\/p>\n<p align=\"justify\">The issue I talked about yesterday was mostly solved with the stencil buffer:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen428.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen428\" 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=\"screen428\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen428_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p align=\"justify\">So that\u2019s good, I can mask where the decals is drawn and where it isn\u2019t\u2026 But unfortunately, it doesn\u2019t solve the issue with the explosions, since there we want to draw the decal, but \u201cbehind\u201d the explosion, but due to the way alpha blending works, it doesn\u2019t work:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen429.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen429\" 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=\"screen429\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen429_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p align=\"justify\">If you\u2019d see the stencil buffer, you\u2019d notice that on the edge of the explosion (where there isn\u2019t almost any color, but it\u2019s necessary for its smoothness) is flagged as not allowing the decal, but we\u2019d like a decal there, and then the explosion\u2026 I can maybe solve this by playing around with the passes (move the explosion to the effect pass, and only draw decals on the alpha pass), but it\u2019s getting to be a sloppier and sloppier implementation\u2026<\/p>\n<p align=\"justify\">Another issue is the edge of the geometry\u2026 For example, on the window of the Skydancer, this works fine if the explosion isn\u2019t on top of the glass:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen430.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen430\" 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=\"screen430\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen430_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p align=\"justify\">But as soon as it overlaps, the UVs get stretched:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen431.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen431\" 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=\"screen431\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen431_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p align=\"justify\">This one I was actually expecting and I can probably solve it with some threshold on the angle between the decal normal and the world normal.<\/p>\n<p align=\"justify\">One more issue, mostly relating to the \u201cscorch marks\u201d decal: what happens on the edges of objects:<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen434.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen434\" 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=\"screen434\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen434_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p align=\"justify\">It seems the scorch is something planar\u2026 I can fix partly finish this by extending the decal box on the Y-axis, but it would just extend the black on top the the wall, which would look very weird\u2026 <\/p>\n<p align=\"justify\">One possible solution for this one is to create some sort of \u201cradial decal\u201d, which instead of being a box, ends up being a sphere and with some different mapping (might be hard for the artist to build the texture for this).<\/p>\n<p align=\"justify\">Finally, another expression of the alpha issue and the fact that alpha-objects aren\u2019t affected by decals (by not letting decals be drawn):<\/p>\n<p align=\"justify\"><a href=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen433.jpg\" class=\"thickbox\"><img loading=\"lazy\" decoding=\"async\" title=\"screen433\" 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=\"screen433\" src=\"http:\/\/www.spellcasterstudios.com\/wp-content\/uploads\/2015\/02\/screen433_thumb.jpg\" width=\"830\" height=\"482\" \/><\/a><\/p>\n<p>The glow of the beam is a billboard drawn on the ground, which will fill the stencil buffer with a mark saying \u201cdon\u2019t draw here\u201d, which stops the decal from being drawn, which spoils the decal effect\u2026<\/p>\n<p>Again, this one might be sorted by doing a separate decal pass\u2026<\/p>\n<p>Finally, one of the problems that isn\u2019t a real problem now is the fact that this requires a lot of rendering in separate passes, etc\u2026 This could be minimized by doing a \u201cgather\u201d phase before rendering\u2026 Basically, just iterate all objects and fetch all the meshes and materials in the scene, with some more properties describing what kind of usage they have\u2026 With that I can then just iterate it and draw\/not draw according to the specific circumstance\u2026<\/p>\n<p>So, basically decals have extended my to-do list instead of reducing it\u2026 For a lot of stuff (like bullet holes on walls), the current solution would work fine, but my main interest at this point was to use the decals for the scorch marks (with the above results), entity shadows (think that one would work in most cases, except inside the facilities) and the shadows for the poison cloud and storm cloud (might work).<\/p>\n<p>So I think the next stop will be creating the gather phase (which I also hope will help clean up the code and optimize a lot, even if there isn\u2019t a big need for it), which is extremely boring! <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\/02\/wlEmoticon-smile.png\" \/><\/p>\n<p><em>Now listening to \u201cSavage Poetry\u201d by \u201cEdguy\u201d<\/em><\/p>\n<p><em>Link of the Day: Found this white paper on how to make a system for AABB trees for collision detection while saving loads of RAM, you might find it interesting\u2026 I know I did: <a title=\"http:\/\/www.codercorner.com\/ZeroByteBVH.pdf\" href=\"http:\/\/www.codercorner.com\/ZeroByteBVH.pdf\">http:\/\/www.codercorner.com\/ZeroByteBVH.pdf<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unfortunately, my initial idea that screen-space decals was some sort of magic bullet was completely wrong\u2026 They work great a lot of the time, easy to implement, fast\u2026 but (there\u2019s always a but) they have some small details which break it down\u2026 The issue I talked about yesterday was mostly solved with the stencil buffer: [&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":[184,256,242],"class_list":["post-2057","post","type-post","status-publish","format-standard","hentry","category-development","category-chrome-hunter","category-technology","tag-bugs","tag-decals","tag-polish"],"_links":{"self":[{"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts\/2057","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=2057"}],"version-history":[{"count":1,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts\/2057\/revisions"}],"predecessor-version":[{"id":2058,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=\/wp\/v2\/posts\/2057\/revisions\/2058"}],"wp:attachment":[{"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spellcasterstudios.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}