I don’t think people at Unity noticed this bug that is going on for months already. The Unity terrain on mobile (android and ios) has smoothness ignored and is completely off the charts. It’s been reported in the forums multiple times and I even modified the default shader myself to fix it (just set the smoothness float to 0). But I download even the new alpha version and the bug is still there.
Reading the URP shader it seems that it’s getting the smoothness value from the Alpha of the texture. That’s why if you use ASTC compression, the terrain looks horrible, but if you switch to RGB24 (no alpha) the bug seems to be gone. (Not really, and you lose all compression on mobile using that format). It doesn’t matter that your texture has no alpha whatsoever, if you set it to ASTC, the shader will ignore your smoothness value and set it to 1 (highest value) because your alpha in the texture is 1 obviously. This bugs ONLY happens if you switch to iOS or Android. It seems that it works in a standalone.
Additionally, you should just replace or add a new shader and remove most of the Lit or Simple Lit stuff. Terrains usually don’t need specular highlights, roughness, smoothness or whatever you want to call it. If you do, it’s expensive. Which kills mobile performance. And most of us do not need it.
Internally if you add the default URP Terrain shader it loads so much junk is crazy on mobile. Load the memory profiler and find that the terrain is loading about 4 shaders, including URP Lit (not even simple lit) and it takes over 140 mb of RAM just with the shaders and nothing else.
You should have a simple lighting terrain shader in URP, but at the bare minimum, fix the current bug on the existing shader.
Thanks for the notes about this issue! Would you mind submitting a bug report about it? Looks like the similar issue in the thread you linked was resolved, but we still have something else to look into.
For a quick fix on the Terrain shader, when the texture has no alpha even if compression is set to ASTC, smoothness should be zero on mobile, not 1.
For a better fix, please take a look at the URP Terrain shader. It’s loading URP Lit and a bunch other shaders behind the scene taking over 140mb in a mobile device just on shaders. URP Terrain should at maximum load URP Simple Lit, not Lit. And I honestly think it should be drastically trimmed for mobile because a terrain usually does not need most of the PBR lighting on a mobile device, and neither can afford 140mb on shaders for a single terrain inclusion. To give you an idea of the craziness, my 4kmx4km terrain with 4 textures takes about 1/5 of the RAM of that single URP Terrain shader.
I’m having this issue also. After switching from ETC to ASTC almost every texture in the scene became glossy. Will be reverting back to ETC for the time being.
As someone that just recently switched to the latest stable (final) version of Unity (2022.1.1f1,) switched to ASTC compression for the textures, and also built my VR game into a standalone .apk for Quest 2, I also experienced this same exact issue a couple of days ago. The funny and strange thing is, I hadn’t poked too much into it yet to discover that this was the case, and I only found this thread when searching google for “unity terrain unlit shader urp,” as I just tried to make a custom terrain material in my URP project to be unlit, noticing that Unity only has a single terrain shader, which is lit.
Hope a fix for this can be pushed out fairly quickly.
I also apologize if this seems like a useless bump. I didn’t intend that at all, but after posting I feel as if it is superflous, albeit relevant.
I have been looking into this bug and it turns out that what is happening is that the shininess is controlled by the alpha channel if the diffuse texture on the terrain layer has an alpha channel. So if you switch from ETC to ASTC, Unity is by default giving the ASTC version an alpha channel value of 1.0f. The way the code is now, when shininess is set by the alpha channel, then the value of the shininess slider is ignored.
A possible fix could be just a toggle in the Inspector “override shininess with alpha” so you can enable/disable.
I suggested that myself on the bug report @mattb-unity to ignore the alpha channel. Also in settings if you disable alpha in the texture it shouldn’t think opaque = shinny. Aside from that, why would you want shininess in a terrain for most cases? Lastly, why do you use URP Lit under the hood for terrains in mobile instead of URP Simple Lit? Heck, why do you even use another shader for terrain because it’s loading a ton of crap shaders into ram for a cell phone just by including a simple terrain in your game. You should have a much simpler shader for mobile devices.
Yes, the import texture settings. You have a Alpha Source, and Alpha Is Transparency there. Setting it to ignore transparency should not make it shiny in the terrain.
But I guess the most user-friendly option would be to have the option in the terrain texture settings itself of “ignore alpha” or “ignore shininess” or whatever you want to call it. Otherwise, we are stuck with ETC compression and we can’t use ASTC compression.
In 2023.1 I’ve added an option in the layer “Smoothness Source” so if your texture has an alpha channel, you can choose to have smoothness sourced from a constant, or from the alpha channel of the texture.
I’m on 2021.3.21 and needed a fix. Simply setting Alpha Source to “None” in the texture import settings didn’t fix the issue for me.
The only solution I found out to work was the following:
Re-export your texture as a png image WITH an alpha channel that contains full transparency (if you do it with the gimp make sure to check the png export option “Save color values from transparent pixels”)
In Unity set Alpha Source to “Input Texture Alpha” and leave “alpha is transparency” unchecked.
And voilà, no more horrendous glossy terrains. What a relief.
Yeah this approach works well. For textures without an alpha channel, Unity will give it an alpha channel (if you select an RGBA texture format) that is fully opaque – which is an unfortunate thing for how this terrain layer stuff works.
No, sorry. This fix added data to the serialized format of the terrain layer so it can “remember” your alpha channel settings. We generally don’t want to backport changes to formats like that.