[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4554] contrib/py/scripts/addons/ online_mat_lib: quick fix for online matlib.
Brendon Murphy
meta.androcto1 at gmail.com
Mon Jun 3 03:08:29 CEST 2013
Revision: 4554
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4554
Author: meta-androcto
Date: 2013-06-03 01:08:26 +0000 (Mon, 03 Jun 2013)
Log Message:
-----------
quick fix for online matlib. bundled lib working again.
Moving cycles > blender node converter to broken_stuff/system_cycles_material_text_node.py until such time as it's working again.
Modified Paths:
--------------
contrib/py/scripts/addons/online_mat_lib/__init__.py
Added Paths:
-----------
branches/broken_stuff/system_cycles_material_text_node.py
Removed Paths:
-------------
contrib/py/scripts/addons/system_cycles_material_text_node.py
Added: branches/broken_stuff/system_cycles_material_text_node.py
===================================================================
--- branches/broken_stuff/system_cycles_material_text_node.py (rev 0)
+++ branches/broken_stuff/system_cycles_material_text_node.py 2013-06-03 01:08:26 UTC (rev 4554)
@@ -0,0 +1,608 @@
+# system_cycles_material_text_node.py Copyright (C) 5-mar-2012, Silvio Falcinelli
+#
+#
+# special thanks to user blenderartists.org cmomoney
+#
+#
+# Show Information About the Blend.
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENCE BLOCK *****
+
+bl_info = {
+ "name": "Cycles Auto Material Texures Node Editor",
+ "author": "Silvio Falcinelli",
+ "version": (0,5),
+ "blender": (2, 62, 0),
+ "api": 44136,
+ "location": "Properties > Material > Automatic Node Editor ",
+ "description": "automatic cycles texture map",
+ "warning": "beta",
+ "wiki_url": 'http://www.rendering3d.net/' \
+ 'scripts/materialedior',
+ "tracker_url": "https://projects.blender.org/tracker/index.php?" \
+ "func=detail&aid=????",
+ "category": "System"}
+
+
+import bpy
+import math
+from math import log
+from math import pow
+from math import exp
+import os.path
+
+
+
+def AutoNodeOff():
+ mats = bpy.data.materials
+ for cmat in mats:
+ cmat.use_nodes=False
+ bpy.context.scene.render.engine='BLENDER_RENDER'
+
+
+def BakingText(tex,mode):
+ print('________________________________________')
+ print('INFO start bake texture ' + tex.name)
+ bpy.ops.object.mode_set(mode='OBJECT')
+ sc=bpy.context.scene
+ tmat=''
+ img=''
+ Robj=bpy.context.active_object
+ for n in bpy.data.materials:
+
+ if n.name=='TMP_BAKING':
+ tmat=n
+
+ if not tmat:
+ tmat = bpy.data.materials.new('TMP_BAKING')
+ tmat.name="TMP_BAKING"
+
+
+ bpy.ops.mesh.primitive_plane_add()
+ tm=bpy.context.active_object
+ tm.name="TMP_BAKING"
+ tm.data.name="TMP_BAKING"
+ bpy.ops.object.select_pattern(extend=False, pattern="TMP_BAKING", case_sensitive=False)
+ sc.objects.active = tm
+ bpy.context.scene.render.engine='BLENDER_RENDER'
+ tm.data.materials.append(tmat)
+ if len(tmat.texture_slots.items()) == 0:
+ tmat.texture_slots.add()
+ tmat.texture_slots[0].texture_coords='UV'
+ tmat.texture_slots[0].use_map_alpha=True
+ tmat.texture_slots[0].texture = tex.texture
+ tmat.texture_slots[0].use_map_alpha=True
+ tmat.texture_slots[0].use_map_color_diffuse=False
+ tmat.use_transparency=True
+ tmat.alpha=0
+ tmat.use_nodes=False
+ tmat.diffuse_color=1,1,1
+ bpy.ops.object.mode_set(mode='EDIT')
+ bpy.ops.uv.unwrap()
+
+ for n in bpy.data.images:
+ if n.name=='TMP_BAKING':
+ n.user_clear()
+ bpy.data.images.remove(n)
+
+
+ if mode == "ALPHA" and tex.texture.type=='IMAGE':
+ sizeX=tex.texture.image.size[0]
+ sizeY=tex.texture.image.size[1]
+ else:
+ sizeX=600
+ sizeY=600
+ bpy.ops.image.new(name="TMP_BAKING", width=sizeX, height=sizeY, color=(0.0, 0.0, 0.0, 1.0), alpha=True, uv_test_grid=False, float=False)
+ bpy.data.screens['UV Editing'].areas[1].spaces[0].image = bpy.data.images["TMP_BAKING"]
+ sc.render.engine='BLENDER_RENDER'
+ img = bpy.data.images["TMP_BAKING"]
+ img=bpy.data.images.get("TMP_BAKING")
+ img.file_format = "JPEG"
+ if mode == "ALPHA" and tex.texture.type=='IMAGE':
+ img.filepath_raw = tex.texture.image.filepath + "_BAKING.jpg"
+
+ else:
+ img.filepath_raw = tex.texture.name + "_PTEXT.jpg"
+
+ sc.render.bake_type = 'ALPHA'
+ sc.render.use_bake_selected_to_active = True
+ sc.render.use_bake_clear = True
+ bpy.ops.object.bake_image()
+ img.save()
+ bpy.ops.object.mode_set(mode='OBJECT')
+ bpy.ops.object.delete()
+ bpy.ops.object.select_pattern(extend=False, pattern=Robj.name, case_sensitive=False)
+ sc.objects.active = Robj
+ img.user_clear()
+ bpy.data.images.remove(img)
+ bpy.data.materials.remove(tmat)
+
+ print('INFO : end Bake ' + img.filepath_raw )
+ print('________________________________________')
+
+def AutoNode():
+
+ mats = bpy.data.materials
+ sc = bpy.context.scene
+
+ for cmat in mats:
+
+ cmat.use_nodes=True
+ TreeNodes=cmat.node_tree
+ links = TreeNodes.links
+
+ shader=''
+ shmix=''
+ shtsl=''
+ Add_Emission=''
+ Add_Translucent=''
+ Mix_Alpha=''
+ sT=False
+ lock=True
+
+ for n in TreeNodes.nodes:
+ if n.type == 'OUTPUT_MATERIAL':
+ if n.label == 'Lock':
+ lock=False
+
+
+ if lock:
+ for n in TreeNodes.nodes:
+ TreeNodes.nodes.remove(n)
+
+
+
+ if not shader :
+ shader = TreeNodes.nodes.new('BSDF_DIFFUSE')
+ shader.location = 0,470
+
+ shout = TreeNodes.nodes.new('OUTPUT_MATERIAL')
+ shout.location = 200,400
+ links.new(shader.outputs[0],shout.inputs[0])
+
+ textures = cmat.texture_slots
+ sM=True
+
+ for tex in textures:
+ if tex:
+ if tex.use:
+ if tex.use_map_alpha:
+ sM=False
+
+ if sc.EXTRACT_ALPHA:
+
+ if tex.texture.type =='IMAGE' and tex.texture.use_alpha:
+
+ if not os.path.exists(bpy.path.abspath(tex.texture.image.filepath + "_BAKING.jpg")) or sc.EXTRACT_OW:
+
+ BakingText(tex,'ALPHA')
+ else:
+ if not tex.texture.type =='IMAGE':
+
+ if not os.path.exists(bpy.path.abspath(tex.texture.name + "_PTEXT.jpg")) or sc.EXTRACT_OW:
+
+ BakingText(tex,'PTEXT')
+
+
+
+
+
+
+ if cmat.use_transparency and cmat.raytrace_transparency.ior == 1 and not cmat.raytrace_mirror.use and sM:
+ if not shader.type == 'BSDF_TRANSPARENT':
+ print("INFO: Make TRANSPARENT shader node " + cmat.name)
+ TreeNodes.nodes.remove(shader)
+ shader = TreeNodes.nodes.new('BSDF_TRANSPARENT')
+ shader.location = 0,470
+ links.new(shader.outputs[0],shout.inputs[0])
+
+
+
+ if not cmat.raytrace_mirror.use and not cmat.use_transparency:
+ if not shader.type == 'BSDF_DIFFUSE':
+ print("INFO: Make DIFFUSE shader node" + cmat.name)
+ TreeNodes.nodes.remove(shader)
+ shader = TreeNodes.nodes.new('BSDF_DIFFUSE')
+ shader.location = 0,470
+ links.new(shader.outputs[0],shout.inputs[0])
+
+
+
+ if cmat.raytrace_mirror.use and cmat.raytrace_mirror.reflect_factor>0.001 and cmat.use_transparency:
+ if not shader.type == 'BSDF_GLASS':
+ print("INFO: Make GLASS shader node" + cmat.name)
+ TreeNodes.nodes.remove(shader)
+ shader = TreeNodes.nodes.new('BSDF_GLASS')
+ shader.location = 0,470
+ links.new(shader.outputs[0],shout.inputs[0])
+
+
+
+
+ if cmat.raytrace_mirror.use and not cmat.use_transparency and cmat.raytrace_mirror.reflect_factor>0.001 :
+ if not shader.type == 'BSDF_GLOSSY':
+ print("INFO: Make MIRROR shader node" + cmat.name)
+ TreeNodes.nodes.remove(shader)
+ shader = TreeNodes.nodes.new('BSDF_GLOSSY')
+ shader.location = 0,520
+ links.new(shader.outputs[0],shout.inputs[0])
+
+
+
+ if cmat.emit > 0.001 :
+ if not shader.type == 'EMISSION' and not cmat.raytrace_mirror.reflect_factor>0.001 and not cmat.use_transparency:
+ print("INFO: Mix EMISSION shader node" + cmat.name)
+ TreeNodes.nodes.remove(shader)
+ shader = TreeNodes.nodes.new('EMISSION')
+ shader.location = 0,450
+ links.new(shader.outputs[0],shout.inputs[0])
+
+ else:
+ if not Add_Emission:
+ print("INFO: Add EMISSION shader node" + cmat.name)
+ shout.location = 550,330
+ Add_Emission = TreeNodes.nodes.new('ADD_SHADER')
+ Add_Emission.location = 370,490
+
+ shem = TreeNodes.nodes.new('EMISSION')
+ shem.location = 180,380
+
+ links.new(Add_Emission.outputs[0],shout.inputs[0])
+ links.new(shem.outputs[0],Add_Emission.inputs[1])
+ links.new(shader.outputs[0],Add_Emission.inputs[0])
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list