World Terrain Material Visible in Editor and Standalone, but Gray in Packaged Game

Unreal Engine Version: 5.2.1
Cesium for Unreal Version: 2.6.0

Hello all, I’m currently experiencing an issue where the Cesium World Terrain shows the expected terrain material in the editor and standalone modes, but shows up gray when packaged.

Outliner setup:

  • CesiumCameraManager
  • CesiumCreditSystem
  • CesiumGeoreference
    • Cesium OSM Buildings
    • Cesium World Terrain

Packaging Settings:

  • Use Pak File (I’ve tried with this ticked and not ticked)
  • Share Material Shader Code (I’ve tried with this ticked and not ticked)
  • Additional Asset Directories to Cook
    • /CesiumForUnreal

Log Output - Note: These errors do not crash the game or cause instability

  • Error: Loading a material resource None with an invalid ShaderMap!
  • Error: Tried to access an uncooked shader map ID in a cooked application
  • Warning: Invalid shader map ID caching shaders for ‘M_CesiumBaseMaterial’, will use default material
  • Can’t compile M_CesiumBaseMaterial with cooked content, will use default material instead
  • Warning: \CesiumForUnreal\Content\Instances\MI_CesiumThreeOverlaysAndClipping: Failed to compile Material Instance with Base M_CesiumBaseMaterial for platform PCD3D_SM6, Default Material will be used in game.

For whatever reason, the M_CesiumBaseMaterial must not be getting cooked or behaves differently, but I’m unsure because it works just fine in the Editor and Standalone modes. I’ve made sure to include the \CesiumForUnreal as additional assets to cook, so I would assume that it is getting cooked, but somehow not linked when packaged.

Any help or suggestions would be greatly appreciated. Thank you

Hi @matthew.king, welcome to the community!

What platform are the packaging for? It looks like probably Windows, based on the mention of PCD3D_SM6. Is that right?

I have seen some problems with the water material in packages games in UE 5.2 (5.3 and 5.4 seem to have fixed the problem). Areas that should be water are instead plain grey. If your tileset materials are missing entirely, though, including in land areas, then that’s quite strange. I think the first thing to check is whether you have the same problem when packaging the Cesium for Unreal Samples project.

Hey Kevin, thank you for reaching out.

Correct, I am building for Windows.

I went ahead and downloaded the Cesium for Unreal Samples project from your github and ran it as configured. I just opened the uproject and attempted to run in editor, standalone, etc.

In the editor, the behavior was as expected, I saw the water, land, everything you would expect.

However, in standalone, I received similar log warnings as before and some additional ones so I’ll post the log below. The behavior this time was gray where water was expected, and the land tiles would pop in and out between gray and terrain when I changed my altitude

LogPlayLevel: Warning: UAT: LogShaderCompilers: Warning: Failed to compile Material /CesiumForUnreal/Materials/M_CesiumBaseMaterial.M_CesiumBaseMaterial (MI:/CesiumForUnreal/Materials/Instances/MI_CesiumThreeOverlaysAndClippingAndWater.MI_CesiumThreeOverlaysAndClippingAndWater) for platform PCD3D_SM5, Default Material will be used in game.

LogPlayLevel: Warning: UAT: LogMaterial: Warning: Cooking a material resource (in M_CesiumBaseMaterial hierarchy) that doesn’t have a valid ShaderMap! Shadermap pointer is null.

LogPlayLevel: Warning: UAT: LogShaderCompilers: Warning: Last Error 206: Failed to create directory for shader debug info ‘C:/Users/[pc_name]/Downloads/cesium-unreal-samples-main/cesium-unreal-samples-main/Saved/ShaderDebugInfo/PCD3D_SM5/M_CesiumBaseMaterial_854a508b588320f2/Default/FCesiumPointAttenuationVertexFactory/TBasePassPSFCachedVolumeIndirectLightingPolicySkylight/0’. Try enabling large file paths or r.DumpShaderDebugShortNames.

LogPlayLevel: Warning: UAT: LogInit: Display: LogShaderCompilers: Warning: Failed to compile Material /CesiumForUnreal/Materials/M_CesiumBaseMaterial.M_CesiumBaseMaterial (MI:/CesiumForUnreal/Materials/Instances/MI_CesiumThreeOverlaysAndClippingAndWater.MI_CesiumThreeOverlaysAndClippingAndWater) for platform PCD3D_SM5, Default Material will be used in game.

LogPlayLevel: Warning: UAT: LogInit: Display: LogMaterial: Warning: Cooking a material resource (in M_CesiumBaseMaterial hierarchy) that doesn’t have a valid ShaderMap! Shadermap pointer is null.

LogPlayLevel: Warning: UAT: LogInit: Display: LogShaderCompilers: Warning: Last Error 206: Failed to create directory for shader debug info ‘C:/Users/[pc_name]/Downloads/cesium-unreal-samples-main/cesium-unreal-samples-main/Saved/ShaderDebugInfo/PCD3D_SM5/M_CesiumBaseMaterial_854a508b588320f2/Default/FCesiumPointAttenuationVertexFactory/TBasePassPSFCachedVolumeIndirectLightingPolicySkylight/0’. Try enabling large file paths or r.DumpShaderDebugShortNames.

LogPlayLevel: Error: UAT: [2024.07.02-13.53.58:096][ 0]LogMaterial: Error: Loading a material resource None with an invalid ShaderMap!

LogPlayLevel: Error: UAT: [2024.07.02-13.53.58:096][ 0]LogMaterial: Error: Tried to access an uncooked shader map ID in a cooked application

LogPlayLevel: Warning: UAT: [2024.07.02-13.53.58:096][ 0]LogMaterial: Warning: Invalid shader map ID caching shaders for ‘M_CesiumBaseMaterial’, will use default material.

LogPlayLevel: Warning: UAT: [2024.07.02-13.53.58:096][ 0]LogMaterial: Warning: [AssetLog] C:\Users[pc_name]\Downloads\cesium-unreal-samples-main\cesium-unreal-samples-main\Saved\StagedBuilds\Windows\Engine\Plugins\Marketplace\CesiumForUnreal\Content\Materials\Instances\MI_CesiumThreeOverlaysAndClippingAndWater: Failed to compile Material Instance with Base M_CesiumBaseMaterial for platform PCD3D_SM5, Default Material will be used in game.

LogPlayLevel: Warning: UAT: [2024.07.02-13.53.58:467][ 0]LogStreaming: Warning: Failed to read file ‘…/…/…/Engine/Plugins/Runtime/SunPosition/Resources/SunPosition.png’ error.

Ticking the box for enabling large file paths as well as setting r.DumpShaderDebugShortNames to 1 did not affect behavior

That warning about long paths is concerning, even if setting the recommended option didn’t help. Windows famously has problems with long paths. There’s a registry setting that can help, but it’s not a perfect solution. Your base path for the project, C:\Users[pc_name]\Downloads\cesium-unreal-samples-main\cesium-unreal-samples-main, is exceptionally long, and could easily be causing long path problems. I suggest moving that to somewhere like C:\dev\cesium-unreal-samples-main and see if that works better. Best to delete the entire directory and re-extract to Samples project to the new location.

I believe I found the issue.

After relocating the project to C:/, I noticed that I still had issues with shaders. Upon closer inspection, I noticed that in-between the warnings and errors was the following.

LogPlayLevel: UAT: Shader is using too many Samplers: 17 (only 16 supported)

I went digging in Engine/CesiumForUnreal/Materials and found ML_CesiumGltf which had the function CesiumGlTFFunction.

I proceeded to select every Texture Sample and change its Sampler Source to Shared: Wrap.

After clicking Apply and Save, I tested in both the CesiumForUnreal and my own project and verified that I could see non-gray textures in standalone mode as well as in the packaged version of the game.

If there is a better solution than editing engine plugin code or transplanting the plugin into the project/plugins directory, please let me know. Otherwise, I believe I have found a solution that works and will consider my issue resolved.

Good to hear that’s working for you! I think you’ll see artifacts at the edges of tiles with raster overlays with all the samplers set to Wrap, though. It’s also not clear to me why we’re just over the sampler limit on your system, but it seems to be working ok elsewhere. Perhaps there’s a setting somewhere that explains the difference? I guess it would have to be a global setting, though, not a project-specific one, since the Cesium for Unreal Samples project isn’t working for you either. In short, I’m a bit at a loss. So let us know if you learn anything more about what’s going on there.

It seems that I have identified the problem,whether you use Ultra Dynamic Sky Plugins,and add the UDS material function into cesium material.