-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to pre-calculate the model's tangent #81
Comments
Never Mind. I figure it out. I use blender to calculate the tangent vector which contain in the fbx file. I recommod to add a new option to calculate the tangent vector. |
Yeah I considered adding tangent calculation but it's actually very complicated to get right, and in practice most people will want to use mikktspace to stay compatible with other software. |
I highly recommend to add the method of tangent calculate. I try to use the mikktspace. Refer to https://www.turais.de/using-mikktspace-in-your-project/, I build the conection between mikktspace and ufbx_mesh. Here is my code. ` CalcMikkTSpaceTangent::CalcMikkTSpaceTangent()
} void CalcMikkTSpaceTangent::calc(ufbx_mesh* mesh)
} int CalcMikkTSpaceTangent::get_vertex_index (const SMikkTSpaceContext* context, int iFace, int iVert)
} int CalcMikkTSpaceTangent::get_num_faces (const SMikkTSpaceContext* context)
} int CalcMikkTSpaceTangent::get_num_vertices_of_face (const SMikkTSpaceContext* context, int iFace) void CalcMikkTSpaceTangent::get_position (const SMikkTSpaceContext* context, float outpos[], int iFace, int iVert)
} void CalcMikkTSpaceTangent::get_normal (const SMikkTSpaceContext* context, float outnormal[], int iFace, int iVert)
} void CalcMikkTSpaceTangent::get_tex_coords (const SMikkTSpaceContext* context, float outuv[], int iFace, int iVert)
} void CalcMikkTSpaceTangent::set_tspace_basic (const SMikkTSpaceContext* context, const float tangentu[], float fSign, int iFace, int iVert)
} Here are two problem.
|
Hmm, adding callbacks to external mikktspace would be an option for sure. It looks like it doesn't support N-gons: static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn)
{
int iTSpacesOffs = 0, f=0, t=0;
int iDstTriIndex = 0;
for (f=0; f<pContext->m_pInterface->m_getNumFaces(pContext); f++)
{
const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
if (verts!=3 && verts!=4) continue; This will make integrating it a lot harder as ufbx would need to create some sort of temporary face mapping with triangulated N-gons. |
In the structure, there has the varible called "vertex_tangent". I use it without consideration, but unfortunate it didn't exist. I wonder how to open the option to calculate the tangent?
The text was updated successfully, but these errors were encountered: