- uvtex_names = [u.name for u in mesh.uv_layers]
- if self.tbn_uvtex in uvtex_names:
- tbn_unit = uvtex_names.index(uvtex)
- del texunits[tbn_unit]
- texunits.insert(0, tbn_unit)
-
- for i in texunits:
+ # TBN coordinates must be generated before vertices are split by any other layer
+ uv_names = [u.name for i, u in texunits]
+ if self.tbn_uvtex in uv_names:
+ tbn_index = uv_names.index(self.tbn_uvtex)
+ unit = texunits[tbn_index]
+ del texunits[tbn_index]
+ texunits.insert(0, unit)
+
+ for i, u in texunits: