I'm working with a mesh created for a rendering engine that has no problem with UVs folded upon themselves, when using a normal map. The destination engine certainly does however, so it's important that I unflip these UVs.
Through my own research, I've discovered that Blender will display the mesh as it would appear in the other engine, as far as flipped UVs go, by leaving the normal map's color space set to sRBG rather than non-color. Yes, I realize you're supposed to set it to non-color, and by doing so the mesh looks great, but my goal isn't to just use it in Blender.
So, the fix, in theory, is pretty straightforward—flip the UV face in the proper direction in relation to the tile it exists in, and then change its material with textures that are flipped in the same direction. This way, the UVs are still mapped to the exact same area of the texture after they're no longer flipped. Of course, the appropriate channel of the normal map is inverted (red for horizontal flipping, green for vertical).
Unfortunately, other than looking at the UVs to see how they're folded, I have no way to determine direction. Even worse, the way Blender identifies flipped UVs is a bit too simplistic. Namely comparing the sign of the area of the UV triangle and its corresponding mesh triangle. Now this will detect flipped UVs, but only if they're flipped in one direction. This is because if you flip a UV in both directions, it's effectively just rotated 180 degrees, rather than inverted.
So, what I need to do is go over every UV triangle and determine its direction relative to its corresponding mesh triangle. This way, I should be able to figure out which way it needs to be flipped and make the appropriate changes.
Only problem is that I'm a bit out of my league on the necessary math. I'm thinking comparing the direction of each UV triangle edge to its corresponding mesh edge, should give me an idea?
upon feedback, I've replaced the original blender file with one of the actual project meshes, and to start out, here's the normal map:
and here's a rundown of what the issue is:
This is the default mesh, with its normal map applied, set to the color space of sRGB, and material settings tweaked to eliminate all shine/reflection. Note the splitting and abrupt changes in shading. This is an indication of flipped UVs
With Magic UV enabled, I can select flipped UVs, which correlates perfectly with the previous screenshot. The reason everything looks selected on the left is because the UV mapping which is often folded in upon itself in order to conserve space.
Unfortunately, fixing this isn't quite as simple as flipping these UV faces in place, as these faces all must retain their position in relation to the texture in order for the mesh to display the intended detail. The solution is in 3 parts.
separate the flipped UV faces from a particular UV island into a separate mesh
flip these faces in the correct direction in relation to the UV tile it's on. So if the original flipped UV faces are on the left side of the tile, and you flip them horizontally, they should end up on the right side.
create a new set of textures by horizontally flipping the originals - being sure to invert the red channel of the Normal map to make said map work as intended. Do the equivalent for a third set of textures, this time vertically flipping them.
apply the horizontally flipped textures to the new mesh.
repeat until everything is flipped.
After applying this method to the outer ring, you can tell the splitting is gone, and the shading is now consistent. This is the goal, so lets move onto the inner ring.
And now we have a problem - yes, it's true that the seams are gone, but now we're left with a smooth gradient from one end to the other.