diff --git a/Charm/ActivityMapEntityView.xaml.cs b/Charm/ActivityMapEntityView.xaml.cs index 1e2e984d..ee4c2c3e 100644 --- a/Charm/ActivityMapEntityView.xaml.cs +++ b/Charm/ActivityMapEntityView.xaml.cs @@ -20,6 +20,7 @@ using Tiger.Schema.Activity.DESTINY2_SHADOWKEEP_2601; using Tiger.Schema.Activity.DESTINY2_WITCHQUEEN_6307; using Tiger.Schema.Entity; +using Tiger.Schema.Shaders; using Tiger.Schema.Static; namespace Charm; @@ -394,7 +395,7 @@ private static void ExtractDataTables(List dataTables, string hash, st foreach (DynamicMeshPart part in element.Unk60.TagData.Unk08.Load(ExportDetailLevel.MostDetailed, null)) { if (part.Material == null) continue; - skyScene.Materials.Add(new ExportMaterial(part.Material)); + skyScene.Materials.Add(new ExportMaterial(part.Material, MaterialType.Transparent)); } } break; @@ -420,7 +421,7 @@ private static void ExtractDataTables(List dataTables, string hash, st { for (int i = item.StartIndex; i < item.StartIndex + item.Count && i < decals.MapDecals.TagData.Locations.Count; i++) { - dynamicScene.Materials.Add(new ExportMaterial(item.Material)); + dynamicScene.Materials.Add(new ExportMaterial(item.Material, MaterialType.Transparent)); } } } diff --git a/Charm/DevView.xaml.cs b/Charm/DevView.xaml.cs index 9cfcb0d1..a873de07 100644 --- a/Charm/DevView.xaml.cs +++ b/Charm/DevView.xaml.cs @@ -228,7 +228,7 @@ private void AddWindow(FileHash hash) foreach (DynamicMeshPart part in parts) { if (part.Material == null) continue; - scene.Materials.Add(new ExportMaterial(part.Material)); + scene.Materials.Add(new ExportMaterial(part.Material, MaterialType.Opaque)); } Exporter.Get().Export(); break; diff --git a/Tiger/Exporters/Exporter.cs b/Tiger/Exporters/Exporter.cs index 484ef0e4..40264a55 100644 --- a/Tiger/Exporters/Exporter.cs +++ b/Tiger/Exporters/Exporter.cs @@ -60,12 +60,14 @@ public void Export() public struct ExportMaterial { public readonly IMaterial Material; + public readonly MaterialType Type; public readonly bool IsTerrain; - public ExportMaterial(IMaterial material, bool isTerrain = false) + public ExportMaterial(IMaterial material, MaterialType type, bool isTerrain = false) { Material = material; IsTerrain = isTerrain; + Type = type; } public override int GetHashCode() diff --git a/Tiger/Exporters/MaterialExporter.cs b/Tiger/Exporters/MaterialExporter.cs index 50fb89f6..fcc49d41 100644 --- a/Tiger/Exporters/MaterialExporter.cs +++ b/Tiger/Exporters/MaterialExporter.cs @@ -41,7 +41,7 @@ public override void Export(Exporter.ExportEventArgs args) if (saveShaders) { string shaderSaveDirectory = $"{args.OutputDirectory}/{scene.Name}"; - material.Material.SaveShaders(shaderSaveDirectory, material.IsTerrain); + material.Material.SaveShaders(shaderSaveDirectory, material.Type, material.IsTerrain); material.Material.SaveVertexShader(shaderSaveDirectory); } } @@ -94,8 +94,7 @@ public override void Export(Exporter.ExportEventArgs args) Directory.CreateDirectory(shaderSaveDirectory); foreach (ExportMaterial material in mapMaterials) { - material.Material.SaveShaders(shaderSaveDirectory, material.IsTerrain); - material.Material.SaveVertexShader(shaderSaveDirectory); + material.Material.SaveShaders(shaderSaveDirectory, material.Type, material.IsTerrain); } } } diff --git a/Tiger/Exporters/Source2Handler.cs b/Tiger/Exporters/Source2Handler.cs index 913cf873..f2321aee 100644 --- a/Tiger/Exporters/Source2Handler.cs +++ b/Tiger/Exporters/Source2Handler.cs @@ -186,8 +186,17 @@ public static void SaveVMAT(string savePath, string hash, IMaterial materialHead { vmat.AppendLine($"\t\tcb0_{entry.Key} \"{entry.Value}\""); } + + vmat.AppendLine($"\t\tcb2_0 \"float4(0,1,1,1)\""); + vmat.AppendLine($"\t\tcb2_1 \"float4(0,1,1,1)\""); + + vmat.AppendLine($"\t\tcb12_4 \"float4(1,0,0,0)\""); + vmat.AppendLine($"\t\tcb12_5 \"float4(0,1,0,0)\""); + vmat.AppendLine($"\t\tcb12_6 \"float4(0,0,1,0)\""); + vmat.AppendLine($"\t\tcb13_0 \"Time\""); vmat.AppendLine($"\t\tcb13_1 \"float4(1,1,1,1)\""); + vmat.AppendLine($"\t}}"); } diff --git a/Tiger/Schema/Entity/Entity.cs b/Tiger/Schema/Entity/Entity.cs index e412ea9d..e0c0c87d 100644 --- a/Tiger/Schema/Entity/Entity.cs +++ b/Tiger/Schema/Entity/Entity.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; using Tiger.Exporters; +using Tiger.Schema.Shaders; namespace Tiger.Schema.Entity; @@ -90,7 +91,7 @@ public void SaveMaterialsFromParts(ExporterScene scene, List dy foreach (var dynamicPart in dynamicParts) { if (dynamicPart.Material == null) continue; - scene.Materials.Add(new ExportMaterial(dynamicPart.Material)); + scene.Materials.Add(new ExportMaterial(dynamicPart.Material, MaterialType.Opaque)); } } diff --git a/Tiger/Schema/Shaders/Material.cs b/Tiger/Schema/Shaders/Material.cs index d5c6ecd1..5462c93c 100644 --- a/Tiger/Schema/Shaders/Material.cs +++ b/Tiger/Schema/Shaders/Material.cs @@ -43,6 +43,12 @@ public struct Output public string Semantic; } + public enum MaterialType + { + Opaque, + Transparent + } + public interface IMaterial : ISchema { public FileHash FileHash { get; } @@ -124,14 +130,14 @@ public string Decompile(byte[] shaderBytecode, string name, string savePath = "h return hlsl; } - public void SaveShaders(string saveDirectory, bool isTerrain = false) + public void SaveShaders(string saveDirectory, MaterialType type, bool isTerrain = false) { Directory.CreateDirectory($"{saveDirectory}/Shaders"); if (PixelShader != null && PixelShader.Hash.IsValid()) { string pixel = Decompile(PixelShader.GetBytecode(), $"ps{PixelShader.Hash}"); string vertex = Decompile(VertexShader.GetBytecode(), $"vs{VertexShader.Hash}"); - string vfx = new S2ShaderConverter().HlslToVfx(this, pixel, vertex, isTerrain); + string vfx = new S2ShaderConverter().HlslToVfx(this, pixel, vertex, type, isTerrain); try { @@ -178,7 +184,7 @@ public void SaveMaterial(string saveDirectory) if (PixelShader != null) { Decompile(PixelShader.GetBytecode(), $"ps{PixelShader.Hash}", hlslPath); - SaveShaders($"{saveDirectory}"); + SaveShaders($"{saveDirectory}", MaterialType.Opaque); } if (VertexShader != null) { @@ -409,3 +415,4 @@ public Material(FileHash fileHash) : base(fileHash) // } } } + diff --git a/Tiger/Schema/Shaders/S2ShaderConverter.cs b/Tiger/Schema/Shaders/S2ShaderConverter.cs index 195fa65d..0af082c3 100644 --- a/Tiger/Schema/Shaders/S2ShaderConverter.cs +++ b/Tiger/Schema/Shaders/S2ShaderConverter.cs @@ -21,8 +21,8 @@ public class S2ShaderConverter private readonly List inputs = new List(); private readonly List outputs = new List(); private static bool isTerrain = false; - private bool bOpacityEnabled = false; - private bool bTranslucent = true; + private bool bRT0 = true; + private static bool bTranslucent = false; private bool bUsesFrontFace = false; private bool bFixRoughness = false; @@ -57,7 +57,7 @@ public class S2ShaderConverter COMMON {{ - //alpha + {(bTranslucent ? $"#ifndef S_ALPHA_TEST\r\n\t#define S_ALPHA_TEST 0\r\n\t#endif\r\n\t#ifndef S_TRANSLUCENT\r\n\t#define S_TRANSLUCENT 1\r\n\t#endif" : "")} //frontface #include ""common/shared.hlsl"" #define CUSTOM_MATERIAL_INPUTS @@ -128,13 +128,14 @@ float4 MainPs( PixelInput i ) : SV_Target0 }} }}"; - public string HlslToVfx(IMaterial material, string pixel, string vertex, bool bIsTerrain = false) + public string HlslToVfx(IMaterial material, string pixel, string vertex, MaterialType type, bool bIsTerrain = false) { //Pixel Shader StringBuilder texSamples = new StringBuilder(); hlsl = new StringReader(pixel); vfx = new StringBuilder(); isTerrain = bIsTerrain; + bTranslucent = type == MaterialType.Transparent; ProcessHlslData(); @@ -149,7 +150,7 @@ public string HlslToVfx(IMaterial material, string pixel, string vertex, bool bI continue; var sampler = material.PS_Samplers[i].Sampler; - texSamples.AppendLine($"\tSamplerState g_s{i + 1} < Filter({sampler.Filter}); AddressU({sampler.AddressU}); AddressV({sampler.AddressV}); AddressW({sampler.AddressW}); ComparisonFunc({sampler.ComparisonFunc}); MaxAniso({sampler.MaxAnisotropy}); >;"); + texSamples.AppendLine($"\tSamplerState s_s{i + 1} < Filter({sampler.Filter}); AddressU({sampler.AddressU}); AddressV({sampler.AddressV}); AddressW({sampler.AddressW}); ComparisonFunc({sampler.ComparisonFunc}); MaxAniso({sampler.MaxAnisotropy}); >;"); } vfxStructure = vfxStructure.Replace("//ps_samplers", texSamples.ToString()); @@ -158,18 +159,17 @@ public string HlslToVfx(IMaterial material, string pixel, string vertex, bool bI hlsl = new StringReader(pixel); StringBuilder instructions = ConvertInstructions(material, false); if (instructions.ToString().Length == 0) - { return ""; - } + vfxStructure = vfxStructure.Replace("//ps_Function", instructions.ToString()); vfxStructure = vfxStructure.Replace("//ps_Inputs", WriteFunctionDefinition(material, false).ToString()); - if (bOpacityEnabled) //This way is stupid but it works - { - bool a = bUsesNormalBuffer || bTranslucent || bUsesFrameBuffer || bUsesDepthBuffer; + //if (bOpacityEnabled) //This way is stupid but it works + //{ + // bool a = bUsesNormalBuffer || bTranslucent || bUsesFrameBuffer || bUsesDepthBuffer; - vfxStructure = vfxStructure.Replace("//alpha", $"#ifndef S_ALPHA_TEST\r\n\t#define S_ALPHA_TEST {(a ? "0" : "1")}\r\n\t#endif\r\n\t#ifndef S_TRANSLUCENT\r\n\t#define S_TRANSLUCENT {(a ? "1" : "0")}\r\n\t#endif"); - } + // vfxStructure = vfxStructure.Replace("//alpha", $"#ifndef S_ALPHA_TEST\r\n\t#define S_ALPHA_TEST {(a ? "0" : "1")}\r\n\t#endif\r\n\t#ifndef S_TRANSLUCENT\r\n\t#define S_TRANSLUCENT {(a ? "1" : "0")}\r\n\t#endif"); + //} vfxStructure = vfxStructure.Replace("//ps_output", AddOutput(material).ToString()); @@ -225,7 +225,7 @@ private void ProcessHlslData() { if (line.Contains("discard") || line.Contains("o0.w = r")) { - bOpacityEnabled = true; + //bOpacityEnabled = true; break; } continue; @@ -454,7 +454,7 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade var dotAfter = line.Split(").")[1]; // todo add dimension - funcDef.AppendLine($"\t\t{equal.TrimStart()}= Tex2DS(g_t{texIndex}, g_s{sampleIndex}, {sampleUv}).{dotAfter}"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= Tex2DS(g_t{texIndex}, s_s{sampleIndex}, {sampleUv}).{dotAfter}"); } else if (line.Contains("Load")) { @@ -509,10 +509,15 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade funcDef.AppendLine($"\t\tint {i.Variable} = 1;"); break; case "float4": - if (i.Semantic == "SV_POSITION0" && i.Variable == "v5") - funcDef.AppendLine($"\t\tfloat4 v5 = i.vPositionSs;"); - else if(i.Variable == "v5") + if (i.Semantic == "SV_POSITION0") + funcDef.AppendLine($"\t\tfloat4 {i.Variable} = i.vPositionSs;"); + else if(i.Variable == "v5" && i.Semantic.Contains("TEXCOORD")) funcDef.AppendLine($"\t\tfloat4 v5 = i.vBlendValues;"); + //else + // funcDef.AppendLine($"\t\tfloat4 {i.Variable} = float4(1,1,1,1);"); + break; + case "float": + funcDef.AppendLine($"\t\tfloat {i.Variable} = 1;"); break; } } @@ -545,7 +550,7 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade while (!line.Contains("{")) { if (line.Contains("SV_TARGET2")) - bTranslucent = false; + bRT0 = false; line = hlsl.ReadLine(); } do @@ -563,8 +568,9 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade } else if (line.Contains("cb12[12]")) { - funcDef.AppendLine($"\t\t{line.TrimStart().Replace("cb12[12].zw", "g_vFrameBufferCopyInvSizeAndUvScale.xy")}"); - funcDef.AppendLine($"\t\t{line.TrimStart().Replace("cb12[12].xy", "g_vFrameBufferCopyInvSizeAndUvScale.xy")}"); + funcDef.AppendLine($"\t\t{line.TrimStart() + .Replace("cb12[12].zw", "g_vFrameBufferCopyInvSizeAndUvScale.xy") + .Replace("cb12[12].xy", "g_vFrameBufferCopyInvSizeAndUvScale.xy")}"); } else if (line.Contains("cb")) { @@ -579,21 +585,25 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade sampleUv = Regex.Replace(sampleUv, pattern, isVertexShader ? "vs_cb$1_$2" : "cb$1_$2"); var dotAfter = line.Split(").")[1]; - funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter}"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter}"); } else { - if (!line.Contains("cb12")) - { - string pattern = @"cb(\d+)\[(\d+)\]"; // Matches cb#[#] - string output = Regex.Replace(line, pattern, isVertexShader ? "vs_cb$1_$2" : "cb$1_$2"); + //if (!line.Contains("cb12")) + //{ + // string pattern = @"cb(\d+)\[(\d+)\]"; // Matches cb#[#] + // string output = Regex.Replace(line, pattern, isVertexShader ? "vs_cb$1_$2" : "cb$1_$2"); + + // funcDef.AppendLine($"\t\t{output.TrimStart()}"); + //} + //else + //{ + // funcDef.AppendLine($"\t\t{line.TrimStart()}"); + //} + string pattern = @"cb(\d+)\[(\d+)\]"; // Matches cb#[#] + string output = Regex.Replace(line, pattern, isVertexShader ? "vs_cb$1_$2" : "cb$1_$2"); - funcDef.AppendLine($"\t\t{output.TrimStart()}"); - } - else - { - funcDef.AppendLine($"\t\t{line.TrimStart()}"); - } + funcDef.AppendLine($"\t\t{output.TrimStart()}"); } } @@ -620,19 +630,19 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade $" bool blue = i.vBlendValues.z > 0.5;\r\n\r\n" + $" if (red && !green && !blue)\r\n" + $" {{\r\n" + - $" {equal} = g_t{texIndex}_0.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + + $" {equal} = g_t{texIndex}_0.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + $" }}\r\n" + $" else if (!red && green && !blue)\r\n" + $" {{\r\n" + - $" {equal} = g_t{texIndex}_1.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + + $" {equal} = g_t{texIndex}_1.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + $" }}\r\n" + $" else if (!red && !green && blue)\r\n" + $" {{\r\n" + - $" {equal} = g_t{texIndex}_2.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + + $" {equal} = g_t{texIndex}_2.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + $" }}\r\n" + $" else if (red && green && blue)\r\n" + $" {{\r\n" + - $" {equal} = g_t{texIndex}_3.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + + $" {equal} = g_t{texIndex}_3.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter}\r\n" + $" }}"); } else if (!material.EnumeratePSTextures().Any(texture => texture.TextureIndex == texIndex)) //Some kind of buffer texture @@ -645,7 +655,7 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade break; case 20: //Usually uses SampleLevel but shouldnt be an issue? bUsesFrameBuffer = true; - funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_tFrameBufferCopyTexture.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter} //t{texIndex}"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_tFrameBufferCopyTexture.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter} //t{texIndex}"); break; default: funcDef.AppendLine($"\t\t{equal.TrimStart()}= float4(1,1,1,1).{dotAfter} //t{texIndex}"); @@ -654,7 +664,7 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade } else { - funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.Sample(g_s{sampleIndex}, {sampleUv}).{dotAfter}"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.Sample(s_s{sampleIndex}, {sampleUv}).{dotAfter}"); } } else if (line.Contains("CalculateLevelOfDetail")) @@ -664,7 +674,7 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade var sampleIndex = Int32.Parse(line.Split("(s")[1].Split("_s,")[0]); var sampleUv = line.Split(", ")[1].Split(")")[0]; - funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.CalculateLevelOfDetail(g_s{sampleIndex}, {sampleUv});"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.CalculateLevelOfDetail(s_s{sampleIndex}, {sampleUv});"); } else if (line.Contains("Load")) { @@ -673,25 +683,41 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade var sampleUv = line.Split("(")[1].Split(")")[0]; var dotAfter = line.Split(").")[1]; - if (texIndex == 2) //Pretty sure this is normal buffer, cant get/use in Forward Rendering... + if (!material.EnumeratePSTextures().Any(texture => texture.TextureIndex == texIndex)) //Some kind of buffer texture { - bUsesNormalBuffer = true; - funcDef.AppendLine($"\t\t{equal.TrimStart()}= v0.{dotAfter}"); + switch (texIndex) + { + case 2: + bUsesNormalBuffer = true; + funcDef.AppendLine($"\t\t{equal.TrimStart()}= v0.{dotAfter}"); + break; + case 10: + bUsesDepthBuffer = true; + funcDef.AppendLine($"\t\t{equal.TrimStart()}= Depth::Get({sampleUv}).{dotAfter} //t{texIndex}.Load({sampleUv}).{dotAfter}"); + break; + case 20: //Usually uses SampleLevel but shouldnt be an issue? + bUsesFrameBuffer = true; + funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_tFrameBufferCopyTexture.Load({sampleUv}).{dotAfter} //t{texIndex}.Load({sampleUv}).{dotAfter}"); + break; + default: + funcDef.AppendLine($"\t\t{equal.TrimStart()}= float4(1,1,1,1).{dotAfter} //t{texIndex}.Load({sampleUv}).{dotAfter}"); + break; + } } - else if (!material.EnumeratePSTextures().Any(texture => texture.TextureIndex == texIndex)) //Some kind of buffer texture + else { - funcDef.AppendLine($"\t\t{equal.TrimStart()}= float4(1,1,1,1).{dotAfter} //t{texIndex}.Load"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= g_t{texIndex}.Load({sampleUv}).{dotAfter}"); } } else if (line.Contains("o0.w = r")) //o0.w = r(?) { funcDef.AppendLine($"\t\t{line.TrimStart()}"); - funcDef.AppendLine($"\t\talpha = 1 - o0.w;"); - } - else if (line.Contains("discard")) - { - funcDef.AppendLine(line.Replace("discard", "\t\t{ alpha = 0; }")); //sometimes o0.w is used for alpha instead on some shaders + //funcDef.AppendLine($"\t\talpha = 1 - o0.w;"); } + //else if (line.Contains("discard")) + //{ + // funcDef.AppendLine(line.Replace("discard", "\t\t{ alpha = 0; }")); + //} else if (line.Contains("o1.xyzw = float4(0,0,0,0);")) { funcDef.AppendLine(line.Replace("o1.xyzw = float4(0,0,0,0);", "\t\to1.xyzw = float4(PackNormal3D(v0.xyz),0);")); //decals(?) have 0 normals sometimes, dont want that @@ -716,7 +742,7 @@ private StringBuilder AddOutput(IMaterial material) { StringBuilder output = new StringBuilder(); - if(!bTranslucent) //uses o1,o2 + if(!bRT0) //uses o1,o2 { //this is fine... output.Append($"\t\t// Normal\r\n " + @@ -748,11 +774,12 @@ private StringBuilder AddOutput(IMaterial material) if (a) //?? { - output.Append($"\t\treturn float4(o0.xyz, {(bUsesFrameBuffer ? "1" : "alpha")});"); + //output.Append($"\t\treturn float4(o0.xyz, {(bUsesFrameBuffer ? "1" : "alpha")});"); + output.Append($"\t\treturn float4(o0.xyz, 1);"); } else { - output.AppendLine($"\t\tMaterial mat = Material::From(i, float4(o0.xyz, alpha), float4(0.5, 0.5, 1, 1), float4(0.5, 0, 1, 1), float3(1.0f, 1.0f, 1.0f), 0);"); + output.AppendLine($"\t\tMaterial mat = Material::From(i, float4(o0.xyz, 1), float4(0.5, 0.5, 1, 1), float4(0.5, 0, 1, 1), float3(1.0f, 1.0f, 1.0f), 0);"); output.AppendLine($"\t\treturn ShadingModelStandard::Shade(i, mat);"); } } diff --git a/Tiger/Schema/Static/StaticMesh.cs b/Tiger/Schema/Static/StaticMesh.cs index 983fc851..9eac858e 100644 --- a/Tiger/Schema/Static/StaticMesh.cs +++ b/Tiger/Schema/Static/StaticMesh.cs @@ -42,6 +42,7 @@ public class MeshPart public List VertexTangents = new List(); public List VertexColours = new List(); public IMaterial? Material; + public MaterialType MaterialType; public int GroupIndex = 0; } @@ -66,7 +67,7 @@ public void SaveMaterialsFromParts(ExporterScene scene, List parts) { if (part.Material == null) continue; - scene.Materials.Add(new ExportMaterial(part.Material)); + scene.Materials.Add(new ExportMaterial(part.Material, part.MaterialType)); } } @@ -105,6 +106,7 @@ private List LoadDecals(ExportDetailLevel detailLevel) StaticPart part = new StaticPart(decalPartEntry); part.GetDecalData(decalPartEntry, _tag); part.Material = decalPartEntry.Material; + part.MaterialType = MaterialType.Transparent; parts.Add(part); } diff --git a/Tiger/Schema/Static/Terrain.cs b/Tiger/Schema/Static/Terrain.cs index 704225d9..bad1ea54 100644 --- a/Tiger/Schema/Static/Terrain.cs +++ b/Tiger/Schema/Static/Terrain.cs @@ -64,11 +64,11 @@ public void LoadIntoExporter(ExporterScene scene, string saveDirectory, bool exp var part = MakePart(partEntry); parts.TryAdd(part, partEntry.Material); - scene.Materials.Add(new ExportMaterial(partEntry.Material, true)); + scene.Materials.Add(new ExportMaterial(partEntry.Material, MaterialType.Opaque, true)); part.Material = partEntry.Material; if (exportStatic) //Need access to material early, before scene system exports - partEntry.Material.SaveShaders($"{saveDirectory}", true); + partEntry.Material.SaveShaders($"{saveDirectory}", MaterialType.Opaque, true); } }