Python mathutils.Color() Examples
The following are 30
code examples of mathutils.Color().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mathutils
, or try the search function
.
Example #1
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 6 votes |
def set_samples(self): samples = self.settings.samples if self.settings.individual_samples and not self.settings.use_autodetect: bakelist = bpy.context.scene.principled_baker_bakelist if self.job_name in bakelist.keys(): samples = bakelist[self.job_name].samples else: if self.job_name == "Diffuse": samples = self.settings.samples_diffuse elif self.job_name == "Bump": samples = self.settings.samples_bump elif self.job_name == "Vertex Color": samples = self.settings.samples_vertex_color elif self.job_name == "Material ID": samples = self.settings.samples_material_id elif self.job_name == "Wireframe": samples = self.settings.samples_wireframe bpy.context.scene.cycles.samples = samples
Example #2
Source File: __init__.py From BlenderTools with GNU General Public License v2.0 | 6 votes |
def set_paint_flavor(node_tree, switch_on): """Set paint flavor to this shader. :param node_tree: node tree of current shader :type node_tree: bpy.types.NodeTree :param switch_on: flag indication if flavor should be switched on or off :type switch_on: bool """ diff_col_n = node_tree.nodes[UnlitTex.DIFF_COL_NODE] diff_mult_n = node_tree.nodes[UnlitTex.TEX_MULT_NODE] if switch_on: for node in node_tree.nodes: if node.location.x > diff_col_n.location.x: node.location.x += 185 location = (diff_mult_n.location.x - 185, diff_mult_n.location.y + 50) paint.init(node_tree, location, diff_col_n.outputs["Color"], diff_mult_n.inputs[0]) else: paint.delete(node_tree)
Example #3
Source File: base.py From BlendLuxCore with GNU General Public License v3.0 | 6 votes |
def draw_common_buttons(self, context, layout): layout.prop(self, "priority") emission_socket = self.inputs["Emission"] if emission_socket.is_linked or emission_socket.default_value != Color((0.0, 0.0, 0.0)): lightgroups = context.scene.luxcore.lightgroups layout.prop_search(self, "lightgroup", lightgroups, "custom", icon=icons.LIGHTGROUP, text="") layout.prop(self, "color_depth") # Warn the user if he tries to use a 2D texture in a volume because it doesn't work has_2D_input = False for socket in self.inputs: node = utils_node.get_linked_node(socket) if node and "2D Mapping" in node.inputs: has_2D_input = True break if has_2D_input: layout.label(text="Can't use 2D textures!", icon=icons.WARNING)
Example #4
Source File: base.py From BlendLuxCore with GNU General Public License v3.0 | 6 votes |
def insert_link(self, link): # Note that this function is called BEFORE the new link is inserted into the node tree. node_tree = self.id_data for old_link in node_tree.links: # Check if an old link is deleted by this new link if old_link.to_socket == link.to_socket: if not old_link.from_socket.enabled: # Links from disabled sockets are not visible to the user, but prevent # other links from being established. This code solves this problem. # Sockets can be disabled on nodes where there are multiple output # sockets, e.g. the pointer node (Material/Volume/Color output, depending # on the selected node tree) node_tree.requested_links.add((link.from_socket, link.to_socket)) break # Try to find a suitable replacement socket (e.g. switch from "Material 1" # to "Material 2" on the Mix node, if "Material 2" is free) for socket in link.to_node.inputs: if socket.bl_idname == link.to_socket.bl_idname and not socket.is_linked: # We can not create the new link directly in this method, instead # the node_tree will create all requested links in its update method node_tree.requested_links.add((old_link.from_socket, socket)) break
Example #5
Source File: node.py From BlendLuxCore with GNU General Public License v3.0 | 6 votes |
def draw_transmission_info(node, layout): try: kd_socket = node.inputs["Diffuse Color"] except KeyError: # For some reason, this socket is named differently in the mattetranslucent material kd_socket = node.inputs["Reflection Color"] kt_socket = node.inputs["Transmission Color"] if not kd_socket.is_linked and not kt_socket.is_linked: # V component of the HSV color model kd_value = kd_socket.default_value.v kt_value = kt_socket.default_value.v # Note that this is an estimation. # We are for example not accounting for specular reflections transmitted = min(1 - kd_value, kt_value) layout.label(text="Transmitted: %.2f" % transmitted, icon=icons.INFO)
Example #6
Source File: nodes.py From Arnold-For-Blender with GNU General Public License v3.0 | 6 votes |
def draw_buttons(self, context, layout): col = layout.column() col.label(text="Color Correction") flow = col.column_flow(align=True) flow.prop(self, "gamma") flow.prop(self, "hue_shift") flow.prop(self, "saturation") flow.prop(self, "contrast") flow.prop(self, "contrast_pivot") flow.prop(self, "exposure") flow.prop(self, "multiply") flow.prop(self, "add") flow.prop(self, "invert") col.label(text="") col = layout.column() col.label(text="Alpha") flow = col.column_flow(align=True) flow.prop(self, "is_luminance") flow.prop(self, "multiply_alpha") flow.prop(self, "add_alpha") flow.prop(self, "invert_alpha") col.label(text="")
Example #7
Source File: common.py From Blender-CM3D2-Converter with Apache License 2.0 | 6 votes |
def get_image_average_color(img, sample_count=10): if not len(img.pixels): return mathutils.Color([0, 0, 0]) pixel_count = img.size[0] * img.size[1] channels = img.channels max_s = 0.0 max_s_color, average_color = mathutils.Color([0, 0, 0]), mathutils.Color([0, 0, 0]) seek_interval = pixel_count / sample_count for sample_index in range(sample_count): index = int(seek_interval * sample_index) * channels color = mathutils.Color(img.pixels[index:index+3]) average_color += color if max_s < color.s: max_s_color, max_s = color, color.s average_color /= sample_count output_color = (average_color + max_s_color) / 2 output_color.s *= 1.5 return max_s_color # 画像のおおよその平均色を取得 (UV版)
Example #8
Source File: do.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def light(self, en, scene, name): """ en: dxf entity name: ignored; exists to make separate and merged objects methods universally callable from _call_types() Creates, links and returns a new light object depending on the type and color of the dxf entity. """ # light_type : distant = 1; point = 2; spot = 3 if self.import_light: type_map = ["NONE", "SUN", "POINT", "SPOT"] layer = self.dwg.layers[en.layer] lamp = bpy.data.lamps.new(en.name, type_map[en.light_type]) if en.color != 256: aci = en.color else: aci = layer.color c = dxfgrabber.aci_to_true_color(aci) lamp.color = Color(c.rgb()) if en.light_type == 3: lamp.spot_size = en.hotspot_angle o = bpy.data.objects.new(en.name, lamp) o.location = self.proj(en.position) dir = self.proj(en.target) - self.proj(en.position) o.rotation_quaternion = dir.rotation_difference(Vector((0, 0, -1))) scene.objects.link(o) return o
Example #9
Source File: __init__.py From BlenderTools with GNU General Public License v2.0 | 6 votes |
def set_paint_flavor(node_tree, switch_on): """Set paint flavor to this shader. :param node_tree: node tree of current shader :type node_tree: bpy.types.NodeTree :param switch_on: flag indication if flavor should be switched on or off :type switch_on: bool """ diff_col_n = node_tree.nodes[UnlitVcolTex.DIFF_COL_NODE] diff_mult_n = node_tree.nodes[UnlitVcolTex.DIFF_MULT_NODE] if switch_on: for node in node_tree.nodes: if node.location.x > diff_col_n.location.x: node.location.x += 185 location = (diff_mult_n.location.x - 185 * 2, diff_mult_n.location.y + 50) paint.init(node_tree, location, diff_col_n.outputs["Color"], diff_mult_n.inputs[0]) else: paint.delete(node_tree)
Example #10
Source File: mesh_carver.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def DrawRightText(text, xt, yt, Size, Color, self): font_id = 0 # Decalage Ombre Sshadow_x = 2 Sshadow_y = -2 blf.size(font_id, Size, 72) blf.position(font_id, xt + Sshadow_x - blf.dimensions(font_id, text)[0], yt + Sshadow_y, 0) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) blf.draw(font_id, text) blf.position(font_id, xt - blf.dimensions(font_id, text)[0], yt, 0) if Color is not None: mColor = mathutils.Color((Color[0], Color[1], Color[2])) bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0) else: bgl.glColor4f(1.0, 1.0, 1.0, 1.0) blf.draw(font_id, text) # Opengl draws
Example #11
Source File: mesh_carver.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def DrawLeftText(text, xt, yt, Size, Color, self): font_id = 0 # Decalage Ombre Sshadow_x = 2 Sshadow_y = -2 blf.size(font_id, Size, 72) blf.position(font_id, xt + Sshadow_x, yt + Sshadow_y, 0) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) blf.draw(font_id, text) blf.position(font_id, xt, yt, 0) if Color is not None: mColor = mathutils.Color((Color[0], Color[1], Color[2])) bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0) else: bgl.glColor4f(1.0, 1.0, 1.0, 1.0) blf.draw(font_id, text) # Draw text (Right position)
Example #12
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 6 votes |
def guess_colors(self, obj): for mat_slot in obj.material_slots: if mat_slot.material: mat = mat_slot.material if MATERIAL_TAG not in mat.keys(): mat_out = get_active_output(mat_slot.material) if self.job_name == 'Emission': node_types = 'EMISSION' elif self.job_name == 'Alpha': node_types = 'BSDF_TRANSPARENT' else: node_types = ALPHA_NODES[self.job_name] color_list = get_value_list_from_node_types( mat_out, 'Color', node_types) if len(color_list) >= 1: self.new_node_colors[self.job_name] = color_list[0]
Example #13
Source File: glossy.py From BlenderExporter with Apache License 2.0 | 6 votes |
def __init__(self, bpyNode, socketName): super().__init__(bpyNode, socketName) input = self.findInput('Color') defaultColor = self.findTexture(input, SPECULAR_TEX) if defaultColor is not None: self.specularColor = Color((defaultColor[0], defaultColor[1], defaultColor[2])) self.mustBakeSpecular = input.mustBake if isinstance(input, AbstractBJSNode) else False # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - input = self.findInput('Roughness') defaultRoughness = self.findTexture(input, ROUGHNESS_TEX) if defaultRoughness is not None: self.roughness = defaultRoughness self.mustBakeRoughness = input.mustBake if isinstance(input, AbstractBJSNode) else False
Example #14
Source File: io_export_babylon.py From BlenderExporter with Apache License 2.0 | 6 votes |
def __init__(self, scene): self.autoClear = True world = scene.world if world: self.ambient_color = world.ambient_color self.clear_color = world.horizon_color else: self.ambient_color = mathutils.Color((0.2, 0.2, 0.3)) self.clear_color = mathutils.Color((0.0, 0.0, 0.0)) self.gravity = scene.gravity if world and world.mist_settings.use_mist: self.fogMode = FOGMODE_LINEAR self.fogColor = world.horizon_color self.fogStart = world.mist_settings.start self.fogEnd = world.mist_settings.depth self.fogDensity = 0.1 Main.log('Python World class constructor completed') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Example #15
Source File: structures.py From godot-blender-exporter with GNU General Public License v2.0 | 6 votes |
def gamma_correct(color): """Apply sRGB color space gamma correction to the given color""" if isinstance(color, float): # seperate color channel return color ** (1 / 2.2) # mathutils.Color does not support alpha yet, so just use RGB # see: https://developer.blender.org/T53540 color = color[0:3] # note that here use a widely mentioned sRGB approximation gamma = 2.2 # it is good enough, the exact gamma of sRGB can be find at # https://en.wikipedia.org/wiki/SRGB if len(color) > 3: color = color[:3] return mathutils.Color(tuple([x ** (1 / 2.2) for x in color])) # ------------------ Implicit Conversions of Blender Types --------------------
Example #16
Source File: spectrum.py From kaleidoscope with GNU General Public License v3.0 | 6 votes |
def set_global_settings(self, context): c = Color() for i in range(0,5): if self.history_count == 0: exec("c.r = PaletteHistory[1"+str(i)+"].r") exec("c.g = PaletteHistory[1"+str(i)+"].g") exec("c.b = PaletteHistory[1"+str(i)+"].b") elif self.history_count == 1: exec("c.r = PaletteHistory["+str(i+5)+"].r") exec("c.g = PaletteHistory["+str(i+5)+"].g") exec("c.b = PaletteHistory["+str(i+5)+"].b") elif self.history_count == 2: exec("c.r = PaletteHistory["+str(i)+"].r") exec("c.g = PaletteHistory["+str(i)+"].g") exec("c.b = PaletteHistory["+str(i)+"].b") c.v = c.v+self.value_slider c.s = c.s+self.saturation_slider # Hue correction, as it is a single sphere without a bound val = c.h+self.hue_slider c.h = val if val < 1 else val - 1 exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0") exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0") exec("self.color"+str(i+1)+" = c.r, c.g, c.b, 1.0")
Example #17
Source File: __init__.py From BlenderTools with GNU General Public License v2.0 | 6 votes |
def set_awhite_flavor(node_tree, switch_on): """Set alpha white flavor to this shader. :param node_tree: node tree of current shader :type node_tree: bpy.types.NodeTree :param switch_on: flag indication if alpha white flavor should be switched on or off :type switch_on: bool """ if switch_on: out_shader_node = node_tree.nodes[UnlitVcolTex.OUT_SHADER_NODE] from_mix_factor = node_tree.nodes[UnlitVcolTex.OPACITY_NODE].outputs[0] from_color_socket = node_tree.nodes[UnlitVcolTex.TEX_MULT_NODE].outputs[0] # remove link to transparency as awhite sets alpha to 1 if out_shader_node.inputs['Transparency'].links: node_tree.links.remove(out_shader_node.inputs['Transparency'].links[0]) location = (out_shader_node.location.x - 185, out_shader_node.location.y) awhite.init(node_tree, location, from_mix_factor, from_color_socket, out_shader_node.inputs['Emissive Color']) else: awhite.delete(node_tree)
Example #18
Source File: mesh_carver.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def DrawCenterText(text, xt, yt, Size, Color, self): font_id = 0 # Decalage Ombre Sshadow_x = 2 Sshadow_y = -2 blf.size(font_id, Size, 72) blf.position(font_id, xt + Sshadow_x - blf.dimensions(font_id, text)[0] / 2, yt + Sshadow_y, 0) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) blf.draw(font_id, text) blf.position(font_id, xt - blf.dimensions(font_id, text)[0] / 2, yt, 0) if Color is not None: mColor = mathutils.Color((Color[0], Color[1], Color[2])) bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0) else: bgl.glColor4f(1.0, 1.0, 1.0, 1.0) blf.draw(font_id, text) # Draw text (Left position)
Example #19
Source File: node_tree_presets.py From BlendLuxCore with GNU General Public License v3.0 | 5 votes |
def _preset_colored_smoke(self, obj, node_tree, output): # If it is not a smoke domain, create the material anyway, but warn the user is_smoke_domain = utils.find_smoke_domain_modifier(obj) new_node("LuxCoreNodeMatNull", node_tree, output) # We need a volume name = "Smoke Volume" vol_node_tree = bpy.data.node_groups.new(name=name, type="luxcore_volume_nodes") vol_nodes = vol_node_tree.nodes # Attach to output node volume_pointer = new_node("LuxCoreNodeTreePointer", node_tree, output, "Volume", "Interior Volume") volume_pointer.node_tree = vol_node_tree volume_pointer.location.x -= 40 volume_pointer.location.y -= 120 # Add volume nodes vol_output = vol_nodes.new("LuxCoreNodeVolOutput") vol_output.location = 300, 200 heterogeneous = new_node("LuxCoreNodeVolHeterogeneous", vol_node_tree, vol_output) smoke_node = new_node("LuxCoreNodeTexSmoke", vol_node_tree, heterogeneous, 0, "Scattering") smoke_node.location = heterogeneous.location + Vector((-500, -160)) if is_smoke_domain: smoke_node.domain = obj heterogeneous.auto_step_settings = True heterogeneous.domain = obj mix_node = new_node("LuxCoreNodeTexColorMix", vol_node_tree, heterogeneous, 0, "Absorption") mix_node.mode = "mix" mix_node.inputs["Color 1"].default_value = (1, 1, 1) vol_node_tree.links.new(smoke_node.outputs["density"], mix_node.inputs["Fac"]) vol_node_tree.links.new(smoke_node.outputs["color"], mix_node.inputs["Color 2"]) # Use IOR of air (doesn't really matter) heterogeneous.inputs["IOR"].default_value = 1 # A smoke material setup only makes sense on the smoke domain object if not is_smoke_domain: self.report({"ERROR"}, 'Object "%s" is not a smoke domain!' % obj.name)
Example #20
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def save_image(self, image): if self.job_name == 'Color' and self.settings.use_alpha_to_color: color_mode = 'RGBA' else: color_mode = self.settings.color_mode # color depth color_depth = self.settings.color_depth if color_depth == 'INDIVIDUAL': bakelist = bpy.context.scene.principled_baker_bakelist if self.job_name in bakelist.keys(): color_depth = bakelist[self.job_name].color_depth else: if self.job_name == "Diffuse": color_depth = self.settings.color_depth_diffuse elif self.job_name == "Bump": color_depth = self.settings.color_depth_bump elif self.job_name == "Vertex Color": color_depth = self.settings.color_depth_vertex_color elif self.job_name == "Material ID": color_depth = self.settings.color_depth_material_id elif self.job_name == "Wireframe": color_depth = self.settings.color_depth_wireframe save_image_as(image, file_path=image.filepath, file_format=self.settings.file_format, color_mode=color_mode, color_depth=color_depth, compression=self.settings.compression, quality=self.settings.quality, tiff_codec=self.settings.tiff_codec, exr_codec=self.settings.exr_codec)
Example #21
Source File: constfloat3.py From BlendLuxCore with GNU General Public License v3.0 | 5 votes |
def srgb_to_linear(color): return Color([channel_srgb_to_linear(c) for c in color])
Example #22
Source File: constfloat3.py From BlendLuxCore with GNU General Public License v3.0 | 5 votes |
def init(self, context): self.outputs.new("LuxCoreSocketColor", "Color")
Example #23
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def new_material(self, name): mat = bpy.data.materials.new(name) mat.use_nodes = True mat[MATERIAL_TAG] = 1 mat_output = mat.node_tree.nodes['Material Output'] mat_output.location = (300.0, 300.0) # 2.79 if is_2_79: mat.node_tree.nodes.remove(mat.node_tree.nodes['Diffuse BSDF']) principled_node = mat.node_tree.nodes.new( type='ShaderNodeBsdfPrincipled') # 2.80 else: principled_node = mat.node_tree.nodes['Principled BSDF'] principled_node.location = (10.0, 300.0) # copy settings to new principled_node for name, val in self.new_principled_node_settings.items(): if name == 'Color': name = 'Base Color' if val is not None: principled_node.inputs[name].default_value = val mat.node_tree.links.new( principled_node.outputs['BSDF'], mat_output.inputs['Surface']) return mat # TODO bug: ignores nodes in groups
Example #24
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def new_image(self, object_name, suffix, prefix=None, alpha=False): file_format = IMAGE_FILE_FORMAT_ENDINGS[self.settings.file_format] name = "{0}{1}.{2}".format( self.get_new_image_prefix(object_name), suffix, file_format) # include ending path = self.get_image_file_path(name) # resolution res = int(self.settings.custom_resolution) if self.settings.resolution == 'CUSTOM' else int( self.settings.resolution) is_float = False if self.settings.color_depth == '8' else True image = bpy.data.images.new( name=name, width=res, height=res, alpha=alpha, float_buffer=is_float) image.colorspace_settings.name = 'sRGB' if self.job_name in [ 'Color', 'Diffuse'] else 'Non-Color' image.generated_color = (0, 0, 0, 1) image.generated_type = 'BLANK' # 2.79 if is_2_79: image.use_alpha = alpha image.filepath = path return image
Example #25
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def new_bake_image(self, object_name): file_format = IMAGE_FILE_FORMAT_ENDINGS[self.settings.file_format] name = "{0}{1}.{2}".format( self.get_new_image_prefix(object_name), self.get_suffix(), file_format) # include ending path = self.get_image_file_path(name) # alpha alpha = False if self.settings.color_mode == 'RGBA' or (self.job_name == 'Color' and self.settings.use_alpha_to_color): alpha = True # color color = (0.5, 0.5, 1.0, 1.0) if get_bake_type( self.job_name) == 'NORMAL' else (0.0, 0.0, 0.0, 1.0) # resolution res = int(self.settings.custom_resolution) if self.settings.resolution == 'CUSTOM' else int( self.settings.resolution) is_float = False if self.settings.color_depth == '8' else True image = bpy.data.images.new( name=name, width=res, height=res, alpha=alpha, float_buffer=is_float) image.colorspace_settings.name = 'sRGB' if self.job_name in [ 'Color', 'Diffuse'] else 'Non-Color' image.generated_color = color image.generated_type = 'BLANK' # 2.79 if is_2_79: image.use_alpha = alpha image.filepath = path return image
Example #26
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def can_bake(self, objects): if not isinstance(objects, list): objects = [objects] for obj in objects: # enabled for rendering? if obj.hide_render: self.report( {'INFO'}, "baking cancelled. '{0}' not enabled for rendering.".format(obj.name)) return False # no material or missing output? if not has_material(obj): if not self.settings.use_vertex_color: self.report( {'INFO'}, "baking cancelled. '{0}' Material missing, Material Output missing, or Material Output input missing.".format(obj.name)) return False # # has vertex color? # if not self.settings.bake_mode == 'BATCH': # if self.settings.use_vertex_color and len(obj.data.vertex_colors) == 0: # self.report( # {'INFO'}, "baking cancelled. '{0}' has no Vertex Color.".format(obj.name)) # return False # empty material slots? for mat_slot in obj.material_slots: if not mat_slot.material: self.report( {'INFO'}, "baking cancelled. '{0}' has empty Material Slots.".format(obj.name)) return False return True
Example #27
Source File: constfloat3.py From BlendLuxCore with GNU General Public License v3.0 | 5 votes |
def update_value_hsv(self, context): col = Color() col.hsv = self.value_hsv self["value"] = srgb_to_linear(col) utils_node.force_viewport_update(self, context) # This is a helper property to offer an "HSV view" on the value property
Example #28
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def prepare_objects_for_bake_vertex_color(self, objects, vertex_color): if not isinstance(objects, list): objects = [objects] for obj in objects: for mat_slot in obj.material_slots: if mat_slot.material: mat = mat_slot.material pb_output_node = new_pb_output_node(mat) pb_emission_node = new_pb_emission_node(mat) socket_to_pb_emission_node_color = pb_emission_node.inputs['Color'] # activate temp output material_output = get_active_output(mat) if material_output: material_output.is_active_output = False pb_output_node.is_active_output = True attr_node = mat.node_tree.nodes.new( type='ShaderNodeAttribute') attr_node[NODE_TAG] = 1 # tag for clean up # attr_node.attribute_name = active_vert_col attr_node.attribute_name = vertex_color.name mat.node_tree.links.new( attr_node.outputs['Color'], socket_to_pb_emission_node_color) # link pb_emission_node to material_output mat.node_tree.links.new( pb_emission_node.outputs[0], pb_output_node.inputs['Surface'])
Example #29
Source File: pbaker_bake.py From Principled-Baker with GNU General Public License v3.0 | 5 votes |
def alpha_channel_to_color(self): if "Color" in self.new_images.keys() and "Alpha" in self.new_images.keys(): img = get_combined_images(self.new_images["Color"], self.new_images["Alpha"], 0, 3) self.new_images["Color"].pixels = img self.new_images["Color"].save()
Example #30
Source File: __init__.py From BlenderTools with GNU General Public License v2.0 | 5 votes |
def set_diffuse(node_tree, color): """Set diffuse color to shader. :param node_tree: node tree of current shader :type node_tree: bpy.types.NodeTree :param color: diffuse color :type color: Color or tuple """ color = _convert_utils.to_node_color(color) node_tree.nodes[Sky.DIFF_COL_NODE].outputs['Color'].default_value = color