Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

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

    dawep7

    Joined:
    Jan 22, 2023
    Posts:
    5
    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:

    upload_2023-8-13_18-3-54.png

    And this is the result:

    upload_2023-8-13_18-4-14.png

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