Search Unity

Question Transparent shader with ognoring target RenderTexture content

Discussion in 'Shader Graph' started by passer, May 23, 2020.

  1. passer

    passer

    Joined:
    Dec 1, 2013
    Posts:
    12
    Hi.
    I have two transparent RenderTexture: background and drawing. Shader should merge this two textures to transparent Quad.

    On event I need to copy drawing texture to background texture. For this I create new background2 texture
    Code (CSharp):
    1.  
    2. layerCopyMaterial.SetTexture("_background", background);
    3. layerCopyMaterial.SetTexture("_drawing", drawing);
    4. Graphics.Blit(emptyTexture, background2, layerCopyMaterial);
    5. background=background2;
    6. Graphics.Blit(emptyTexture, drawing);
    7.  
    After this Quad should have same image. But I found problem that initial color of background2 texture is affecting merging result.
    If I make shader non blending then quad became non transparent so this is not solution.
    I use blending like
    Blend SrcAlpha OneMinusSrcAlpha

    Is there any solution for this? Only to use two shaders with and without blending?