A lightweight library for upgrading stubbed shaders to actual shaders at runtime.
Stubbed shaders are dummy shaders that contain the properties of the real John Hopoo shaders. This means stubbed shaders are safe to include in your project and asset bundles. At runtime, the stubbed shaders are upgraded to the real shaders, and the material properties are preserved!
If you are looking for the RoR2 Stubbed Shaders, you can find them here.
This mod is a general solution for swapping your stubbed shaders with real shaders at runtime.
Make sure you are using the
ShaderSwapper
namespace!
ShaderSwapper methods are asynchronous. You can start them as a coroutine from your plugin like so:
base.StartCoroutine(myAssetBundle.UpgradeStubbedShadersAsync());
ShaderSwapper will run in the background to upgrade the shaders of every material in your asset bundle.
Alternatively, you could yield UpgradeStubbedShadersAsync
in your IContentPackProvider
:
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
// ...
var upgradeStubbedShaders = myAssetBundle.UpgradeStubbedShadersAsync();
while (upgradeStubbedShaders.MoveNext())
{
yield return upgradeStubbedShaders.Current;
}
// ...
}
Auto-included materials (partially greyed out) will NOT be found by ShaderSwapper.
For questions or bug reports, you can find me in the RoR2 Modding Server @Groove_Salad
Or, you can post issues on the GitHub
- RoR2StubbedShaders: A curated collection of stubbed shaders for RoR2
- RuntimeMaterialInspector: A tool for editing material properties in-game