KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.45k stars 306 forks source link

Blender and glTF Export - Fix Mirrored Parts Shading Issues #2252

Open aiaustin opened 1 month ago

aiaustin commented 1 month ago

Describe the bug

I am getting shading/colour issues on glTF exports of parts in Blender models that were probably created in the far distant past as a mirror of an airplane wing or piece on one side transposed to the other. The "broken" parts sometimes look dark or black in Blender at other times they may be normally coloured. For some parts I was just able to duplicate and mirror the part again in Blender 4.1.1 to replace a broken object and that worked fine. But some parts cannot be mirrored.

I can't see what the difference is between each side, but when I export to glTF (for example) in the Khronos viewer the parts shows as a grey colour versus the proper colour of the other side. I checked and there is no negative scale on the piece. I also flipped face normals (both ways!) but that made no difference.

I have checked a glTF export of the Blender model in the Khronos glTF Sample Viewer and in the tool's Debug Settings the faulty part does have different "Shaded Normals", "Geometry Normals", "Geometry Tangents" and "Geometry Bitangents".

I wonder if anyone has seen this and knows the trick to correct it?

Ideally I want to be able to fix the model in Blender, be able to export as glTF and have that work in the Khronos glTf Sample Viewer without shading issues. The have a process clear enough ton be able to repeat on other models with similar issues. As well as document that process here to help others in future.

Sample Model X-15-1.zip

This occurs on multiple Blender models, but one sample X-15 rocket plane model that exhibits this behaviour is the "X-15-1" by TaffGoch on 3D Warehouse https://3dwarehouse.sketchup.com/model/a3a3a3d2ccc590eeaef99de91a3e555/X-15-1

To Reproduce Steps to reproduce the behavior:

  1. Open a .blend file that has such an issue. Sample provided is the X-15 rocket plane from
  2. Observe the properties for the right chine which is okay and the left chine which has the issue.
  3. Export the model to .glb
  4. Open model in Khronos glTf sample Viewer and observe the issue with the left chine.
  5. For clearer issue display look at Advanced Settings Debug Settings for Shading Normal, Tangents, BiTangents
  6. Issue can occur when glTF/glb is exported to other platforms, but some work, maybe because they are ignoring some feature that the faulty part exhibits.

Expected behavior Model to be able to be modified to not have such non-correctable parts or glTF exporter to compensate.

Screenshots

.blend file/ .gltf (mandatory) A zipped folder containing a .blend file for exporter issues and a .gltf file for importer issues. Please take care to include all resources, such as textures in the .zip file. If you are not allowed to share your file, make sure to create a new one from scratch that shows the issue. You can also try to delete or modify some data (objects, change textures, replace some meshes by some placeholder), to be able to share it without restriction.

Version

Additional context Many models exhibit this behaviours. probably ones where parts are mirrored when originally built. Sometimes taking a copy of the good side part and mirroring afresh in recent Blender works, but that is not always possible with the type of model.

aiaustin commented 1 month ago

Blender snapshot attached along with Khronos glTF Sample Viewer normal view and one of the Debug views. I should add that I have checked for the obvious things like scale showing negative, normal facing the same way as the good side, etc. From internet searches I do suspect some issue with Tangents, BiTangents or Shading. But how to fix that is quite another matter.

Blender-X15-1 Khronos-X15 Khronos-glTF-Viewer-Shading-Normal-X15-1

julienduroure commented 1 month ago

Hello, Still under investigation, but seems the model is quite weird. Trying to remove double on this part of the plane delete huge number of vertices

aiaustin commented 3 weeks ago

Yes, I saw that too.. but sticking to why the left chine is handled differently, it is an example of the general problem I see in several models. It would be good to explain it or get a fix anyone can replicate.