ShaderPatch: new config value syntax
This commit is contained in:
@@ -4,16 +4,20 @@
|
||||
Compat=1
|
||||
|
||||
# Lyb's toon shader improvements (24 sept 2019)
|
||||
# Toon: Set to `0.9, -0.5` (or another pair of values) to use
|
||||
# Toon: Adjusts toon shader lighting
|
||||
Toon=0
|
||||
# Toon_Eyes: Set to anything except 0 to use
|
||||
Toon_Val1=0.9
|
||||
Toon_Val2=-0.5
|
||||
# Toon_Eyes: Adjusts toon shader eyes
|
||||
Toon_Eyes=0
|
||||
# Toon_Hair: Set to `1.25` (or another value) to use
|
||||
# Toon_Hair: Adjusts toon shader hair (brightness?)
|
||||
Toon_Hair=0
|
||||
# Toon_Lines1: Set to `0.75` (or another value) to use
|
||||
Toon_Lines1=0
|
||||
# Toon_Lines2: Set to `0.75, 0.75` (or another pair of values) to use
|
||||
Toon_Lines2=0
|
||||
Toon_Hair_Val1=1.25
|
||||
# Toon_Lines: Adjusts toon shader outlines
|
||||
Toon_Lines=0
|
||||
Toon_Lines_Val1=0.75
|
||||
Toon_Lines_Val2=0.75
|
||||
Toon_Lines_Val3=0.75
|
||||
|
||||
[Patches]
|
||||
# Compatibility patches:
|
||||
@@ -25,9 +29,9 @@ esm_gauss\.0\.fp=arch:TU||cfg:compat||from:RCP sum.y, sum.y;(\r?\n) MUL||to:RCP
|
||||
cloth_npr1\.fp=arch:TU||cfg:compat||from:SSG _tmp0.yw, ybr.xxzz;||to:TEMP _tmpForSSG; SGE _tmpForSSG.xz, ybr.xxzz, 0; SUB _tmpForSSG.xz, _tmpForSSG.xxzz, 1; SGT _tmpForSSG.yw, ybr.xxzz, 0; ADD _tmp0.yw, _tmpForSSG.xxzz, _tmpForSSG.yyww;
|
||||
|
||||
# Lyb's toon shader improvements:
|
||||
.*cloth_npr.*=cfg:toon||from:MAD tmp.y, lc.z, 1.2, -0.5;||to:MAD tmp.y, lc.z, <cfg>;
|
||||
.*cloth_npr.*=cfg:toon||from:MAD tmp.y, lc.z, 1.2, -0.5;||to:MAD tmp.y, lc.z, <val1>, <val2>;
|
||||
.*skin_default.*=cfg:toon||from:MAD diff.xyz, spec, spec_ratio, diff;||to:
|
||||
.*eye.*=cfg:toon_eyes||from:ADD o_color_f0.w, diff.x, diff.y;||to:
|
||||
.*hair_npr1.*=cfg:toon_hair||from:MUL spec.x, tmp.x, 0.7;||to:MUL spec.x, tmp.x, 0.7; MUL diff, diff, <cfg>;
|
||||
.*tone_map_npr1.*=cfg:toon_lines1||from:MUL density.y, density.y, 0.25;||to:MUL density.y, density.y, <cfg>;
|
||||
.*tone_map_npr1.*=cfg:toon_lines2||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, <cfg>;
|
||||
.*hair_npr1.*=cfg:toon_hair||from:MUL spec.x, tmp.x, 0.7;||to:MUL spec.x, tmp.x, 0.7; MUL diff, diff, <val1>;
|
||||
.*tone_map_npr1.*=cfg:toon_lines||from:MUL density.y, density.y, 0.25;||to:MUL density.y, density.y, <val1>;
|
||||
.*tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, <val2>, <val3>;
|
||||
@@ -149,12 +149,9 @@ void LoadConfig()
|
||||
else if (section == "config")
|
||||
{
|
||||
equalSplit[1] = TrimString(equalSplit[1], " \t");
|
||||
if (equalSplit[1] != "0") // ignore when == 0 to allow disabling via checkbox
|
||||
{
|
||||
// force cfg key to lower because ini shouldn't be case sensitive
|
||||
std::transform(equalSplit[0].begin(), equalSplit[0].end(), equalSplit[0].begin(), ::tolower);
|
||||
configMap.insert(std::pair<std::string, std::string>(equalSplit[0], equalSplit[1]));
|
||||
}
|
||||
// force cfg key to lower because ini shouldn't be case sensitive
|
||||
std::transform(equalSplit[0].begin(), equalSplit[0].end(), equalSplit[0].begin(), ::tolower);
|
||||
configMap.insert(std::pair<std::string, std::string>(equalSplit[0], equalSplit[1]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +193,8 @@ void hookedLoadFromFarcThunk(FArchivedFile** ppFile)
|
||||
}
|
||||
|
||||
bool cfgMatches = false;
|
||||
if (patch.cfg.length() == 0 || configMap.find(patch.cfg) != configMap.end())
|
||||
if (patch.cfg.length() == 0 || // patch has no config setting
|
||||
(configMap.find(patch.cfg) != configMap.end() && configMap[patch.cfg] != "0")) // patch has a toggle and is not set to 0
|
||||
{
|
||||
cfgMatches = true;
|
||||
}
|
||||
@@ -208,9 +206,15 @@ void hookedLoadFromFarcThunk(FArchivedFile** ppFile)
|
||||
|
||||
modifiedStr = std::regex_replace(modifiedStr, patch.dataRegex, patch.dataReplace);
|
||||
|
||||
if (patch.cfg.length() > 0)
|
||||
if (patch.cfg.length() > 0) // patch has a config setting
|
||||
{
|
||||
modifiedStr = StringReplace(modifiedStr, "<cfg>", configMap[patch.cfg]);
|
||||
int valNum = 0;
|
||||
std::string valKey;
|
||||
while (valNum++, valKey = patch.cfg + "_val" + std::to_string(valNum),
|
||||
configMap.find(valKey) != configMap.end()) // loop until there's no more config values set
|
||||
{
|
||||
modifiedStr = StringReplace(modifiedStr, "<val" + std::to_string(valNum) + ">", configMap[valKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user