mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Generate white vertex colours if missing
This commit is contained in:
parent
107f6706d3
commit
2c5f22047a
1 changed files with 5 additions and 5 deletions
|
|
@ -394,10 +394,9 @@ public class VertexAttribute
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VertexAttribute? Color(Accessors accessors)
|
public static VertexAttribute Color(Accessors accessors)
|
||||||
{
|
{
|
||||||
if (!accessors.TryGetValue("COLOR_0", out var accessor))
|
accessors.TryGetValue("COLOR_0", out var accessor);
|
||||||
return null;
|
|
||||||
|
|
||||||
var element = new MdlStructs.VertexElement()
|
var element = new MdlStructs.VertexElement()
|
||||||
{
|
{
|
||||||
|
|
@ -406,11 +405,12 @@ public class VertexAttribute
|
||||||
Usage = (byte)MdlFile.VertexUsage.Color,
|
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(
|
return new VertexAttribute(
|
||||||
element,
|
element,
|
||||||
index => BuildByteFloat4(values[index])
|
index => BuildByteFloat4(values?[index] ?? Vector4.One)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue