Fade Objects Using C# & Standard Shader (Built-in RP)
Published: 28 Sep 2021
Learn how to fade out objects that block line of sight to your player, or any other object, while still using the Unity Standard Shader! No custom shader writing or Shader Graph editing required!
A common problem with top-down games is objects can block line of sight to the player, resulting in a less-than optimal experience for the player because they can get lost or confused. Using this technique you can resolve this problem and make a better experience for your players by fading out objects that block line of sight to any object while still using the Unity Standard Shader!
I use this exact same technique in my game Llama Survival!
In this tutorial you'll learn how to fade objects out using the Standard Shader (Built-In Render Pipeline) when they block line of sight to your player. You'll learn how to:
⚫ Find objects blocking line line of sight to the player (or any other object)
⚫ Fade out all objects blocking line of sight
⚫ Fade in objects that were faded after they no longer block line of sight
Objects that can block line of sight can have multiple behaviors for fading:
⚫ Fade a single object
⚫ Fade an object and its children
⚫ Fade target renderers
👨💻 As always, all code from this video is available on GitHub: https://github.com/llamacademy/fade-objects-standard-shader
🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly
📚 Resources:
⚫ If you are using URP, check out: https://youtu.be/vmLIy62Gsnk to see how to do this same process with URP! Repo: https://github.com/llamacademy/urp-fading-standard-shaders
⚫ C# IEquatable: https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1?view=net-5.0
⚫ Unity Standard Shader Documentation: https://docs.unity3d.com/Manual/StandardShaderMaterialParameterRenderingMode.html - the source of truth for this video!
🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:
🌟 Patreon: https://www.patreon.com/llamacademy
🌟 YouTube Member: https://www.youtube.com/channel/UCnWm6pMD38R1E2vCAByGb6w/join or click the Join button on any video
📚 Take my Unity ShaderGraph Course:
https://www.gamedev.tv/p/unity-shader-graph?affcode=45216_kuvg0bp7
👕 Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/
💸 Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4
💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publisher-sale?aid=1101l9QvC (affiliate)
💸 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sale=true&orderBy=1&aid=1101l9QvC (affiliate)
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.