2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2009-2023 Blender Authors
|
2023-06-15 13:09:04 +10:00
|
|
|
#
|
2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2023-06-15 13:09:04 +10:00
|
|
|
|
2009-05-10 12:12:05 +00:00
|
|
|
import bpy
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
from bpy.types import Menu, Panel, UIList
|
2023-02-23 22:00:57 +01:00
|
|
|
from bpy.app.translations import contexts as i18n_contexts
|
2010-01-08 08:54:41 +00:00
|
|
|
from rna_prop_ui import PropertyPanel
|
2018-07-05 12:44:15 +02:00
|
|
|
from bpy_extras.node_utils import find_node_input
|
2011-09-20 18:29:19 +00:00
|
|
|
|
2025-05-04 13:26:03 +02:00
|
|
|
from bl_ui.space_properties import PropertiesAnimationMixin
|
2024-07-30 11:59:54 +02:00
|
|
|
|
2018-06-02 21:40:33 +02:00
|
|
|
|
2019-03-12 10:59:57 +11:00
|
|
|
class MATERIAL_MT_context_menu(Menu):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Material Specials"
|
2010-01-28 17:31:11 +00:00
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw(self, _context):
|
2010-01-28 17:31:11 +00:00
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
layout.operator("material.copy", icon='COPYDOWN')
|
2018-10-31 18:33:23 +01:00
|
|
|
layout.operator("object.material_slot_copy")
|
2010-01-28 17:31:11 +00:00
|
|
|
layout.operator("material.paste", icon='PASTEDOWN')
|
2019-07-31 12:04:52 -07:00
|
|
|
layout.operator("object.material_slot_remove_unused")
|
2025-05-07 08:06:52 +02:00
|
|
|
layout.operator("object.material_slot_remove_all")
|
2010-01-28 17:31:11 +00:00
|
|
|
|
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
class MATERIAL_UL_matslots(UIList):
|
2017-03-20 09:43:18 +11:00
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
|
2012-12-28 10:45:59 +00:00
|
|
|
# assert(isinstance(item, bpy.types.MaterialSlot)
|
2014-04-25 05:31:20 +10:00
|
|
|
# ob = data
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
slot = item
|
|
|
|
|
ma = slot.material
|
2020-12-11 22:20:31 +01:00
|
|
|
|
|
|
|
|
layout.context_pointer_set("id", ma)
|
2022-03-03 15:28:48 -08:00
|
|
|
layout.context_pointer_set("material_slot", slot)
|
2020-12-11 22:20:31 +01:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
2013-11-23 20:37:23 +01:00
|
|
|
if ma:
|
|
|
|
|
layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
|
|
|
|
|
else:
|
|
|
|
|
layout.label(text="", icon_value=icon)
|
2015-04-14 10:29:11 +10:00
|
|
|
elif self.layout_type == 'GRID':
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
layout.alignment = 'CENTER'
|
2013-02-08 16:01:21 +00:00
|
|
|
layout.label(text="", icon_value=icon)
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
|
|
2015-01-29 15:35:06 +11:00
|
|
|
class MaterialButtonsPanel:
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
|
2009-05-20 13:34:04 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
mat = context.material
|
|
|
|
|
return mat and (context.engine in cls.COMPAT_ENGINES) and not mat.grease_pencil
|
2010-08-09 01:37:09 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class MATERIAL_PT_preview(MaterialButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Preview"
|
2018-07-15 00:13:35 +02:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2024-07-04 12:46:29 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
2010-08-12 19:36:10 +00:00
|
|
|
self.layout.template_preview(context.material)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel):
|
2023-01-24 17:58:58 +01:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
2023-09-29 14:32:54 +10:00
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
|
}
|
2010-08-12 19:36:10 +00:00
|
|
|
_context_path = "material"
|
2010-12-17 10:33:28 +00:00
|
|
|
_property_type = bpy.types.Material
|
2011-04-04 10:13:04 +00:00
|
|
|
|
2017-03-18 20:03:24 +11:00
|
|
|
|
2017-04-25 18:46:59 +02:00
|
|
|
class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = ""
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
bl_options = {'HIDE_HEADER'}
|
2024-10-30 13:20:01 +11:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
|
}
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
2019-03-08 15:30:22 -03:00
|
|
|
ob = context.object
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
mat = context.material
|
2019-03-08 15:30:22 -03:00
|
|
|
|
2024-12-14 11:19:24 +01:00
|
|
|
if mat and mat.grease_pencil:
|
2019-03-08 15:30:22 -03:00
|
|
|
return False
|
2025-01-21 21:02:26 +08:00
|
|
|
if ob and ob.type == 'GREASEPENCIL':
|
|
|
|
|
return False
|
2019-03-08 15:30:22 -03:00
|
|
|
|
2025-01-21 21:02:26 +08:00
|
|
|
return (
|
|
|
|
|
(ob or mat) and
|
2025-01-13 11:05:23 +01:00
|
|
|
(context.engine in cls.COMPAT_ENGINES)
|
2025-01-21 21:02:26 +08:00
|
|
|
)
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
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
|
2018-10-31 18:33:23 +01:00
|
|
|
rows = 3
|
2019-07-07 22:24:11 +10:00
|
|
|
if is_sortable:
|
2018-10-31 18:33:23 +01:00
|
|
|
rows = 5
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
|
|
row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
|
|
|
|
|
|
|
|
|
|
col = row.column(align=True)
|
2018-10-01 10:45:50 +02:00
|
|
|
col.operator("object.material_slot_add", icon='ADD', text="")
|
|
|
|
|
col.operator("object.material_slot_remove", icon='REMOVE', text="")
|
2017-04-25 18:46:59 +02:00
|
|
|
|
2018-10-31 18:33:23 +01:00
|
|
|
col.separator()
|
|
|
|
|
|
2019-03-12 10:59:57 +11:00
|
|
|
col.menu("MATERIAL_MT_context_menu", icon='DOWNARROW_HLT', text="")
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
|
2018-07-15 01:22:24 +02:00
|
|
|
row = layout.row()
|
|
|
|
|
|
|
|
|
|
if ob:
|
2021-01-13 15:08:09 +01:00
|
|
|
row.template_ID(ob, "active_material", new="material.new")
|
2018-07-15 01:22:24 +02:00
|
|
|
|
|
|
|
|
if slot:
|
2024-09-12 19:23:09 +02:00
|
|
|
row.prop(slot, "link", icon_only=True)
|
2018-07-15 01:22:24 +02:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
if ob.mode == 'EDIT':
|
2017-04-25 18:46:59 +02:00
|
|
|
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")
|
|
|
|
|
|
|
|
|
|
elif mat:
|
2018-07-15 01:22:24 +02:00
|
|
|
row.template_ID(space, "pin_id")
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def panel_node_draw(layout, ntree, _output_type, input_name):
|
2018-07-05 12:44:15 +02:00
|
|
|
node = ntree.get_output_node('EEVEE')
|
2017-05-30 17:16:36 +02:00
|
|
|
|
|
|
|
|
if node:
|
2018-09-20 19:26:41 +02:00
|
|
|
input = find_node_input(node, input_name)
|
2017-08-01 18:03:16 +02:00
|
|
|
if input:
|
|
|
|
|
layout.template_node_view(ntree, node, input)
|
|
|
|
|
else:
|
|
|
|
|
layout.label(text="Incompatible output node")
|
|
|
|
|
else:
|
|
|
|
|
layout.label(text="No output node")
|
2017-05-30 17:16:36 +02:00
|
|
|
|
|
|
|
|
|
2017-04-25 18:46:59 +02:00
|
|
|
class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Surface"
|
|
|
|
|
bl_context = "material"
|
2024-10-30 13:20:01 +11:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
2017-04-25 23:48:26 +02:00
|
|
|
|
2017-05-30 17:16:36 +02:00
|
|
|
if mat.use_nodes:
|
2024-04-18 22:49:34 +02:00
|
|
|
layout.use_property_split = True
|
2018-09-21 07:31:29 +10:00
|
|
|
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Surface")
|
2017-05-30 17:16:36 +02:00
|
|
|
else:
|
2024-04-18 22:49:34 +02:00
|
|
|
layout.prop(mat, "use_nodes", icon='NODETREE')
|
|
|
|
|
layout.use_property_split = True
|
2017-05-30 17:16:36 +02:00
|
|
|
layout.prop(mat, "diffuse_color", text="Base Color")
|
2018-06-01 12:14:08 +02:00
|
|
|
layout.prop(mat, "metallic")
|
2017-05-17 17:41:21 +02:00
|
|
|
layout.prop(mat, "specular_intensity", text="Specular")
|
2018-05-31 13:32:53 +02:00
|
|
|
layout.prop(mat, "roughness")
|
2017-04-25 18:46:59 +02:00
|
|
|
|
|
|
|
|
|
2018-09-20 19:26:41 +02:00
|
|
|
class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Volume"
|
2023-02-23 22:00:57 +01:00
|
|
|
bl_translation_context = i18n_contexts.id_id
|
2018-09-20 19:26:41 +02:00
|
|
|
bl_context = "material"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2024-10-30 13:20:01 +11:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
2018-09-20 19:26:41 +02:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
engine = context.engine
|
|
|
|
|
mat = context.material
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
return mat and mat.use_nodes and (engine in cls.COMPAT_ENGINES) and not mat.grease_pencil
|
2018-09-20 19:26:41 +02:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
2020-05-01 15:21:41 +02:00
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
2018-09-20 19:26:41 +02:00
|
|
|
mat = context.material
|
|
|
|
|
|
2018-09-21 07:31:29 +10:00
|
|
|
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Volume")
|
2018-09-20 19:26:41 +02:00
|
|
|
|
|
|
|
|
|
2023-10-20 16:59:20 +02:00
|
|
|
class EEVEE_MATERIAL_PT_displacement(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Displacement"
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2024-10-30 13:20:01 +11:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
2023-10-20 16:59:20 +02:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
engine = context.engine
|
|
|
|
|
mat = context.material
|
|
|
|
|
return mat and mat.use_nodes and (engine in cls.COMPAT_ENGINES) and not mat.grease_pencil
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
|
|
|
|
|
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Displacement")
|
|
|
|
|
|
|
|
|
|
|
2024-04-27 20:58:15 +02:00
|
|
|
class EEVEE_MATERIAL_PT_thickness(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Thickness"
|
2024-06-15 14:11:45 +02:00
|
|
|
bl_translation_context = i18n_contexts.id_material
|
2024-04-27 20:58:15 +02:00
|
|
|
bl_context = "material"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
engine = context.engine
|
|
|
|
|
mat = context.material
|
|
|
|
|
return mat and mat.use_nodes and (engine in cls.COMPAT_ENGINES) and not mat.grease_pencil
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
|
|
|
|
|
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Thickness")
|
|
|
|
|
|
|
|
|
|
|
2024-07-30 17:49:25 +02:00
|
|
|
def draw_material_surface_settings(layout, mat, is_eevee=True):
|
|
|
|
|
col = layout.column(heading="Backface Culling")
|
|
|
|
|
col.prop(mat, "use_backface_culling", text="Camera")
|
|
|
|
|
col.prop(mat, "use_backface_culling_shadow", text="Shadow")
|
|
|
|
|
col.prop(mat, "use_backface_culling_lightprobe_volume", text="Light Probe Volume")
|
|
|
|
|
|
|
|
|
|
col = layout.column(align=True)
|
|
|
|
|
|
|
|
|
|
if is_eevee:
|
|
|
|
|
col.prop(mat, "displacement_method", text="Displacement")
|
|
|
|
|
col = col.column(align=True)
|
|
|
|
|
|
|
|
|
|
col.enabled = mat.displacement_method != 'BUMP'
|
|
|
|
|
# Clarify that this is for displacement if the displacement method setting is not above.
|
|
|
|
|
max_diplacement_text = "Max Distance" if is_eevee else "Max Displacement"
|
|
|
|
|
col.prop(mat, "max_vertex_displacement", text=max_diplacement_text)
|
|
|
|
|
|
|
|
|
|
if mat.displacement_method == 'DISPLACEMENT':
|
|
|
|
|
layout.label(text="Unsupported displacement method", icon='ERROR')
|
|
|
|
|
|
|
|
|
|
if is_eevee:
|
|
|
|
|
layout.prop(mat, "use_transparent_shadow")
|
|
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
col.prop(mat, "surface_render_method", text="Render Method")
|
|
|
|
|
if mat.surface_render_method == 'BLENDED':
|
|
|
|
|
col.prop(mat, "use_transparency_overlap", text="Transparency Overlap")
|
|
|
|
|
elif mat.surface_render_method == 'DITHERED':
|
|
|
|
|
col.prop(mat, "use_raytrace_refraction", text="Raytraced Transmission")
|
|
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
col.prop(mat, "thickness_mode", text="Thickness")
|
|
|
|
|
if mat.surface_render_method == 'DITHERED':
|
|
|
|
|
col.prop(mat, "use_thickness_from_shadow", text="From Shadow")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def draw_material_volume_settings(layout, mat, is_eevee=True):
|
|
|
|
|
layout.prop(mat, "volume_intersection_method", text="Intersection" if is_eevee else "Volume Intersection")
|
|
|
|
|
|
|
|
|
|
|
2019-08-27 15:47:30 +02:00
|
|
|
def draw_material_settings(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
|
2024-07-30 17:49:25 +02:00
|
|
|
draw_material_surface_settings(layout, mat, False)
|
|
|
|
|
draw_material_volume_settings(layout, mat, False)
|
2019-08-27 15:47:30 +02:00
|
|
|
|
|
|
|
|
|
2024-10-30 13:19:59 +11:00
|
|
|
# TODO: used by `./scripts/addons_core/hydra_storm/ui.py`, move to `EEVEE_NEXT_MATERIAL_PT_settings`.
|
2018-12-07 00:43:07 +01:00
|
|
|
class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Settings"
|
2017-07-09 12:01:29 +02:00
|
|
|
bl_context = "material"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
2019-03-17 17:52:05 +01:00
|
|
|
def draw(self, context):
|
2019-08-27 15:47:30 +02:00
|
|
|
draw_material_settings(self, context)
|
2017-07-09 12:01:29 +02:00
|
|
|
|
|
|
|
|
|
2019-08-27 15:47:30 +02:00
|
|
|
class EEVEE_MATERIAL_PT_viewport_settings(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Settings"
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
bl_parent_id = "MATERIAL_PT_viewport"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER'}
|
2017-08-09 23:48:42 +02:00
|
|
|
|
2019-08-27 15:47:30 +02:00
|
|
|
def draw(self, context):
|
|
|
|
|
draw_material_settings(self, context)
|
2017-11-14 00:49:54 +01:00
|
|
|
|
2017-07-11 12:39:20 +02:00
|
|
|
|
2022-07-25 09:08:54 +02:00
|
|
|
class EEVEE_NEXT_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Settings"
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
|
2023-10-20 16:59:20 +02:00
|
|
|
layout.prop(mat, "pass_index")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EEVEE_NEXT_MATERIAL_PT_settings_surface(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Surface"
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
bl_parent_id = "EEVEE_NEXT_MATERIAL_PT_settings"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
|
2024-07-30 17:49:25 +02:00
|
|
|
draw_material_surface_settings(layout, mat)
|
2024-04-30 20:32:46 +02:00
|
|
|
|
2022-07-25 09:08:54 +02:00
|
|
|
|
2023-10-20 16:59:20 +02:00
|
|
|
class EEVEE_NEXT_MATERIAL_PT_settings_volume(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Volume"
|
|
|
|
|
bl_context = "material"
|
|
|
|
|
bl_parent_id = "EEVEE_NEXT_MATERIAL_PT_settings"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'}
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
|
2024-07-30 17:49:25 +02:00
|
|
|
draw_material_volume_settings(layout, mat)
|
2022-07-25 09:08:54 +02:00
|
|
|
|
|
|
|
|
|
2018-05-30 19:53:46 +02:00
|
|
|
class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
|
2018-06-01 16:07:25 +02:00
|
|
|
bl_label = "Viewport Display"
|
2018-05-30 19:53:46 +02:00
|
|
|
bl_context = "material"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2019-05-19 11:23:43 +02:00
|
|
|
bl_order = 10
|
2018-05-30 19:53:46 +02:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
mat = context.material
|
|
|
|
|
return mat and not mat.grease_pencil
|
2018-05-30 19:53:46 +02:00
|
|
|
|
2019-03-17 17:52:05 +01:00
|
|
|
def draw(self, context):
|
2018-05-30 19:53:46 +02:00
|
|
|
layout = self.layout
|
2018-05-31 13:32:53 +02:00
|
|
|
layout.use_property_split = True
|
2018-05-30 19:53:46 +02:00
|
|
|
|
2019-03-17 17:52:05 +01:00
|
|
|
mat = context.material
|
|
|
|
|
|
2018-05-31 13:32:53 +02:00
|
|
|
col = layout.column()
|
2018-11-28 15:57:40 +01:00
|
|
|
col.prop(mat, "diffuse_color", text="Color")
|
|
|
|
|
col.prop(mat, "metallic")
|
2018-05-31 13:32:53 +02:00
|
|
|
col.prop(mat, "roughness")
|
2018-05-30 19:53:46 +02:00
|
|
|
|
|
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Line Art"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2021-03-29 16:27:18 +02:00
|
|
|
bl_order = 10
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
mat = context.material
|
|
|
|
|
return mat and not mat.grease_pencil
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
2021-04-26 23:30:54 +08:00
|
|
|
layout.use_property_split = True
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
mat = context.material
|
|
|
|
|
lineart = mat.lineart
|
|
|
|
|
|
2021-07-19 22:58:15 +08:00
|
|
|
layout.prop(lineart, "use_material_mask", text="Material Mask")
|
2021-03-16 19:35:53 +01:00
|
|
|
|
2021-07-19 22:58:15 +08:00
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.active = lineart.use_material_mask
|
|
|
|
|
row = col.row(align=True, heading="Masks")
|
2021-04-26 23:30:54 +08:00
|
|
|
for i in range(8):
|
2021-07-19 22:58:15 +08:00
|
|
|
row.prop(lineart, "use_material_mask_bits", text=" ", index=i, toggle=True)
|
|
|
|
|
if i == 3:
|
|
|
|
|
row = col.row(align=True)
|
2021-06-28 22:26:23 +08:00
|
|
|
|
|
|
|
|
row = layout.row(align=True, heading="Custom Occlusion")
|
2021-07-19 22:58:15 +08:00
|
|
|
row.prop(lineart, "mat_occlusion", text="Levels")
|
2021-03-16 19:35:53 +01:00
|
|
|
|
2022-06-29 22:54:29 +08:00
|
|
|
row = layout.row(heading="Intersection Priority")
|
|
|
|
|
row.prop(lineart, "use_intersection_priority_override", text="")
|
|
|
|
|
subrow = row.row()
|
|
|
|
|
subrow.active = lineart.use_intersection_priority_override
|
|
|
|
|
subrow.prop(lineart, "intersection_priority", text="")
|
|
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
|
2024-07-30 11:59:54 +02:00
|
|
|
class MATERIAL_PT_animation(MaterialButtonsPanel, Panel, PropertiesAnimationMixin):
|
|
|
|
|
COMPAT_ENGINES = {
|
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
2024-09-27 16:29:32 +02:00
|
|
|
layout.use_property_decorate = False
|
2024-07-30 11:59:54 +02:00
|
|
|
|
|
|
|
|
# MaterialButtonsPanel.poll ensures this is not None.
|
|
|
|
|
material = context.material
|
|
|
|
|
|
|
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.label(text="Material")
|
|
|
|
|
self.draw_action_and_slot_selector(context, col, material)
|
|
|
|
|
|
|
|
|
|
if node_tree := material.node_tree:
|
|
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.label(text="Shader Node Tree")
|
|
|
|
|
self.draw_action_and_slot_selector(context, col, node_tree)
|
|
|
|
|
|
|
|
|
|
|
2017-03-18 20:03:24 +11:00
|
|
|
classes = (
|
2019-03-12 10:59:57 +11:00
|
|
|
MATERIAL_MT_context_menu,
|
2017-03-20 02:34:32 +11:00
|
|
|
MATERIAL_UL_matslots,
|
|
|
|
|
MATERIAL_PT_preview,
|
2017-04-25 18:46:59 +02:00
|
|
|
EEVEE_MATERIAL_PT_context_material,
|
|
|
|
|
EEVEE_MATERIAL_PT_surface,
|
2018-09-20 19:26:41 +02:00
|
|
|
EEVEE_MATERIAL_PT_volume,
|
2023-10-20 16:59:20 +02:00
|
|
|
EEVEE_MATERIAL_PT_displacement,
|
2024-04-27 20:58:15 +02:00
|
|
|
EEVEE_MATERIAL_PT_thickness,
|
2018-12-07 00:43:07 +01:00
|
|
|
EEVEE_MATERIAL_PT_settings,
|
2022-07-25 09:08:54 +02:00
|
|
|
EEVEE_NEXT_MATERIAL_PT_settings,
|
2023-10-20 16:59:20 +02:00
|
|
|
EEVEE_NEXT_MATERIAL_PT_settings_surface,
|
|
|
|
|
EEVEE_NEXT_MATERIAL_PT_settings_volume,
|
2021-03-16 19:35:53 +01:00
|
|
|
MATERIAL_PT_lineart,
|
2018-05-30 19:53:46 +02:00
|
|
|
MATERIAL_PT_viewport,
|
2019-08-27 15:47:30 +02:00
|
|
|
EEVEE_MATERIAL_PT_viewport_settings,
|
2024-07-30 11:59:54 +02:00
|
|
|
MATERIAL_PT_animation,
|
2018-07-15 00:13:35 +02:00
|
|
|
MATERIAL_PT_custom_props,
|
2017-03-18 20:03:24 +11:00
|
|
|
)
|
|
|
|
|
|
2018-05-30 19:53:46 +02:00
|
|
|
|
2011-04-04 10:13:04 +00:00
|
|
|
if __name__ == "__main__": # only for live edit.
|
2017-03-18 20:03:24 +11:00
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|