Search Unity

Question Dealing with RT alpha channel

Discussion in 'Shaders' started by Abended, May 9, 2021.

  1. Abended

    Abended

    Joined:
    Oct 9, 2018
    Posts:
    142
    I have this great dynamic RT I've made. I've just got a new asset that I want on my mesh in the inverse of my RT's alpha channel. In the new asset's shader they are looking for a black/white texture. Can I (easily) spit out the inverse of my RT's alpha channel as the input to this new shader? I know in my shader, I could do oneminus to flip it, but I don't think that would help. the texture is 2048x2048. My shader is in shadergraph, of which I am still a novice, the asset's shader is in HLSL - because of course, it has to be a complicated situation.

    In a perfect world, I could modify the asset's shader so I wouldn't have to double down on the memory for this texture. But the more I look at HLSL, the more it still has not clicked for me.

    ok, first question. I've seen a lot of desaturated textures as additional textures for shaders. Is it possible to just add a texture and just use it's alpha channel? If I strip out the alpha separately, I am forced to create an additional texture. I would like to just push my RT, have the shader pull the alpha, and then have it oneminus. I just don't know what's possible.
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,724
    Your post is a bit unclear. (the title being about something different doesn't help either).

    Please correct me if I'm wrong:

    You have a shader (made in shadergraph?) that you use to generate an RT. You want that RT to be used as input for another shader, that is an HLSL shader, but you want the RT's alpha reversed.

    I'm not sure why you're saying this wouldn't help.

    Not sure why you would double down on memory.

    Also doing the one minus in HLSL is easy

    tex.a = 1 - tex.a;
     
  3. Abended

    Abended

    Joined:
    Oct 9, 2018
    Posts:
    142
    Hi @AcidArrow
    Yes I do not want to double down on memory.

    Using an mpb I can send my RT to another shader (HLSL) as a texture.

    However that input expects a desaturated black/white image. Can I change the HLSL to take a normal texture, but only deal with the alpha channel of that texture?

    I appreciate the one minus tip, that does seem easy.
     
    Last edited: May 10, 2021