From ee9d840b915dba939ef7155582d526346ee03930 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Mon, 27 Feb 2023 06:01:16 +0100 Subject: [PATCH 1/2] Add test running instructions --- node_wrangler/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 node_wrangler/README.md diff --git a/node_wrangler/README.md b/node_wrangler/README.md new file mode 100644 index 000000000..33648cf5f --- /dev/null +++ b/node_wrangler/README.md @@ -0,0 +1,5 @@ +# Running Tests + +``` +./util_test.py +``` -- 2.30.2 From 604a4d678b2bd74869a0a2f342ddea6208688767 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Mon, 27 Feb 2023 06:06:03 +0100 Subject: [PATCH 2/2] Add texturecan test --- node_wrangler/util.py | 7 +++++-- node_wrangler/util_test.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/node_wrangler/util.py b/node_wrangler/util.py index 80ca0bed5..b3425c85d 100644 --- a/node_wrangler/util.py +++ b/node_wrangler/util.py @@ -153,10 +153,13 @@ def match_files_to_socket_names(files, sockets): for sname in sockets: for name, tag_list in names_to_tag_lists.items(): - if sname[0] == "Normal" and "dx" in tag_list: + if sname[0] == "Normal": # Blender wants GL normals, not DX (DirectX) ones: # https://www.reddit.com/r/blender/comments/rbuaua/texture_contains_normaldx_and_normalgl_files/ - continue + if 'dx' in tag_list: + continue + if 'directx' in tag_list: + continue matches = set(sname[1]).intersection(set(tag_list)) if matches: diff --git a/node_wrangler/util_test.py b/node_wrangler/util_test.py index 210259aed..4735aaadf 100755 --- a/node_wrangler/util_test.py +++ b/node_wrangler/util_test.py @@ -225,6 +225,34 @@ class TestPutFileNamesInSockets(unittest.TestCase): }, ) + def test_texturecan(self): + """Texture from: https://www.texturecan.com/details/67/""" + + files = [ + MockFile("metal_0010_ao_1k.jpg"), + MockFile("metal_0010_color_1k.jpg"), + MockFile("metal_0010_height_1k.png"), + MockFile("metal_0010_metallic_1k.jpg"), + MockFile("metal_0010_normal_directx_1k.png"), + MockFile("metal_0010_normal_opengl_1k.png"), + MockFile("metal_0010_roughness_1k.jpg"), + ] + sockets = sockets_fixture() + match_files_to_socket_names(files, sockets) + + assert_sockets( + self, + sockets, + { + "Ambient Occlusion": "metal_0010_ao_1k.jpg", + "Base Color": "metal_0010_color_1k.jpg", + "Displacement": "metal_0010_height_1k.png", + "Metallic": "metal_0010_metallic_1k.jpg", + "Normal": "metal_0010_normal_opengl_1k.png", + "Roughness": "metal_0010_roughness_1k.jpg", + }, + ) + if __name__ == "__main__": unittest.main(verbosity=2) -- 2.30.2