Draw.Text doesn't work with ZTest

Avatar
  • updated

Using the following code:

using( Draw.Command( cam ) )
{
Draw.BlendMode = ShapesBlendMode.Transparent;
Draw.ZTest = UnityEngine.Rendering.CompareFunction.Always;
Draw.Text(txt, pos.ToVector3(h), rot, text, 2.25f, textColor);

Draw.Disc(pos.ToVector3(h), rot, 0.04f, pointColor);

}

The points, lines, disc, etc all draw on top of other geometry. But the Text does not.

Edit - Might this be due to the 4.2.0 performance changes to Text. I understand that some features like masking might be a real pain, but disabling depth testing customization is surely a critical feature for text.

Reporting a bug? please specify Unity version:
2022.1.16f1
Reporting a bug? please specify Shapes version:
4.2.1
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator

this was removed as of 4.2.0 in favor of a huge performance gain. more info here: (duplicate thread)

https://shapes.userecho.com/en/communities/1/topics/467-how-to-maskscissor-the-drawtext

I might look into getting this back in a future update if it's something people really need! though it's pretty nontrivial to do in a performant way

Avatar
Scott Richmond

Yeah I saw that posted just after I made this ticket. I understand that you need to keep things performant, but the lack of depth customisation for text makes the feature unusable for us. We use Shapes primarily as a powerful debugging tool to show a lot of under the hood info in the game. These things necessarily need to render on top of game geometry. So this really causes Shapes to be hard for us to use. I would imagine a good portion of your userbase might fall into the same boat as us - If you're making actual user facing game features with text you'd surely use the actual TMP components and tools, which provide a lot more customisation necessary for a game feature.

As for the depth testing itself - Isn't the requirement for this simply to add it to the MPB to be passed on to the shader? I'm unsure how this affects core performance?

One other thing: We lost quite a few hours on this, thinking this "bug" was our fault. We started using Shapes after you released 4.2.0 so we missed the note in the release notes about it. Could I please get you to consider ensuring that you update your documentation with these API flaws? Literally just a sentence under the Depth Drawing section would've saved us a lot of time.

Avatar
Freya Holmér creator

It's less about keeping things a little more performant but rather make it performant to be useful in the first place. The text feature was borderline useless before because of how much it both allocated and how slow it was. Now it's possible to use it, with the one downside that custom render features aren't supported. The portion of users who couldn't use shapes text at all because of how slow it was is far bigger than those who require the use of render features

The reason it's not just about including it in the MPB is that render features (Ztest, stencil, ZWrite, depth offset) aren't supported by MPBs. If it was that simple it wouldn't be a big deal to add it, but right now there's a whole material/asset management system to make it possible to set these as well, which comes with quite a bit of nontrivial overhead both in performance, memory, and workload on my end

But yeah, I could add a doc note about it until it's fixed

Avatar
Scott Richmond

What if you added to the API an option to let us push/pop a `TextMaterial` Material on to draw with, so that way we can supply our own custom setups for drawing text?