[Bf-extensions-cvs] [9db24518] master: glTF exporter: fix UVMap export when ORM are using different maps
Julien Duroure
noreply at git.blender.org
Thu Sep 17 19:00:31 CEST 2020
Commit: 9db2451888a5f5a67d3d3d0fc2a967c208a3a801
Author: Julien Duroure
Date: Thu Sep 17 19:00:16 2020 +0200
Branches: master
https://developer.blender.org/rBA9db2451888a5f5a67d3d3d0fc2a967c208a3a801
glTF exporter: fix UVMap export when ORM are using different maps
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
M io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 24ccb2e0..8eaf5e8d 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, 4, 28),
+ "version": (1, 4, 29),
'blender': (2, 90, 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 8dc5896f..c346a831 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py
@@ -146,7 +146,7 @@ def __gather_emissive_texture(blender_material, export_settings):
emissive = gltf2_blender_get.get_socket(blender_material, "Emissive")
if emissive is None:
emissive = gltf2_blender_get.get_socket_old(blender_material, "Emissive")
- return gltf2_blender_gather_texture_info.gather_texture_info((emissive,), export_settings)
+ return gltf2_blender_gather_texture_info.gather_texture_info(emissive, (emissive,), export_settings)
def __gather_extensions(blender_material, export_settings):
@@ -187,6 +187,7 @@ def __gather_normal_texture(blender_material, export_settings):
if normal is None:
normal = gltf2_blender_get.get_socket_old(blender_material, "Normal")
return gltf2_blender_gather_texture_info.gather_material_normal_texture_info_class(
+ normal,
(normal,),
export_settings)
@@ -226,22 +227,19 @@ def __gather_orm_texture(blender_material, export_settings):
return None
# Double-check this will past the filter in texture_info
- info = gltf2_blender_gather_texture_info.gather_texture_info(result, export_settings)
+ info = gltf2_blender_gather_texture_info.gather_texture_info(result[0], result, export_settings)
if info is None:
return None
return result
def __gather_occlusion_texture(blender_material, orm_texture, export_settings):
- if orm_texture is not None:
- return gltf2_blender_gather_texture_info.gather_material_occlusion_texture_info_class(
- orm_texture,
- export_settings)
occlusion = gltf2_blender_get.get_socket(blender_material, "Occlusion")
if occlusion is None:
occlusion = gltf2_blender_get.get_socket_old(blender_material, "Occlusion")
return gltf2_blender_gather_texture_info.gather_material_occlusion_texture_info_class(
- (occlusion,),
+ occlusion,
+ orm_texture or (occlusion,),
export_settings)
@@ -297,14 +295,22 @@ def __gather_clearcoat_extension(blender_material, export_settings):
clearcoat_roughness_slots = (clearcoat_roughness_socket,)
if len(clearcoat_roughness_slots) > 0:
- combined_texture = gltf2_blender_gather_texture_info.gather_texture_info(clearcoat_roughness_slots, export_settings)
if has_clearcoat_texture:
- clearcoat_extension['clearcoatTexture'] = combined_texture
+ clearcoat_extension['clearcoatTexture'] = gltf2_blender_gather_texture_info.gather_texture_info(
+ clearcoat_socket,
+ clearcoat_roughness_slots,
+ export_settings,
+ )
if has_clearcoat_roughness_texture:
- clearcoat_extension['clearcoatRoughnessTexture'] = combined_texture
+ clearcoat_extension['clearcoatRoughnessTexture'] = gltf2_blender_gather_texture_info.gather_texture_info(
+ clearcoat_roughness_socket,
+ clearcoat_roughness_slots,
+ export_settings,
+ )
if __has_image_node_from_socket(clearcoat_normal_socket):
clearcoat_extension['clearcoatNormalTexture'] = gltf2_blender_gather_texture_info.gather_material_normal_texture_info_class(
+ clearcoat_normal_socket,
(clearcoat_normal_socket,),
export_settings
)
@@ -336,7 +342,11 @@ def __gather_transmission_extension(blender_material, export_settings):
transmission_slots = (transmission_socket,)
if len(transmission_slots) > 0:
- combined_texture = gltf2_blender_gather_texture_info.gather_texture_info(transmission_slots, export_settings)
+ combined_texture = gltf2_blender_gather_texture_info.gather_texture_info(
+ transmission_socket,
+ transmission_slots,
+ export_settings,
+ )
if has_transmission_texture:
transmission_extension['transmissionTexture'] = combined_texture
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
index d0cf4517..a89b0ca1 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py
@@ -90,7 +90,7 @@ def __gather_base_color_texture(blender_material, export_settings):
else:
inputs = (base_color_socket,)
- return gltf2_blender_gather_texture_info.gather_texture_info(inputs, export_settings)
+ return gltf2_blender_gather_texture_info.gather_texture_info(base_color_socket, inputs, export_settings)
def __gather_extensions(blender_material, export_settings):
@@ -115,28 +115,29 @@ def __gather_metallic_factor(blender_material, export_settings):
def __gather_metallic_roughness_texture(blender_material, orm_texture, export_settings):
- if orm_texture is not None:
- texture_input = orm_texture
+ metallic_socket = gltf2_blender_get.get_socket(blender_material, "Metallic")
+ roughness_socket = gltf2_blender_get.get_socket(blender_material, "Roughness")
+
+ hasMetal = metallic_socket is not None and __has_image_node_from_socket(metallic_socket)
+ hasRough = roughness_socket is not None and __has_image_node_from_socket(roughness_socket)
+
+ if not hasMetal and not hasRough:
+ metallic_roughness = gltf2_blender_get.get_socket_old(blender_material, "MetallicRoughness")
+ if metallic_roughness is None or not __has_image_node_from_socket(metallic_roughness):
+ return None
+ texture_input = (metallic_roughness,)
+ elif not hasMetal:
+ texture_input = (roughness_socket,)
+ elif not hasRough:
+ texture_input = (metallic_socket,)
else:
- metallic_socket = gltf2_blender_get.get_socket(blender_material, "Metallic")
- roughness_socket = gltf2_blender_get.get_socket(blender_material, "Roughness")
-
- hasMetal = metallic_socket is not None and __has_image_node_from_socket(metallic_socket)
- hasRough = roughness_socket is not None and __has_image_node_from_socket(roughness_socket)
-
- if not hasMetal and not hasRough:
- metallic_roughness = gltf2_blender_get.get_socket_old(blender_material, "MetallicRoughness")
- if metallic_roughness is None or not __has_image_node_from_socket(metallic_roughness):
- return None
- texture_input = (metallic_roughness,)
- elif not hasMetal:
- texture_input = (roughness_socket,)
- elif not hasRough:
- texture_input = (metallic_socket,)
- else:
- texture_input = (metallic_socket, roughness_socket)
-
- return gltf2_blender_gather_texture_info.gather_texture_info(texture_input, export_settings)
+ texture_input = (metallic_socket, roughness_socket)
+
+ return gltf2_blender_gather_texture_info.gather_texture_info(
+ texture_input[0],
+ orm_texture or texture_input,
+ export_settings,
+ )
def __gather_roughness_factor(blender_material, export_settings):
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
index e8cc7c58..59cd5614 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_texture_info.py
@@ -23,40 +23,46 @@ from io_scene_gltf2.io.com.gltf2_io_extensions import Extension
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions
-def gather_texture_info(blender_shader_sockets, export_settings):
- return __gather_texture_info_helper(blender_shader_sockets, 'DEFAULT', export_settings)
+# blender_shader_sockets determine the texture and primary_socket determines
+# the textranform and UVMap. Ex: when combining an ORM texture, for
+# occlusion the primary_socket would be the occlusion socket, and
+# blender_shader_sockets would be the (O,R,M) sockets.
-def gather_material_normal_texture_info_class(blender_shader_sockets, export_settings):
- return __gather_texture_info_helper(blender_shader_sockets, 'NORMAL', export_settings)
+def gather_texture_info(primary_socket, blender_shader_sockets, export_settings):
+ return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'DEFAULT', export_settings)
-def gather_material_occlusion_texture_info_class(blender_shader_sockets, export_settings):
- return __gather_texture_info_helper(blender_shader_sockets, 'OCCLUSION', export_settings)
+def gather_material_normal_texture_info_class(primary_socket, blender_shader_sockets, export_settings):
+ return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'NORMAL', export_settings)
+
+def gather_material_occlusion_texture_info_class(primary_socket, blender_shader_sockets, export_settings):
+ return __gather_texture_info_helper(primary_socket, blender_shader_sockets, 'OCCLUSION', export_settings)
@cached
def __gather_texture_info_helper(
+ primary_socket: bpy.types.NodeSocket,
blender_shader_sockets: typing.Tuple[bpy.types.NodeSocket],
kind: str,
export_settings):
- if not __filter_texture_info(blender_shader_sockets, export_settings):
+ if not __fi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list