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.49k stars 317 forks source link

Merge Vertices option merging vertices that shouldn't merge #1316

Closed AreCreeps closed 1 year ago

AreCreeps commented 3 years ago

Describe the bug I have been studying models from a game called Dragon Ball FighterZ, and these models rely heavily on proper normals for shading. Not enabling the merge vertices option seems to break some of the normals when the model is posed, however, enabling it seems to fix the issue.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Where the .gltf file is located'
  2. Click on 'Import .gltf'
  3. Enable 'Merge Vertices' while importing
  4. See error

Expected behavior The models have 2 meshes in particular that have issues when I enable this option. These meshes are very different, but some vertices tend to line up and the merge when they shouldn't. Both of these assigned to separate materials as they serve separate purposes.

Screenshots This is a screenshot of what the model looks like when I don't enable merge vertices. The bulky mesh used for shadow-casting purposes while a separate, more detailed mesh is inside this bulky mesh for the actual shader. image

This is a screenshot of what the model looks like when I do enable merge vertices. Some of the vertices that line up completely merge and destroy some parts of the models. image

.blend file/ .gltf Here is the model in question. The meshes that are causing the issue are assigned to dummy_material_0 (main model) and dummy_material_2 (shadow model). Cell Model.zip

Version

Additional context I think that giving an option to import the meshes in the .gltf files assigned to different materials as separate models could possibly solve this issue.

donmccurdy commented 3 years ago

Not enabling the merge vertices option seems to break some of the normals when the model is posed...

Can you share steps to see this problem? I tried a few edits in pose mode and didn't spot anything. This sounds like the main problem, in my opinion.


Looking at the screenshots, it is clear that merging vertices causes the overlapping mesh surfaces to shift in ways that change intersections. But because one is used for shadow casting, it is not obvious to me that they should maintain the same points of intersection after merging vertices — does this cause any actual problems, since presumably the shadow-casting mesh is not normally displayed?

Note that merging vertices requires rounding and snapping, and that within a glTF file these are two distinct sets of vertices. Maintaining distances between surfaces on the order of a floating point error is not necessarily possible, although perhaps a tolerance/precision option would be enough.

donmccurdy commented 3 years ago

For comparison I tried merging vertices in an offline tool, with configurable tolerance. The results are different, but I'm not sure how to tell whether they're "better". In this case I got very similar results for a wide range of tolerance choices, so perhaps the implementation is different in other ways. 🤔

npm install --global @gltf-transform/cli
gltf-transform weld CEN_body.gltf Cen_body_welded.glb --tolerance 0.0001

CEN_body_welded.glb.zip

Screen Shot 2021-03-31 at 7 38 16 PM

julienduroure commented 1 year ago

Hello, This is a quite old ticket, and seems we are not able to reproduce and get news from the bug reporter Without any news within a month, I suggest to close this ticket

julienduroure commented 1 year ago

Let's close this ticket. Please open a new one with a .blend file if you still have an issue