diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-05-07 10:59:14 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-05-07 10:59:14 +0300 |
commit | 447abeb9be69dcef24ea9c47bb2bde4488f9cb83 (patch) | |
tree | 1bb1318fb212e1371febde3e5410e1bc15efda86 /io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py | |
parent | ae8d56888683894676f924232b1f66c879c8a82c (diff) |
glTF exporter: image texture: manage rough without metal, metal without rough
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py | 23 |
1 files changed, 18 insertions, 5 deletions
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 1242c08d..1eccdeeb 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py @@ -165,15 +165,28 @@ def __gather_orm_texture(blender_material, export_settings): metallic_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Metallic") roughness_socket = gltf2_blender_get.get_socket_or_texture_slot(blender_material, "Roughness") - if metallic_socket is None or roughness_socket is None\ - or not __has_image_node_from_socket(metallic_socket)\ - or not __has_image_node_from_socket(roughness_socket): + + 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_or_texture_slot_old(blender_material, "MetallicRoughness") if metallic_roughness is None or not __has_image_node_from_socket(metallic_roughness): return None - return (occlusion, metallic_roughness, metallic_roughness) + result = (occlusion, metallic_roughness) + elif not hasMetal: + result = (occlusion, roughness_socket) + elif not hasRough: + result = (occlusion, metallic_socket) + else: + result = (occlusion, roughness_socket, metallic_socket) + + # Double-check this will past the filter in texture_info (otherwise there are different resolutions or other problems). + info = gltf2_blender_gather_texture_info.gather_texture_info(result, export_settings) + if info is None: + return None - return (occlusion, roughness_socket, metallic_socket) + return result def __gather_occlusion_texture(blender_material, orm_texture, export_settings): if orm_texture is not None: |