Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Trying to get an outline working on a custom font in Unity 6000.1.6f

A topic by GamerReality created 33 days ago Views: 224 Replies: 7
Viewing posts 1 to 8

I'm in Unity 6000.1.6f with the latest version of Super Text Mesh and working on a VR project for Windows and Android builds.

I'm trying to set up UI text using two fonts I've downloaded, Playpen and CherryBomb. The text should be white. The following issues happen with both ttf texts:

Whenever I use any of the STM outline shaders, the outline's color overpowers the text color. Lowering the width only moves my text down; I'm not even sure why. 

When I try to use the STM Ultra shader, the text gets all these weird artifacts and eventually disappears. That's been happening to me since I started the project in Unity 2023.2, but I've been putting off the UI in my game until now.

Thanks in advance

Developer

Hey!

Are you sure this is the Ultra shader? Normally the UI on the inspector there should change when it's been applied, and in your screenshot it's showing the configuration for the Universal shaders. (Additionally, the rendering going on here is what I would expect the Universal shader to do in this circumstance, where it's only rendering the final pass of the outline and ignoring the text pass) So please try clicking the "Ultra" button next to the shadier field on the inspector to apply that shader to your material. Please let me know if that makes a difference.


If nothing changes when pressing that button and you don't get any errors in the console, try saving your scene as that will force STM to rebuild the material settings.

Hey,

Thanks for the speedy reply as well as your incredible asset. I look forward to using it and making my game stand out. 

You’re right, the screenshot is showing the universal shader and it’s overpowering black outline. I didn’t take a screenshot of the Ultra shader being applied because it had made the text invisible by the time I was ready to screenshot. I’ve noticed that saving the scene seems to help in other situations, but unfortunately it wasn’t the fix this time.

Developer

Ah got it, so yes for the Universal shader there, that is just what it does and why I made the Ultra shader. (But apparently it works fine in builds?)

Do you have any screenshots of the weird artifacts in the Ultra shader? It sounds like... hm, the material/font is changing, but the UVs don't update to match immediately which they really should. Saving *should* usually correct that, but that's odd... if an error showed up that got cleared (an error I would like to fix btw), STM might have entered a stalled state. If you select the object in the hierarchy and press ctrl+d to duplicate it, does anything change on the new object created?

I've reopened the project today. No errors or relevant warnings, but this is how the ultra shader is looking. I can finally see an outline, but background objects are clipping through it somehow. I'm realizing now that the text is disappearing when I have the ground plane in the background, so it's the same problem there.

It's almost like my text is somehow so low in some kind of layers that it's not showing up over an outline (as seen in my first screenshot, where the text is all black), and it's not being drawn above game objects in the scene. This isn't exclusive to the cherrybomb font; this happens no matter what font I switch to.

I'm running mostly default inspector settings. I don't know what would have caused this:


That seems to be the problem, but as I just went to look into your samples to bring one to my scene, the text objects I've attached screenshots of are now rendering fine, except I can't get any outline on them even though they're using the ultra shader. I'm sure they'll revert to their old problem in a few minutes, though.

Developer

Ok those screenshots and description help a lot! Here's some things to try:


In the inspector try disabling ZWrite. This is basically there just to make it so Ultra shader outlines don't go over the previous letter, but if your outlines are thin enough you may as well disable it, it can *sometimes* cause something like this to happen if text is is a 3D space like this, rather than being on a UI. I feel like this shouldn't be happening with ZWrite on though, so if this solves it I'll look into how to prevent it from being a problem in the first place.


I'd also check out the rendering order of those objects in the background, is their render queue above 3000? You can try changing the render queue value on STM's material settings to something higher!


Do you get a result similar to what you want when using the Universal shader (plain version with out outline) then adding an outline through STMMaskableGraphic? That's also an option for rendering outline effects now, too!

Hey thanks for replying, I didn't see it and got busy with other things as we're trying to launch the game in less than two weeks. 

Toggling ZWrite and changing the render queue didn't fix it unfortunately. I'm seemingly able to use STMMaskableGraphic on one text field that I was testing real quick, but I also remember STMMaskableGraphic not working a month ago when troubleshooting this.

I'd also like to ask about runtime optimizations since I've been on a war path to get this game to run well on the Quest 2. I've learned that batches have been killing me because of the open world type layout of my game. Is there anything in your package to help reduce batches? Like somehow instancing text fields or their outlines? I think each STM component is a draw call and double the ones that use an outline component. Also, maybe you have a function to stop rendering text a certain distance away from the camera? If not, I'll probably remove any outlines and also set up a component on each canvas that enables the gameobject only when the camera is nearby.

Developer

Hm, STM has its own system to combine materials, but on the Ultra shader, at least for now, proper batching is disabled due to how it breaks vert indices for outline and dropshadow effects. (Will experiment with replacing this with index data stored on a UV channel at some point, I think there might be one UV channel free *maybe* so that would possibly allow batching if changed) If you're not using the super smooth outlines, you could try the default Universal shader instead? It's more lightweight compared to the Ultra one too, especially since I wasn't able to complete the optimization pass on the Ultra shader I tried earlier this year. (More on how to still get the outline effect with this soon...)


The material combiner system reduces draw calls if two meshes share the same basic text settings. So same font, same material, etc. Effects like basic color tags do not matter, as those are applied with vertex colour, but the"texture" color tag will make a new material. From your last screenshot, this seems to be the case already, though... So I'm not entirely sure why each component is causing a new draw call. A culling script is a great idea though regardless! (You can also try disabling the STM component but leaving the meshrenderer & meshfilter on, that could potentially give a performance boost, but I have not tested this)


STMMaskableGraphic may help, all it does is let STM behave as a "MaskableGraphic" component properly, so that could be the cause of the Z issue here, potentially. I'm not sure what would have made it not work a month ago, so it's worth another shot! That should hopefully enforce some rendering order features. Additionally!!With STMMaskableGraphic, you can use a basic shader like the default Universal one, and then use Unity's "outline" component to render an outline that way. I also did work with LeTai's assets to get their asset "True Shadow" working together with STM, which can produce a batched, smooth outline if configured properly.  https://assetstore.unity.com/packages/tools/gui/true-shadow-ui-soft-shadow-and-g...


Another small thing to try is, is anything different if you nudge the text forwards a bit? There could just be an issue with the Z buffer somewhere, so if the text and background are on the same layer, I could imagine it getting scrambled together with VR rendering, somehow. (The text is *supposed* to push itself forward a bit with effects like this, but I can see VR as being an edge-case I didn't account for. There's a manual "ZDepth" value in the Ultra shader that might give a better result if adjusted, I can send shader variants soon but I think the Universal shader should be tried first)