How can I remove these black dots on the materials ?

Hi everone,

I have some problems when changing alpha percent of the materials.

I got this strange view when i change the alpha value of its material like below.

public static void SetTransparentOfObject(GameObject obj, float TransparentPercent)
         {
             foreach (Material m in obj.GetComponent<Renderer>().materials)
             {
                 m.SetFloat("_Mode", 2);
                 m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                 m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                 m.DisableKeyword("_ALPHATEST_ON");
                 m.EnableKeyword("_ALPHABLEND_ON");
                 m.renderQueue = 3000;
                 m.color = new Color(m.color.r, m.color.g, m.color.b, TransparentPercent);
             }
         }

I wrote this code to do that. Can you tell me where is my wrong, thanks.

Nothing is wrong, it’s rendering as intended. You’re using Unity’s Standard Shader which uses dithered alpha for transparent shadows. This can be disabled on some newer versions of Unity in the Graphics settings (it’s the option named “Enable Semitransparent Shadows”), or more directly you can disable shadow casting on the renderer component of the object you’re making transparent.

1 Like

Thank you @bgolus for your fast reply. Probably I’ll disable the shadows for these objects but I also tried to find the “enable semitransparent shadows” option but I can’t find any where. Could you tell me where can I find that option please. Thanks again. (By the way I’m using 2018.1.0f2 Personal version)

If you don’t see it, you probably don’t have it. I think it was added in Unity 2018.1

I’m using 2018.1 already but thank you for your help. :wink:

Thank you @bgolus .