2D Text not reacting to URP light sources?

I’ve been trying to manage a little UI System. I have the URP installed so I can add some fancy lighting to my 2D UI system (The entire game is essentially a UI system). The lighting with URP doesn’t seem to affect TMP text objects.

Even after following this thread - Plans For Hdrp Compatibility For Tmp? page-3#post-7463915

I was able to obtain specific URP shaders for TMP objects, but the objects still wont be affected by any 2D URP lights. I have tried:

-Tweaking the Shader settings in the editor
-Changing the Canvas to occupy World Space
-Making my own custom Material (Bad Idea)

I’ve been caught on this for quite a few days, am I missing something? I’ve attached example of what I am dealing with.

To use TMP with SRP, you will need to make sure you are using the latest release of the TMP package which is version 3.2.0-pre.3 for Unity 2020.3 or newer.

You will also need re-import the TMP Essential Resources which contain the updated SRP shaders. To re-import the TMP Essential Resources, go to “Window - TextMeshPro - Import …” menu.

Once the TMP Essential Resources have been updated, you will see new shaders available which includes both URP and HDRP sets of shaders including Unlit and Lit shaders.

1 Like

Thanks for the quick reply! Unfortunately my 2020.3.32f1 version of Unity only allows me to have TMP Version 3.0.6. It will not allow me to update it. I’m going to upgrade the project to 2021.3.4f1 to see if that allows me to update it from the package manager.

Version 3.2.0-pre.3 is a preview release. You will need to enable show preview packages in Package Manager in order to see it but you will most certainly be able to use it in 2020.3 or newer versions of Unity.

1 Like

I have [Enable Pre-release Packages] Turned on, and I can see other items in the Unity Registry marked with the yellow Pre label. However there is still only TMP 3.0.6 marked with the Release sticker. There aren’t any indicators pointing me to the preview release. I am rather confused, I’m even using the guide at:
https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.2/manual/index.html
Apologies for the inconvenience, normally I’d find a Youtube tutorial, but most people seem to be using 3.0.6

[UPDATE] : It appears that Unity Version 2021 never actually shows the pre release package for TMP 3.2.0. I downgraded back to 2020.3.32 and found that after uninstalling TMP the reinstall allows you to “See other versions”. Currently fixing all the bugs from the downgrade

[UPDATE 2] : Unfortunately It did not work, I installed the pre release and re-Imported but the Text is still unresponsive to URP 2D Lights.

8185239--1066458--tmp2.png

Make sure that you are using one of the newer shaders which in this case would be the SDF URP Lit shader as seen below.

8185824--1066593--upload_2022-6-7_1-21-54.png

Again, thanks for helping me out with this. Here is an attachment with what I’m seeing right now. I have TMP 3.2.0-pre.3 And the Shader SDF URP LIT is applied. The only distinction I can make is the base material for your text is SDF - URP LIT. Could this be the cause? If so, I can’t seem to find that specific material in the TMP Folders.

8187288--1066875--tmp3.png

You should definitely be using the SDF URP LIT shader on your text object.

Any reason you are using a component that works with the Canvas as opposed to the normal component that works with the MeshRenderer?

Getting lighting to work correctly with the Canvas can be challenging even when using WorldSpace render mode.

I just tested with version 3.2.0-pre.3 with the above shader with normal component and this works as expect as seen below.

8188107--1067040--upload_2022-6-7_15-52-53.png

1 Like

I tried your suggestion and used the non UI Text mesh pro alongside the normal TextMeshPro (MeshRenderer).
Both with the correct shader on. Neither reacting to the 2D lighting system. Here’s another file of what I see.
(I’d still want to use the UI Components in any case as the project is mostly 2D UI)

8188470--1067106--tmp4.png

To those of you wondering, I found an answer (Although it wasn’t the one I was hoping for). TMP does not seem to work with the 2D URP lighting system. By switching back to the base URP lighting system (Which doesn’t work as efficiently for 2D projects) I found that the TMP objects, specifically the ones with mesh rendering components, work just fine.

Unfortunately I don’t have a workaround right now, I’ll keep messing around with things until I find a solution. Here’s an attachment of what it looks like without the 2D Renderer on, The TMP is now responsive to the light, at the cost of not having the canvas light itself correctly. Rip

Good find. I’ll take a look as soon as possible to try to figure out why the 2D Light don’t work as expected.

1 Like

Excuse me for bothering again

Have you figured out a way to show “See other versions” on 2021 LTS again? @IsDarKsly

Is there another way to downgrade to a certain package using 2021 LTS? @Stephan_B

-------------------EDITED------------------

Never mind, here it is:

or force downgrade:

I encountered this problem in my 2D project a while back. I eventually decided to use the Universal Renderer over the 2D Renderer.

Before the switch, however, I was able to come up with a workaround for this problem. What I did was open up the “TMP_SDF-URP Lit” shader graph and change the material in the graph inspector from Lit to Sprite Lit.

If you want to keep the original Lit shader graph intact, you can duplicate the file, make the new changes in it, and rename it to something like “TMP_SDF-URP Sprite Lit”.

I didn’t do much experimenting so I can’t guarantee if you’ll encounter any new errors down the road. Hopefully this fixes your problem in the short term until an official bug fix is released.

3 Likes

Anything new on the 2D lightning problem?

Oh my god, dude. You saved me! Thanks so so much for this… it’s so dumb, really.
Please, Unity developer Stephan_B, if you’re still working at Unity: Fix this! It’s 2 minutes work, just copy-paste the URP Lit shader and set the Material to “Sprite Lit” instead of “Lit”. This just cost me 2 hours of research. Jesus.

1 Like

Hi there. Thanks for the info @Metamor . Can someone from Unity please indicate whether using the “Sprite Lit” material is the preferred way to workaround (or fix) this problem? I’m not finding any bug report that matches this problem in the unity issue tracker.

1 Like

Ty, saved me a lot of headache.

This seems to work nicely, although the text vertex colors needs some rework, as some colors got darker and almost black…

THANK YOU!