diff --git a/Tiger/Exporters/MetadataExporter.cs b/Tiger/Exporters/MetadataExporter.cs index 5712d1ab..03a6ff5c 100644 --- a/Tiger/Exporters/MetadataExporter.cs +++ b/Tiger/Exporters/MetadataExporter.cs @@ -104,7 +104,8 @@ public MetadataScene(ExporterScene scene) mapLight.Unk10.TagData.Unk40[i].Translation, mapLight.Unk10.TagData.Unk40[i].Rotation, new Vector2(1,1), //new Vector2(mapLight.Unk10.TagData.Unk30[i].UnkA0.W, mapLight.Unk10.TagData.Unk30[i].UnkB0.W), //Not right - (data.TagData.Unk40.Count > 0 ? data.TagData.Unk40[0].Vec : data.TagData.Unk60[0].Vec)); + (data.TagData.Unk40.Count > 0 ? data.TagData.Unk40[0].Vec : data.TagData.Unk60[0].Vec), + mapLight.Unk10.TagData.Unk58.TagData.InstanceBounds[i].Corner2.X - mapLight.Unk10.TagData.Unk58.TagData.InstanceBounds[i].Corner1.X); } } foreach(SMapDecalsResource decal in scene.Decals) @@ -134,13 +135,15 @@ public MetadataScene(ExporterScene scene) { foreach(var entry in mapLight.Value) { + var data = FileResourcer.Get().GetSchemaTag(mapLight.Key); AddLight( mapLight.Key, "Spot", new Vector4(entry.Position.X, entry.Position.Y, entry.Position.Z, 1), entry.Quaternion, - new Vector2(1.0, 1.0), - new Vector4(1.0,1.0,1.0,1.0)); + new Vector2(1, 1), + data.TagData.UnkE8.TagData.Unk40.Count > 0 ? data.TagData.UnkE8.TagData.Unk40[0].Vec : data.TagData.UnkE8.TagData.Unk60[0].Vec); + } } @@ -240,7 +243,7 @@ public void AddCubemap(string name, Vector3 scale, Vector4 quatRotation, Vector3 }); } - public void AddLight(string name, string type, Vector4 translation, Vector4 quatRotation, Vector2 size, Vector4 color) + public void AddLight(string name, string type, Vector4 translation, Vector4 quatRotation, Vector2 size, Vector4 color, float range = 13) { //Idk how color/intensity is handled, so if its above 1 just bring it down float R = color.X > 1 ? color.X / 100 : color.X; @@ -257,7 +260,8 @@ public void AddLight(string name, string type, Vector4 translation, Vector4 quat Translation = new[] { translation.X, translation.Y, translation.Z }, Rotation = new[] { quatRotation.X, quatRotation.Y, quatRotation.Z, quatRotation.W }, Size = new[] { size.X, size.Y }, - Color = new[] { R, G, B } + Color = new[] { R, G, B }, + Range = range }); } @@ -373,6 +377,8 @@ private struct JsonLight public float[] Rotation; public float[] Size; public float[] Color; + public float Range; + public bool Shadowing; } private struct JsonDecal { diff --git a/Tiger/Exporters/Source2Handler.cs b/Tiger/Exporters/Source2Handler.cs index f2321aee..abbba6b8 100644 --- a/Tiger/Exporters/Source2Handler.cs +++ b/Tiger/Exporters/Source2Handler.cs @@ -190,6 +190,11 @@ public static void SaveVMAT(string savePath, string hash, IMaterial materialHead vmat.AppendLine($"\t\tcb2_0 \"float4(0,1,1,1)\""); vmat.AppendLine($"\t\tcb2_1 \"float4(0,1,1,1)\""); + for(int i = 0; i < 37; i++) + { + vmat.AppendLine($"\t\tcb8_{i} \"float4(1,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)\""); diff --git a/Tiger/Schema/Shaders/S2ShaderConverter.cs b/Tiger/Schema/Shaders/S2ShaderConverter.cs index 0af082c3..8b48e368 100644 --- a/Tiger/Schema/Shaders/S2ShaderConverter.cs +++ b/Tiger/Schema/Shaders/S2ShaderConverter.cs @@ -22,7 +22,7 @@ public class S2ShaderConverter private readonly List outputs = new List(); private static bool isTerrain = false; private bool bRT0 = true; - private static bool bTranslucent = false; + private bool bTranslucent = false; private bool bUsesFrontFace = false; private bool bFixRoughness = false; @@ -57,7 +57,7 @@ public class S2ShaderConverter COMMON {{ - {(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" : "")} + //alpha //frontface #include ""common/shared.hlsl"" #define CUSTOM_MATERIAL_INPUTS @@ -164,12 +164,12 @@ public string HlslToVfx(IMaterial material, string pixel, string vertex, Materia 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; - - // 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"); - //} + if (bTranslucent) //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 0\r\n\t#endif\r\n\t#ifndef S_TRANSLUCENT\r\n\t#define S_TRANSLUCENT 1\r\n\t#endif"); + } vfxStructure = vfxStructure.Replace("//ps_output", AddOutput(material).ToString()); @@ -564,12 +564,12 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade funcDef.AppendLine($"\t\t{line.TrimStart() .Replace("cb12[7].xyz", "vCameraToPositionDirWs") .Replace("v4.xyz", "float3(0,0,0)") - .Replace("cb12[14].xyz", "-vCameraToPositionDirWs")}"); + .Replace("cb12[14].xyz", "vCameraToPositionDirWs")}"); } else if (line.Contains("cb12[12]")) { funcDef.AppendLine($"\t\t{line.TrimStart() - .Replace("cb12[12].zw", "g_vFrameBufferCopyInvSizeAndUvScale.xy") + .Replace("cb12[12].zw", "(1/g_vFrameBufferCopyInvSizeAndUvScale.xy)") .Replace("cb12[12].xy", "g_vFrameBufferCopyInvSizeAndUvScale.xy")}"); } else if (line.Contains("cb")) @@ -651,7 +651,7 @@ private StringBuilder ConvertInstructions(IMaterial material, bool isVertexShade { case 10: bUsesDepthBuffer = true; - funcDef.AppendLine($"\t\t{equal.TrimStart()}= Depth::Get({sampleUv}).{dotAfter} //t{texIndex}"); + funcDef.AppendLine($"\t\t{equal.TrimStart()}= 1-Depth::GetNormalized({sampleUv}).{dotAfter} //t{texIndex}"); break; case 20: //Usually uses SampleLevel but shouldnt be an issue? bUsesFrameBuffer = true; diff --git a/Tiger/Schema/Static/StaticMapData.cs b/Tiger/Schema/Static/StaticMapData.cs index 2caadd6c..97517b22 100644 --- a/Tiger/Schema/Static/StaticMapData.cs +++ b/Tiger/Schema/Static/StaticMapData.cs @@ -545,11 +545,20 @@ public struct D2Class_BA6C8080 public struct SMapSpotLightResource { [SchemaField(0x10)] - public Tag Unk10; // D2Class_716C8080, might be related to lights for entities? + public Tag Unk10; // D2Class_716C8080, might be related to lights for entities? [SchemaField(0x1C)] public TigerHash Unk1C; } +[SchemaStruct(TigerStrategy.DESTINY2_WITCHQUEEN_6307, "716C8080", 0x110)] +public struct D2Class_716C8080 +{ + [SchemaField(0xE8, TigerStrategy.DESTINY2_WITCHQUEEN_6307)] + public Tag UnkE8; + [SchemaField(0xEC, TigerStrategy.DESTINY2_WITCHQUEEN_6307)] + public Tag UnkEC; +} + // /// // /// Boss entity data resource? // /// diff --git a/Tiger/Schema/Static/StaticMeshData.cs b/Tiger/Schema/Static/StaticMeshData.cs index 365bb244..563581a6 100644 --- a/Tiger/Schema/Static/StaticMeshData.cs +++ b/Tiger/Schema/Static/StaticMeshData.cs @@ -84,6 +84,7 @@ private List GenerateParts(Dictionary staticPa { StaticPart part = new(staticPartEntry); part.Material = materialMap[i]; + part.MaterialType = MaterialType.Opaque; part.GetAllData(_tag.Buffers[staticPartEntry.BufferIndex], parent); parts.Add(part); } @@ -221,6 +222,7 @@ private List GenerateParts(Dictionary staticPa { StaticPart part = new StaticPart(staticPartEntry); part.Material = materialMap[i]; + part.MaterialType = MaterialType.Opaque; part.GetAllData(mesh, parent); parts.Add(part); } diff --git a/Tiger/Schema/Static/StaticPart.cs b/Tiger/Schema/Static/StaticPart.cs index 719ddc75..682a43aa 100644 --- a/Tiger/Schema/Static/StaticPart.cs +++ b/Tiger/Schema/Static/StaticPart.cs @@ -10,6 +10,7 @@ public StaticPart(SStaticPart terrainPartEntry) : base() IndexOffset = terrainPartEntry.IndexOffset; IndexCount = terrainPartEntry.IndexCount; PrimitiveType = PrimitiveType.TriangleStrip; + MaterialType = Shaders.MaterialType.Opaque; } public StaticPart(SStaticMeshPart staticPartEntry) : base() @@ -17,6 +18,7 @@ public StaticPart(SStaticMeshPart staticPartEntry) : base() IndexOffset = staticPartEntry.IndexOffset; IndexCount = staticPartEntry.IndexCount; PrimitiveType = (PrimitiveType)staticPartEntry.PrimitiveType; + MaterialType = Shaders.MaterialType.Opaque; } public StaticPart(SStaticMeshDecal decalPartEntry) : base() @@ -24,6 +26,7 @@ public StaticPart(SStaticMeshDecal decalPartEntry) : base() IndexOffset = decalPartEntry.IndexOffset; IndexCount = decalPartEntry.IndexCount; PrimitiveType = (PrimitiveType)decalPartEntry.PrimitiveType; + MaterialType = Shaders.MaterialType.Transparent; } public void GetAllData(SStaticMeshBuffers buffers, SStaticMesh container)