Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Need help overlaying camouflage patterns (sprites) to existing sprites in the scene

Discussion in 'Shader Graph' started by sbcreations, Oct 29, 2023.

  1. sbcreations

    sbcreations

    Joined:
    Feb 10, 2020
    Posts:
    10
    UPDATE: After some help, I figured out why the shader wasn't working. When I updated to include the texture of the tent and multiply it then it works, though it isn't very practicle to create a new shader for each object that needs the tent applied (considering I will have multiple factions identified by tent patterns). Still looking for a solution that will allow me to create a shader for each tint, without having to specifify the sprite object it will be attached to so that at runtime I can change out the material on the sprite renderer with a camo pattern. Hopefully that makes sense. Maybe this isn't doable with shader graph and instead I should continue continue trying to come up with a solution using a sprite mask. Thanks again fro any help.


    I have a game object which includes a 2D sprite renderer with a sprite of a tent. I have a library of sprites that are simple camouflage png patterns which I have imported as sprites. I have been attempting to use a shader graph (image below) to create a material of the camo patterns that I can then apply to objects in the scene at runtime (in this case the tent) but I just can't seem to get that to work. The material attaches but the tent sprite does not reflect the camo pattern once applied.

    I was able to hack a solution together by putting a sprite mask component on the tent and then creating a new child game object that contains the camo sprite with the renderer mask set to 'Visible Inside Mask'. The result isn't great as I have to keep the opacity of the camo sprite low to see the details of the tent still. I am hoping there is a better way to do this.

    I am somewhat new to Unity in that I have been using it for about 8 months now. I have mostly made simple 2D games and haven't worked much with the shader graph so this is stumping me. I have searched on this subject for the last two days and haven't come across a solution yet so any advice or if you could point me to a resource to read up on I would greatly appreciate it. Thanks! Screenshot 2023-10-29 184321.png
     

    Attached Files:

    Last edited: Oct 30, 2023