Search Unity

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

Discussion in 'World Building' started by 2darray, Jul 12, 2019.

  1. 2darray

    2darray

    Joined:
    Jun 6, 2012
    Posts:
    18
    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. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    659
    I'm seeing the same behavior too. Can confirm it only happens w/ a built player.
     
  3. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    659
    OK, this is fixed by adding the standard terrain shader to the build. Project Settings -> Graphics -> Always Included Shaders. Add Terrain/Standard.
     
  4. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    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.
     
    MichaelEGA likes this.
  5. MichaelEGA

    MichaelEGA

    Joined:
    Oct 11, 2019
    Posts:
    40
    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.
     
    Last edited: Oct 18, 2022
    Tony_Max likes this.
  6. prithwisdas2017

    prithwisdas2017

    Joined:
    Jul 6, 2022
    Posts:
    1
    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!
     
  7. tw00275

    tw00275

    Joined:
    Oct 19, 2018
    Posts:
    92
    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.
     
  8. EgoJacky

    EgoJacky

    Joined:
    Aug 15, 2017
    Posts:
    28
    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:
    https://assetstore.unity.com/packages/vfx/shaders/amplify-shader-pack-202484#description

    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.
     
    Last edited: Feb 16, 2024
  9. Tony_Bera

    Tony_Bera

    Joined:
    Feb 12, 2024
    Posts:
    2
    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.