Mixedrealitytoolkit-unity: Clipping primitive does not behave the same in editor and on HoloLens

Created on 29 Jul 2019  Â·  4Comments  Â·  Source: microsoft/MixedRealityToolkit-Unity

Describe the bug

I am trying to use the clipping primitive feature of the MRTK standard shader in order to clip elements when they get outside of a list. These elements are simple buttons, based on the PressableButtonHoloLens2 prefab from the MRTK. They are instaciated and their renderers added to the clipping box at runtime (using aelement.GetComponentsInChildren<Renderer>() and clippingBox.AddRenderer(Renderer _renderer) ).

It behaves perfectly in the Unity editor (since the bug #5290 is fixed). However, When I deploy the project to HoloLens 2, the only clipped element of the buttons is the text (which is not using the same shader as the other elements of the button).

A strange thing is that it seems to work well in the Hololens if an element is already in the list at start with its renderers referenced on the clipping box by hand.

Expected behavior

The clipping feature should behave the same way in editor and on HoloLens.

Your Setup (please complete the following information)

  • Unity Version 2019.1.9f1
  • MRTK 2 RC 2.1

Target Platform (please complete the following information)

  • HoloLens 2
Bug

Most helpful comment

There is a “use camera pre render” option on the clipping object. You can make a script that checks for new game objects not registered with the clipping object and add them to the stack. Unfortunately this can’t happen in the update loop since it happens in OnWillRender on the TMP object. Absolutely atrocious “feature”. It’s a pain to deal with.

All 4 comments

Hi @Bertrand75014, thank you for reporting this! Could you please see if this issue is still present when using the latest version of the mrtk_development branch? I believe this is similar to this issue https://github.com/microsoft/MixedRealityToolkit-Unity/issues/5239 and was fixed in this pull request https://github.com/microsoft/MixedRealityToolkit-Unity/pull/5291

Hi @Cameron-Micka, it is working on Hololens with the latest version of mrtk_development. Thanks!
One more little thing, the MixedRealityToolkit/TextMeshPro shader is clipping the text differently when using different fonts from the MRTK. For example, some special characters like 'àéèù¨£' are not clipped with the "seguisb SDF" font. The other fonts are not clipped at all.
However if I use "LiberationSans SDF - Fallback" from TextMesh Pro, the text is correctly clipped, when "LiberationSans SDF" is not clipped at all.
I will use seguisb without accents for now.

@Bertrand75014 that's great to hear clipping is working now! @radicalad actually encountered the same issue you mentioned above. After some debugging we found that when Text Mesh Pro encounters a character from the extended ASCII character set it adds a NEW gameobject and renderer for just that character. Which means the original GetComponentsInChildren() and AddRenderer(Renderer _renderer) doesn't catch the new renderer. So, you might have to call GetComponentsInChildren() and AddRenderer(Renderer _renderer) after changing the Text Mesh Pro text to contain a extended ASCII character.

There is a “use camera pre render” option on the clipping object. You can make a script that checks for new game objects not registered with the clipping object and add them to the stack. Unfortunately this can’t happen in the update loop since it happens in OnWillRender on the TMP object. Absolutely atrocious “feature”. It’s a pain to deal with.

Was this page helpful?
0 / 5 - 0 ratings