Search Unity

Transparent Texture Gets a Gray Shadow at the Corner of Screen

Discussion in 'Shaders' started by donamin1, Jun 20, 2016.

  1. donamin1

    donamin1

    Joined:
    Apr 4, 2013
    Posts:
    26
    Hi
    I'm using this simple transparent shader to create a sniper scope on UI.

    Code (CSharp):
    1. Shader "MaskedTexture"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Base (RGB)", 2D) = "white" {}
    6.         _Mask ("Culling Mask", 2D) = "white" {}
    7.     }
    8.     SubShader
    9.     {
    10.         Tags {"Queue"="Transparent"}
    11.         Blend SrcAlpha OneMinusSrcAlpha
    12.         Pass
    13.         {
    14.             SetTexture [_Mask] {combine texture}
    15.             SetTexture [_MainTex] {combine texture, previous}
    16.         }
    17.     }
    18. }
    It's working fine except that when I move the scope to the corner of screen, a weird gray shadow shows on the scope (check the screenshot below). Can anyone help me solve that? thanks!



    As you can see in the image, the central scope is working fine. But the one at the corner is looking gray. When I move the cornered scope to the center, the gray effect goes. But I need to use this shader at the corner!
     
  2. donamin1

    donamin1

    Joined:
    Apr 4, 2013
    Posts:
    26
    In case anyone cares, I managed to solve it. For some reason fog was affecting the UI. I turned the fog off and the gray shadow went away (my fog was gray).