Terrain and NavMesh Not Working in Build But Does in Editor

Hi all, I’ve got a build-only (PC) bug in my 3D RPG that I’ve been investigating all week, and could really use some help. The core issue is that the Terrain within my “combat arena” prefab is not visible and/or missing in a build. The rest of the Instantiated prefab the terrain is a part of all show correctly, including props and water plane. An additional related build-only bug is that NavMesh.SamplePosition calls to the navmesh that is usually at the location of the terrain are coming up as misses, causing any characters to not be placed on the terrain.

I’ve investigated and have not observed errors with the navmesh building process, so it feels safe to assume that the terrain is just missing or misplaced at the time I normally build the navmesh surface (being built at runtime with NavMeshComponents).

Everything works as it should be in the editor (Version 2018.4.0f1). Below is an image of the build bug, and the expected behavior in the editor.


Below is what the Arena prefab and terrain look like in the Scene view:

Some other information:
-The game takes you from an RTS “field” terrain, into this combat arena, JRPG style when you hit an enemy group. This is still in the same scene, I’m just showing/hiding the arena and moving the characters to locations on the arena terrain. The field terrain uses the same materials and textures as the combat arena terrain, and that is working as expected in the editor and build (visuals, position, and navmesh are all present).

-The Terrain is using a modified material/shader as we have a fog of war system (modified from the UFOW asset - Ultimate Fog of War | Utilities Tools | Unity Asset Store). I haven’t had any issues with terrain to this point in 2 years of development, so it leads me to believe there is something different about the arena terrains we recently created, not necessarily with the material/shaders itself. However, in the build output file I noticed the following Shader warning related to terrain:

WARNING: Shader Unsupported: ‘Hidden/Nature/Terrain/Utilities’ - All passes removed
ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: ‘Hidden/Nature/Terrain/Utilities’ - Setting to default shader.
Shader ‘Nature/Terrain/Diffuse’: dependency ‘Details1’ shader ‘Hidden/TerrainEngine/Details/WavingDoublePass’ not found
Shader ‘Nature/Terrain/Diffuse’: dependency ‘Details2’ shader ‘Hidden/TerrainEngine/Details/BillboardWavingDoublePass’ not found
Shader ‘Nature/Terrain/Diffuse’: dependency ‘Tree0’ shader ‘Hidden/TerrainEngine/BillboardTree’ not found
Shader ‘UFoW/Terrain/Standard’: dependency ‘BaseMapShader’ shader ‘Hidden/TerrainEngine/Splatmap/UFoW-Standard-Base’ not found

-To attempt to fix the above, I’ve tried including all shaders I could find mentioned to the “always included shaders” list in graphics settings. I am still receiving the warnings after many (long) builds. The hope was that the terrain material was just not displaying due to this, but that doesn’t seem to be the case?

-DrawInstanced is set to false on all the terrain. I notice in the editor when I turn that on as a test, I get the same visual result. Perhaps the build is changing that setting or trying to do something that causes the invisibility?

-I’ve used unity cloud builds, local builds, and both with Debugging enabled. All build paths give the same, incorrect, behavior.

-I’ve added cheats to try to allow me to move the terrain after the fact/before creating the navmesh manually. In the editor I can move the terrain way off screen, and the terrain will move back into position with my cheats. These do not work, in the sense that the terrain does not show up, but they are firing and detecting the Terrain game object (showing that the terrain object is present and not destroyed).

-I moved the TerrainData into a Resources folder, in case the data was not coming through, but that didn’t seem to make a change.

The builds for making our game can take up to an hour normally, and much longer if I try to force all of of these additional shaders (lots of shader variants, it turns out, in those UFOW shaders)

I’d appreciate any and all leads on things I should be trying. Thanks so much for any help, I’ve definitely been struggling!

After our quick conversation on twitter yesterday, did you manage to get somewhere with that?

Did you find anything in the log, any meaningful trace in it that would allow to track down the culprit, or at least narrow down the potential offenders?

I’m happy to report that I have a build that is working! I tried a number of things at once so I am now trying to verify exactly which change was the fix, and I’ll confirm as soon as I verify with a future build. But here’s what I did that probably had an effect:

-I added all of the Arena Prefabs into a resources folder (The prefabs that include the terrain as a child in addition to all other props). Those prefabs should have been included without doing that, and all the other props seemed to be present in the previous build, but I think this ensured that anything not referenced was included in the build.

Secondly, I added some calls to ensure the terrain “drawInstanced” property was set to false on all of the terrain objects. drawInstanced should have already been set to false, but this would fix any unexpected changes from outside sources.

Oddly, the WARNING: Shader Unsupported: 'Hidden/Nature/Terrain/Utilities - all passes removed lines were still present in the output, but they only appear when combat started / the arenas objects were set to active. I’m not sure what’s going there, but it doesn’t seem to be the source of the original problem with terrain visibility.