mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix up export a little
This commit is contained in:
parent
9fae88934d
commit
ea04cc554f
1 changed files with 7 additions and 6 deletions
|
|
@ -318,11 +318,17 @@ public class MeshExporter
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_geometryType == typeof(VertexPositionNormalTangent))
|
if (_geometryType == typeof(VertexPositionNormalTangent))
|
||||||
|
{
|
||||||
|
// (Bi)tangents are universally stored as ByteFloat4, which uses 0..1 to represent the full -1..1 range.
|
||||||
|
// TODO: While this assumption is safe, it would be sensible to actually check.
|
||||||
|
var bitangent = ToVector4(attributes[MdlFile.VertexUsage.Tangent1]) * 2 - Vector4.One;
|
||||||
|
|
||||||
return new VertexPositionNormalTangent(
|
return new VertexPositionNormalTangent(
|
||||||
ToVector3(attributes[MdlFile.VertexUsage.Position]),
|
ToVector3(attributes[MdlFile.VertexUsage.Position]),
|
||||||
ToVector3(attributes[MdlFile.VertexUsage.Normal]),
|
ToVector3(attributes[MdlFile.VertexUsage.Normal]),
|
||||||
FixTangentVector(ToVector4(attributes[MdlFile.VertexUsage.Tangent1]))
|
bitangent
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
throw new Exception($"Unknown geometry type {_geometryType}.");
|
throw new Exception($"Unknown geometry type {_geometryType}.");
|
||||||
}
|
}
|
||||||
|
|
@ -440,11 +446,6 @@ public class MeshExporter
|
||||||
throw new Exception($"Unknown skinning type {_skinningType}");
|
throw new Exception($"Unknown skinning type {_skinningType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Clamps any tangent W value other than 1 to -1. </summary>
|
|
||||||
/// <remarks> Some XIV models seemingly store -1 as 0, this patches over that. </remarks>
|
|
||||||
private static Vector4 FixTangentVector(Vector4 tangent)
|
|
||||||
=> tangent with { W = tangent.W == 1 ? 1 : -1 };
|
|
||||||
|
|
||||||
/// <summary> Convert a vertex attribute value to a Vector2. Supported inputs are Vector2, Vector3, and Vector4. </summary>
|
/// <summary> Convert a vertex attribute value to a Vector2. Supported inputs are Vector2, Vector3, and Vector4. </summary>
|
||||||
private static Vector2 ToVector2(object data)
|
private static Vector2 ToVector2(object data)
|
||||||
=> data switch
|
=> data switch
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue