Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Discussion Shader that draws a specific layer over the Player's legs but not over his upper body.

Discussion in '2D' started by dawep7, Aug 13, 2023.

  1. dawep7


    Jan 22, 2023
    I already have some solution but I'm new to Unity shaders and I'm afraid that my way is overengineered. I tried to achieve this effect with Sprite Mask, but I didn't figure out how to do a gradient effect. So here is my current solution:

    I have a separate layer for the Player and Walls. On the Player object is an attached Camera that has Culling Mask which filters other layers than "Walls" (so it draws only the "Walls" layer). I created Render Texture and set it up as an output of the Camera. I also want my player to be able to change colors so there is an input color. Now this is what the Shader Graph looks like:


    And this is the result:


    Currently I'm happy with that. I don't wanna get stuck on it but I wonder If I could do it better.