{"id":2986,"date":"2021-05-16T14:33:40","date_gmt":"2021-05-16T14:33:40","guid":{"rendered":"http:\/\/dbbd.sg\/blog\/?p=2986"},"modified":"2021-12-22T01:59:06","modified_gmt":"2021-12-22T01:59:06","slug":"black-hole-shader-graph","status":"publish","type":"post","link":"https:\/\/dbbd.sg\/blog\/2021\/05\/black-hole-shader-graph\/","title":{"rendered":"Sucked into the vacuum of a black hole: Unity Shader Graph"},"content":{"rendered":"<p>One of the effects I&#8217;ve liked in games is the &#8220;everything being sucked into a black hole vacuum&#8221; look. What are the correct words to describe it? Does this effect already have a proper name or keyword? In <a href=\"https:\/\/www.youtube.com\/watch?v=6PAZcZfPUuc\">Virtual Virtual Reality<\/a>, the conceit is that you&#8217;re the human employee pruning and vacuuming some machine&#8217;s lovely domestic abode and suddenly without warning it is as if you have done a terrible thing; you&#8217;ve accidentally sucked the first layer of the world away by mistake!&#8230;<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3391\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/virtualvirtualreality.gif\" alt=\"\" width=\"800\" height=\"444\" \/><\/p>\n<p>Today, I was reminded of it again whilst watching <a href=\"https:\/\/www.youtube.com\/watch?v=ISz3VuTwQqk\">the (ever inspiring) devlog for the indie game Farewell North<\/a>, so I wanted to figure out how it was made. In Farewell North, it seems like it is being used in the playback scene for memories; the visual effect of being sucked back into the projector is exactly what makes them feel like ethereal memories being played back.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3392\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/farewellnorth.gif\" alt=\"\" width=\"800\" height=\"475\" \/><\/p>\n<p>This evening I spent a while trying to figure it out. The answer seems to be using Unity&#8217;s Shader Graph (which I&#8217;ve actually never properly used before, but it reminds me of Blender&#8217;s shader nodes, so I guess roughly get the node based system). I looked around for <a href=\"https:\/\/www.youtube.com\/watch?v=eujfez6W53E\">examples<\/a> and <a href=\"https:\/\/learn.unity.com\/tutorial\/shadergraph-vertex-position\">explanations of how it was created<\/a>. I am glad to say that with all the power of the internets and online resources, it was indeed possible for me to understand how one can recreate the &#8220;sucked into a vacuum&#8221; effect. <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/Vector3.Lerp.html\">Lerp<\/a> refers to linear interpolation and the value will change from a to b over t. There&#8217;s a Vector3 to set the origin point of the &#8220;BlackHole&#8221; or where everything will be sucked into \/ spat out of. And then there is a slider property for the &#8220;Effect&#8221; (a bit like &#8220;time&#8221; in this case) which can be helpfully tweaked in Inspector for testing purposes. &#8220;Range&#8221; is a fixed value. There&#8217;s obviously a lot more I can experiment with Shader Graph. But for now&#8230; a working example of the &#8220;Sucked-into-a-blackhole-vacuum&#8221; Shader Graph looks like this:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3393\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/Screenshot-2021-05-16-at-9.43.57-PM-1024x563-1.png\" alt=\"\" width=\"1024\" height=\"563\" srcset=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/Screenshot-2021-05-16-at-9.43.57-PM-1024x563-1.png 1024w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/Screenshot-2021-05-16-at-9.43.57-PM-1024x563-1-300x165.png 300w, https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/Screenshot-2021-05-16-at-9.43.57-PM-1024x563-1-768x422.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-3394\" src=\"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/shaderblackhole.gif\" alt=\"\" width=\"800\" height=\"529\" \/><\/p>\n<p style=\"text-align: center;\"><em>My basic version of the &#8220;Sucked-into-a-blackhole-vacuum&#8221; look&#8230;<\/em><\/p>\n<p>Imagine my Spheres and Cubes teleporting endlessly from this world to another world and then back again &#8211; oh wait now you don&#8217;t even have to imagine it, here&#8217;s an actual visual representation of it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the effects I&#8217;ve liked in games is the &#8220;everything being sucked into a black hole vacuum&#8221; look. What are the correct words to describe it? Does this effect already have a proper name or keyword? In Virtual Virtual Reality, the conceit is that you&#8217;re the human employee pruning and vacuuming some machine&#8217;s lovely [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3391,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1048,1028,1031],"tags":[442,1056,1055,157],"jetpack_featured_media_url":"https:\/\/dbbd.sg\/blog\/wp-content\/uploads\/2021\/09\/virtualvirtualreality.gif","_links":{"self":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts\/2986"}],"collection":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/comments?post=2986"}],"version-history":[{"count":5,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts\/2986\/revisions"}],"predecessor-version":[{"id":3396,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/posts\/2986\/revisions\/3396"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/media\/3391"}],"wp:attachment":[{"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/media?parent=2986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/categories?post=2986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbbd.sg\/blog\/wp-json\/wp\/v2\/tags?post=2986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}