-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T79104: Exporting a valid GLTF (was valid before import) causes GLTF validation errors #1138
Comments
Linked to #372 ? |
Confirmed that using "Degenerative dissolve" solve the issue. |
Yeah, there are tris with collinear verts. There are two solutions I can think of... We could just write some fixed value (say, (0,1,0)) whenever we have a zero normal. This would satisfy the validator and it shouldn't matter since degenerate tris are invisible. Or we could try to filter out any tris that have at least one zero normal. |
Filtering will probably be more time consuming that writing some fixed value, doesn't it? My vote goes for writing some fixed value, since tris are invisible, no matter the value |
Fixed value would be easier to code :) Can this wait until after #1120? I think setting a fixed value would just be # Change all zero normals to [0,1,0]
is_zero = ~normals.any(axis=1)
normals[is_zero, 1] = 1 |
Yes, sure, let's wait after #1120 (BTW, test are in progress, i will batch merge lot's of PR after 2.90 release) |
Patch I guess (I didn't test it) diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index ca38aa7..19d3b35 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -348,6 +348,12 @@ def __get_normals(blender_mesh, key_blocks, armature, blender_object, export_set
ns[:] = __apply_mat_to_all(normal_transform, ns)
__normalize_vecs(ns)
+ for ns in [normals, *morph_normals]:
+ # Replace zero normals with the unit UP vector.
+ # This happens (only?) for degenerate tris.
+ is_zero = ~ns.any(axis=1)
+ ns[is_zero, 2] = 1
+
# glTF stores deltas in morph targets
for ns in morph_normals:
ns -= normals |
Do you plan to open a PR, or do you want me to to it? |
I can do it. |
See https://developer.blender.org/T79104
On 2.83
The text was updated successfully, but these errors were encountered: