Using terrain.drawInstanced in a build - 'Shader unsupported: Hidden/Nature/Terrain/Utilities'

Hello! I’m having a rendering problem with my (fancy, new) Terrains, but it only occurs in a build, and only if I’m using the new “draw instanced” feature.

(Editor/Non-instanced: works, Editor/Instanced: works, Build/Non-instanced: works, Build/Instanced: visual bug)

The result is that all of my terrain has the correct shapes, but it looks like a Standard material with an all-black surface, but it does appear to have correct normals (so I guess it’s not transferring the terrain’s visual properties correctly).

This is the first warning I get in a build where the bug occurs, which seems relevant:

WARNING: Shader Unsupported: 'Hidden/Nature/Terrain/Utilities' - All passes removed

I’m generating all of the TerrainData with the (also-new) CopyActiveRenderTextureTo functions, so maybe that’s somehow related? This is on Windows 10, DX11.

I’m using Unity 2019.1.0f2 - so maybe this has already been fixed in a later version? I searched the changelogs for 2019.1.1 up to 2019.1.9 for terrain related stuff, but I didn’t see anything that felt definitely-related to this case.

Thanks!

2 Likes

I’m seeing the same behavior too. Can confirm it only happens w/ a built player.

OK, this is fixed by adding the standard terrain shader to the build. Project Settings → Graphics → Always Included Shaders. Add Terrain/Standard.

13 Likes

I added Terrain/Diffuse, Terrain/Standard, and finally Terrain/Specular. It wasn’t until the last one that my terrain started appearing. What’s strange is that I ran some test and in once instance without these added, the terrain appeared fine. In another, it did not.

My terrain are stored in scenes which I load at runtime asynchronously. It seems like in some instances Unity is able to examine the scene and add the correct shaders, but in others it is not. The only difference between the two tests were the number of scenes in the build. The tests where the terrain appeared there were only two scenes; the test where there were 5 scenes didn’t work.

Maybe when you have more than 2 two scenes Unity doesn’t try to figure out which shaders the scenes need? I don’t know, it seems like it could be a bug.

1 Like

Been looking for this for a while. Thank you! Most answers just tell you to turn drawInstanced off but when you do that the terrain doesn’t look as nice and doesn’t reconnect properly with neighbour terrains when you move things around.

EDIT: I was procedurally generating my terrains so I also had to make sure there was a terrain in the scene with drawInstanced turned on when I built the game.

1 Like

In my case, I have deselected the Draw Instanced and also added Terrain/Diffuse, Terrain/Standard, Terrain/Specular. But none worked for me. The fact is that my terrain is being created during runtime and none of the solutions that you guys have provided seem to work for me. Any help would be greatly appreciated!

Since you’re creating terrain at runtime, you’ll need to include at least one terrain in a scene in your build, or Unity will strip those shaders from the build.

It doesn’t have to be a scene that the player ever goes to. You can make a new scene with just a terrain in it, open Build Settings and add it to the list of scenes that will be included.

All the solutions in this thread didn’t help for me. Maybe because I am using URP

In my case, I had to use a Custom Terrain Shader that allows GPU Instancing.
I used the TerrainSimple material from this Package:

I edited the Terrain Simple, Terrain Simple AddPass and Terrain Simple BasePass Shader to support GPU Instancing. For this edit, I used the Amplify Shader Editor. After that, I checked GPU Instancing on the Terrain Simple material and applied the material to my terrain.

I also placed one Terrain inside a Scene, just to make sure, because my game is spawning them.
And I added the three new shaders to be always included in the Project Settings.

Tested it with a Linux and Android Build, it’s working so far.

i have Terrain/Diffuse, Terrain/Standard, Terrain/Specular. in my always include but i still face the error and i dont know how to make a shader can someone help please.