diff --git a/.gitignore b/.gitignore index 719bc068..5faedd58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .vs/Switch_Toolbox/v15/Server/sqlite3/db.lock +*.resources +Debug/ +Release/ \ No newline at end of file diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 465ffdee..63b87b0d 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index d07d109d..6d5ead1a 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm index bf2b049e..3fab36b2 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 44872f24..39072059 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES.cs b/Switch_FileFormatsMain/FileFormats/BFRES.cs index 88666087..7a47816f 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES.cs @@ -152,7 +152,6 @@ namespace FirstPlugin bfres.resFile.Models[CurMdl].Shapes.Clear(); bfres.resFile.Models[CurMdl].VertexBuffers.Clear(); bfres.resFile.Models[CurMdl].Materials.Clear(); - // bfres.resFile.Models[CurMdl].MaterialDict.Clear(); int i = 0; var duplicates = model.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c); @@ -166,6 +165,7 @@ namespace FirstPlugin bfres.resFile.Models[CurMdl].Shapes.Add(shape.Shape); bfres.resFile.Models[CurMdl].VertexBuffers.Add(shape.VertexBuffer); + shape.Shape.VertexBufferIndex = (ushort)(bfres.resFile.Models[CurMdl].VertexBuffers.Count - 1); SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape); } @@ -213,6 +213,7 @@ namespace FirstPlugin bfres.resFileU.Models[CurMdl].Shapes.Add(shape.Text, shape.ShapeU); bfres.resFileU.Models[CurMdl].VertexBuffers.Add(shape.VertexBufferU); + shape.ShapeU.VertexBufferIndex = (ushort)(bfres.resFileU.Models[CurMdl].VertexBuffers.Count - 1); SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape); } @@ -223,14 +224,6 @@ namespace FirstPlugin } CurMdl++; } - bfres.resFile.SkeletalAnims.Clear(); - if (EditorRoot.Nodes.ContainsKey("FSKA")) - { - foreach (BfresSkeletonAnim ska in EditorRoot.Nodes["FSKA"].Nodes) - { - bfres.resFile.SkeletalAnims.Add(ska.SkeletalAnim); - } - } } private void SetShaderAssignAttributes(FMAT.ShaderAssign shd, FSHP shape) diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresStructs.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresStructs.cs index 4261b2dc..02dc1a57 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresStructs.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresStructs.cs @@ -1438,115 +1438,123 @@ namespace Bfres.Structs return; } BfresModelImportSettings settings = new BfresModelImportSettings(); + + if (BFRES.IsWiiU) + settings.DisableMaterialEdits(); + settings.SetModelAttributes(assimp.objects[0]); if (settings.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; - if (Replace) + if (!BFRES.IsWiiU && Replace) { materials.Clear(); Nodes["FmatFolder"].Nodes.Clear(); MatStartIndex = 0; } - foreach (STGenericMaterial mat in assimp.materials) + if (!BFRES.IsWiiU) { - FMAT fmat = new FMAT(); - fmat.Material = new Material(); - if (settings.ExternalMaterialPath != string.Empty) + foreach (STGenericMaterial mat in assimp.materials) { - fmat.Material.Import(settings.ExternalMaterialPath); - fmat.ReadMaterial(fmat.Material); - } - - fmat.Text = mat.Text; - //Setup placeholder textures - //Note we can't add/remove samplers so we must fill these slots - foreach (var t in fmat.textures) - { - t.wrapModeS = 0; - t.wrapModeT = 0; - - switch (t.Type) + FMAT fmat = new FMAT(); + fmat.Material = new Material(); + if (settings.ExternalMaterialPath != string.Empty) { - case STGenericMatTexture.TextureType.Diffuse: - t.Name = "Basic_Alb"; - break; - case STGenericMatTexture.TextureType.Emission: - t.Name = "Basic_Emm"; - break; - case STGenericMatTexture.TextureType.Normal: - t.Name = "Basic_Nrm"; - break; - case STGenericMatTexture.TextureType.Specular: - t.Name = "Basic_Spm"; - break; - case STGenericMatTexture.TextureType.SphereMap: - t.Name = "Basic_Sphere"; - break; - case STGenericMatTexture.TextureType.Metalness: - t.Name = "Basic_Mtl"; - break; - case STGenericMatTexture.TextureType.Roughness: - t.Name = "Basic_Rgh"; - break; - case STGenericMatTexture.TextureType.MRA: - t.Name = "Basic_MRA"; - break; - case STGenericMatTexture.TextureType.Shadow: - t.Name = "Basic_Bake_st0"; - break; - case STGenericMatTexture.TextureType.Light: - t.Name = "Basic_Bake_st1"; - break; + fmat.Material.Import(settings.ExternalMaterialPath); + fmat.ReadMaterial(fmat.Material); } - } - if (PluginRuntime.bntxContainers.Count > 0) - { - foreach (var node in Parent.Parent.Nodes["EXT"].Nodes) - { - if (node is BinaryTextureContainer) - { - var bntx = (BinaryTextureContainer)node; - - bntx.ImportBasicTextures("Basic_Alb"); - bntx.ImportBasicTextures("Basic_Nrm"); - bntx.ImportBasicTextures("Basic_Spm"); - bntx.ImportBasicTextures("Basic_Sphere"); - bntx.ImportBasicTextures("Basic_Mtl"); - bntx.ImportBasicTextures("Basic_Rgh"); - bntx.ImportBasicTextures("Basic_MRA"); - bntx.ImportBasicTextures("Basic_Bake_st0"); - bntx.ImportBasicTextures("Basic_Bake_st1"); - bntx.ImportBasicTextures("Basic_Emm"); - } - } - } - - foreach (var tex in mat.TextureMaps) - { + fmat.Text = mat.Text; + //Setup placeholder textures + //Note we can't add/remove samplers so we must fill these slots foreach (var t in fmat.textures) { - if (t.Type == tex.Type) + t.wrapModeS = 0; + t.wrapModeT = 0; + + switch (t.Type) { - t.Name = tex.Name; - t.wrapModeS = tex.wrapModeS; - t.wrapModeT = tex.wrapModeT; - t.wrapModeW = tex.wrapModeW; - t.Type = tex.Type; + case STGenericMatTexture.TextureType.Diffuse: + t.Name = "Basic_Alb"; + break; + case STGenericMatTexture.TextureType.Emission: + t.Name = "Basic_Emm"; + break; + case STGenericMatTexture.TextureType.Normal: + t.Name = "Basic_Nrm"; + break; + case STGenericMatTexture.TextureType.Specular: + t.Name = "Basic_Spm"; + break; + case STGenericMatTexture.TextureType.SphereMap: + t.Name = "Basic_Sphere"; + break; + case STGenericMatTexture.TextureType.Metalness: + t.Name = "Basic_Mtl"; + break; + case STGenericMatTexture.TextureType.Roughness: + t.Name = "Basic_Rgh"; + break; + case STGenericMatTexture.TextureType.MRA: + t.Name = "Basic_MRA"; + break; + case STGenericMatTexture.TextureType.Shadow: + t.Name = "Basic_Bake_st0"; + break; + case STGenericMatTexture.TextureType.Light: + t.Name = "Basic_Bake_st1"; + break; } } + + if (PluginRuntime.bntxContainers.Count > 0) + { + foreach (var node in Parent.Parent.Nodes["EXT"].Nodes) + { + if (node is BinaryTextureContainer) + { + var bntx = (BinaryTextureContainer)node; + + bntx.ImportBasicTextures("Basic_Alb"); + bntx.ImportBasicTextures("Basic_Nrm"); + bntx.ImportBasicTextures("Basic_Spm"); + bntx.ImportBasicTextures("Basic_Sphere"); + bntx.ImportBasicTextures("Basic_Mtl"); + bntx.ImportBasicTextures("Basic_Rgh"); + bntx.ImportBasicTextures("Basic_MRA"); + bntx.ImportBasicTextures("Basic_Bake_st0"); + bntx.ImportBasicTextures("Basic_Bake_st1"); + bntx.ImportBasicTextures("Basic_Emm"); + } + } + } + + foreach (var tex in mat.TextureMaps) + { + foreach (var t in fmat.textures) + { + if (t.Type == tex.Type) + { + t.Name = tex.Name; + t.wrapModeS = tex.wrapModeS; + t.wrapModeT = tex.wrapModeT; + t.wrapModeW = tex.wrapModeW; + t.Type = tex.Type; + } + } + } + fmat.Material.Name = Text; + fmat.SetMaterial(fmat.Material); + + List keyList = new List(materials.Keys); + fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text); + + materials.Add(fmat.Text, fmat); + Nodes["FmatFolder"].Nodes.Add(fmat); } - fmat.Material.Name = Text; - fmat.SetMaterial(fmat.Material); - - List keyList = new List(materials.Keys); - fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text); - - materials.Add(fmat.Text, fmat); - Nodes["FmatFolder"].Nodes.Add(fmat); } + foreach (STGenericObject obj in assimp.objects) { FSHP shape = new FSHP(); @@ -1556,6 +1564,10 @@ namespace Bfres.Structs shape.vertexAttributes = settings.CreateNewAttributes(); shape.boneIndx = obj.BoneIndex; shape.MaterialIndex = obj.MaterialIndex + MatStartIndex; + + if (BFRES.IsWiiU) + shape.MaterialIndex = 0; + shape.Text = obj.ObjectName; shape.lodMeshes = obj.lodMeshes; shape.CreateNewBoundingBoxes(); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs index d3b1ba12..7a0df1e8 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs @@ -737,6 +737,7 @@ namespace FirstPlugin } IList faceList = new List(); + msh.IndexBuffer = new Syroot.NintenTools.Bfres.Buffer(); foreach (int f in mesh.faces) { faceList.Add((uint)f); @@ -757,7 +758,10 @@ namespace FirstPlugin } public static void SaveVertexBuffer(FSHP fshp) { - VertexBufferHelper helper = new VertexBufferHelper(new VertexBuffer(), Syroot.BinaryData.ByteOrder.LittleEndian); + VertexBuffer buffer = new VertexBuffer(); + buffer.Attributes = new ResDict(); + + VertexBufferHelper helper = new VertexBufferHelper(buffer, Syroot.BinaryData.ByteOrder.BigEndian); List atrib = new List(); fshp.UpdateVertices(); diff --git a/Switch_FileFormatsMain/FileFormats/GFPAK.cs b/Switch_FileFormatsMain/FileFormats/GFPAK.cs index 27bd395f..dd52c57d 100644 --- a/Switch_FileFormatsMain/FileFormats/GFPAK.cs +++ b/Switch_FileFormatsMain/FileFormats/GFPAK.cs @@ -166,7 +166,7 @@ namespace FirstPlugin if (sfd.ShowDialog() == DialogResult.OK) { - File.WriteAllBytes(sfd.FileName, data); + File.WriteAllBytes(sfd.FileName, STLibraryCompression.Type_LZ4.Decompress(data)); } } } diff --git a/Switch_FileFormatsMain/FileFormats/KCL.cs b/Switch_FileFormatsMain/FileFormats/KCL.cs index 907d560b..ff0a51c8 100644 --- a/Switch_FileFormatsMain/FileFormats/KCL.cs +++ b/Switch_FileFormatsMain/FileFormats/KCL.cs @@ -54,8 +54,7 @@ namespace FirstPlugin } public byte[] Save() { - KCLRoot root = (KCLRoot)EditorRoot; - return root.kcl.Write(Syroot.BinaryData.ByteOrder.LittleEndian); + return Data; } private static void SaveCompressFile(byte[] data, string FileName, CompressionType CompressionType, int Alignment = 0, bool EnableDialog = true) @@ -207,7 +206,8 @@ namespace FirstPlugin return; } kcl = MarioKart.MK7.KCL.FromOBJ(mod); - Read(kcl.Write(Syroot.BinaryData.ByteOrder.LittleEndian)); + FileHandler.Data = kcl.Write(Syroot.BinaryData.ByteOrder.LittleEndian); + Read(FileHandler.Data); } } diff --git a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs index 23a85059..2b0bab31 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs @@ -717,10 +717,10 @@ namespace FirstPlugin return false; } - public void LoadOpenGLTexture() + public BRTI_Texture LoadOpenGLTexture() { if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized) - return; + return null; LoadTexture(Texture); @@ -785,6 +785,8 @@ namespace FirstPlugin break; } renderedGLTex.display = loadImage(renderedGLTex); + + return renderedGLTex; } //Gets the decompressed byte[] @@ -808,10 +810,14 @@ namespace FirstPlugin decomp = DDS_Decompress.DecompressBC5(data, (int)Width, (int)Height, false); else if (Format == SurfaceFormat.BC5_SNORM) decomp = DDS_Decompress.DecompressBC5(data, (int)Width, (int)Height, true); - else if (Format == SurfaceFormat.R8_UNORM) - decomp = DDS_PixelDecode.DecodeR8G8(data, (int)Width, (int)Height); - else if (Format == SurfaceFormat.R8_G8_B8_A8_SRGB) - decomp = DDS_PixelDecode.DecodeR8G8B8A8(data, (int)Width, (int)Height); + else if (Format == SurfaceFormat.BC6_FLOAT) + decomp = DDS_Decompress.DecompressBC6(data, (int)Width, (int)Height, true); + else if (Format == SurfaceFormat.BC6_UFLOAT) + decomp = DDS_Decompress.DecompressBC6(data, (int)Width, (int)Height, false); + else if (Format == SurfaceFormat.BC7_SRGB) + decomp = DDS_Decompress.DecompressBC7(data, (int)Width, (int)Height, true); + else if (Format == SurfaceFormat.BC7_UNORM) + decomp = DDS_Decompress.DecompressBC7(data, (int)Width, (int)Height, false); else if (Format == SurfaceFormat.R8_G8_B8_A8_UNORM) decomp = DDS_PixelDecode.DecodeR8G8B8A8(data, (int)Width, (int)Height); else @@ -819,12 +825,11 @@ namespace FirstPlugin decomp = Properties.Resources.TextureError; Console.WriteLine($"Format {Format} not supported!"); - // throw new Exception($"Format {Format} not supported!"); + // throw new Exception($"Format {Format} not supported!"); } return decomp; } - public unsafe Bitmap GLTextureToBitmap(BRTI_Texture t, int id) { Bitmap bitmap = new Bitmap(t.width, t.height); @@ -1095,7 +1100,7 @@ namespace FirstPlugin if (IsDX10) dds.header.ddspf.fourCC = "DX10"; - dds.Save(dds, FileName, mipmaps, IsDX10); + dds.Save(dds, FileName, IsDX10, mipmaps); } public void LoadTexture(Texture tex, int target = 1) { diff --git a/Switch_FileFormatsMain/FileFormats/Texture/FTEX.cs b/Switch_FileFormatsMain/FileFormats/Texture/FTEX.cs index 14acba96..7311e13e 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/FTEX.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/FTEX.cs @@ -254,7 +254,7 @@ namespace FirstPlugin if (IsDX10) dds.header.ddspf.fourCC = "DX10"; - dds.Save(dds, FileName, renderedTex.mipmaps, IsDX10); + dds.Save(dds, FileName, IsDX10, renderedTex.mipmaps); } diff --git a/Switch_FileFormatsMain/FileFormats/Texture/GTX.cs b/Switch_FileFormatsMain/FileFormats/Texture/GTX.cs index 20c3f340..45eb75af 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/GTX.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/GTX.cs @@ -74,7 +74,6 @@ namespace FirstPlugin //From https://github.com/jam1garner/Smash-Forge/blob/master/Smash%20Forge/Filetypes/Textures/GTX.cs //Todo. Add swizzling back - public struct GX2Surface { public int dim; @@ -411,6 +410,9 @@ namespace FirstPlugin 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + + /*--------------------------------------- * * Code ported from AboodXD's GTX Extractor https://github.com/aboood40091/GTX-Extractor/blob/master/gtx_extract.py diff --git a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj index 841b3c0e..b8d7e20e 100644 --- a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj +++ b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj @@ -30,7 +30,7 @@ pdbonly true - ..\Switch_Toolbox\Lib\Plugins\ + ..\Switch_Toolbox\bin\Release\Lib\Plugins\ TRACE prompt 4 diff --git a/Switch_Toolbox/Lib/Plugins/AxInterop.WMPLib.dll b/Switch_Toolbox/Lib/Plugins/AxInterop.WMPLib.dll index 1a51f14a..d07bca3f 100644 Binary files a/Switch_Toolbox/Lib/Plugins/AxInterop.WMPLib.dll and b/Switch_Toolbox/Lib/Plugins/AxInterop.WMPLib.dll differ diff --git a/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.dll b/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.dll index e1f0505d..4f0c5287 100644 Binary files a/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.dll and b/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.dll differ diff --git a/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.pdb b/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.pdb index b7395a7e..695f7602 100644 Binary files a/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.pdb and b/Switch_Toolbox/Lib/Plugins/FirstPlugin.Plg.pdb differ diff --git a/Switch_Toolbox/Lib/Plugins/Interop.WMPLib.dll b/Switch_Toolbox/Lib/Plugins/Interop.WMPLib.dll index a85477c5..b0af9dcb 100644 Binary files a/Switch_Toolbox/Lib/Plugins/Interop.WMPLib.dll and b/Switch_Toolbox/Lib/Plugins/Interop.WMPLib.dll differ diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll index ffe9200c..a4f90f61 100644 Binary files a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll and b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll differ diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll b/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll index 65ea73a7..b27bd462 100644 Binary files a/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll and b/Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll differ diff --git a/Switch_Toolbox/Shader/KCL.frag b/Switch_Toolbox/Shader/KCL.frag index 27b5b23c..52d9c612 100644 --- a/Switch_Toolbox/Shader/KCL.frag +++ b/Switch_Toolbox/Shader/KCL.frag @@ -1,6 +1,7 @@ #version 330 in vec3 normal; in vec3 color; +in vec3 position; uniform vec3 difLightDirection; uniform vec3 difLightColor; @@ -14,6 +15,31 @@ uniform mat4 modelview; out vec4 FragColor; +//inspired by blender checker texture node +float checker(vec3 p) +{ + p.x = (p.x + 0.000001) * 0.999999; + p.y = (p.y + 0.000001) * 0.999999; + p.z = (p.z + 0.000001) * 0.999999; + + int xi = int(round(abs(p.x))); + int yi = int(round(abs(p.y))); + int zi = int(round(abs(p.z))); + + if (mod(yi,2)==0) { + if(mod(xi,2) != mod(zi,2)) + return 1; + else + return 0.5; + } + else { + if (mod(xi,2) == mod(zi,2)) + return 1; + else + return 0.5; + } +} + void main() { @@ -34,18 +60,10 @@ void main() vec3 displayNormal = (normal.xyz * 0.5) + 0.5; - vec4 diffuseColor = vec4(1); - - float halfLambert = dot(difLightDirection, normal.xyz); - halfLambert = (halfLambert + 1) / 2; - vec3 lighting = mix(ambLightColor, difLightColor, halfLambert); // gradient based lighting - - float normalBnW = dot(vec4(normal * mat3(modelview), 1.0), vec4(0.15,0.15,0.15,1.0)); - - vec3 outputColor = color.rgb * normalBnW; - - FragColor = vec4(outputColor.rgb,1); - if (renderType == 1) // normals color FragColor = vec4(displayNormal.rgb,1); + else{ + float shading = max(displayNormal.y,0.5); + FragColor = vec4(vec3(1,1,1)*shading*checker(position*0.015625), 1); + } } diff --git a/Switch_Toolbox/Shader/KCL.vert b/Switch_Toolbox/Shader/KCL.vert index 09127184..cc5af3df 100644 --- a/Switch_Toolbox/Shader/KCL.vert +++ b/Switch_Toolbox/Shader/KCL.vert @@ -8,6 +8,7 @@ in vec3 vColor; out vec3 normal; out vec3 color; +out vec3 position; uniform mat4 mvpMatrix; @@ -15,6 +16,7 @@ void main() { normal = vNormal; color = vColor; + position = vPosition; gl_Position = mvpMatrix * vec4(vPosition.xyz, 1.0); diff --git a/Switch_Toolbox/Switch_Toolbox.csproj b/Switch_Toolbox/Switch_Toolbox.csproj index 1070e667..6c92f718 100644 --- a/Switch_Toolbox/Switch_Toolbox.csproj +++ b/Switch_Toolbox/Switch_Toolbox.csproj @@ -40,6 +40,10 @@ Tool.ico + + ..\packages\AssimpNet.4.1.0\lib\net40\AssimpNet.dll + False + ..\packages\Costura.Fody.3.1.4\lib\net46\Costura.dll False @@ -54,18 +58,19 @@ ..\packages\K4os.Compression.LZ4.1.1.1\lib\net46\K4os.Compression.LZ4.dll + False ..\packages\K4os.Compression.LZ4.Streams.1.1.1\lib\net46\K4os.Compression.LZ4.Streams.dll + False ..\packages\K4os.Hash.xxHash.1.0.5\lib\net46\K4os.Hash.xxHash.dll + False ..\packages\lz4net.1.0.15.93\lib\net4-client\LZ4.dll - - - ..\packages\IonKiwi.lz4.net.1.0.11\lib\net46\lz4.AnyCPU.loader.dll + False ..\Switch_FileFormatsMain\Externals\NAudio.dll @@ -82,6 +87,7 @@ False Lib\SARCExt.dll + False ..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\SFGraphics.dll @@ -100,21 +106,8 @@ False - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll @@ -278,6 +271,7 @@ {d82a2c08-2a65-43af-bda6-a36cc27aa003} Updater + True @@ -370,6 +364,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -404,6 +401,8 @@ + + \ No newline at end of file diff --git a/Switch_Toolbox/packages.config b/Switch_Toolbox/packages.config index be0d4431..71353775 100644 --- a/Switch_Toolbox/packages.config +++ b/Switch_Toolbox/packages.config @@ -1,5 +1,6 @@  + diff --git a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs index 0dcadd44..9f33a1b5 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpHelper.cs @@ -9,44 +9,5 @@ namespace Switch_Toolbox.Library { public class AssimpHelper { - public static void ToNumerics(Matrix4x4 matIn, out System.Numerics.Matrix4x4 matOut) - { - //Assimp matrices are column vector, so X,Y,Z axes are columns 1-3 and 4th column is translation. - //Columns => Rows to make it compatible with numerics - matOut = new System.Numerics.Matrix4x4(matIn.A1, matIn.B1, matIn.C1, matIn.D1, //X - matIn.A2, matIn.B2, matIn.C2, matIn.D2, //Y - matIn.A3, matIn.B3, matIn.C3, matIn.D3, //Z - matIn.A4, matIn.B4, matIn.C4, matIn.D4); //Translation - } - - public static void FromNumerics(System.Numerics.Matrix4x4 matIn, out Matrix4x4 matOut) - { - //Numerics matrix are row vector, so X,Y,Z axes are rows 1-3 and 4th row is translation. - //Rows => Columns to make it compatible with assimp - - //X - matOut.A1 = matIn.M11; - matOut.B1 = matIn.M12; - matOut.C1 = matIn.M13; - matOut.D1 = matIn.M14; - - //Y - matOut.A2 = matIn.M21; - matOut.B2 = matIn.M22; - matOut.C2 = matIn.M23; - matOut.D2 = matIn.M24; - - //Z - matOut.A3 = matIn.M31; - matOut.B3 = matIn.M32; - matOut.C3 = matIn.M33; - matOut.D3 = matIn.M34; - - //Translation - matOut.A4 = matIn.M41; - matOut.B4 = matIn.M42; - matOut.C4 = matIn.M43; - matOut.D4 = matIn.M44; - } } } diff --git a/Switch_Toolbox_Library/FileFormats/DDS.cs b/Switch_Toolbox_Library/FileFormats/DDS.cs index 09931333..f7c162df 100644 --- a/Switch_Toolbox_Library/FileFormats/DDS.cs +++ b/Switch_Toolbox_Library/FileFormats/DDS.cs @@ -9,6 +9,7 @@ using Syroot.BinaryData; using System.IO; using System.Windows.Forms; using Switch_Toolbox.Library; +using Switch_Toolbox.Library.IO; namespace Switch_Toolbox.Library { @@ -185,12 +186,12 @@ namespace Switch_Toolbox.Library } public DDS(byte[] data) { - BinaryDataReader reader = new BinaryDataReader(new MemoryStream(data)); + FileReader reader = new FileReader(new MemoryStream(data)); Load(reader); } public DDS(string FileName) { - BinaryDataReader reader = new BinaryDataReader(new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read)); + FileReader reader = new FileReader(new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read)); Load(reader); } @@ -258,9 +259,9 @@ namespace Switch_Toolbox.Library DX10header.arrayFlag = reader.ReadUInt32(); DX10header.miscFlags2 = reader.ReadUInt32(); } - public void Save(DDS dds, string FileName, List> data = null, bool IsDX10 = false) + public void Save(DDS dds, string FileName, bool IsDX10 = false, List> data = null) { - BinaryDataWriter writer = new BinaryDataWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write)); + FileWriter writer = new FileWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.Write)); writer.Write(Encoding.ASCII.GetBytes("DDS ")); writer.Write(header.size); writer.Write(header.flags); @@ -277,7 +278,7 @@ namespace Switch_Toolbox.Library writer.Write(header.ddspf.size); writer.Write(header.ddspf.flags); - writer.Write(header.ddspf.fourCC); + writer.WriteSignature(header.ddspf.fourCC); writer.Write(header.ddspf.RGBBitCount); writer.Write(header.ddspf.RBitMask); writer.Write(header.ddspf.GBitMask); diff --git a/Switch_Toolbox_Library/FileFormats/DDS_Decompress.cs b/Switch_Toolbox_Library/FileFormats/DDS_Decompress.cs index 86f23667..1c1b1a86 100644 --- a/Switch_Toolbox_Library/FileFormats/DDS_Decompress.cs +++ b/Switch_Toolbox_Library/FileFormats/DDS_Decompress.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Diagnostics; using System.Drawing; using Switch_Toolbox.Library; @@ -439,6 +436,65 @@ namespace Switch_Toolbox.Library return BitmapExtension.GetBitmap(Output, W * 4, H * 4); } + public static Bitmap DecompressBC6(Byte[] data, int width, int height, bool IsSNORM) + { + DDS dds = new DDS(); + dds.bdata = data; + dds.header.height = (uint)height; + dds.header.width = (uint)width; + dds.DX10header = new DDS.DX10Header(); + dds.DX10header.DXGI_Format = DDS.DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM_SRGB; + dds.Save(dds, "temp.dds"); + + Process myProcess = new Process(); + myProcess.StartInfo.UseShellExecute = false; + myProcess.StartInfo.RedirectStandardOutput = true; + myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + myProcess.StartInfo.CreateNoWindow = true; + myProcess.StartInfo.FileName = "Lib/texconv.exe"; + myProcess.StartInfo.Arguments += "temp.dds"; + + if (IsSNORM) + myProcess.StartInfo.Arguments += " -srgb"; + + if (IsSNORM) + myProcess.StartInfo.Arguments += " -f " + "BC7_UNorm_SRgb"; + else + myProcess.StartInfo.Arguments += " -f " + "BC7_UNorm"; + + return null; + } + public static Bitmap DecompressBC7(Byte[] data, int width, int height, bool IsSNORM) + { + DDS dds = new DDS(); + dds.bdata = data; + dds.header = new DDS.Header(); + dds.header.height = (uint)height; + dds.header.width = (uint)width; + dds.header.ddspf = new DDS.Header.DDS_PixelFormat(); + dds.header.ddspf.fourCC = "DX10"; + + dds.DX10header = new DDS.DX10Header(); + dds.DX10header.DXGI_Format = DDS.DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM_SRGB; + dds.Save(dds, "temp.dds", true); + + Process myProcess = new Process(); + myProcess.StartInfo.UseShellExecute = false; + myProcess.StartInfo.RedirectStandardOutput = true; + myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal; + myProcess.StartInfo.CreateNoWindow = true; + myProcess.StartInfo.FileName = "Lib/texconv.exe"; + myProcess.StartInfo.Arguments += "temp.dds "; + myProcess.StartInfo.Arguments += "-ft "; + myProcess.StartInfo.Arguments += "png "; + myProcess.StartInfo.Arguments += "-f "; + myProcess.StartInfo.Arguments += "R10G10B10A2_UNORM "; + myProcess.StartInfo.Arguments += "-y "; + myProcess.Start(); + + return new Bitmap("temp.png"); + } + public static int Get16(byte[] Data, int Address) { return diff --git a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj index 8a6c2f4f..5d9b5e33 100644 --- a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj @@ -78,22 +78,9 @@ ..\Switch_Toolbox\Lib\Syroot.Maths.dll - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll - - - ..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll - - - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll - - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll diff --git a/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt b/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt index 77d1682d..6e26926d 100644 --- a/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt +++ b/Updater/obj/Release/Updater.csproj.FileListAbsolute.txt @@ -5,3 +5,9 @@ C:\Users\Nathan\source\repos\Switch_Toolbox\Updater\obj\Release\Updater.csprojAs C:\Users\Nathan\source\repos\Switch_Toolbox\Updater\obj\Release\Updater.csproj.CoreCompileInputs.cache C:\Users\Nathan\source\repos\Switch_Toolbox\Updater\obj\Release\Updater.exe C:\Users\Nathan\source\repos\Switch_Toolbox\Updater\obj\Release\Updater.pdb +C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox\Updater\bin\Release\Updater.exe.config +C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox\Updater\bin\Release\Updater.exe +C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox\Updater\bin\Release\Updater.pdb +C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox\Updater\obj\Release\Updater.csproj.CoreCompileInputs.cache +C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox\Updater\obj\Release\Updater.exe +C:\Users\Nathan\Documents\GitHub\Switch_Toolbox\Switch-Toolbox\Updater\obj\Release\Updater.pdb diff --git a/Updater/obj/Release/Updater.csprojAssemblyReference.cache b/Updater/obj/Release/Updater.csprojAssemblyReference.cache deleted file mode 100644 index f0434e87..00000000 Binary files a/Updater/obj/Release/Updater.csprojAssemblyReference.cache and /dev/null differ diff --git a/Updater/obj/Release/Updater.exe b/Updater/obj/Release/Updater.exe index 4399395d..e19773de 100644 Binary files a/Updater/obj/Release/Updater.exe and b/Updater/obj/Release/Updater.exe differ diff --git a/Updater/obj/Release/Updater.pdb b/Updater/obj/Release/Updater.pdb index 78035e17..12fea753 100644 Binary files a/Updater/obj/Release/Updater.pdb and b/Updater/obj/Release/Updater.pdb differ