[Bf-extensions-cvs] [82574a38] master: glTF exporter: Fix emission factor exporting

Julien Duroure noreply at git.blender.org
Wed Feb 27 18:19:07 CET 2019


Commit: 82574a386e1ee717e34e960c529e21c8787e04e7
Author: Julien Duroure
Date:   Wed Feb 27 18:18:11 2019 +0100
Branches: master
https://developer.blender.org/rBA82574a386e1ee717e34e960c529e21c8787e04e7

glTF exporter: Fix emission factor exporting

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index a67b62f6..c68e29eb 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -515,3 +515,4 @@ def unregister():
     # remove from the export / import menu
     bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
     bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
+
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
index 41bb7649..5fff246a 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
@@ -103,8 +103,13 @@ def __gather_emissive_factor(blender_material, export_settings):
     emissive_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Emissive")
     if emissive_socket is None:
         emissive_socket = gltf2_blender_get.get_socket_or_texture_slot_old(blender_material, "EmissiveFactor")
-    if isinstance(emissive_socket, bpy.types.NodeSocket) and not emissive_socket.is_linked:
-        return list(emissive_socket.default_value)[0:3]
+    if isinstance(emissive_socket, bpy.types.NodeSocket):
+        if emissive_socket.is_linked:
+            # In glTF, the default emissiveFactor is all zeros, so if an emission texture is connected,
+            # we have to manually set it to all ones.
+            return [1.0, 1.0, 1.0]
+        else:
+            return list(emissive_socket.default_value)[0:3]
     return None



More information about the Bf-extensions-cvs mailing list