[Bf-extensions-cvs] [7ad5abd] master: Materials Utils: Update to Mix Nodes, report switch

lijenstina noreply at git.blender.org
Sat Sep 3 02:45:49 CEST 2016


Commit: 7ad5abd14b050edbaa6f5ef51a31af70dee329eb
Author: lijenstina
Date:   Sat Sep 3 02:43:59 2016 +0200
Branches: master
https://developer.blender.org/rBA7ad5abd14b050edbaa6f5ef51a31af70dee329eb

Materials Utils: Update to Mix Nodes, report switch

Changes mostly touching materials_cycles_converter
Add color mix nodes tree between images and shader input
Add a scene prop for switching off the report in the UI
Remove the preferences conv_path entry it's not used
Remove the Value to RGB node for now (adding it properly needs an
refactor)
Change the placement of the texture nodes (hidden if > 1)

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

M	materials_utils/__init__.py
M	materials_utils/materials_cycles_converter.py
M	materials_utils/warning_messages_utils.py

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

diff --git a/materials_utils/__init__.py b/materials_utils/__init__.py
index 94021da..019b32b 100644
--- a/materials_utils/__init__.py
+++ b/materials_utils/__init__.py
@@ -1687,28 +1687,30 @@ class MATERIAL_MT_scenemassive_opt(Menu):
 
     def draw(self, context):
         layout = self.layout
-        sc = context.scene
+        scene = context.scene.mat_specials
 
-        layout.prop(sc.mat_specials, "EXTRACT_ALPHA",
+        layout.prop(scene, "EXTRACT_ALPHA",
                     text="Extract Alpha Textures (slow)")
         use_separator(self, context)
-        layout.prop(sc.mat_specials, "EXTRACT_PTEX",
+        layout.prop(scene, "EXTRACT_PTEX",
                     text="Extract Procedural Textures (slow)")
         use_separator(self, context)
-        layout.prop(sc.mat_specials, "EXTRACT_OW", text="Re-extract Textures")
+        layout.prop(scene, "EXTRACT_OW", text="Re-extract Textures")
+        use_separator(self, context)
+        layout.prop(scene, "SET_FAKE_USER", text="Set Fake User on unused images")
         use_separator(self, context)
-        layout.prop(sc.mat_specials, "SET_FAKE_USER", text="Set Fake User on unused images")
+        layout.prop(scene, "SCULPT_PAINT", text="Sculpt/Texture paint mode")
         use_separator(self, context)
-        layout.prop(sc.mat_specials, "SCULPT_PAINT", text="Sculpt/Texture paint mode")
+        layout.prop(scene, "UV_UNWRAP", text="Set Auto UV Unwrap (Active Object)")
         use_separator(self, context)
-        layout.prop(sc.mat_specials, "UV_UNWRAP", text="Set Auto UV Unwrap (Active Object)")
+        layout.prop(scene, "enable_report", text="Enable Report in the UI")
         use_separator(self, context)
 
         layout.label("Set the Bake Resolution")
-        res = str(sc.mat_specials.img_bake_size)
+        res = str(scene.img_bake_size)
         layout.label("Current Setting is : %s" % (res + "x" + res), icon='INFO')
         use_separator(self, context)
-        layout.prop(sc.mat_specials, "img_bake_size", icon='NODE_SEL', expand=True)
+        layout.prop(scene, "img_bake_size", icon='NODE_SEL', expand=True)
 
 
 class MATERIAL_PT_scenemassive(Panel):
@@ -1805,7 +1807,7 @@ class MATERIAL_MT_biconv_help(Menu):
         layout.label(text="If possible, avoid multiple conversions in a row")
         layout.label(text="Save Your Work Often", icon="ERROR")
         use_separator(self, context)
-        layout.label(text="Add a Mix Shader & Duplicate Missing Links")
+        layout.label(text="Try to link them manually using Mix Color nodes")
         layout.label(text="Only the last Image in the stack gets linked to Shader")
         layout.label(text="Current limitation:", icon="MOD_EXPLODE")
         use_separator(self, context)
@@ -1936,6 +1938,11 @@ class material_specials_scene_props(PropertyGroup):
             default=False,
             description=("Use automatical Angle based UV Unwrap of the active Object"),
             )
+    enable_report = BoolProperty(
+            attr="enable_report",
+            default=False,
+            description=("Enable Converter Report in the UI"),
+            )
     img_bake_size = EnumProperty(
             name="Bake Image Size",
             description="Set the resolution size of baked images \n",
@@ -1952,14 +1959,6 @@ class material_specials_scene_props(PropertyGroup):
 class VIEW3D_MT_material_utils_pref(AddonPreferences):
     bl_idname = __name__
 
-    conv_path = StringProperty(
-        name="Save Directory",
-        description=("Path to save images during conversion \n"
-                     "Default is the location of the blend file"),
-        default="//",
-        subtype='DIR_PATH',
-        )
-
     show_warnings = BoolProperty(
             name="Enable Warning messages",
             default=False,
@@ -2054,6 +2053,7 @@ class VIEW3D_MT_material_utils_pref(AddonPreferences):
     def draw(self, context):
         layout = self.layout
         sc = context.scene
+
         box = layout.box()
         box.label("Save Directory")
         split = box.split(0.85)
diff --git a/materials_utils/materials_cycles_converter.py b/materials_utils/materials_cycles_converter.py
index 1b46c0f..1cb23ba 100644
--- a/materials_utils/materials_cycles_converter.py
+++ b/materials_utils/materials_cycles_converter.py
@@ -5,6 +5,9 @@
 import bpy
 from os import path as os_path
 from bpy.types import Operator
+from math import (log2,
+                  ceil,
+                  )
 from bpy.props import (
             BoolProperty,
             EnumProperty,
@@ -26,6 +29,8 @@ CHECK_AUTONODE = False
 NODE_COLOR = (0.32, 0.75, 0.32)
 # set the node color for the paint base images (default reddish)
 NODE_COLOR_PAINT = (0.6, 0.0, 0.0)
+# set the mix node color (default blueish)
+NODE_COLOR_MIX = (0.1, 0.7, 0.8)
 
 # color for sculpt/texture painting setting (default clay the last entry is Roughness)
 PAINT_SC_COLOR = (0.80, 0.75, 0.54, 0.9)
@@ -267,13 +272,10 @@ def AutoNode(active=False, operator=None):
             # and a Color Ramp node
             shader = TreeNodes.nodes.new('ShaderNodeBsdfDiffuse')
             shader.location = 0, 470
-            shader_val = TreeNodes.nodes.new('ShaderNodeValToRGB')
-            shader_val.location = 0, 270
             shout = TreeNodes.nodes.new('ShaderNodeOutputMaterial')
             shout.location = 200, 400
             try:
                 links.new(shader.outputs[0], shout.inputs[0])
-                links.new(shader.inputs[0], shader_val.outputs[0])
             except:
                 link_fail = True
 
@@ -291,7 +293,6 @@ def AutoNode(active=False, operator=None):
                         shader.location = 0, 470
                         try:
                             links.new(shader.outputs[0], shout.inputs[0])
-                            links.new(shader.inputs[0], shader_val.outputs[0])
                         except:
                             link_fail = True
 
@@ -303,7 +304,6 @@ def AutoNode(active=False, operator=None):
                         shader.location = 0, 470
                         try:
                             links.new(shader.outputs[0], shout.inputs[0])
-                            links.new(shader.inputs[0], shader_val.outputs[0])
                         except:
                             link_fail = True
 
@@ -315,7 +315,6 @@ def AutoNode(active=False, operator=None):
                         shader.location = 0, 520
                         try:
                             links.new(shader.outputs[0], shout.inputs[0])
-                            links.new(shader.inputs[0], shader_val.outputs[0])
                         except:
                             link_fail = True
 
@@ -329,7 +328,6 @@ def AutoNode(active=False, operator=None):
                         shader.location = 0, 450
                         try:
                             links.new(shader.outputs[0], shout.inputs[0])
-                            links.new(shader.inputs[0], shader_val.outputs[0])
                         except:
                             link_fail = True
                     else:
@@ -390,8 +388,6 @@ def AutoNode(active=False, operator=None):
                     for link in links:
                         links.remove(link)
 
-                    TreeNodes.nodes.remove(shader_val)
-
                     clay_frame = TreeNodes.nodes.new('NodeFrame')
                     clay_frame.name = 'Clay Material'
                     clay_frame.label = 'Clay Material'
@@ -476,6 +472,8 @@ def AutoNode(active=False, operator=None):
                                 img_name = (img.name if hasattr(img, "name") else "NO NAME")
                                 shtext = TreeNodes.nodes.new('ShaderNodeTexImage')
                                 shtext.location = tex_node_loc
+                                shtext.hide = True
+                                shtext.width_hidden = 150
                                 shtext.image = img
                                 shtext.name = img_name
                                 shtext.label = "Image " + img_name
@@ -504,6 +502,8 @@ def AutoNode(active=False, operator=None):
                                         img_name = (img.name if hasattr(img, "name") else "NO NAME")
                                         shtext = TreeNodes.nodes.new('ShaderNodeTexImage')
                                         shtext.location = tex_node_loc
+                                        shtext.hide = True
+                                        shtext.width_hidden = 150
                                         shtext.image = img
                                         shtext.name = img_name
                                         shtext.label = "Baked Image " + img_name
@@ -538,7 +538,7 @@ def AutoNode(active=False, operator=None):
                     if sT and sculpt_paint is False:
                         if tex.use_map_color_diffuse:
                             try:
-                                links.new(shtext.outputs[0], shader_val.inputs[0])
+                                links.new(shtext.outputs[0], shader.inputs[0])
                             except:
                                 pass
                         if tex.use_map_emit:
@@ -569,7 +569,7 @@ def AutoNode(active=False, operator=None):
 
                         if tex.use_map_mirror:
                             try:
-                                links.new(shtext.outputs[0], shader_val.inputs[0])
+                                links.new(shtext.outputs[0], shader.inputs[0])
                             except:
                                 link_fail = True
 
@@ -682,6 +682,8 @@ def AutoNode(active=False, operator=None):
                         img = bpy.data.images.get(paint_img_name)
                         img_name = (img.name if hasattr(img, "name") else "NO NAME")
                         shtext = TreeNodes.nodes.new('ShaderNodeTexImage')
+                        shtext.hide = True
+                        shtext.width_hidden = 150
                         shtext.location = tex_node_loc
                         shtext.image = img
                         shtext.name = img_name
@@ -695,12 +697,17 @@ def AutoNode(active=False, operat

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list