Search Unity

Getting depth mask to work with android 7+

Discussion in 'Shaders' started by lmbarns, Nov 30, 2017.

  1. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    I've been using the depth mask off the wiki for years, but it no longer works on Android 7+. Tested a bunch of devices, both before and after upgrading the os, and the OS seems to be the only factor in making it not work.

    Code (CSharp):
    1.  
    2. Shader "Masked/Mask2" {
    3.     SubShader {
    4.         Tags {"Queue" = "Geometry-10" }
    5.  
    6.         ColorMask 0
    7.         ZWrite On
    8.  
    9.         Pass {}
    10.     }
    11. }

    In the editor, older androids, ios, etc it works, but not android 7+ it renders black instead of invisible where the mask geometry occludes the geometry it's supposed to be masking out.

    At "Geometry-10", it's very crude looking black, very pixelated, if I change it to "Geometry-1000", it renders black still but much higher resolution.

    Anyone have any ideas for a workaround or alternative? I need to mask off sections in a situation where a user can look at the object from many different angles, so I'm not sure if stencil buffer is going to be good enough. I need to show a hole through something, but mask off when viewed from a steep angle on the side