Search code examples
shaderhololensmrtk

MRTK2 stencil effect not working on TextMeshPro Text


i am currently working on a HoloLens 2 application using the assets provided by the MRTK2 example scene for materials. To be precise im using the stencil material with the portal and frame.

Everything works good, when applying the MRTK Standards Shader to the GameObject and enabling "Stencil Testing", except of Text Mesh Pro Objects. The portal like effect for the others does not apply to the texts and they are getting displayed as usual.

The Text Mesh Pro objects use a specific shader for MRTK which can be changed to the MRTK Standard Shader making the portal effect work on them but therefore making the text unreadable and changing the color to black.

My question is if there is a way to keep the text readable, while making use of the stencil effect.

Thanks!

MRTK Version: 2.1.0 Text Mesh Pro Version: 1.4.1 Unity Version: 2018.4.15

Heres a picture of the text, with the MRTK Text Mesh Pro Shader and the MRTK Standards Shader:


Solution

  • The solution was to change the Render Mode to "Cutout" for the material used for the text (not for the other objects), when using the MRTK Standard Shader for TextMeshPro components.

    Render Mode: Cutout

    and dont forget to actiavte "Enable Stencil Testing" at the buttom of the material with the following settings:

    Stencil Reference: 1

    Stencil Comparison: Equal

    Stencil Operation: Keep

    How it should look like: https://i.sstatic.net/yRnK4.png