google / bigwheels

BigWheels is a cross-platform, API agnostic framework to build graphics applications.
Apache License 2.0
94 stars 37 forks source link

[glTF] Calculate tangents if not provided #460

Open footballhead opened 7 months ago

footballhead commented 7 months ago

Using scene::GltfLoader, some models in glTF-Sample-Assets do not render correctly since the TANGENT primitive attribute is missing.

Currently, if tangents are not present then the tangent will be set to {0, 0, 0, 0}; normal maps won't be rendered correctly.

From 3.7.2.1:

When tangents are not specified, client implementations SHOULD calculate tangents using default MikkTSpace algorithms with the specified vertex positions, normals, and texture coordinates associated with the normal texture.

This would allow us to render more models correctly like: