Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Quads not working with URP in UI?

A topic by paulstraw created Mar 29, 2021 Views: 1,016 Replies: 16
Viewing posts 1 to 12
(1 edit)

Hi there, I've been using quads successfully with the built-in render pipeline, but am currently in the process of upgrading my project to URP to take advantage of some significant mobile performance boosts. I'm hitting an issue with quads in UI, however. All of my testing has been in 2021.1.0f1.

Quads show up fine in world space STM instances, but not within UI. I set up an example scene in a fresh project with two STM instances to demonstrate this:

Is this a known issue, or am I possibly missing some sort of setup process? I tried searching here and in the docs with no luck.

Developer

Hey!


I haven't tried out 2021.1.0f1 yet and I'm about to go to bed, but my best guess is...

On the parent canvas, is "TexCoord1" included with additional shader channels? Super Text Mesh should automatically set this value, but maybe they changed something...? I can't seem to see any differences in the docs just yet though, so I can take a deeper dive into this tomorrow if that isn't the solution.

Thanks for the quick reply, Kai. TexCoord1 is selected in the additional shader channels on the parent canvas.

Developer

Okay, I'll download Unity 2021 tomorrow and see if I can find the issue. I have a feeling I know what it could be, and if it's the case, it's not anything I can fix...

If you want to test this yourself, in SuperTextMesh.cs, there's a single "#if UNITY_2017_1_OR_NEWER" line in there. If you change up the code so that directive is always true, does the bug still happen? This directive is so older versions of Unity wouldn't crash when trying to render multiple materials on a CanvasRenderer, as they weren't supported. So my first guess is that Unity 2021 somehow thinks it's older than 2017 and isn't rendering quads because of that.


Another quick idea, do quads render when you build the project? I've had similar reports in the past where outlines don't render in-editor, but in builds they render just fine. I doubt it's this (and I hope it's not this...) but it's something I'd check anyway.


Just today a few friends were telling me that Unity 2021 is a beta of sorts, so it's possible this could be something out of my control for the time being, just as a heads up! In an absolutely worst-case scenario, I'd write a script to pin non-UI objects to the UI, but hopefully it won't have to come to that.

I tried removing that conditional, but it didn't seem to have any effect. Quads don't seem to render in builds either for my main project (iOS build), or test project (Mac build).

Definitely understand 2021 is hot off the presses and there might not be much you can do at this point. I'd been holding out for point light shadows, but now that they're in, URP perf gains are just too much to pass up. Worst case, I can just rework things to avoid using quads until you're unblocked. Thanks for looking into it!

Developer

I really should be asleep - but I keep thinking about what could be causing this (even though this is a new version of Unity) Maybe... I'm guessing changing the canvas type from screenspace to worldspace doesn't make a difference?


In an extremely desperate scenario, I could write a script that automatically uses custom STM events to spawn new STM objects for characters that require additional materials, I think... Yeah, it should be doable, just not really favourable.

I'll keep thinking about what could be causing this, I'm not finding any issues related to CanvasRenderers and multiple materials on Google just yet, but 2021 iiiis pretty new. Hopefully this will be one of those issues that just solves itself, but I could file a bug report with Unity... I'm just not sure if this is my fault or Unity's just yet

Yes, that's correct, no change from switching between screen/world space. The original spot I noticed this was in world-space UI.

Developer (4 edits)

Replying here since itch's reply chain thing is getting kinda crazy... hopefully you see the notif.

Downloaded Unity 2021 and made a URP project and something is definitely up here.

What I find most interesting is this:


This above screenshot is regular text, and...


This is UI text!

I'm going to assume this is the exact same issue you're having... for whatever reason, STM is grabbing the text as a mask texture instead of the active quad. You can see the outline on the first pic's quad is totally wrong, it's normally supposed to be an outline of the quad like you would expect. On regular text, it's still rendering correctly anyway, despite this. But on UI text, the incorrect mask is being applied! The little bit of the quad that overlaps with the incorrect mask is rendering. The verts are using the right UVs, but the wrong texture... and the second material used for quads appears to have the correct texture, despite this. I'm having a bit of trouble with 2021's material inspector, though.

I'm currently digging through my own material generation and shader code to figure out what could be causing this in Unity 2021/URP, so... hopefully something will click, soon


Yeah, as I shift Materials around, it seems to always use the mask of the first material on the mesh renderer...


Yeah, for now it might just be a Unity bug? Everything seems to be in-line, materials-wise. The mesh renderer has 3 submeshes, 3 materials, each materials has the exact data it should have... but both the meshrenderer and canvasrenderer are using the wrong non-main texture data on submeshes besides the first one. If I flip the order of the Quad and Text materials on the mesh renderer:


...We get the correct outline for the quad! (Ignoring everything else being broken)

I'll keep thinking about if there's anything I'm missing, but nothing is striking me just yet

Very interesting, thanks for the in-depth description. The screenshots you posted look just like what I see in the editor, so I'm glad to know it's not just something on my end, at least.

Developer (1 edit)

Downloaded Unity 2021.1 the other day and made a scene with URP and this seems to work now!

Wow, thanks for the follow-up after so long, Kai!

Can you clarify what version of 2021.1 you're using where you see this as fixed? I just tried with 2021.1.14f1, and sadly I'm still seeing the same behavior in both my test and real projects.




Developer (1 edit)

Gah! Shoot that's embarrassing. The version was 2021.1.13f1. I think I... forgot to test in UI mode, so it's probably exactly the same. Well... back to trying to figure this out I guess, really sorry about that.

(1 edit)

Ah, bummer. I know the feeling all too well. 馃檭

Do you think 2021.x is now mature enough that it's worth investigating this more? I would quite like to get this issue resolved, if possible.

Developer

Yeah, I mentioned the bug on twitter and Unity told me to DM them, so I did... we'll see how it goes, I guess.

Developer

Alright... just got an email so here's what it said...

"""

Thanks for getting in touch, we actually know about this issue and you can check the status here:

https://issuetracker.unity3d.com/issues/the-first-submesh-texture-is-overridden-...


he case is resolved and should be fixed in Unity 2022.1.0a3 and the versions above. We are currently also evaluating requests for backporting the fix to 2021.2, 2021.1 streams.

"""


*Looks at the calendar* well. Hopefully that "backporting" happens. I didn't even know Unity had a 2022 version, the 2021 build is still clearly in beta... I'm going to keep emailing them, so I'll post more updates as it happens. Glad to know this issue finally isn't my fault, though!

Thanks for continuing to follow up on this, Kai. Indeed, hopefully that backporting ends up happening!

Status is updated to Fix In Review for 2021.1.X

So here's hoping it shows up in 2021.1.21f.