Exporting tangents from UE4 for synced normal baking

Hi guys,

I have been doing some normal maps tests. UE4 has an option to import the tangents if they are present in the FBX file and Substance Designer can bake using those too but unfortunately I don’t get any in my FBX files as I use Modo and that’s not something it does.

UE4 generate fine tangents if there are none present in the file and Substance does that too. But there are many different possible variations in the exact algorithm used to compute normal mapping tangents, so the tangents generated by Substance and those generated by UE4 are slightly different and this can result in some shading errors.

Now I have to say that I got a decent result just by using the defaults, so maybe that should be considered good enough as it is but I wanted to try to see if I could get a truly synced workflow.

So I had this idea, why not just export the tangents from UE4. Unfortunately the static mesh FBX exporter of UE4 doesn’t include the tangents. And if we didn’t have all the source code that would have been the end of that idea. But amazingly, we do have the source code. So I just modified the export code to export the tangents and it worked right away!

I’d like to share this little mod, so that you can use this workflow if you’re interested, but since those forums are public I’m not sure where I should post the modified code since it should only be available to other licensees.

Right now, it’s not very convenient to have to import/export every mesh in UE4 before baking them but in time it should be possible to create a small command line utility to do the same thing.

Hmmm, this should just work if you import the mesh with “Import Normals” as the normals option instead of Calculate Normals. I didn’t have to use the normals and tangents option, just normals.

We modify the surface normals on a regular basis. Many artists here use “Surface Weighted Normals” to help with man-made things, or another script called “GetVertNormalsFromFace” that lets you specify flat faces that will preserve their flatness using vertex normals.

Yes, in a real world scenario, I would just make sure my object has good normals and that large flat areas of my object are flat in my normal map. But I wanted to see how far I could push it with an object where the normals are just averaged. I probably got carried away a bit with that but at least now I know I can get a perfectly synced workflow if I ever need it!

Thank you for the reply!