Skip to content

Commit

Permalink
Merge pull request KhronosGroup#1851 from KhronosGroup/fix_1849_round…
Browse files Browse the repository at this point in the history
…_normals

Round normals to avoid vertex split
  • Loading branch information
julienduroure authored Feb 11, 2023
2 parents d189049 + b5ef8e0 commit 2ad6c77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from . import gltf2_blender_export_keys
from ...io.com.gltf2_io_debug import print_console
from ...io.com.gltf2_io_constants import NORMALS_ROUNDING_DIGIT
from io_scene_gltf2.blender.exp import gltf2_blender_gather_skins
from io_scene_gltf2.io.com import gltf2_io_constants
from io_scene_gltf2.blender.com import gltf2_blender_conversion
Expand Down Expand Up @@ -710,10 +711,13 @@ def __get_normals(self):

self.normals = self.normals.reshape(len(self.blender_mesh.loops), 3)

self.normals = np.round(self.normals, NORMALS_ROUNDING_DIGIT)

self.morph_normals = []
for key_block in key_blocks:
ns = np.array(key_block.normals_split_get(), dtype=np.float32)
ns = ns.reshape(len(self.blender_mesh.loops), 3)
ns = np.round(ns, NORMALS_ROUNDING_DIGIT)
self.morph_normals.append(ns)

# Transform for skinning
Expand Down
3 changes: 3 additions & 0 deletions addons/io_scene_gltf2/io/com/gltf2_io_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ class BufferViewTarget(IntEnum):
GLTF_DATA_TYPE_MAT4 = "MAT4"

GLTF_IOR = 1.5

# Rounding digit used for normal rounding
NORMALS_ROUNDING_DIGIT = 4

0 comments on commit 2ad6c77

Please sign in to comment.