Shaders from mounted pak are not loaded when I mount the pak file and open the map from it

Greetings everyone. I am struggling with the issue for several days already and hope that someone will be able to help.

Summary: Shaders from mounted pak are not loaded when I mount the pak file and open the map from it.

How to reproduce:

  1. Create an empty project with an empty map.
  2. Setup launcher profile (using the unreal frontend/project launcher) to create the base release. All settings are similar to PakLoader plugin example: PakLoaderPlugin.pdf - Google Drive
  3. Add the test code to mount the pak and open level. At the moment I use the PakLoader plugin (by BlueMountains) and its slightly modified test actor blueprint that mounts pak, registers mount points and loads asset registry from the pak file.
  4. Run the launcher profile and wait for the project to be built.
  5. Run the project and make sure that map is not opened and nothing happens, check that log says that it can’t fine pak.
  6. Create an empty plugin and launcher profile for it (again, same settings to what PakLoader plugin uses).
  7. Add the new map to the plugin, put some simple static mesh with simple material and texture (e.g. generate static mesh from geometry cube and drop some jpeg texture onto it).
  8. Build the DLC.
  9. Put the DLC pak to the path from the previously built game tries to load pak.
  10. Run the game and check that the map is loaded but static mesh in the scene has no material and texture.
  11. Check log and see something similar to this:

[2021.10.22-13.57.57:816][ 0]LogPakFile: New pak file E:\UE4\PakDemoProject\TestDLC.pak added to pak precacher.
[2021.10.22-13.57.57:819][ 0]LogShaders: Error: Missing shader resource for hash ‘5053DD5A025565740995E4963A720EFAD283B2C3’ for shader platform 0 in the shader library
[2021.10.22-13.57.57:820][ 0]LogMaterial: Error: Tried to access an uncooked shader map ID in a cooked application
[2021.10.22-13.57.57:820][ 0]LogMaterial: Warning: Invalid shader map ID caching shaders for ‘T_Example_Mat’, will use default material.
[2021.10.22-13.57.57:820][ 0]LogMaterial: Can’t compile T_Example_Mat with cooked content, will use default material instead
[2021.10.22-13.57.57:820][ 0]LogMaterial: Warning: [AssetLog] /TestDLC/T_Example_Mat.T_Example_Mat: Failed to compile Material for platform PCD3D_SM5, Default Material will be used in game.

  1. Open PAK file using PakViewer or list its files using UnrealPak and check that built shader archive exists in the pak (e.g. ShaderArchive-TestDLC-PCD3D_SM5.ushaderbytecode) but it is not loaded by the game.

Notes:

  1. If you add the plugin file before packing the base game, and it gets linked into the release, everything works fine (not sure if shaders in this case are linked to the base release shader archive or not).
  2. I also tried to debug engine to understand when it loads game shaders, but I saw that it only loads them on the game start and also in editor when the new plugin is mounted which is not applicable to the cooked game.
  3. In example pak shipped with PakLoader plugin there is no ushaderbytecode archive included but it loads meshes with some materials and textures, all project settings are default just as in the newly created plugin I’m testing with.

Sorry for long post but I really need some help at the moment. Appreciate any help. Peace to everyone and thanks in advance.

Disable ‘Share Material Shader Code’ in project settings.

This is an optimization, but breaks material references in PAK files. You need to go without it, so each material has standalone code in the PAK file.

2 Likes

Thanks man you saved me!

1 Like