-
Notifications
You must be signed in to change notification settings - Fork 19
Config Documentation
The same material definition format is used throughout the shader and texture handling functions. It is specified as follows:
A MATERIAL root level node. This defines a set of textures that will be used to create (or adjust) a material. Inside of it are contained the shader name, texture paths, shader properties, and mesh names to construct the material. Multiple MATERIAL blocks may be used anywhere that they are supported, each denoting different shader/texture/mesh combinations that should be applied simultaneously. E.g. the first MATERIAL block applies to all meshes except the window meshes. The second MATERIAL block might only apply to only the window meshes (which meshes are in each block is specified in the configs).
Example of the simplest material setup; applying a single material with a single texture to an entire model, with no additional properties specified.
MATERIAL
{
//the name of the shader to use
shader = KSP/Diffuse
//the textures to assign to the texture slots in the shader
//these are defined as 'texture = <shaderTextureSlot>, <pathToTexture>'
texture = _MainTex, SSTU/Assets/ST-GEN-DSP-ISS-DIFF
}
Example of a compound material setup. This ends up creating two materials, one for the first TEXTURE block, one for the second TEXTURE block. Each material is only applied to the meshes specified by the mesh= and excludeMesh= lines. This would all be considered part of one 'Texture Set'(though might not be labeled as such depending on where it is used).
// the 'main' material assignment; in this case it is being applied
// to all meshes EXCEPT those specified by the 'excludeMesh' definitions
MATERIAL
{
//the name of the shader to use
shader = SSTU/SolarShader
//the textures to assign to the texture slots in the shader
//these are defined as 'texture = <shaderTextureSlot>, <pathToTexture>'
texture = _MainTex, SSTU/Assets/ST-GEN-DSP-ISS-DIFF
texture = _BumpMap, SSTU/Assets/ST-GEN-DSP-ISS-NRM
texture = _SpecMap, SSTU/Assets/ST-GEN-DSP-ISS-SPEC
texture = _Emissive, SSTU/Assets/ST-GEN-DSP-ISS-GLOW
texture = _AOMap, SSTU/Assets/ST-GEN-DSP-ISS-AO
//meshes may either be specified as a 'blacklist' or a 'whitelist'
// to use the 'blacklist' function, specify at least one 'excludeMesh=' line
// any meshes not excluded will have this material applied
// to use the 'whitelist' function, specify at least one 'mesh=' line
// any mesh that matches the name exactly will have this material applied
excludeMesh = ST-GEN-DSP-ISS
excludeMesh = ST-DSP-ISS-Base
excludeMesh = ST-DSP-ISS-TopCap
//PROPERTY blocks can be used for any exposed shader uniform property; float values and color inputs
PROPERTY
{
//the name of the property as defined in the shader
name = _RimFalloff
//for float properties, specify a 'float=' value
float = 2
}
PROPERTY
{
name = _BacklightClamp
float = 0.25
}
PROPERTY
{
name = _Shininess
float = 0.25
}
PROPERTY
{
name = _Color
//for color properties, specify a 'color=' value
color = 1.0, 1.0, 1.0, 1.0
}
}
//the 'second' material assignment
//this material will only be applied to the meshes specified by the 'mesh=' lines
//which happens to be the meshes that were excluded from the first material
MATERIAL
{
shader = SSTU/Masked
texture = _MainTex, SSTU/Assets/ST-GEN-DSP-ISS-DIFF
texture = _BumpMap, SSTU/Assets/ST-GEN-DSP-ISS-NRM
texture = _SpecMap, SSTU/Assets/ST-GEN-DSP-ISS-SPEC
texture = _AOMap, SSTU/Assets/ST-GEN-DSP-ISS-AO
mesh = ST-GEN-DSP-ISS
mesh = ST-DSP-ISS-Base
mesh = ST-DSP-ISS-TopCap
PROPERTY
{
name = _Shininess
float = 0.08
}
}
//between material setups of the two TEXTURE blocks, all meshes within the model have been adjusted and had shaders/textures reassigned.
If all that you want to do is replace the shader and/or textures assigned to a model, you can use the Default Shader Assignment feature.
This feature is used by creating a config file that specifies what model(s) to update, what mesh(es) in the model to adjust, and what shaders/textures to use for each mesh.
Config Example:
KSP_MODEL_SHADER
{
// this is the name of the configuration
// it should be unique amongst KSP_MODEL_SHADER configs to allow for MM patching
name = SSTU/Assets/ST-GEN-DSP-ISS
//this is the name of the model file to adjust.
//you may specify multiple 'model =', which each line denoting a separate .mu model to adjust
model = SSTU/Assets/ST-GEN-DSP-ISS
//the TEXTURE blocks set up a material to be applied to one or more meshes
//see blow for examples/details on how to set these up
MATERIAL
{
//internals here; see texture definition from above
}
}
Example of a single material being used to replace the window shaders on one of the stock command pods:
KSP_MODEL_SHADER
{
name = Glass
model = Squad/Parts/Command/Mk1-2Pod/model
MATERIAL
{
shader = SSTU/PBR/StockMetallicBumped
mesh = SideWindow
mesh = FrontWindow
texture = _MainTex, YourModHere/Assets/newWindowDIFF
texture = _MetallicGlossMap, YourModHere/Assets/newWindowMET
}
}
The texture switch part-module facilitates switching between 'Texture Sets' at run-time. The module is added to a part such as:
MODULE
{
//standard module name
name = KSPTextureSwitch
//this is the root transform from which the texture set will be applied; allows for models to use multiple texture-switch modules
transformName = MainChuteTransform
//for recolorable texture sets, this is the name that will be displayed for the 'section' in the GUI
sectionName = Main Chute
//define the default/starting texture set; must be a texture set added below
currentTextureSet = Parachutes-A
//each 'textureSet=' line adds an additional texture set selection to the module
textureSet = Parachutes-A
textureSet = Parachutes-B
textureSet = Parachutes-C
// you can also define them 'in-line', by adding the texture set directly to the module. When done this way, these texture
// sets will not be able to be referenced anywhere else (no other patches can use them). You also do not need the 'textureSet = '
// line for sets added in this way.
// The below example would add the 'Parachutes-D' texture set to the texture-switching module
KSP_TEXTURE_SET
{
//internal setup is the same as everywhere else
name = Parachutes-D
//MATERIAL blocks/etc would go here
}
}
And its texture-sets refer to root-node texture sets, constructed such as:
KSP_TEXTURE_SET
{
name = Parachutes-A
title = Striped
recolorable = true
MATERIAL
{
shader = SSTU/Masked
texture = _MainTex, SSTU/Assets/SC-GEN-PAR-DIFF
texture = _BumpMap, SSTU/Assets/SC-GEN-PAR-NRM
texture = _SpecMap, SSTU/Assets/SC-GEN-PAR-SPEC
texture = _MaskTex, SSTU/Assets/SC-GEN-PAR-MASK-A
texture = _AOMap, SSTU/Assets/SC-GEN-PAR-AO
}
COLORS
{
mainColor = white
secondColor = orange
detailColor = white
}
}
As can be seen in the texture set example above, there is a COLORS block that denotes the default colors to be used by a recolorable texture set.