Search Unity

Resolved Sample Texture 2D fills transparent areas

Discussion in 'Shader Graph' started by Therozin, Oct 2, 2019.

  1. Therozin

    Therozin

    Joined:
    Dec 11, 2017
    Posts:
    2
    Hello,

    I'm currently having troubles sampling a 2D texture with transparency. In some scenarios, the sampler just ignores the alpha canal and straight up fills it with a nearby color. I've been searching for a while now on the forum and the Internet, but nothing is coming up. I've attached a few screenshots of what is happening.

    To answer to a bunch of questions :
    • I'm working with Unity 2019.2.4f1 and LWRP 6.9.1.
    • I'm using an unlit shader, where the master node is set to transparent.
    • I've seen that using a black outline around the image preserves the transparency, but I'd like to actually get ride of this outline.
    • I've tried it with several others images. The black outline trick always works.
    • It has nothing to do with hidden information of color of the transparent pixels. They are all set as black.
    Any idea what it could be? I'd give a lot just to have the slightest idea of how to correct that.


    Screenshot_1.png ShaderTest1.png

    First set of image, with the black outline. It works fine.

    resultGraph.png ShaderTest2.png

    Second set of images, without the black outline. It gets crazy.
     
  2. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    The shader graph preview doesn't show the alpha but simply the content of the color channels. Your image processing tool fills the transparent area differently in both cases.
    When the import settings are correct alpha should work fine. Try attaching a node to the alpha output and look at it's preview, it should contain the greyscale alpha channel.

    Example:
    upload_2019-10-2_10-34-58.png

    If that doesn't show alpha correctly your texture importer settings are wrong.
     
  3. Therozin

    Therozin

    Joined:
    Dec 11, 2017
    Posts:
    2
    The alpha is correctly shown by the the multiplier, so the problem doesn't come from here. But I tried to apply the same technique at the ending result, but there were no alpha. Seems it has been lost somewhere in the process, I'll check it out. Thanks for the idea and the tip!
     
  4. BoyceCecil

    BoyceCecil

    Joined:
    Oct 18, 2021
    Posts:
    2
    I Have the same problem and it's not the texture importer's fault, anyone could help?

    12-05_10-51_2021.png