From 5e6ca8b22c384fa5b4246d09ab3371d671454df3 Mon Sep 17 00:00:00 2001 From: ackwell Date: Sun, 14 Jan 2024 17:37:34 +1100 Subject: [PATCH] Improve fallback handling --- .../Import/Models/Export/MaterialExporter.cs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Penumbra/Import/Models/Export/MaterialExporter.cs b/Penumbra/Import/Models/Export/MaterialExporter.cs index 98e4b3b9..0b109ddf 100644 --- a/Penumbra/Import/Models/Export/MaterialExporter.cs +++ b/Penumbra/Import/Models/Export/MaterialExporter.cs @@ -158,6 +158,14 @@ public class MaterialExporter }; } + private ref struct TableRow + { + public int Stepped; + public int Previous; + public int Next; + public float Weight; + } + private readonly struct MultiplyOperation { public static void Execute(Image target, Image multiplier) @@ -320,20 +328,21 @@ public class MaterialExporter .WithAlpha(isFace? AlphaMode.MASK : AlphaMode.OPAQUE, 0.5f); } - private ref struct TableRow - { - public int Stepped; - public int Previous; - public int Next; - public float Weight; - } - private static MaterialBuilder BuildFallback(Material material, string name) { Penumbra.Log.Warning($"Unhandled shader package: {material.Mtrl.ShaderPackage.Name}"); - return BuildSharedBase(material, name) + + var materialBuilder = BuildSharedBase(material, name) .WithMetallicRoughnessShader() - .WithChannelParam(KnownChannel.BaseColor, KnownProperty.RGBA, Vector4.One); + .WithBaseColor(Vector4.One); + + if (material.Textures.TryGetValue(TextureUsage.SamplerDiffuse, out var diffuse)) + materialBuilder.WithBaseColor(BuildImage(diffuse, name, "basecolor")); + + if (material.Textures.TryGetValue(TextureUsage.SamplerNormal, out var normal)) + materialBuilder.WithNormal(BuildImage(normal, name, "normal")); + + return materialBuilder; } private static MaterialBuilder BuildSharedBase(Material material, string name)