
{"id":67,"date":"2021-01-30T18:34:34","date_gmt":"2021-01-30T18:34:34","guid":{"rendered":"http:\/\/crashedcreativity.pl\/?p=67"},"modified":"2022-06-22T20:02:28","modified_gmt":"2022-06-22T20:02:28","slug":"meet-shaders-part-1-luna-the-shadow-dust-effect","status":"publish","type":"post","link":"https:\/\/crashedcreativity.pl\/index.php\/2021\/01\/30\/meet-shaders-part-1-luna-the-shadow-dust-effect\/","title":{"rendered":"Meet shaders (part 1) &#8211; Luna The shadow dust effect"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"438\" src=\"http:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/shader_test2-SampleScene-PC-Mac-Linux-Standalone-Unity-2020.2.2f1-Personal-_DX11_-30.01.2021-18_17_00-1-e1612027574341-1024x438.png\" alt=\"\" class=\"wp-image-70\" srcset=\"https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/shader_test2-SampleScene-PC-Mac-Linux-Standalone-Unity-2020.2.2f1-Personal-_DX11_-30.01.2021-18_17_00-1-e1612027574341-1024x438.png 1024w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/shader_test2-SampleScene-PC-Mac-Linux-Standalone-Unity-2020.2.2f1-Personal-_DX11_-30.01.2021-18_17_00-1-e1612027574341-300x128.png 300w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/shader_test2-SampleScene-PC-Mac-Linux-Standalone-Unity-2020.2.2f1-Personal-_DX11_-30.01.2021-18_17_00-1-e1612027574341-768x328.png 768w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/shader_test2-SampleScene-PC-Mac-Linux-Standalone-Unity-2020.2.2f1-Personal-_DX11_-30.01.2021-18_17_00-1-e1612027574341.png 1334w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Hi, Today I want to share a result of my first aproach to shader implementation. I have decided to look closeler to this feature after seeing  <a href=\"https:\/\/www.lantern-studio.com\/\">LUNA &#8211; The Shadow Dust (lantern-studio.com)<\/a>. Visualy astonishong.<\/p>\n\n\n\n<p>I wanted to make a reverse engineering some effect i have noticed waching this game.<\/p>\n\n\n\n<p>I decided to use Universal Render Pieline. This Unity asset gives a posiibility to make shaders in very simple manner, using visual graph<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"http:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/shader_test2-SampleScene-PC-Mac-Linux-Standalone-Unity-2020.2.2f1-Personal-_DX11_-2021-01-30-18-16-44.mp4\"><\/video><\/figure>\n\n\n\n<h2>Requirements<\/h2>\n\n\n\n<p>Unity 2020.2.2f1 or higher<\/p>\n\n\n\n<p>In this version 2D renderers feature  is not experimental anymore and shader properties are exposed for the animator which is very useful<\/p>\n\n\n\n<h2>Installation UPR<\/h2>\n\n\n\n<p>UPR works in Unity V2019 and above. To install UPR go to Unity, Window \u2192 Package Manager, and search&nbsp;<strong>Universal RP<\/strong><\/p>\n\n\n\n<p>Create a folder named URP or any other name you like, then create \u2192 Rendering \u2192 Universal Render Pipeline \u2192 Pipeline Asset (Forward Renderer)<\/p>\n\n\n\n<p>Then In the Edit \u2192 Project Settings \u2192 Graphics, select the&nbsp;<code>UniversalRenderPipelineAsset (UniversalRenderPipelineAsset)<\/code>&nbsp;for&nbsp;<code>Scriptable Render Pipeline Settings<\/code><\/p>\n\n\n\n<p>In order to use 2d lights. create \u2192 Rendering \u2192 Universal Render Pipeline-&gt; 2D Renderer and assign it to Universal Render Pipeline Asset created above<\/p>\n\n\n\n<h2>Creating first shader<\/h2>\n\n\n\n<p>Create-&gt;Shader-&gt;Universal Render Pipeline-&gt; Sprite Lit Shader Graph<\/p>\n\n\n\n<p>I have createt property Color(Input parameter of the shader accessible from a scene)   for sand color. Honestly until shader is not finished it is better create input node insted property. You will be able to see results on preview.<\/p>\n\n\n\n<p>I have created a property: texture. Analogicaly it is better to drag and drop some texture  into the graph.<\/p>\n\n\n\n<p>One more parameter Value (called &#8220;phase&#8221;). (Insted of one You can add slider to play with parameter an remove it after shader is ready)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>All parameters have to be dragged and dropped to the graph.<\/p>\n\n\n\n<p>I have connected color with &#8220;Base Color&#8221; on &#8220;Fragment&#8221; Node.<\/p>\n\n\n\n<p>With texture wchich was actualy a mask i had to play a little bit. I show You the finall result of it<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1882\" height=\"948\" src=\"http:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/Zrzut-ekranu-2021-01-30-191456.png\" alt=\"\" class=\"wp-image-74\" srcset=\"https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/Zrzut-ekranu-2021-01-30-191456.png 1882w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/Zrzut-ekranu-2021-01-30-191456-300x151.png 300w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/Zrzut-ekranu-2021-01-30-191456-1024x516.png 1024w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/Zrzut-ekranu-2021-01-30-191456-768x387.png 768w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/Zrzut-ekranu-2021-01-30-191456-1536x774.png 1536w\" sizes=\"(max-width: 1882px) 100vw, 1882px\" \/><\/figure>\n\n\n\n<p>Slider (finaly &#8220;phase&#8221;) was conected twice: With R input of &#8220;Combine&#8221; node&#8221; and with &#8220;Add Node&#8221; (adding 0.01 value). Output of add withc was connected two &#8220;G&#8221; input of &#8220;Combine&#8221;. In this way i hav coded in RG two values (not colors) which can be input Min Max of Remap (requires two values input) Second Remap input was set to 0 and 1. Output of a Remap was connected two. Sprite Mask channel of &#8220;Fragmnt&#8221; node.\\<\/p>\n\n\n\n<p>Remap: Math-&gt;Range-&gt;Remap<\/p>\n\n\n\n<p>Add : Math -&gt;Basic<\/p>\n\n\n\n<p>Combine: Channel<\/p>\n\n\n\n<p>Click &#8220;Save Asset&#8221;<\/p>\n\n\n\n<p>Create material and set this shader in shader property. Set texture like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"399\" src=\"http:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/sand_smooth-1024x399.jpg\" alt=\"\" class=\"wp-image-76\" srcset=\"https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/sand_smooth-1024x399.jpg 1024w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/sand_smooth-300x117.jpg 300w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/sand_smooth-768x300.jpg 768w, https:\/\/crashedcreativity.pl\/wp-content\/uploads\/2021\/01\/sand_smooth.jpg 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Set a sand Color<\/p>\n\n\n\n<p>Now You can apply this material to sprite (there will be warning that this material have no main texture but it will work anyway)<\/p>\n\n\n\n<p>You can create sprite animation changing &#8220;phase&#8221; value of shader<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, Today I want to share a result of my first aproach to shader implementation. I have decided to look<\/p>\n<div class=\"read-button read_more_btn_text\"><a class=\"read_more\" href=\"https:\/\/crashedcreativity.pl\/index.php\/2021\/01\/30\/meet-shaders-part-1-luna-the-shadow-dust-effect\/\">Read Now<span class=\"arrow_readm\"> &#x25BA;<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":70,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/posts\/67"}],"collection":[{"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":7,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/79"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/media\/70"}],"wp:attachment":[{"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crashedcreativity.pl\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}