From ff65ae699df057a763d95ad5a9a2fb4cc433766f Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Thu, 17 Oct 2024 18:13:18 -0400 Subject: [PATCH] Fix multi channel combined UVs --- .../Bfres/Editing/ModelConversion/BfresModelImporter.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs b/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs index c486990..e7b83ea 100644 --- a/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs +++ b/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs @@ -876,6 +876,7 @@ private static VertexBuffer GenerateVertexBuffer(ResFile resFile, IOMesh mesh, S binormal.Z, 1)); } + int currentIdx = 0; for (int i = 0; i < vertex.UVs?.Count; i++) { if (i >= TexCoords.Length) @@ -883,18 +884,20 @@ private static VertexBuffer GenerateVertexBuffer(ResFile resFile, IOMesh mesh, S if (settings.CombineUVs && i % 2 == 0 && i < vertex.UVs.Count - 1) { - TexCoords[i][v] = new Vector4F( + TexCoords[currentIdx][v] = new Vector4F( vertex.UVs[i].X, 1 - vertex.UVs[i].Y, vertex.UVs[i + 1].X, 1 - vertex.UVs[i + 1].Y); + currentIdx++; } else { - TexCoords[i][v] = new Vector4F( + TexCoords[currentIdx][v] = new Vector4F( vertex.UVs[i].X, 1 - vertex.UVs[i].Y, 0, 0); + currentIdx++; } }