Fix system dlls compiling and improve KCL shader
This commit is contained in:
parent
74d42d1b8b
commit
a81cfc0f98
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
|
||||
.vs/Switch_Toolbox/v15/Server/sqlite3/db.lock
|
||||
*.resources
|
||||
Debug/
|
||||
Release/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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)
|
||||
|
@ -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<string> keyList = new List<string>(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<string> keyList = new List<string>(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();
|
||||
|
@ -737,6 +737,7 @@ namespace FirstPlugin
|
||||
}
|
||||
|
||||
IList<uint> faceList = new List<uint>();
|
||||
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<VertexAttrib>();
|
||||
|
||||
VertexBufferHelper helper = new VertexBufferHelper(buffer, Syroot.BinaryData.ByteOrder.BigEndian);
|
||||
List<VertexBufferHelperAttrib> atrib = new List<VertexBufferHelperAttrib>();
|
||||
fshp.UpdateVertices();
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -30,7 +30,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\Switch_Toolbox\Lib\Plugins\</OutputPath>
|
||||
<OutputPath>..\Switch_Toolbox\bin\Release\Lib\Plugins\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -40,6 +40,10 @@
|
||||
<ApplicationIcon>Tool.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AssimpNet, Version=4.1.0.0, Culture=neutral, PublicKeyToken=0d51b391f59f42a6, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AssimpNet.4.1.0\lib\net40\AssimpNet.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Costura, Version=3.1.4.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Costura.Fody.3.1.4\lib\net46\Costura.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
@ -54,18 +58,19 @@
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4, Version=1.1.0.0, Culture=neutral, PublicKeyToken=27d14aecb5186925, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.1.1.1\lib\net46\K4os.Compression.LZ4.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.1.0.0, Culture=neutral, PublicKeyToken=27d14aecb5186925, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.1.1\lib\net46\K4os.Compression.LZ4.Streams.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.5.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.5\lib\net46\K4os.Hash.xxHash.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="LZ4, Version=1.0.15.93, Culture=neutral, PublicKeyToken=62e1b5ec1eec9bdd, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\lz4net.1.0.15.93\lib\net4-client\LZ4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="lz4.AnyCPU.loader, Version=1.0.11.0, Culture=neutral, PublicKeyToken=7aa3c636ef56b77f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\IonKiwi.lz4.net.1.0.11\lib\net46\lz4.AnyCPU.loader.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NAudio">
|
||||
<HintPath>..\Switch_FileFormatsMain\Externals\NAudio.dll</HintPath>
|
||||
@ -82,6 +87,7 @@
|
||||
<Reference Include="SARCExt, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Lib\SARCExt.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SFGraphics">
|
||||
<HintPath>..\..\..\..\Documents\Visual Studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Lib\SFGraphics.dll</HintPath>
|
||||
@ -100,21 +106,8 @@
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||
@ -278,6 +271,7 @@
|
||||
<ProjectReference Include="..\Updater\Updater.csproj">
|
||||
<Project>{d82a2c08-2a65-43af-bda6-a36cc27aa003}</Project>
|
||||
<Name>Updater</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -370,6 +364,9 @@
|
||||
<Content Include="Lib\Syroot.NintenTools.NSW.Bntx.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\texconv.exe">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\VGAudio.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@ -404,6 +401,8 @@
|
||||
<Error Condition="!Exists('..\packages\Fody.3.2.9\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.2.9\build\Fody.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.4\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.4\build\Costura.Fody.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\AssimpNet.4.1.0\build\AssimpNet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\AssimpNet.4.1.0\build\AssimpNet.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.3.1.4\build\Costura.Fody.targets')" />
|
||||
<Import Project="..\packages\AssimpNet.4.1.0\build\AssimpNet.targets" Condition="Exists('..\packages\AssimpNet.4.1.0\build\AssimpNet.targets')" />
|
||||
</Project>
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AssimpNet" version="4.1.0" targetFramework="net462" />
|
||||
<package id="Costura.Fody" version="3.1.4" targetFramework="net461" />
|
||||
<package id="CsvHelper" version="8.0.0-beta01" targetFramework="net462" />
|
||||
<package id="DockPanelSuite" version="3.0.4" targetFramework="net461" />
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<List<byte[]>> data = null, bool IsDX10 = false)
|
||||
public void Save(DDS dds, string FileName, bool IsDX10 = false, List<List<byte[]>> 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);
|
||||
|
@ -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
|
||||
|
@ -78,22 +78,9 @@
|
||||
<HintPath>..\Switch_Toolbox\Lib\Syroot.Maths.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||
|
@ -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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user