From 2c5f22047a1d84eff94cbce4f14f9b9ee1f89bb2 Mon Sep 17 00:00:00 2001 From: ackwell Date: Wed, 17 Jan 2024 23:25:20 +1100 Subject: [PATCH] Generate white vertex colours if missing --- Penumbra/Import/Models/Import/VertexAttribute.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Penumbra/Import/Models/Import/VertexAttribute.cs b/Penumbra/Import/Models/Import/VertexAttribute.cs index b5b20a3a..7c875162 100644 --- a/Penumbra/Import/Models/Import/VertexAttribute.cs +++ b/Penumbra/Import/Models/Import/VertexAttribute.cs @@ -394,10 +394,9 @@ public class VertexAttribute return result; } - public static VertexAttribute? Color(Accessors accessors) + public static VertexAttribute Color(Accessors accessors) { - if (!accessors.TryGetValue("COLOR_0", out var accessor)) - return null; + accessors.TryGetValue("COLOR_0", out var accessor); var element = new MdlStructs.VertexElement() { @@ -406,11 +405,12 @@ public class VertexAttribute Usage = (byte)MdlFile.VertexUsage.Color, }; - var values = accessor.AsVector4Array(); + // Some shaders rely on the presence of vertex colors to render - fall back to a pure white value if it's missing. + var values = accessor?.AsVector4Array(); return new VertexAttribute( element, - index => BuildByteFloat4(values[index]) + index => BuildByteFloat4(values?[index] ?? Vector4.One) ); }