I am using the MeshRenderer version TextMeshPro and have found that in the Vision Simulator each character quad can cause z-fighting with each other, even if the content is transparent.
Here is an image of the issue.
Here is how it looks in the editor.
In the editor you can see the mesh wireframe of the quads and this lines up with the issue. I will say that there is a good distance between this text mesh and the opaque geometry behind it.
I would like to try replacing the shader used by the text to use Alpha Cutout instead of Transparency to see if this can resolve the issue but I found this post which makes it look like we need some post processing build script to swap the shaders. I’ve tried this and managed to make some beautiful magenta.
I have also tried using the included “TextSDFSmoothstep” shader from the Polyspatial package in the Editor but it shows me blank squares instead of the font.
What is the best way to customise the shader on device?
We’re going to be adding support for custom materials/shaders in UI text (and images), but for MeshRenderers, you should be able to copy TextSDFSmoothstep, modify that, and use it directly in a custom Font asset. However, to eliminate the z fighting, you might instead try using a visionOS Sorting Group (with
Depth Pass equal to
Post Pass, the default) containing the text MeshRenderer. That will ensure that the depth values for all the text is only written after the colors are rendered.
In 1.0.3, this requires a slight modification because of the masking component. To bypass the masking component, just connect the Multiply node closest to the Fragment block directly to the fragment Alpha. That change won’t be necessary when we release the support for custom materials/shaders on UI components.
Using alpha clipping (with a threshold of 0.5) does seem to work, FWIW, though it might appear “shimmery” on device when in one’s peripheral vision because of the foveated rendering.
Thank you for this info - it helped a lot. The sorting group solved my overlapping text glyphs z-fighting.
I also updated the shader to remove the mask and I added outline support. I found this shader has issues where it fades out weirdly at the top of the scene view/game view. I opted to swap shaders on startup and use the original TMP for edit mode for now.