[Bf-extensions-cvs] [dc2d9b08] blender-v3.1-release: glTF exporter: manage factors for Clearcoat extension

Julien Duroure noreply at git.blender.org
Sat Feb 12 13:36:01 CET 2022


Commit: dc2d9b0864daf6805c89632004f8c98c91cc311b
Author: Julien Duroure
Date:   Sat Feb 12 13:35:51 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rBAdc2d9b0864daf6805c89632004f8c98c91cc311b

glTF exporter: manage factors for Clearcoat extension

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

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 9ed65aed..97574bb9 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,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": (1, 8, 14),
+    "version": (1, 8, 15),
     'blender': (3, 1, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
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 6bd7834b..a15f0f8d 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
@@ -273,7 +273,9 @@ def __gather_clearcoat_extension(blender_material, export_settings):
         clearcoat_extension['clearcoatFactor'] = clearcoat_socket.default_value
         clearcoat_enabled = clearcoat_extension['clearcoatFactor'] > 0
     elif __has_image_node_from_socket(clearcoat_socket):
-        clearcoat_extension['clearcoatFactor'] = 1
+        fac = gltf2_blender_get.get_factor_from_socket(clearcoat_socket, kind='VALUE')
+        # default value in glTF is 0.0, but if there is a texture without factor, use 1
+        clearcoat_extension['clearcoatFactor'] = fac if fac != None else 1.0
         has_clearcoat_texture = True
         clearcoat_enabled = True
 
@@ -283,7 +285,9 @@ def __gather_clearcoat_extension(blender_material, export_settings):
     if isinstance(clearcoat_roughness_socket, bpy.types.NodeSocket) and not clearcoat_roughness_socket.is_linked:
         clearcoat_extension['clearcoatRoughnessFactor'] = clearcoat_roughness_socket.default_value
     elif __has_image_node_from_socket(clearcoat_roughness_socket):
-        clearcoat_extension['clearcoatRoughnessFactor'] = 1
+        fac = gltf2_blender_get.get_factor_from_socket(clearcoat_roughness_socket, kind='VALUE')
+        # default value in glTF is 0.0, but if there is a texture without factor, use 1
+        clearcoat_extension['clearcoatRoughnessFactor'] = fac if fac != None else 1.0
         has_clearcoat_roughness_texture = True
 
     # Pack clearcoat (R) and clearcoatRoughness (G) channels.



More information about the Bf-extensions-cvs mailing list