From 59dd045a42a7d57e920fae816c897d96c5a9354e Mon Sep 17 00:00:00 2001 From: 4sval Date: Fri, 28 Oct 2022 03:16:39 +0200 Subject: [PATCH] not perfect but better --- CUE4Parse | 2 +- FModel/MainWindow.xaml.cs | 2 +- FModel/Resources/default.frag | 12 ++++++------ FModel/Views/Snooper/Material.cs | 14 ++++++++++++-- FModel/Views/Snooper/Model.cs | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index 19781943..a70e6850 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 19781943809b520d21bc038a1078148f632c1a4c +Subproject commit a70e6850b658c1cc2d392ff1a14cd5d3faed78a5 diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index f8e42816..b07c5ae1 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -79,7 +79,7 @@ public partial class MainWindow #if DEBUG await _threadWorkerView.Begin(cancellationToken => _applicationView.CUE4Parse.Extract(cancellationToken, - "FortniteGame/Content/Environments/Artemis/Sets/Seven/Village/Meshes/S_Seven_Village_Wall_01A_Window02.uasset")); + "FortniteGame/Content/Athena/Artemis/Maps/Buildings/15x25/Artemis_Blimp_party.umap")); #endif } diff --git a/FModel/Resources/default.frag b/FModel/Resources/default.frag index 7603e37f..0f45b2bb 100644 --- a/FModel/Resources/default.frag +++ b/FModel/Resources/default.frag @@ -7,9 +7,9 @@ in float fTexIndex; in vec4 fColor; struct Material { - sampler2D diffuseMap[4]; - sampler2D normalMap[4]; - sampler2D specularMap[4]; + sampler2D diffuseMap[8]; + sampler2D normalMap[8]; + sampler2D specularMap[8]; sampler2D emissionMap; bool useSpecularMap; @@ -37,13 +37,13 @@ uniform bool display_vertex_colors; out vec4 FragColor; -vec4 getValueFromSamplerArray(sampler2D array[4]) { +vec4 getValueFromSamplerArray(sampler2D array[8]) { if (fTexIndex < 1.0) { return texture(array[0], fTexCoords); } if (fTexIndex < 2.0) { - return texture(array[2], fTexCoords); - } if (fTexIndex < 3.0) { return texture(array[1], fTexCoords); + } if (fTexIndex < 3.0) { + return texture(array[2], fTexCoords); } else { return texture(array[3], fTexCoords); } diff --git a/FModel/Views/Snooper/Material.cs b/FModel/Views/Snooper/Material.cs index 8b5f4c72..af3711d4 100644 --- a/FModel/Views/Snooper/Material.cs +++ b/FModel/Views/Snooper/Material.cs @@ -31,6 +31,7 @@ public class Material : IDisposable public Material() { Parameters = new CMaterialParams2(); + UvNumber = 1; DiffuseColor = Vector4.Zero; EmissionColor = Vector4.Zero; IsUsed = false; @@ -58,7 +59,7 @@ public class Material : IDisposable var guid = original.LightingGuid; if (cache.TryGetTexture(guid, out var texture)) { - array[index++] = texture; + array[index] = texture; } else if (original.GetFirstMip() is { } mip) { @@ -66,27 +67,36 @@ public class Material : IDisposable var t = new Texture(data, mip.SizeX, mip.SizeY, original); cache.AddTexture(guid, t); - array[index++] = t; + array[index] = t; } } index = 0; Diffuse = new Texture[UvNumber]; foreach (var d in Parameters.GetDiffuseTextures()) + { if (index < UvNumber && d is UTexture2D original) Add(Diffuse, original); + index++; + } index = 0; Normals = new Texture[UvNumber]; foreach (var n in Parameters.GetNormalsTextures()) + { if (index < UvNumber && n is UTexture2D original) Add(Normals, original); + index++; + } index = 0; SpecularMasks = new Texture[UvNumber]; foreach (var s in Parameters.GetSpecularMasksTextures()) + { if (index < UvNumber && s is UTexture2D original) Add(SpecularMasks, original); + index++; + } // diffuse light is based on normal map, so increase ambient if no normal map _ambientLight = new Vector3(Normals[0] == null ? 1.0f : 0.2f); diff --git a/FModel/Views/Snooper/Model.cs b/FModel/Views/Snooper/Model.cs index c77213db..761ca249 100644 --- a/FModel/Views/Snooper/Model.cs +++ b/FModel/Views/Snooper/Model.cs @@ -79,7 +79,7 @@ public class Model : IDisposable for (int m = 0; m < Materials.Length; m++) { if ((materials[m]?.TryLoad(out var material) ?? false) && material is UMaterialInterface unrealMaterial) - Materials[m] = new Material(lod.NumTexCoords, unrealMaterial); + Materials[m] = new Material(4, unrealMaterial); // lod.NumTexCoords else Materials[m] = new Material(); } @@ -201,7 +201,7 @@ public class Model : IDisposable _vao.BindInstancing(); // VertexAttributePointer 7, 8, 9, 10 } - { // setup all materials for use in different UV channels + { // setup all used materials for use in different UV channels for (var i = 0; i < Materials.Length; i++) { if (!Materials[i].IsUsed) continue;