Search Unity

Help Wanted How to control SampleTexture2D opacity?

Discussion in 'Shader Graph' started by _watcher_, Aug 7, 2019.

  1. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    129
    Hi

    as shown in the pic below, i cant seem to get different opacity (less than 100% opaque) in a Texture2D. How do you guys do it?

    picture link (imgur)
     
  2. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    17
    The preview does not show opacity! Your nodes should work.
     
  3. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    127
    If you don't see the mesh that is using this shader going transparent, the cause of this may be that you didn't set the master node to transparent mode.
     
  4. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    129
    Yes, i did want to point out, that i know that Preview might not show transparency correctly, however this is not the case, i still dont get correct transparency on the target.

    The master node is actually a node for Sprite, its an in-preview SpriteLitMaster node for Renderer2D (sprite renderer) that works with their custom implementation of 2D Lights. I do not know where to set what you call "transparent mode", however, when i use a Texture2D png mask to mask my Albedo (Color(3)) input in my master node, i DO get correct transparency. So i think the master node does support transparency (simply doesn't expose the 'transparent mode' parameter? - im not familiar with this parameter). Anyways transparency DOES work and shows correctly when used in above way.

    This is an example how the SpriteLitMaster node looks like in SG.

    NOTE: the "Mask" input is not used to mask the sprite, rather, it is used to tell if lights hitting those pixels affect them or not (so the "Mask (4)" is about masking lights, not about masking the target).

    What i hoped to get as an answer and suggestion, is someone to say "hey your use of split + combine" and vector1 for alpha is WRONG, and "this is how it should be done" example. But what you are both essentially saying is that the above example of me using / set transparency using Split/Combine + change alpha input of combine is correct, yes? Yet it does not seem to work for the SpriteLitMaster node, so maybe i should seek support in their forum thread?

    Thanks
     
    iSinner likes this.
  5. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    17
    Yes.
     
  6. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    127
    The way you split and combine is fine.
    The transparent mode is in the cog menu on the master node, but that applies to standard and hdrp master nodes. I wasn't sure which type of master node you were using so I assumed it.

    Color in the image of the master node accepts vector 4, so if you make sure you give him all 4 values with alpha in the forth one, it should work, if it doesn't, that's most likely a bug.
     
    _watcher_ likes this.
  7. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    129
    I checked the cog after you posted your first reply, but it's not in there. Im going to redirect this to the mentioned 2DLights sub-forum, where i'll seek further help on the matter. I'm also glad to hear that the approach is correct for the other mentioned master nodes.

    Thanks again.