Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Clipping GUIText

Discussion in 'Shaders' started by raybarrera, Jun 14, 2013.

  1. raybarrera

    raybarrera

    Joined:
    Nov 20, 2010
    Posts:
    207
    Hello!

    Is there any way to clip GUIText?

    Not 3d text, not any 3rd party text, but GUIText. The app I'm working on uses large blocks of text and bitmap fonts just won't do (too crunchy).

    So, is there any way to clip GUIText via shaders? Unfortunately, clipping using multiple cameras is a half-measure and not quite doing it for us.
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    GUI Text is "3D" (that is to say, it's a mesh like any other). And it uses bitmap fonts. You can cut the pixels off however you want in the fragment shader.
     
  3. raybarrera

    raybarrera

    Joined:
    Nov 20, 2010
    Posts:
    207
    If I understand it correctly, Unity simply generates the atlases on the fly for GUIText.
    The issue I have is that I've not been able to get it to draw behind other objects. It seems to ignore the queue order on shaders I've tried.
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    What you're looking for is called depth or Z testing, not clipping. The reason 3D text appears on top of everything by default is that it uses the default text shader, which has ZTest Always set. Use pretty much any other shader and it should work, or make your own version of that shader which has the normal ZTest LEqual.
     
  5. raybarrera

    raybarrera

    Joined:
    Nov 20, 2010
    Posts:
    207
    To be clear, I can get this to work just fine on 3DText.
    However, objects with a GUIText component don't work with the same shader that works for 3DText.
     
  6. raybarrera

    raybarrera

    Joined:
    Nov 20, 2010
    Posts:
    207
    Anyone know?