Skip to content

Commit 09a2bc7

Browse files
committed
basic documentation
it could be better but its better than nothing
1 parent 605d60e commit 09a2bc7

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project will be documented in this file
44

5+
## Unreleased
6+
7+
Major build system refactor, and adoption by the KSPModdingLibs team.
8+
9+
### Added
10+
11+
- Added material-replacement functionality using the `SHABBY_MATERIAL_DEF` node
12+
13+
514
## 0.3.0 - 2022-08-03
615

716
Add the rest of the main harmony distro

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Shabby
2+
======
3+
4+
[![GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
5+
[![CKAN: Indexed](https://img.shields.io/badge/CKAN-Indexed-brightgreen.svg)](https://github.com/KSP-CKAN/CKAN)
6+
7+
Shabby is a shader asset bundle loader and material replacement mod for KSP.
8+
9+
## Dependencies
10+
* [Harmony2](https://github.com/KSPModdingLibs/HarmonyKSP)
11+
12+
## Usage
13+
14+
### Loading Shaders
15+
16+
Create an asset bundle in Unity with the ".shab" file extension. Target Windows, but make OpenGLCore is enabled as a graphics API under Project Settings>Player.
17+
18+
Place the resulting shab file in your mod anywhere under GameData. The shaders within it can be used in mu files just like any of the builtin KSP shaders.
19+
20+
### Replacing Shaders
21+
22+
The `SHABBY` top-level config node contains shader information. with the following sub-nodes:
23+
24+
- **`REPLACEMENT`**, with the string-valued keys `name` and `shader`. Defines a simple one-to-one shader replacement.
25+
26+
- **`ICON_SHADER`**, with the string-valued keys `shader` and `iconShader`. It specifies that the shader with the given name is to be substituted when used in an icon prefab. **Without this configuration, all custom shaders will be replaced by stock code with `KSP/ScreenSpaceMask` in icon prefabs and thus editor part icons.**
27+
28+
The **`SHABBY_MATERIAL_DEF`** top-level config node specifies a replacement shader and any number of shader properties to be modified. It contains the following items:
29+
- **`name`** (required): a unique identifier for this material.
30+
- `displayName` (optional): a human-facing name. Not used in Shabby but may be accessed by other mods depending on this mod. Defaults to `name` if not specified.
31+
- `updateExisting` (optional): whether to apply changes to the existing material, or to create a new material from scratch. Defaults to `true`.
32+
- **`shader`** (optional in update-existing mode, otherwise required): name of the shader to apply. May be a stock shader or one loaded by Shabby.
33+
- `preserveRenderQueue` (optional): whether the existing render queue of the material should be preserved when its shader is replaced. Defaults to `false`, which will reset the render queue to the shader's default.
34+
- One or none of each the following nodes, to specify the corresponding type of shader property to be applied. They contain any number of keys of the format `_Property = value`:
35+
- `KEYWORD {}`: the value is a boolean (`true` or `false`).
36+
- `FLOAT {}`
37+
- `COLOR {}`: the value is either a float color (`r, g, b` or `r, g, b, a` normalized to `[0, 1]`), an HTML hex color (`#rgb`, `#rrggbb`, `#rgba`, or `#rrggbbaa`), or a named Unity color.
38+
- `VECTOR {}`: the value is a Vector4. All four components must be specified.
39+
- `TEXTURE {}`: the value is a GameData-relative path to a texture file, sans extension.
40+
41+
Material replacements are applied in `PART`s using the **`SHABBY_MATERIAL_REPLACE`** node. It contains the following items:
42+
- **`materialDef`** (required): the unique identifier of the material definition to apply.
43+
- Optionally, exactly one of the following. If neither are specified, the replacement is applied to the entire part.
44+
1. At least one `targetMaterial` key with a string value, specifying that the existing material with that name is to be replaced. This is the recommended workflow.
45+
2. At least one `targetTransform` key with a string value, specifying that all meshes under that transform (recursively) are to have their materials replaced.
46+
- Optionally, any number of `ignoreMesh` keys with string values, specifying that the mesh with the given name is to be ignored even if it matches one of the target conditions. This applies to the mesh itself only, not any of its children.
47+
48+
Multiple material replacement nodes may be defined in the part, but they should apply to distinct meshes. The behavior in case of overlap is unspecified.
49+
50+
All of the above configurations may be modified by ModuleManager.
51+
52+
The material replacement is performed once per part, during prefab compilation. The result is indistinguishable from the model `mu` natively containing the replaced material. In particular, this is compatible with existing texture switching mods such as B9PartSwitch.
53+
54+
An example configuration:
55+
56+
```text
57+
SHABBY_MATERIAL_DEF
58+
{
59+
name = ExampleMaterial
60+
61+
shader = TU/Metallic // This is just an example; to use a TU shader one must load it as a `.shab` bundle first.
62+
63+
Texture
64+
{
65+
_MainTex = MyMod/Assets/PBRdiff
66+
_MetallicGlossMap = MyMod/Assets/PBRmet
67+
_AOMap = MyMod/Assets/PBRmet
68+
}
69+
70+
Float
71+
{
72+
_Metal = 0.5
73+
_Smoothness = 0.96
74+
}
75+
}
76+
77+
@PART[MyPart]:FOR[MyMod]
78+
{
79+
SHABBY_MATERIAL_REPLACE
80+
{
81+
materialDef = ExampleMaterial
82+
targetTransform = transformA
83+
targetTransform = transformB
84+
excludeMesh = Flag
85+
}
86+
}
87+
```
88+
89+
90+

0 commit comments

Comments
 (0)