Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Alpha map for 2D sprite?

Discussion in '2D' started by scryedzxp, Jun 5, 2023.

  1. scryedzxp

    scryedzxp

    Joined:
    May 14, 2013
    Posts:
    47
    Let's say I have the following 2D sprite:

    upload_2023-6-5_11-50-49.png

    and alpha map:

    upload_2023-6-5_11-51-51.png

    How can I make parts of the sprite transparent based on the alpha map given? The end result should be something like this:

    upload_2023-6-5_11-57-59.png

    I tried following this video but the sprite just ends up turning black.
     
  2. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    use shader graph, like this
    Untitled2.png Untitled.png
     
  3. scryedzxp

    scryedzxp

    Joined:
    May 14, 2013
    Posts:
    47
    Thanks for replying. I actually tried using the Shader Graph to achieve this but I'm getting the same issue someone else was having where the material always returned pink. I saw your response in that thread where you suggest to use a different base shader.

    What version of unity are you using and which shader did you use to achieve this? I'm using 2021.3.25 LTS and Create->ShaderGraph->URP->SpriteLitShaderGraph (as well as SpriteUnlitShaderGraph)
     
  4. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    this is the shader, if it doesnt work its maybe a problem of the pipeline
     

    Attached Files:

  5. scryedzxp

    scryedzxp

    Joined:
    May 14, 2013
    Posts:
    47