Skip to content

Adding Shaders

Chris Adderley edited this page Mar 16, 2021 · 3 revisions

Adding shaders is fairly easy and modular.

Create Shader

Make a shader! Make sure to take note of the name you give it, eg Waterfall/MyAwesomeShader

Export Shader as an Asset Bundle from Unity

Do this via the usual Unity way - tag it as an asset in a new bundle, and build the bundle. I won't get into this as the method is nothing special.

Rename AssetBundle

You should rename the file generated. The target name should be myShaderBundleOfDoom-platform.waterfall, where platform is one of windows, linux, macos. The platform allows control over what shader versions might be loaded on different platforms, if you need to compile different versions.

Add Bundle to Waterfall

Put the bundle in GameData\Waterfall\Shaders\. It will be loaded up when KSP starts.

Use The Shader

Use the shader in an effect by specifying the name you gave it when authoring the MATERIAL block of a MODEL node appropriately.

(Optional) Make the Shader available for use in the UI

Create an empty configuration file anywhere in GameData, say GameData/MyModName/WaterfallShaders.cfg.

Add entries for each shader you want to use in the UI. name is the name of the shader as defined in the shader code, description is a short bit of text to show. workflow is which workflow you should use it with, values are Dynamic, Deforming, Billboards.

WATERFALL_TEXTURE
{
  name = Cloud Noise
  path = Waterfall/FX/fx-noise-4
  description = fx-noise-4
}