Search Unity

Text Mesh and ZTest not compatible?

Discussion in 'Shaders' started by tsphillips, Mar 17, 2008.

  1. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    Any time I have a ZTest LEqual with any Text Mesh, the mesh won't render. It is as if anything with a Text Mesh attached always has a z depth fixed to infinitely distant.

    The end goal here is to have text meshes properly hidden behind other objects. Looking around the forum and the wiki, it seems like a proper ZTest LEqual used to work, but perhaps something changed? Is there something I need to do to the Text Mesh to make it recognize its correct depth?
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Hmm... it should work. Paste the shader?
     
  3. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    Here it is...

    Code (csharp):
    1. Shader "GUI/Colored Text Shader"
    2.  {
    3.     Properties {
    4.         _MainTex ("Font Texture", 2D) = "white" {}
    5.         _Color ("Color", Color) = (1, 1, 1, 1)
    6.     }
    7.    
    8.     SubShader {
    9.  
    10.         lighting Off
    11.         cull off
    12.         zwrite on
    13.         ztest lequal // shouldn't this work?
    14.         Fog { Mode Off }
    15.         Tags {"Queue" = "Transparent" }
    16.  
    17.         Pass {
    18.             Blend SrcAlpha OneMinusSrcAlpha
    19.             SetTexture [_MainTex] {
    20.                 ConstantColor[_Color]
    21.                 Combine constant, texture
    22.             }
    23.         }
    24.     }
    25.  }
    26.  
     
  4. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    Quick note about the ZWrite -- I have tried on and off, but will turn it off once the text is rendering correctly.
     
  5. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    The shader works for me...
     

    Attached Files:

  6. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    Aras - thanks for taking a look at it. I just tried it on a newer iMac and it works, but it wasn't working on one of the original Intel iMacs. I will put together a test project on the older iMac; if it still doesn't work there, then I will file a bug report.
     
  7. tsphillips

    tsphillips

    Joined:
    Jan 9, 2006
    Posts:
    359
    I built a simple project on the older iMac and now it's working. User error strike again. :?