From 92e2024cb839e665763b9621d607151fcf8aa0cb Mon Sep 17 00:00:00 2001
From: Julien Duroure <julien.duroure@gmail.com>
Date: Mon, 26 Jun 2023 19:19:59 +0200
Subject: [PATCH] Fix: glTF importer shading flat/smooth

glTF importer: fix shading flat/smooth. polygons were to be flat by default, now they are smooth.

So updating to flat when no normals in input glTF

Pull Request: https://projects.blender.org/blender/blender-addons/pulls/104717
---
 io_scene_gltf2/__init__.py                       | 2 +-
 io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 3 ++-
 2 files changed, 3 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..12df0b383 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -641,7 +641,8 @@ 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
+        mesh.shade_flat()
         return
 
     if gltf.import_settings['import_shading'] == "SMOOTH":
-- 
GitLab