Smooth_Salad-ShaderSwapper icon

ShaderSwapper

A lightweight library for upgrading stubbed shaders to actual shaders at runtime.

Last updated 10 months ago
Total downloads 437552
Total rating 5 
Categories Libraries
Dependency string Smooth_Salad-ShaderSwapper-1.0.1
Dependants 180 other packages depend on this package

README

Shader Swapper

A lightweight library for upgrading stubbed shaders to actual shaders at runtime.

Stubbed Shaders?

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.

Examples

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;
    }

    // ...
}

Materials with stubbed shaders must be explicitly included in your asset bundles

Auto-included materials (partially greyed out) will NOT be found by ShaderSwapper.

Contact

For questions or bug reports, you can find me in the RoR2 Modding Server @Groove_Salad

Or, you can post issues on the GitHub

See Also