Text glitching

Does anyone know what could cause some kind of text glitching in visionOS with PolySpatial? I am not so experienced with Unity but I basically have a Canvas with a solid background image and texts on it. When I run it on the device, the border of each letter looks kinda too sharp and moving/glitching around.

Can you record this and share the settings of the canvas, text, and font

What version of Unity/PolySpatial are you using? VisionOS 2.0 introduced support for the fragment derivative functions in shader graphs, which we use in PolySpatial 2.X/Unity 6000 to improve the quality of text rendering. We didn’t backport that to PolySpatial 1.X/Unity 2022.3, because we want 1.X to maintain compatibility with visionOS 1.0.

However, in both versions, there are a couple font material properties (Gradient Scale and Sharpness) that affect text sharpness, and decreasing the sharpness (or the gradient scale) may help.

I am using PolySpatial 1.3.11/Unity 2022.3.43f1

Thanks for the tip with the gradient scale, I will play around with that tomorrow when I have again access to a device, maybe I can also provide a video/image that shows the issue then.

So here is how the text looks on the device. The font is an SDF font if that is somehow relevant and here are the configs:

Video: https://tempuno.com/videos/TextGlitchUnityVision.MP4



The aliasing on the text is definitely something that would be improved if you upgraded to PolySpatial 2.X/Unity 6000, which is generally what we would recommend.

I upgraded to Unity 6 and PolySpatial 2.X and this indeed fixed it, thanks! I only see it a bit on the side if I focus another element but I guess that comes from foveated rendering and cannot really be fixed, right?

I also recently made a post about another issue with the immersive spacing not closing after leaving the safe area of 1.5m - do you maybe also know a fix for that? Unbounded Volume Camera - Safe Area / Progressive issues

I think there are probably opportunities for us to improve this, but we haven’t gotten around to experimenting with it yet. You could definitely try adjusting (decreasing) the Sharpness property in the font material (this is in the included default TMP material, Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF.asset), after showing Debug Settings:

You can also use a custom shader graph for text, taking the included default shader graph (Packages/com.unity.polyspatial/Resources/Shaders/TextSDFSmoothstep.shadergraph) and modifying it. The main part to look at is the custom function node in the center (ComputeSDFAlpha), and in particular these lines:

float pixelSize = abs(ddx(UV0.y)) + abs(ddy(UV0.y));
pixelSize *= TextureHeight * 0.75;
float scale = (1 / pixelSize) * GradientScale * (Sharpness + 1);

What this does is use the fragment derivative functions and the inputs (GradientScale, Sharpness) to determine the step size (which is the inverse of the scale). The fragment derivative functions do incorporate foveation; the area outside the fovea will have a lower resolution and thus a larger pixel size with respect to the UV. So, decreasing the GradientScale or Sharpness will decrease the scale (increase the step size), as will increasing the pixel size.

If you do find a change that works for you, let us know! We may be able to incorporate it into the shader. This shader is really just a direct translation of the original TextMeshPro mobile shader, and wasn’t designed from the beginning with XR in mind.

Sorry, I’m not sure what’s going on in that case.

Thanks for the additional help! For the other issue I found a workaround today, I will add this as a solution to my post.

1 Like