diff options
author | Bastiaan Olij <mux213@gmail.com> | 2018-12-08 13:43:46 +1100 |
---|---|---|
committer | Bastiaan Olij <mux213@gmail.com> | 2018-12-08 13:43:46 +1100 |
commit | fa63a0fe835868148c9ac6ab9a3f260928155c70 (patch) | |
tree | c71b546e66f8531cd2bea79a37a3874cfa6c41d1 /modules/csg | |
parent | 9b78147bce3de156eda3bd64a60133c4f2acc823 (diff) |
Reverse bitangent on everythings to ensure default normal map behavriour is consistent
Diffstat (limited to 'modules/csg')
-rw-r--r-- | modules/csg/csg_shape.cpp | 13 | ||||
-rw-r--r-- | modules/csg/csg_shape.h | 1 |
2 files changed, 1 insertions, 13 deletions
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 4e35014459..f4b061f494 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -197,17 +197,6 @@ void CSGShape::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexc fvTexcOut[1] = t.y; } -void CSGShape::mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert) { - ShapeUpdateSurface &surface = *((ShapeUpdateSurface *)pContext->m_pUserData); - - int i = (iFace * 3 + iVert) * 4; - - surface.tansw[i++] = fvTangent[0]; - surface.tansw[i++] = fvTangent[1]; - surface.tansw[i++] = fvTangent[2]; - surface.tansw[i++] = fSign; -} - void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, const tbool bIsOrientationPreserving, const int iFace, const int iVert) { @@ -216,7 +205,7 @@ void CSGShape::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const f int i = iFace * 3 + iVert; Vector3 normal = surface.normalsw[i]; Vector3 tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]); - Vector3 bitangent = Vector3(fvBiTangent[0], fvBiTangent[1], fvBiTangent[2]); + Vector3 bitangent = Vector3(-fvBiTangent[0], -fvBiTangent[1], -fvBiTangent[2]); // for some reason these are reversed, something with the coordinate system in Godot float d = bitangent.dot(normal.cross(tangent)); i *= 4; diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index 0a4bb5f665..7326f3d36a 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -97,7 +97,6 @@ private: static void mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert); static void mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert); static void mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert); - static void mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert); static void mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, const tbool bIsOrientationPreserving, const int iFace, const int iVert); |