Skip to content

Commit f904733

Browse files
committed
Various Material adjustments based on knew data.
1 parent 95b55b2 commit f904733

File tree

4 files changed

+63
-38
lines changed

4 files changed

+63
-38
lines changed

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: 3 additions & 3 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 } },

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/Textures/Enums/XivTexType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public enum XivTexType
3333
Icon,
3434
Vfx,
3535
UI,
36+
Decal,
3637
Other
3738
}
3839
}

0 commit comments

Comments
 (0)