Search Unity

Black pixels when masking with depthmask shader in Android

Discussion in 'Vuforia' started by swogdog, Mar 28, 2018.

  1. swogdog

    swogdog

    Joined:
    Jan 7, 2013
    Posts:
    14
    I cannot seems to figure this out. I get these awful black pixels showing up where objects are supposed to be masked by the depthmask shader/material. It only happens on Android devices, and does not happen in editor or iOS. I found in some other forums and threads to try to set ZTest to Always in the shader, and that just made the depthmask not work at all, it didn't mask anything.

    Anyone else seeing this or have any ideas?

    I'm using Unity 2017.3.1f1 and the Vuforia that comes with it.

    Thanks in advance!
     
  2. swogdog

    swogdog

    Joined:
    Jan 7, 2013
    Posts:
    14
    Image here for reference. The black pixels on the bottom of the parachute and box are behind the mask.

     
  3. whogas

    whogas

    Joined:
    Oct 18, 2013
    Posts:
    46
    Hello, I assume you have moved on from this issue at this point, but I'm leaving this here since I could only find other people with this problem and no current answers. To solve this, I modified the SetRenderQueue script that tags along with this masking shader to turn off z-writing for the object that will be masked. I also made sure that the queue for the masked object was higher than other elements in the stackups I was dealing with.

    You can turn off z-writing any way you wish, really, be it through your own shader or anything.

    Here's the line I added for this masked object. Hope this helps or at least gets someone on a good path.

    Code (CSharp):
    1. renderer.material.SetInt("_ZWrite", 0);