From a2ae5da47f3e189463c9a9c3d8277cfc45d7a2d1 Mon Sep 17 00:00:00 2001 From: 4sval Date: Fri, 16 Dec 2022 22:41:20 +0100 Subject: [PATCH] final fantasy emissive intensity --- CUE4Parse | 2 +- FModel/Views/Snooper/Material.cs | 2 +- FModel/Views/Snooper/Renderer.cs | 52 +++++++++++++++----------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index 00663461..3b341d78 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 00663461bc32e1c0bac12448e2f5c65c78c57dd0 +Subproject commit 3b341d780a08f1bf38b0246750d476d4b948b286 diff --git a/FModel/Views/Snooper/Material.cs b/FModel/Views/Snooper/Material.cs index f2a5ba57..bfbb756b 100644 --- a/FModel/Views/Snooper/Material.cs +++ b/FModel/Views/Snooper/Material.cs @@ -112,7 +112,7 @@ public class Material : IDisposable if (Parameters.TryGetScalar(out var roughness, "Rough", "Roughness", "Ro Multiplier", "RO_mul", "Roughness_Mult")) Roughness = roughness; - if (Parameters.TryGetScalar(out var emissiveMultScalar, "emissive mult", "Emissive_Mult")) + if (Parameters.TryGetScalar(out var emissiveMultScalar, "emissive mult", "Emissive_Mult", "EmissiveIntensity")) EmissiveMult = emissiveMultScalar; else if (Parameters.TryGetLinearColor(out var emissiveMultColor, "Emissive Multiplier", "EmissiveMultiplier")) EmissiveMult = emissiveMultColor.R; diff --git a/FModel/Views/Snooper/Renderer.cs b/FModel/Views/Snooper/Renderer.cs index bd96fe45..d0123656 100644 --- a/FModel/Views/Snooper/Renderer.cs +++ b/FModel/Views/Snooper/Renderer.cs @@ -267,25 +267,6 @@ public class Renderer : IDisposable { for (int j = 0; j < textureData.Length; j++) { - var diffuse_key = j switch - { - 0 => "Diffuse", - > 0 => $"Diffuse_Texture_{j + 1}", - _ => CMaterialParams2.FallbackDiffuse - }; - var normal_key = j switch - { - 0 => "Normals", - > 0 => $"Normals_Texture_{j + 1}", - _ => CMaterialParams2.FallbackNormals - }; - var specularmasks_key = j switch - { - 0 => "SpecularMasks", - > 0 => $"SpecularMasks_{j + 1}", - _ => CMaterialParams2.FallbackNormals - }; - if (textureData[j]?.Load() is not { } textureDataIdx) continue; @@ -293,15 +274,24 @@ public class Renderer : IDisposable overrideMaterial.TryLoad(out var oMaterial) && oMaterial is UMaterialInterface oUnrealMaterial) material.SwapMaterial(oUnrealMaterial); - if (textureDataIdx.TryGetValue(out FPackageIndex diffuse, "Diffuse") && - diffuse.Load() is UTexture2D diffuseTexture) - material.Parameters.Textures[diffuse_key] = diffuseTexture; - if (textureDataIdx.TryGetValue(out FPackageIndex normal, "Normal") && - normal.Load() is UTexture2D normalTexture) - material.Parameters.Textures[normal_key] = normalTexture; - if (textureDataIdx.TryGetValue(out FPackageIndex specular, "Specular") && - specular.Load() is UTexture2D specularTexture) - material.Parameters.Textures[specularmasks_key] = specularTexture; + WorldTextureData(material, textureDataIdx, "Diffuse", j switch + { + 0 => "Diffuse", + > 0 => $"Diffuse_Texture_{j + 1}", + _ => CMaterialParams2.FallbackDiffuse + }); + WorldTextureData(material, textureDataIdx, "Normal", j switch + { + 0 => "Normals", + > 0 => $"Normals_Texture_{j + 1}", + _ => CMaterialParams2.FallbackNormals + }); + WorldTextureData(material, textureDataIdx, "Specular", j switch + { + 0 => "SpecularMasks", + > 0 => $"SpecularMasks_{j + 1}", + _ => CMaterialParams2.FallbackNormals + }); } } } @@ -331,6 +321,12 @@ public class Renderer : IDisposable } } + private void WorldTextureData(Material material, UObject textureData, string name, string key) + { + if (textureData.TryGetValue(out FPackageIndex package, name) && package.Load() is UTexture2D texture) + material.Parameters.Textures[key] = texture; + } + private void AdditionalWorlds(UObject actor, Matrix4x4 relation, CancellationToken cancellationToken) { if (!actor.TryGetValue(out FSoftObjectPath[] additionalWorlds, "AdditionalWorlds") ||