diff options
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_material.py')
-rw-r--r-- | release/scripts/startup/bl_ui/properties_material.py | 196 |
1 files changed, 168 insertions, 28 deletions
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 73740df37e8..9aed338bad4 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -21,7 +21,7 @@ import bpy from bpy.types import Menu, Panel, UIList from rna_prop_ui import PropertyPanel from bpy.app.translations import pgettext_iface as iface_ - +from bpy_extras.node_utils import find_node_input, find_output_node def active_node_mat(mat): # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate @@ -82,7 +82,7 @@ class MATERIAL_UL_matslots(UIList): layout.prop(ma, "name", text="", emboss=False, icon_value=icon) else: layout.label(text="", icon_value=icon) - if ma and not context.scene.render.use_shading_nodes: + if ma and not context.view_render.use_shading_nodes: manode = ma.active_node_material if manode: layout.label(text=iface_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode)) @@ -101,7 +101,7 @@ class MaterialButtonsPanel: @classmethod def poll(cls, context): - return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES) + return context.material and (context.engine in cls.COMPAT_ENGINES) class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): @@ -114,7 +114,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): # An exception, don't call the parent poll func because # this manages materials for all engine types - engine = context.scene.render.engine + engine = context.engine return (context.material or context.object) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -197,7 +197,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return mat and (not simple_material(mat)) and (mat.type in {'SURFACE', 'WIRE', 'VOLUME'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -250,7 +250,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -307,7 +307,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -360,7 +360,7 @@ class MATERIAL_PT_shading(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -394,7 +394,7 @@ class MATERIAL_PT_transp(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): @@ -460,7 +460,7 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): @@ -518,7 +518,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): @@ -569,7 +569,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -622,7 +622,7 @@ class MATERIAL_PT_flare(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): @@ -656,7 +656,7 @@ class MATERIAL_PT_game_settings(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES) + return context.material and (context.engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -685,7 +685,7 @@ class MATERIAL_PT_physics(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES) + return context.material and (context.engine in cls.COMPAT_ENGINES) def draw(self, context): layout = self.layout @@ -718,7 +718,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return mat and (mat.type in {'SURFACE', 'WIRE', 'HALO'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -746,7 +746,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel, Panel): col.prop(tan, "width_fade") ob = context.object if ob and ob.type == 'MESH': - col.prop_search(tan, "uv_layer", ob.data, "uv_textures", text="") + col.prop_search(tan, "uv_layer", ob.data, "uv_layers", text="") else: col.prop(tan, "uv_layer", text="") col.separator() @@ -764,7 +764,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -795,11 +795,6 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel): row.prop(mat, "use_light_group_local", text="Local") col = split.column() - col.prop(mat, "use_face_texture") - sub = col.column() - sub.active = mat.use_face_texture - sub.prop(mat, "use_face_texture_alpha") - col.separator() col.prop(mat, "use_vertex_color_paint") col.prop(mat, "use_vertex_color_light") col.prop(mat, "use_object_color") @@ -807,6 +802,9 @@ class MATERIAL_PT_options(MaterialButtonsPanel, Panel): if simple_material(base_mat): col.prop(mat, "pass_index") + col.label("Edit Image") + col.template_ID(mat, "edit_image") + class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel): bl_label = "Shadow" @@ -816,7 +814,7 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -866,7 +864,7 @@ class MATERIAL_PT_transp_game(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (engine in cls.COMPAT_ENGINES) def draw_header(self, context): @@ -899,7 +897,7 @@ class VolumeButtonsPanel: @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES) @@ -984,7 +982,7 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return mat and simple_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -1025,7 +1023,7 @@ class MATERIAL_PT_volume_options(VolumeButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - engine = context.scene.render.engine + engine = context.engine return check_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES) def draw(self, context): @@ -1055,6 +1053,145 @@ class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel): _property_type = bpy.types.Material +class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): + bl_label = "" + bl_context = "material" + bl_options = {'HIDE_HEADER'} + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + engine = context.engine + return (context.material or context.object) and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + + mat = context.material + ob = context.object + slot = context.material_slot + space = context.space_data + + if ob: + is_sortable = len(ob.material_slots) > 1 + rows = 1 + if (is_sortable): + rows = 4 + + row = layout.row() + + row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows) + + col = row.column(align=True) + col.operator("object.material_slot_add", icon='ZOOMIN', text="") + col.operator("object.material_slot_remove", icon='ZOOMOUT', text="") + + col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="") + + if is_sortable: + col.separator() + + col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' + col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + + if ob.mode == 'EDIT': + row = layout.row(align=True) + row.operator("object.material_slot_assign", text="Assign") + row.operator("object.material_slot_select", text="Select") + row.operator("object.material_slot_deselect", text="Deselect") + + split = layout.split(percentage=0.65) + + if ob: + split.template_ID(ob, "active_material", new="material.new") + row = split.row() + + if slot: + row.prop(slot, "link", text="") + else: + row.label() + elif mat: + split.template_ID(space, "pin_id") + split.separator() + + +def panel_node_draw(layout, ntree, output_type): + node = find_output_node(ntree, output_type) + + if node: + input = find_node_input(node, 'Surface') + if input: + layout.template_node_view(ntree, node, input) + else: + layout.label(text="Incompatible output node") + else: + layout.label(text="No output node") + + +class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel): + bl_label = "Surface" + bl_context = "material" + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + engine = context.engine + return context.material and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + + mat = context.material + + layout.prop(mat, "use_nodes", icon='NODETREE') + layout.separator() + + if mat.use_nodes: + panel_node_draw(layout, mat.node_tree, ('OUTPUT_EEVEE_MATERIAL', 'OUTPUT_MATERIAL')) + else: + raym = mat.raytrace_mirror + layout.prop(mat, "diffuse_color", text="Base Color") + layout.prop(raym, "reflect_factor", text="Metallic") + layout.prop(mat, "specular_intensity", text="Specular") + layout.prop(raym, "gloss_factor", text="Roughness") + + +class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel): + bl_label = "Options" + bl_context = "material" + COMPAT_ENGINES = {'BLENDER_EEVEE'} + + @classmethod + def poll(cls, context): + engine = context.engine + return context.material and (engine in cls.COMPAT_ENGINES) + + def draw(self, context): + layout = self.layout + + mat = context.material + + layout.prop(mat, "blend_method") + + if mat.blend_method != "OPAQUE": + layout.prop(mat, "transparent_shadow_method") + + row = layout.row() + row.active = ((mat.blend_method == "CLIP") or (mat.transparent_shadow_method == "CLIP")) + row.prop(mat, "alpha_threshold") + + if mat.blend_method not in {"OPAQUE", "CLIP", "HASHED"}: + layout.prop(mat, "transparent_hide_backside") + + layout.prop(mat, "use_screen_refraction") + layout.prop(mat, "refraction_depth") + + layout.prop(mat, "use_screen_subsurface") + row = layout.row() + row.active = mat.use_screen_subsurface + row.prop(mat, "use_sss_translucency") + + classes = ( MATERIAL_MT_sss_presets, MATERIAL_MT_specials, @@ -1083,6 +1220,9 @@ classes = ( MATERIAL_PT_volume_integration, MATERIAL_PT_volume_options, MATERIAL_PT_custom_props, + EEVEE_MATERIAL_PT_context_material, + EEVEE_MATERIAL_PT_surface, + EEVEE_MATERIAL_PT_options, ) if __name__ == "__main__": # only for live edit. |