diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-07-03 10:44:45 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-07-03 10:45:34 -0300 |
commit | e63c64e256bc77618e4ea5ab13ecba6306ced0e6 (patch) | |
tree | 5afb9164567b5d0682dab6f93d84e7261529c78a /editor/import | |
parent | afbb5261e660acf08dd62f698d353e95fc7fb6bb (diff) |
Clean up normalmapping, make sure tangents are imported correctly.
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/editor_import_collada.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index e0a2ea624e..7948db3797 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -908,12 +908,20 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me #ifndef NO_UP_AXIS_SWAP if (collada.state.up_axis == Vector3::AXIS_Z) { + Vector3 bn = vertex.normal.cross(vertex.tangent.normal) * vertex.tangent.d; + SWAP(vertex.vertex.z, vertex.vertex.y); vertex.vertex.z = -vertex.vertex.z; SWAP(vertex.normal.z, vertex.normal.y); vertex.normal.z = -vertex.normal.z; SWAP(vertex.tangent.normal.z, vertex.tangent.normal.y); vertex.tangent.normal.z = -vertex.tangent.normal.z; + SWAP(bn.z, bn.y); + bn.z = -bn.z; + + vertex.tangent.d = vertex.normal.cross(vertex.tangent.normal).dot(bn) > 0 ? 1 : -1; + + print_line("Tangent " + itos(p_i) + ": " + vertex.tangent); } #endif |