Search Unity

Question Sprite Eraser with Shader Graph

Discussion in 'Shaders' started by Elvard, Jul 30, 2021.

  1. Elvard

    Elvard

    Joined:
    Dec 8, 2018
    Posts:
    1
    Hello,
    I've been trying to create a shader that allows me to erase a sprite with touch input in order to reveal something that is underneath. The problem is that I've managed to pass the click/touch position to the shadergraph and erase that part with a circle that has feathering.
    The problem is that the previous positions are not saved, therefore the mask always moves with the touch input but only erases the current position. My idea was to create an array of positions and send it to the SG but I have no idea how or if would be performant at all.


    Here's what I've got so far on my Shadergraph:



    Here's what the current behavior looks now:
    https://i.gyazo.com/bec363ee1d9ee6141491c2e35c1d4761.mp4

    Thank you for your attention!
     
  2. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    Hi!
    Since shader execute individually each frame(some exception like compute shader),
    so they don't know what last frame happenend.

    You need render your mask into render texture to store mask.
    Then you apply this mask to your eraser shader.