Mirrored UV Problem with blender exporter

Post Reply
seelad
Posts: 2
Joined: Mon Feb 25, 2019 8:05 pm

Tue Feb 26, 2019 2:00 am

For a fix, see the attachments.

There is currently an issue with the blender mesh exporter causing binormals to be incorrectly calculated when the mesh has mirrored UVs, or in some other cases. This causes the normal map to display inverted, so bumps become dents or vice versa. This is immediately obvious if you try to export the human body mesh that comes with the blender templates. Although I am not 100% sure, since the arm UVs do not share the exact same space, but they may both be mirrored. Either way, seam lines appear on the upper arms near the shoulders because of the incorrect binormals.

The blender exporter does not account for mirrored UVs/textures on certain geometry. This is because the exporter does not take into account the bitangent_sign to correct the binormals when exporting a mesh. I have put together a fix on the exporter script, however I have only tested it exclusively on Blender 2.79. Here's what the body exports look like:
BinormalExample.png
BinormalExample.png (3.64 MiB) Viewed 4380 times
Left is the current blender exporter.
Center is what ships with the game
Right is the blender exporter with the fix.

On the far left you'll notice the face looks strange and some seams along the arm and shoulders. On the right, the seams on the arms and shoulders appear as they should but the head is brighter, and the seam on the neck is still obvious. I am not sure what is causing this, but it does not seem to be an issue with mirrored UVs, perhaps its because the head uses a second uv layer or maybe I did not account for something, I don't really know.

This issue does not only happen with custom races either, it can happen if you make anything with mirrored geometry and you don't change the UVs. I made a pair of boots where one boot was a mirror of the other and there were little plates on the boots that are supposed to 'pop' outward. On the non-mirrored boot it works as intended, but on the mirrored boot it was inverted.

Image

After running it through the exporter with the fix, both boots came out correctly.

Image

I have added a fix in the attachments called "OgreExport.zip" just replace the OgreExport.py in the kenshi blender exporter folder with the one in the zip. Make sure you backup the original script just in case. Then load up your models and re-export them as you would normally.
Attachments
OgreExport.zip
(10.63 KiB) Downloaded 198 times

oi__io
Posts: 29
Joined: Sat Feb 03, 2018 4:13 am

Tue Feb 26, 2019 9:27 am

Thank you for sharing the modified Blender exporter. It is a more elegant and simpler solution than having to manually inverting the green channel of normal map as I've proposed in this thread. Making a custom race based on vanilla body mesh should be more straightforward with your plugin.

I wish the dev would see this and share with us if they have better solution to remove the neck seam altogether.

someone
Developer
Posts: 360
Joined: Fri Aug 23, 2013 6:00 pm
Contact:

Thu Feb 28, 2019 2:47 pm

Seems I didn't test the exporter enough. I have uploaded a new version in the blender topic with a more complete fix for this.

I investigated the remaining seam on the neck. Turns out the model itself has a seam there which is fixed by the normal map. If you mark that seam as sharp or rip it in blender you should get the same result as the vanilla mesh.

seelad
Posts: 2
Joined: Mon Feb 25, 2019 8:05 pm

Fri Mar 01, 2019 12:23 am

Awesome! Thank you for taking the time to figure out that neck seam issue, and for creating a proper fix for the blender exporter. I realize I just sorta cobbled together something.

oi__io
Posts: 29
Joined: Sat Feb 03, 2018 4:13 am

Fri Mar 01, 2019 1:42 am

Thank you Sam for looking into it and also for the exporter update. You're the best! :D

arkhiel
Posts: 74
Joined: Wed Aug 06, 2014 9:07 am

Fri Mar 01, 2019 7:56 am

Does it has something to do with the fact that in max too if i clone something normals are reverted for the clone? (however if you attach the original to the clone, and only in that way, it fixes it)

User avatar
okawfj
Posts: 2
Joined: Mon Jan 29, 2018 3:09 am

Mon Mar 04, 2019 10:38 pm

Thank you for a wonderful fix!
omochi

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests