glTF-Blender-IO icon indicating copy to clipboard operation
glTF-Blender-IO copied to clipboard

Normal Maps Export Incorrectly

Open ManishJu opened this issue 3 years ago • 3 comments

Describe the bug

The normal map is not exported correctly with the model provided in the file. When you export and import the model back you can see the incorrect normal map. After import, on changing the mode of Color-Space from Non-Color ( Correct ) to sRGB ( Incorrect ) in the Normal texture node
the rendering results become correct !?

To Reproduce Steps to reproduce the behavior:

  1. Go to Shading tab and see the correct normal map and its settings
  2. Click on File->Export->gltf2
  3. Select Format type : gltf Binary
  4. In Include , select the selection "Selected Objects"
  5. In Transform, select +y option
  6. In geometry select UV and NORMALS
  7. In animation do not select anything.
  8. Name the file anything and save.
  9. Import back the saved file
  10. Go to the shading tab and you will see the model imported with incorrect normal.

Expected behavior The normal map should behave correctly in Non-Color mode after import

Screenshots You can see the incorrect import and the original correct model with the same shader graph bug1

.blend file/ .gltf link to file : https://drive.google.com/file/d/1WE5Ku22UWeTxKJu46uUnHVaYjxjmuYTf/view?usp=sharing

Version

  • OS: Windows 10
  • Blender Version : 2.93.4
  • GLTF Exporter Version : Default 1.6.16 and Latest 1.17.30

ManishJu avatar Oct 04 '21 13:10 ManishJu

Hello, Display is OK with online viewer https://gltf-viewer.donmccurdy.com/ Seems the problem come from importer, not from exporter. Can anyone confirm?

julienduroure avatar Oct 06 '21 06:10 julienduroure

The exported .glb does show this issue, it's subtly visible as a seam on the front of the shoe in my viewer:

Screen Shot 2021-10-06 at 10 48 40 PM

I'm pretty sure the problem is related to the normal map being a .exr image. I'm not too sure how those files work, perhaps something (either in this addon or in Blender?) is doing an unwanted linear -> sRGB conversion when exporting the image?

If I manually export the normal map as a PNG and then drop it into the file, things look fine:

before after
before after

Aside – it's generally a good idea to include vertex tangents in the export when debugging a normal map issue, but that doesn't seem to have been the cause here.

donmccurdy avatar Oct 07 '21 06:10 donmccurdy

@donmccurdy I was having this very same issue a couple of days ago, and converting the EXR to PNG in Blender solved the issue indeed.

ikermozos avatar Oct 09 '21 02:10 ikermozos

can confirm this issue with most models from polyhaven as they use exr as default texture format for the models

eg: https://polyhaven.com/a/drawer_cabinet

the normal map texture seems to be exporting in linear color space instead of sRGB

Before exr

After changing the normal map's color space from 'non-color data' to 'sRGB' exrsrgb

Is this correct ?

optimus007 avatar Sep 30 '22 11:09 optimus007

we are having this issue as well. it appears the exported normal maps are being exported in the wrong color space. the source map is correctly set to non-color. but when you import the file the normal map color is wrong and you get the faceting issue. to resolve it you need to set the normal map image to srgb. not sure how to properly resolve this.

JaduBen avatar Oct 05 '22 16:10 JaduBen

follow up, it appears this is fixed in blender 3.3

JaduBen avatar Oct 05 '22 17:10 JaduBen

Yes, I just tested with 3.3.1 released today, and problem is now solved. Closing

julienduroure avatar Oct 05 '22 19:10 julienduroure