Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to apply a vertex mask to a sprite shader in Shader Graph?

Discussion in 'Shader Graph' started by RedVonix, Oct 17, 2019.

  1. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    421
    Could someone give me some advice on how to remap a vertex mask to the actual vertex positions of a mesh in a sprite shader? What I have here (in the attached image) DOES work - as long as we don't use sprites from an atlas. What happens is that the vertex mask ends up getting the same pixel positions from its texture, as the sprite does from the sprite atlas. What I need to do is have the vertex mask use the UV positions INSTEAD OF the pixel positions. I'm a bit lost on how to do that in shader graph...
     

    Attached Files:

  2. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    421
    Got it! Have to pass in the vertex positions to the UV of the vertex mask texture!
     
    JarekKaa94 likes this.
  3. JarekKaa94

    JarekKaa94

    Joined:
    May 31, 2018
    Posts:
    10
    Can you get me example? Please.
     
  4. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    421
    In ShaderGraph, just create a Vertex Position node, and a UV node, then pass the Vertex Position into the UV Node, then use that UV node for the UV of the mask texture.
     
    JarekKaa94 likes this.
  5. JarekKaa94

    JarekKaa94

    Joined:
    May 31, 2018
    Posts:
    10
    Thanx for fast answer, but i don't know how do this. I create 2 node: "Position" and "UV". How i can pass Position into the UV Node? UV node don't have input slot. Adnotacja 2019-12-10 183305.png
     
  6. RedVonix

    RedVonix

    Joined:
    Dec 13, 2011
    Posts:
    421
    My bad - just pass the Position directly into the UV for the Sample Texture.
     
    JarekKaa94 likes this.
  7. JarekKaa94

    JarekKaa94

    Joined:
    May 31, 2018
    Posts:
    10
    It's WORK! Thanx!
     
    RedVonix likes this.