Closed lexaknyazev closed 3 years ago
Also zero-length normal vectors. The Blender exporter writes zero-length normals for degenerate triangles.
Today I tried creating a model with degenerate TEXCOORD_0
triangles. It was a cube where the entire UV map was [0.5, 0.5]. Good news, the Blender-IO project would not write any invalid tangents for the test model. This "degenerate UV" case is the only case I could think of where an artist would legitimately come up with questionable tangent vectors, and even here Blender won't produce zero-length tangents.
So, I think it's fine to disallow zero-length tangents in the spec. No changes to the Blender exporter appear to be needed.
Blender does produce zero-length normals quite reproducibly as a result of degenerate triangles, for example starting and then escaping out of an extrude of one face of a cube. The validator flags this as an error. It can be cleaned up with Mesh -> Cleanup -> Degenerate Dissolve.
I'm OK with disallowing zero-length tangents as well.
Not unit size normal vectors could be used to store ambient occlusion information. A normal with a zero length indicates that vertex should not be lit by a light source.
@gleblebedev For an individual game engine, tricks like that can be quite useful, but in glTF the goals include broad compatibility across a wide range of platforms and engines. The spec already states that normals must be "normalized" (meaning unit-length), and I think it's just an oversight that tangents were not already specified that way as well. Various open-source implementations and sample viewers for glTF will automatically normalize both these vectors to protect against invalid data.
Degenerate geometry should not be included in a glTF. Unlit geometry should be tagged with the KHR_materials_unlit extension. Ambient occlusion has a texture channel allocated when needed.
This issue has been brought up several times in different glTF tools repos. In some cases, exporters write tangent vector as zero.
We need the spec to clarify whether it's allowed and to provide some implementation guidelines for better ecosystem consistency.