Skip to content

Commit 86620bb

Browse files
committed
Update 2.3.1.7
2 parents 0a27270 + 0bdf092 commit 86620bb

File tree

14 files changed

+194
-107
lines changed

14 files changed

+194
-107
lines changed

xivModdingFramework/Cache/XivCache.cs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,14 +2189,24 @@ private static void ProcessDependencyQueue(object sender, DoWorkEventArgs e)
21892189
if (file != null)
21902190
{
21912191
level = XivDependencyGraph.GetDependencyLevel(file);
2192-
if (level == XivDependencyLevel.Invalid) continue;
2192+
if (level == XivDependencyLevel.Invalid)
2193+
{
2194+
RemoveFromChildQueue(file);
2195+
continue;
2196+
}
21932197

2194-
// The get call will automatically cache the data, if it needs updating.
2195-
var task = GetChildFiles(file, false);
2198+
try
2199+
{
2200+
// The get call will automatically cache the data, if it needs updating.
2201+
var task = GetChildFiles(file, false);
21962202

2197-
// Set a safety timeout here.
2198-
task.Wait(3000);
2199-
RemoveFromChildQueue(file);
2203+
// Set a safety timeout here.
2204+
task.Wait(3000);
2205+
}
2206+
finally
2207+
{
2208+
RemoveFromChildQueue(file);
2209+
}
22002210
continue;
22012211

22022212
}
@@ -2215,14 +2225,23 @@ private static void ProcessDependencyQueue(object sender, DoWorkEventArgs e)
22152225
else
22162226
{
22172227
level = XivDependencyGraph.GetDependencyLevel(file);
2218-
if (level == XivDependencyLevel.Invalid) continue;
2228+
if (level == XivDependencyLevel.Invalid)
2229+
{
2230+
RemoveFromParentQueue(file);
2231+
continue;
2232+
}
22192233

2220-
// The get call will automatically cache the data, if it needs updating.
2221-
var task = GetParentFiles(file, false);
2234+
try
2235+
{
2236+
// The get call will automatically cache the data, if it needs updating.
2237+
var task = GetParentFiles(file, false);
22222238

2223-
// Set a safety timeout here.
2224-
task.Wait(3000);
2225-
RemoveFromParentQueue(file);
2239+
// Set a safety timeout here.
2240+
task.Wait(3000);
2241+
} finally
2242+
{
2243+
RemoveFromParentQueue(file);
2244+
}
22262245
continue;
22272246
}
22282247
}

xivModdingFramework/Cache/XivDependencyGraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static async Task<List<IItemModel>> GetSharedMaterialItems(this IItemMode
7777
foreach (var i in sameModelItems)
7878
{
7979
var info = await imc.GetImcInfo(i);
80-
if (info.Variant == originalInfo.Variant)
80+
if (info.MaterialSet == originalInfo.MaterialSet)
8181
{
8282
sameMaterialItems.Add(i);
8383
}

xivModdingFramework/Items/Categories/Companions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public async Task<Dictionary<string, char[]>> GetDemiHumanMountTextureEquipPartL
371371

372372
var index = new Index(_gameDirectory);
373373
var imc = new Imc(_gameDirectory);
374-
var version = (await imc.GetImcInfo(itemModel)).Variant.ToString().PadLeft(4, '0');
374+
var version = (await imc.GetImcInfo(itemModel)).MaterialSet.ToString().PadLeft(4, '0');
375375

376376
var id = itemModel.ModelInfo.PrimaryID.ToString().PadLeft(4, '0');
377377
var bodyVer = itemModel.ModelInfo.SecondaryID.ToString().PadLeft(4, '0');

xivModdingFramework/Items/Categories/Gear.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public async Task<List<XivRace>> GetRacesForTextures(XivGear xivGear, XivDataFil
362362
{
363363
// Get the material version for the item from the imc file
364364
var imc = new Imc(_gameDirectory);
365-
var gearVersion = (await imc.GetImcInfo(xivGear)).Variant.ToString().PadLeft(4, '0');
365+
var gearVersion = (await imc.GetImcInfo(xivGear)).MaterialSet.ToString().PadLeft(4, '0');
366366

367367
var modelID = xivGear.ModelInfo.PrimaryID.ToString().PadLeft(4, '0');
368368

xivModdingFramework/Materials/DataContainers/XivMtrl.cs

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ public ShaderInfo GetShaderInfo()
336336
info.RenderBackfaces = true;
337337
}
338338

339+
var txul = TextureUsageList;
340+
var txdl = TextureDescriptorList;
341+
var shpl = ShaderParameterList;
342+
339343
info.Preset = MtrlShaderPreset.Default;
340344
if (info.Shader == MtrlShader.Standard)
341345
{
@@ -347,7 +351,14 @@ public ShaderInfo GetShaderInfo()
347351
{
348352
if(hasSpec)
349353
{
350-
info.Preset = MtrlShaderPreset.DiffuseSpecular;
354+
if (GetTextureUsage(XivTexType.Specular) != null)
355+
{
356+
info.Preset = MtrlShaderPreset.Monster;
357+
}
358+
else
359+
{
360+
info.Preset = MtrlShaderPreset.DiffuseSpecular;
361+
}
351362
} else
352363
{
353364
info.Preset = MtrlShaderPreset.DiffuseMulti;
@@ -806,7 +817,7 @@ private void RegenerateTextureUsageList(ShaderInfo info)
806817
{
807818
SetTextureUsage(XivTexType.Normal);
808819
SetTextureUsage(XivTexType.Diffuse);
809-
SetTextureUsage(XivTexType.Multi);
820+
SetTextureUsage(XivTexType.Decal);
810821
SetTextureUsage(XivTexType.Specular);
811822
}
812823
else
@@ -819,42 +830,36 @@ private void RegenerateTextureUsageList(ShaderInfo info)
819830
else if (info.Shader == MtrlShader.Standard)
820831
{
821832
SetTextureUsage(XivTexType.Normal);
822-
if(info.Preset == MtrlShaderPreset.Default)
833+
if (info.Preset == MtrlShaderPreset.Default)
823834
{
824-
SetTextureUsage(XivTexType.Multi);
835+
SetTextureUsage(XivTexType.Decal);
825836

826-
} else if(info.Preset == MtrlShaderPreset.DiffuseMulti)
837+
}
838+
else if (info.Preset == MtrlShaderPreset.DiffuseMulti)
827839
{
828840
// This seems to crash the game atm.
829841
SetTextureUsage(XivTexType.Diffuse);
830-
SetTextureUsage(XivTexType.Multi);
831-
} else
832-
{
833-
SetTextureUsage(XivTexType.Diffuse);
834-
SetTextureUsage(XivTexType.Multi);
835-
}
836-
if (info.HasDiffuse)
837-
{
842+
SetTextureUsage(XivTexType.Decal);
838843
}
839-
if (info.HasMulti || info.HasSpec)
844+
else if (info.Preset == MtrlShaderPreset.Monster)
840845
{
846+
SetTextureUsage(XivTexType.Diffuse);
847+
SetTextureUsage(XivTexType.Decal);
848+
849+
// This flag seems to convert Specular textures to Multi textures.
850+
SetTextureUsage(XivTexType.Specular);
841851
}
842-
if(info.HasSpec)
852+
else
843853
{
844-
// What does this do? It's only found on extremely rare items with specular maps,
845-
// and if when we add it/touch it, it either totally breaks the specularity, or crashes.
846-
// And on the items it is involved in, adding/removing it seems to do nothing.
847-
// Might be a glass shader only value?
848-
// SetTextureUsage(XivTexType.Specular);
854+
SetTextureUsage(XivTexType.Diffuse);
855+
SetTextureUsage(XivTexType.Decal);
849856
}
850857
}
851858
else
852859
{
853860
// This is uh... Glass shader? I think is the only fall through here.
854861
SetTextureUsage(XivTexType.Normal);
855-
SetTextureUsage(XivTexType.Diffuse);
856-
SetTextureUsage(XivTexType.Multi);
857-
SetTextureUsage(XivTexType.Specular);
862+
SetTextureUsage(XivTexType.Decal);
858863
}
859864

860865
}
@@ -866,16 +871,14 @@ private void RegenerateShaderParameterList(ShaderInfo info)
866871
{
867872
var args = new Dictionary<MtrlShaderParameterId, List<float>>();
868873

869-
args.Add(MtrlShaderParameterId.Common1, null);
870-
args.Add(MtrlShaderParameterId.Common2, null);
874+
args.Add(MtrlShaderParameterId.AlphaLimiter, null);
875+
args.Add(MtrlShaderParameterId.Occlusion, null);
871876

872877
if (info.Shader == MtrlShader.Skin)
873878
{
874879
args.Add(MtrlShaderParameterId.SkinColor, null);
875880
args.Add(MtrlShaderParameterId.SkinMatParamRow2, null);
876881
args.Add(MtrlShaderParameterId.SkinWetnessLerp, null);
877-
//args.Add(MtrlShaderParameterId.SkinWetnessLerp, new List<float>() { 1.0f });
878-
//args.Add(MtrlShaderParameterId.SkinMatParamRow2, new List<float>() { 1.0f, 1.0f, 1.0f });
879882
args.Add(MtrlShaderParameterId.SkinUnknown2, null);
880883
args.Add(MtrlShaderParameterId.SkinFresnel, null);
881884
args.Add(MtrlShaderParameterId.Reflection1, null);
@@ -896,10 +899,21 @@ private void RegenerateShaderParameterList(ShaderInfo info)
896899
args.Add(MtrlShaderParameterId.Face1, null);
897900
}
898901
}
899-
else if (info.Shader == MtrlShader.Standard || info.Shader == MtrlShader.Glass)
902+
else if (info.Shader == MtrlShader.Standard)
900903
{
901-
args.Add(MtrlShaderParameterId.Equipment1, null);
902-
args.Add(MtrlShaderParameterId.Reflection1, null);
904+
if (info.Preset == MtrlShaderPreset.Monster)
905+
{
906+
args.Remove(MtrlShaderParameterId.AlphaLimiter);
907+
args.Remove(MtrlShaderParameterId.Occlusion);
908+
args.Add(MtrlShaderParameterId.AlphaLimiter, new List<float>() { 0.5f });
909+
args.Add(MtrlShaderParameterId.Occlusion, new List<float>() { 0.25f });
910+
args.Add(MtrlShaderParameterId.Hair1, new List<float>() { 0 });
911+
}
912+
else
913+
{
914+
args.Add(MtrlShaderParameterId.Equipment1, null);
915+
args.Add(MtrlShaderParameterId.Reflection1, null);
916+
}
903917
}
904918
else if (info.Shader == MtrlShader.Iris)
905919
{
@@ -924,6 +938,13 @@ private void RegenerateShaderParameterList(ShaderInfo info)
924938
args[MtrlShaderParameterId.SkinColor] = new List<float>() { 3f, 3f, 3f };
925939
}
926940
}
941+
else if(info.Shader == MtrlShader.Glass)
942+
{
943+
args.Remove(MtrlShaderParameterId.AlphaLimiter);
944+
args.Remove(MtrlShaderParameterId.Occlusion);
945+
args.Add(MtrlShaderParameterId.AlphaLimiter, new List<float>() { 0.25f });
946+
args.Add(MtrlShaderParameterId.Hair2, new List<float>() { 1.0f });
947+
}
927948

928949

929950
// Regenerate the list.
@@ -1468,6 +1489,7 @@ public enum MtrlShaderPreset
14681489
Face,
14691490
FaceNoPores,
14701491
FaceBright,
1492+
Monster,
14711493
}
14721494

14731495
/// <summary>
@@ -1476,8 +1498,8 @@ public enum MtrlShaderPreset
14761498
/// </summary>
14771499
public enum MtrlShaderParameterId : uint
14781500
{
1479-
Common1 = 699138595, // Used in every material. Overwriting bytes with 0s seems to have no effect.
1480-
Common2 = 1465565106, // Used in every material. Overwriting bytes with 0s seems to have no effect.
1501+
AlphaLimiter = 699138595, // Used in every material. Overwriting bytes with 0s seems to have no effect.
1502+
Occlusion = 1465565106, // Used in every material. Overwriting bytes with 0s seems to have no effect.
14811503

14821504
SkinColor = 740963549, // This skin args seem to be the same for all races.
14831505
SkinWetnessLerp = 2569562539,
@@ -1575,7 +1597,7 @@ public bool HasSpec
15751597
{
15761598
get
15771599
{
1578-
if (Shader == MtrlShader.Standard && Preset == MtrlShaderPreset.DiffuseSpecular)
1600+
if (Shader == MtrlShader.Standard && (Preset == MtrlShaderPreset.DiffuseSpecular || Preset == MtrlShaderPreset.Monster))
15791601
{
15801602
return true;
15811603
} else if(Shader == MtrlShader.Furniture || Shader == MtrlShader.DyeableFurniture)
@@ -1626,6 +1648,7 @@ public static List<MtrlShaderPreset> GetAvailablePresets(MtrlShader shader)
16261648
{
16271649
//presets.Add(MtrlShaderPreset.DiffuseMulti);
16281650
presets.Add(MtrlShaderPreset.DiffuseSpecular);
1651+
presets.Add(MtrlShaderPreset.Monster);
16291652
} else if(shader == MtrlShader.Skin)
16301653
{
16311654
presets.Add(MtrlShaderPreset.BodyNoPores);

xivModdingFramework/Materials/FileTypes/Mtrl.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public XivDataFile DataFile
100100
public static Dictionary<XivTexType, TextureUsageStruct> TextureUsageValues = new Dictionary<XivTexType, TextureUsageStruct>()
101101
{
102102
{ XivTexType.Normal, new TextureUsageStruct() { TextureType = 4113354501, Unknown = 2815623008 } },
103-
{ XivTexType.Multi, new TextureUsageStruct() { TextureType = 3531043187, Unknown = 4083110193 } },
103+
{ XivTexType.Decal, new TextureUsageStruct() { TextureType = 3531043187, Unknown = 4083110193 } },
104104
{ XivTexType.Diffuse, new TextureUsageStruct() { TextureType = 3054951514, Unknown = 1611594207 } },
105105
{ XivTexType.Specular, new TextureUsageStruct() { TextureType = 3367837167, Unknown = 2687453224 } },
106106
{ XivTexType.Skin, new TextureUsageStruct() { TextureType = 940355280, Unknown = 735790577 } },
@@ -110,8 +110,8 @@ public XivDataFile DataFile
110110

111111
// Shader Parameter defaults. For most of them they seem to be used as multipliers.
112112
public static Dictionary<MtrlShaderParameterId, List<float>> ShaderParameterValues = new Dictionary<MtrlShaderParameterId, List<float>>() {
113-
{ MtrlShaderParameterId.Common1, new List<float>(){ 0.5f } },
114-
{ MtrlShaderParameterId.Common2, new List<float>(){ 1f } },
113+
{ MtrlShaderParameterId.AlphaLimiter, new List<float>(){ 0.5f } },
114+
{ MtrlShaderParameterId.Occlusion, new List<float>(){ 1f } },
115115
{ MtrlShaderParameterId.SkinColor, new List<float>(){ 1.4f, 1.4f, 1.4f } }, // Direct R/G/B Multiplier. 3.0 for Limbal rings.
116116
{ MtrlShaderParameterId.Reflection1, new List<float>(){ 1f } },
117117
{ MtrlShaderParameterId.SkinWetnessLerp, new List<float>(){ 3f } },
@@ -219,7 +219,7 @@ public async Task<XivMtrl> GetMtrlData(IItemModel item, string mtrlFile, int dxV
219219
try
220220
{
221221
var imcEntry = await imc.GetImcInfo(item);
222-
materialSet = imcEntry.Variant;
222+
materialSet = imcEntry.MaterialSet;
223223
}
224224
catch
225225
{
@@ -1088,7 +1088,7 @@ public static async Task<int> GetMaterialSetId(IItem item)
10881088
{
10891089
var imc = new Imc(XivCache.GameInfo.GameDirectory);
10901090
var entry = await imc.GetImcInfo((IItemModel)item);
1091-
return entry.Variant;
1091+
return entry.MaterialSet;
10921092
} catch
10931093
{
10941094
return 0;

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public async Task ExportMdlToFile(IItemModel item, XivRace race, string outputFi
103103
try
104104
{
105105
var _imc = new Imc(_gameDirectory);
106-
mtrlVariant = (await _imc.GetImcInfo(item)).Variant;
106+
mtrlVariant = (await _imc.GetImcInfo(item)).MaterialSet;
107107
}
108108
catch (Exception ex)
109109
{
@@ -1736,9 +1736,9 @@ public async Task<List<string>> GetReferencedMaterialPaths(string mdlPath, int m
17361736
var imcInfos = info.GetAllEntries(slot, true);
17371737
foreach (var i in imcInfos)
17381738
{
1739-
if (i.Variant != 0)
1739+
if (i.MaterialSet != 0)
17401740
{
1741-
materialVariants.Add(i.Variant);
1741+
materialVariants.Add(i.MaterialSet);
17421742
}
17431743
}
17441744
}
@@ -4405,7 +4405,7 @@ public async Task<long> CopyModel(string originalPath, string newPath, string so
44054405
var imcEntries = await _imc.GetEntries(await root.GetImcEntryPaths());
44064406

44074407
var materialSets = new HashSet<byte>();
4408-
imcEntries.ForEach(x => materialSets.Add(x.Variant));
4408+
imcEntries.ForEach(x => materialSets.Add(x.MaterialSet));
44094409

44104410
// Language is irrelevant here.
44114411
var _mtrl = new Mtrl(_gameDirectory, IOUtil.GetDataFileFromPath(newPath), XivLanguage.None);

xivModdingFramework/Models/ModelTextures/ModelTexture.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ private static void ComputeShaderColors(CustomModelColors colors, ShaderInfo in
469469
newDiffuse = baseDiffuse;
470470
newSpecular = baseSpecular;
471471

472+
472473
// This var is technically defined in the Shaders parameters.
473474
// But we can use a constant copy of it for now, since it's largely non-changeable.
474475
const float PlayerColorMultiplier = 1.4f;
@@ -487,13 +488,13 @@ private static void ComputeShaderColors(CustomModelColors colors, ShaderInfo in
487488
// Has a raw specular.
488489
newSpecular = baseSpecular;
489490

490-
} else if(info.Preset == MtrlShaderPreset.DiffuseMulti)
491+
} else if(info.Preset == MtrlShaderPreset.DiffuseMulti || info.Preset == MtrlShaderPreset.Monster)
491492
{
492493
// Has a raw diffuse.
493494
newDiffuse = baseDiffuse;
494495

495496
// But we also have to modulate that diffuse color by the multi red channel.
496-
newDiffuse = MultiplyColor(newDiffuse, baseSpecular.R);
497+
//newDiffuse = MultiplyColor(newDiffuse, baseSpecular.R);
497498

498499
newDiffuse.A = baseNormal.B;
499500

xivModdingFramework/Mods/RootCloner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
365365
// Validate all variants/material sets for valid materials, and copy materials as needed to fix.
366366
if (Imc.UsesImc(Destination))
367367
{
368-
var mSets = newMetadata.ImcEntries.Select(x => x.Variant).Distinct();
368+
var mSets = newMetadata.ImcEntries.Select(x => x.MaterialSet).Distinct();
369369
foreach (var mSetId in mSets)
370370
{
371371
var path = Destination.Info.GetRootFolder() + "material/v" + mSetId.ToString().PadLeft(4, '0') + "/";

0 commit comments

Comments
 (0)