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 [2D ShaderGraph] how to offset certain pixels in a sprite.

Discussion in 'Shader Graph' started by GMan_Wolf, May 22, 2020.

  1. GMan_Wolf

    GMan_Wolf

    Joined:
    Jan 30, 2016
    Posts:
    7
    Hello

    I have been trying for ages to get this right and just cant seem to get the final thing to come together.
    I am trying to manipulate the Y offset of only certain pixels in my sprite.

    Say these particular pixels have an alpha less than 1 while the rest of sprite is 1. I am able to get the whole image to move up and down by Taking a position node, splitting it, adding to the Y, combining and plugging it into the final sprite lit master.

    I am able to split the image into only the pixels with less than 1 alpha and those that = 1 by using a step and multiplying by the sample texture. But i dont know how to apply the offset up and down to only those pixels with the alpha less than 1.

    Can anyone point me in the right direction or help link me to some video/text tutorial.

    Thanks
     
  2. GMan_Wolf

    GMan_Wolf

    Joined:
    Jan 30, 2016
    Posts:
    7
    So I half figured it out by using a tile and offset feeding into the UV of a texture sample and then masking out the pixels i wanted and lerping it together at the end with the original texture sample minus what i had masked off... Worked great on a single sprite.. but when i tried it on Tilemap with sprite from a spritesheet it was all messed up, It was "scrolling" the tilesheet and i was getting the neighbouring tiles bleed in... which i guess makes sense.. but I could just not figure out how to get it to isolate just to the tile