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 Creating transparency in a specific point of a sprite (very close)

Discussion in 'Shader Graph' started by dr4, Aug 16, 2019.

  1. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    106
    Hi,

    I have been trying to create a shader graph that creates a transparency in a specific point, I could get it to make an specific point totally transparent (creating a hole) but no matter what I try I cannot get to create something that I can regulate making it more or less transparent (so you can see through it but without it being just a hole), I feel like I'm very close but after a whole day trying I couldn't get any further,change the alpha of the whole sprite is easy enough but change it in a specific position is being a nightmare, could anyone advice?

    this is how it looks (the hole is following a transform.position so I basically can move it around):

    upload_2019-8-16_23-19-46.png


    this is my shadergraph:

    upload_2019-8-16_23-22-49.png
     
  2. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    If you don't want the transparent part to be clipped entirely, don't use alpha clip then, use the alpha channel. It will have transparency levels, not just 0 or 1, if that's what you are looking for.

    As for controlling where the transparency lands, i'm don't quite understand the requirements.

    Do you need to control where the transparent thing lands in UV space,, object space, world space? how do you need to control it?
     
  3. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    106
    thanks for answering Isinner, I tried to use alpha channel but couldn't get it to make only one point transparent,everything I tried affected the whole sprite.

    Yes, it would be world position, as you can see in the screenshot "_TransparencyPoint" is a vector3, with exactly that you get the result posted in the first image, I just want that hole to be semitransparent, not just a hole
     
  4. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    Then you need to calculate the transparency based on the distance of that certain pixel from your world space position, and plug it in alpha.

    Think of a range in which your transparency will vary, lets say 0..0.5, then calculate the distance from a pixel in world space to your Vector3, then set your alpha based on it, you can use a remap node.