diff options
author | Kalle-Samuli Riihikoski <haikalle@gmail.com> | 2019-07-30 14:26:34 +0300 |
---|---|---|
committer | Kalle-Samuli Riihikoski <haikalle@gmail.com> | 2019-07-30 14:26:56 +0300 |
commit | 87e00386cf191674a42d320a4cbe18ddae2a94e0 (patch) | |
tree | 824cc39aeb0244951a82352ddd953f098320f60e /io_coat3D | |
parent | 27381001d7b9332eb669f1023f14b40d1f15f962 (diff) |
io_coat3D: Improve alpha textures
Diffstat (limited to 'io_coat3D')
-rw-r--r-- | io_coat3D/__init__.py | 13 | ||||
-rw-r--r-- | io_coat3D/data.json | 13 | ||||
-rw-r--r-- | io_coat3D/tex.py | 13 |
3 files changed, 23 insertions, 16 deletions
diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py index a987c1f0..83e13171 100644 --- a/io_coat3D/__init__.py +++ b/io_coat3D/__init__.py @@ -40,6 +40,7 @@ import os import ntpath import re import shutil +import pathlib import time import bpy @@ -495,12 +496,10 @@ class SCENE_OT_export(bpy.types.Operator): if run_background_update: if bpy.app.timers.is_registered(run_import_periodically): bpy.app.timers.unregister(run_import_periodically) - print('Disabling listener') run_background_update = False else: if not bpy.app.timers.is_registered(run_import_periodically): bpy.app.timers.register(run_import_periodically, persistent=True) - print('Enabling listener') run_background_update = True return {'FINISHED'} @@ -536,11 +535,10 @@ class SCENE_OT_export(bpy.types.Operator): coa = bpy.context.active_object.coat3D coat3D.exchangedir = set_exchange_folder() + p = pathlib.Path(coat3D.exchangedir) kokeilu = coat3D.exchangedir[:-9] - print('export kokeilu:', kokeilu) Blender_folder2 = ("%s%sExchange" % (kokeilu, os.sep)) Blender_folder2 += ('%sexport.txt' % (os.sep)) - print('BB: ', Blender_folder2) if (os.path.isfile(Blender_folder2)): os.remove(Blender_folder2) @@ -793,13 +791,11 @@ class SCENE_OT_import(bpy.types.Operator): if run_background_update: if bpy.app.timers.is_registered(run_import_periodically): bpy.app.timers.unregister(run_import_periodically) - print('Disabling listener') run_background_update = False else: if not bpy.app.timers.is_registered(run_import_periodically): bpy.app.timers.register(run_import_periodically, persistent=True) - print('Enabling listener') run_background_update = True return {'FINISHED'} @@ -1195,7 +1191,6 @@ class SCENE_OT_import(bpy.types.Operator): if (os.path.isfile(osoite_3b)): mesh_time = os.path.getmtime(new_obj.coat3D.applink_address) b_time = os.path.getmtime(osoite_3b) - print('abs:', abs(mesh_time-b_time)) if (abs(mesh_time-b_time) < 240): new_obj.coat3D.applink_3b_path = osoite_3b new_obj.coat3D.applink_3b_just_name = just_3b_name @@ -1230,7 +1225,6 @@ class SCENE_OT_import(bpy.types.Operator): return {'FINISHED'} def run_import_periodically(): - # print("Runing timers update check") coat3D = bpy.context.scene.coat3D kokeilu = coat3D.exchangedir[:-9] Blender_folder2 = ("%s%sExchange" % (kokeilu, os.sep)) @@ -1240,19 +1234,16 @@ def run_import_periodically(): try: os.path.isfile(Blender_folder2) except Exception as e: - print(e) run_background_update = False if bpy.app.timers.is_registered(run_import_periodically): bpy.app.timers.unregister(run_import_periodically) return time_interval if os.path.isfile(Blender_folder2): - # ! cant get proper context from timers for now. Override context: https://developer.blender.org/T62074 window = bpy.context.window_manager.windows[0] ctx = {'window': window, 'screen': window.screen, 'workspace': window.workspace} bpy.ops.import_applink.pilgway_3d_coat() else: - # print("GOZ: Nothing to update") return time_interval if not run_background_update and bpy.app.timers.is_registered(run_import_periodically): diff --git a/io_coat3D/data.json b/io_coat3D/data.json index e6eccae1..4eaf03e8 100644 --- a/io_coat3D/data.json +++ b/io_coat3D/data.json @@ -98,6 +98,19 @@ "huenode": "no", "node_location": [ 100, 100 ], "node_color": [ 0.1, 0.5, 0.1 ] + }, + + "alpha": { + "name": "alpha", + "colorspace": "noncolor", + "normal": "no", + "displacement": "no", + "find_input": [ "Alpha"], + "input": 8, + "rampnode": "no", + "huenode": "no", + "node_location": [ 0, -1000 ], + "node_color": [0.535, 0.608, 0.306] } } diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py index 685eab9c..75d50e72 100644 --- a/io_coat3D/tex.py +++ b/io_coat3D/tex.py @@ -347,7 +347,6 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures): #r coat3D.remove_path = True createnodes(index_mat, texcoat, create_group_node, tile_list, objekti, ind, is_new) - def createnodes(active_mat,texcoat, create_group_node, tile_list, objekti, ind, is_new): # Cretes new nodes and link textures into them bring_color = True # Meaning of these is to check if we can only update textures or do we need to create new nodes bring_metalness = True @@ -717,15 +716,19 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, else: if (texcoat['alpha'] != []): - if (type['name'] == 'color'): + if (type['name'] == 'alpha'): act_material.links.new(node.outputs[1], notegroup.inputs[8]) else: if (type['name'] == 'color'): act_material.links.new(node.outputs[1], notegroup.inputs[8]) + if(type['name'] != 'alpha'): + huenode = createExtraNodes(act_material, node, type) + else: + huenode = node + huenode.location = -100, -800 - huenode = createExtraNodes(act_material, node, type) - - act_material.links.new(huenode.outputs[0], notegroup.inputs[type['input']]) + if(type['name'] != 'alpha'): + act_material.links.new(huenode.outputs[0], notegroup.inputs[type['input']]) if (main_mat.type != 'MIX_SHADER' and input_color != -1): main_material.links.new(applink_tree.outputs[type['input']], main_mat.inputs[input_color]) if(type['name'] == 'color'): #Alpha connection into Principled shader |