MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

MixedRealityTextMeshPro Sprite shader

Open mgrman opened this issue 5 years ago • 7 comments

Describe the problem

TextMeshPro uses TextMeshPro/Sprite shader to render any custom sprites that you author. This shader does not support single pass instanced rendering nor clipping primitites. So it makes TMP sprites not usable with MRTK.

Describe the solution you'd like

Provide MRTK specific shader for use with TextMeshPro Sprite rendering.

Describe alternatives you've considered

Manually adjust the shader but it does not work and feels hacky. Proper MRTK solution would be better.

Additional context

Link to desired TMP functionality: http://digitalnativestudios.com/textmeshpro/docs/rich-text/#sprite

mgrman avatar Jul 01 '21 07:07 mgrman

Hello @mgrman, Thanks for bringing TMP Sprite Shader issue this to our attention! Can you give us a little bit more information about your Unity and MRTK setup? This will help give a starting point for us to reproduce this issue as you saw it. Did you see any warnings or errors in the Unity console when you were trying to initialize custom sprites?

elbuhofantasma avatar Jul 01 '21 16:07 elbuhofantasma

Hi @elbuhofantasma,

the use case we have, is to use ClippingBox to clip text as you scroll. For text we use TextMeshPro.

The problem is that even if you use ClippingBox and set both the TMP renderer and the sprite submesh renderer, the sprite is not clipped. image image image image

This sample was created using standard TMP and MRTK, the sprites are EmojiOne which are included in TMP.

If you need any more info to reproduce this, please let me know.

mgrman avatar Jul 02 '21 13:07 mgrman

Hello @mgrman Thank you for the detailed information! We will investigate and update this issue when the investigation is finished.

elbuhofantasma avatar Jul 02 '21 16:07 elbuhofantasma

The team and I looked at this issue earlier this morning, and determined that this is a Unity issue. So I marked it as an external bug and will follow up as we get more information from Unity. I am going to keep this issue open in the meantime.

elbuhofantasma avatar Jul 02 '21 21:07 elbuhofantasma

@elbuhofantasma Unity bug? MRTK provides own variant of the main Text Mesh Pro shader for use with clipping box, but does not provide a variant of Text Mesh Pro Sprite shader, which makes sprites in Text Mesh Pro not usable with MRTK Clipping Box.

To me it seems on MRTK to provide a variant of the shader for use with it's own features. Since Unity cannot provide a shader for feature only MRTK has.

mgrman avatar Jul 02 '21 21:07 mgrman

Thank you @mgrman for reporting this! I agree this looks like a new feature request/bug we should support. In the MRTK we should fork the TMP sprite shader and add the relevant single pass instanced rendering support and clipping primitive support.

Cameron-Micka avatar Jul 09 '21 18:07 Cameron-Micka

Hello @mgrman, I have written the shader that you have requested in PR #10096. This PR fixes the issue of sprites not clipping with the ClippingBox and not running on devices when Single Pass Instanced Rendering is enabled. I will close this issue when the PR is merged. Thank you again for your feature request!

Here is this shader in action in the editor: clipping

elbuhofantasma avatar Jul 20 '21 16:07 elbuhofantasma