Modular Game Features and Shaders

Hi Epic Games,

I have another question around Modular Game Features. We’re in a situation where we do a fair amount of work in shaders, and as a consequence we have a fair amount of shader code related to modular game features (plugins). Are shaders supported via plugins?

The problem is that when the game feature plugins are loaded, it is too late to register the shaders. I believe part of the problem is that the plugins go via bExplicitlyLoaded, and so are loaded too late for the shader systems. We could perhaps inject into the plugin definition, and read those at the correct time and register them then, but I really just wanted to check we weren’t missing anything, or if perhaps this is a coming feature.

Thanks,

Bram

Steps to Reproduce

  • Create a new game feature plugin
  • Add a shader
  • Register the shader in the plugin module
  • Assert the shader is registered too late for Unreal

Hi,

If I understand your question correctly, then yes, generally plugins do support containing shaders.

In terms of being loaded at the correct time, modules that contain shaders in plugins will need to have their Loading Phase set to PostConfigInit.

There are a couple of docs on this topic here:

Thanks,

Hayden

Hi Hayden,

Sorry - those pages don’t mention anything about game feature plugins? And in the plugin near the bExplicitlyLoaded variable it says:

/** When true, this plugin’s modules will not be loaded automatically nor will it’s content be mounted automatically. It will load/mount when explicitly requested and LoadingPhases will be ignored */

So it seems as though for game feature plugins (that are explicitly loaded), the PostConfigInit loading phase will be ignored. We could force bExplicitlyLoaded to be false, but that seems counter to the reason the variable was introduced.

Thanks,

Bram

Hi Bram,

I have just discussed this with a colleague who is more across Game Feature Plugins. Where we got to was that it might be possible to get shaders working correctly by forcibly making sure that the content is cooked and registered at the correct time, and likely by setting bExclicitlyLoaded false, but we get to a point where it may not be worthwhile using a Game Feature Plugin to begin with. It seems like this is a similar thought process to what you have already expressed. I don’t believe this is strictly supported out of the box, in terms of how Game Feature Plugins tend to function.

What I would recommend at this stage would simply be to move only the shaders (and any dependencies) to their own module in a regular plugin, where you can set the loading phase and have it be respected, and list this plugin as a dependency for your Game Feature Plugin (or otherwise ensure it is included and enabled). You may also need to disable Share Material Shader Code in the project settings.

Thanks,

Hayden