From f3bc210ae886dbf5ce1b12a495b8a0201720f1ee Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Mon, 26 Jun 2023 19:01:49 +0200 Subject: [PATCH 1/2] glTF importer: fix shading flat/smooth --- io_scene_gltf2/__init__.py | 2 +- io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 518c43b29..86854422f 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -4,7 +4,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (3, 6, 25), + "version": (3, 6, 27), 'blender': (3, 5, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py index 8bdb9ad4e..8f3471ed9 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py @@ -641,7 +641,9 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs): num_polys = len(mesh.polygons) if gltf.import_settings['import_shading'] == "FLAT": - # Polys are flat by default; don't have to do anything + # Polys are smooth by default, setting to flat + poly_smooths = np.full(num_polys, False) + mesh.polygons.foreach_set('use_smooth', poly_smooths) return if gltf.import_settings['import_shading'] == "SMOOTH": -- 2.30.2 From fe264350bd272ecbb70ace8782de6ab9081c0e6f Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Mon, 26 Jun 2023 19:13:53 +0200 Subject: [PATCH 2/2] glTF importer: cleanup, use shade_flat instead of use_smooth attribute on each poly --- io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py index 8f3471ed9..12df0b383 100755 --- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py @@ -642,8 +642,7 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs): if gltf.import_settings['import_shading'] == "FLAT": # Polys are smooth by default, setting to flat - poly_smooths = np.full(num_polys, False) - mesh.polygons.foreach_set('use_smooth', poly_smooths) + mesh.shade_flat() return if gltf.import_settings['import_shading'] == "SMOOTH": -- 2.30.2