UI: add material settings in shader editor sidebar.

Differential Revision: https://developer.blender.org/D3926
This commit is contained in:
Lucas Boutrot 2018-12-07 00:43:07 +01:00 committed by Brecht Van Lommel
parent 5fdf739e7f
commit d40bffa17f
Notes: blender-bot 2023-02-14 04:39:12 +01:00
Referenced by commit ac68f44b8a, fix shader editor errors when showing world shader tree
Referenced by issue #58945, Editmode Tool in topbar not updated after deleting object from the outliner
Referenced by issue #58935, 2D window text info shows camera as active while it's not
3 changed files with 118 additions and 24 deletions

View File

@ -54,6 +54,16 @@ class CyclesButtonsPanel:
return context.engine in cls.COMPAT_ENGINES
class CyclesNodeButtonsPanel:
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
COMPAT_ENGINES = {'CYCLES'}
@classmethod
def poll(cls, context):
return context.engine in cls.COMPAT_ENGINES
def get_device_type(context):
return context.user_preferences.addons[__package__].preferences.compute_device_type
@ -1668,31 +1678,29 @@ class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
@staticmethod
def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
mat = context.material
layout.prop(mat, "pass_index")
def draw(self, context):
self.draw_shared(self, context.material)
class CYCLES_MATERIAL_PT_settings_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_parent_id = "CYCLES_MATERIAL_PT_settings"
bl_context = "material"
@classmethod
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
@staticmethod
def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
mat = context.material
cmat = mat.cycles
col = layout.column()
@ -1700,22 +1708,21 @@ class CYCLES_MATERIAL_PT_settings_surface(CyclesButtonsPanel, Panel):
col.prop(cmat, "use_transparent_shadow")
col.prop(cmat, "displacement_method", text="Displacement Method")
def draw(self, context):
self.draw_shared(self, context.material)
class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_parent_id = "CYCLES_MATERIAL_PT_settings"
bl_context = "material"
@classmethod
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
@staticmethod
def draw_shared(self, context, mat):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
mat = context.material
cmat = mat.cycles
col = layout.column()
@ -1725,6 +1732,9 @@ class CYCLES_MATERIAL_PT_settings_volume(CyclesButtonsPanel, Panel):
col.prop(cmat, "volume_interpolation", text="Interpolation")
col.prop(cmat, "homogeneous_volume", text="Homogeneous")
def draw(self, context):
self.draw_shared(self, context, context.material)
class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
bl_label = "Bake"
@ -1959,6 +1969,42 @@ class CYCLES_RENDER_PT_simplify_culling(CyclesButtonsPanel, Panel):
sub.prop(cscene, "distance_cull_margin", text="Distance")
class CYCLES_NODE_PT_settings(CyclesNodeButtonsPanel, Panel):
bl_label = "Settings"
bl_category = "Node"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
snode = context.space_data
return CyclesNodeButtonsPanel.poll(context) and \
snode.tree_type == 'ShaderNodeTree' and snode.id
def draw(self, context):
material = context.space_data.id
CYCLES_MATERIAL_PT_settings.draw_shared(self, material)
class CYCLES_NODE_PT_settings_surface(CyclesNodeButtonsPanel, Panel):
bl_label = "Surface"
bl_category = "Node"
bl_parent_id = "CYCLES_NODE_PT_settings"
def draw(self, context):
material = context.space_data.id
CYCLES_MATERIAL_PT_settings_surface.draw_shared(self, material)
class CYCLES_NODE_PT_settings_volume(CyclesNodeButtonsPanel, Panel):
bl_label = "Volume"
bl_category = "Node"
bl_parent_id = "CYCLES_NODE_PT_settings"
def draw(self, context):
material = context.space_data.id
CYCLES_MATERIAL_PT_settings_volume.draw_shared(self, context, material)
def draw_device(self, context):
scene = context.scene
layout = self.layout
@ -2087,6 +2133,9 @@ classes = (
CYCLES_MATERIAL_PT_settings_volume,
CYCLES_RENDER_PT_bake,
CYCLES_RENDER_PT_debug,
CYCLES_NODE_PT_settings,
CYCLES_NODE_PT_settings_surface,
CYCLES_NODE_PT_settings_volume,
)

View File

@ -204,8 +204,8 @@ class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel):
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Volume")
class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
bl_label = "Options"
class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
bl_label = "Settings"
bl_context = "material"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@ -214,12 +214,11 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
engine = context.engine
return context.material and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
@staticmethod
def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
mat = context.material
layout.prop(mat, "blend_method")
if mat.blend_method != 'OPAQUE':
@ -236,6 +235,9 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel):
layout.prop(mat, "refraction_depth")
layout.prop(mat, "use_sss_translucency")
def draw(self, context):
self.draw_shared(self, context.material)
class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
bl_label = "Viewport Display"
@ -246,9 +248,8 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
def poll(cls, context):
return context.material
def draw(self, context):
mat = context.material
@staticmethod
def draw_shared(self, mat):
layout = self.layout
layout.use_property_split = True
@ -257,6 +258,9 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel):
col.prop(mat, "metallic")
col.prop(mat, "roughness")
def draw(self, context):
self.draw_shared(self, context.material)
classes = (
MATERIAL_MT_specials,
@ -265,7 +269,7 @@ classes = (
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
EEVEE_MATERIAL_PT_volume,
EEVEE_MATERIAL_PT_options,
EEVEE_MATERIAL_PT_settings,
MATERIAL_PT_viewport,
MATERIAL_PT_custom_props,
)

View File

@ -27,6 +27,10 @@ from .properties_grease_pencil_common import (
AnnotationDataPanel,
GreasePencilToolsPanel,
)
from .properties_material import (
EEVEE_MATERIAL_PT_settings,
MATERIAL_PT_viewport
)
class NODE_HT_header(Header):
@ -552,6 +556,41 @@ class NODE_PT_grease_pencil_tools(GreasePencilToolsPanel, Panel):
# toolbar, but which may not necessarily be open
class EEVEE_NODE_PT_material_settings(Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
bl_category = "Node"
bl_label = "Settings"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
snode = context.space_data
return (context.engine in cls.COMPAT_ENGINES) and \
snode.tree_type == 'ShaderNodeTree' and snode.id
def draw(self, context):
material = context.space_data.id
EEVEE_MATERIAL_PT_settings.draw_shared(self, material)
class NODE_PT_material_viewport(Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = 'UI'
bl_category = "Node"
bl_label = "Viewport Display"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
snode = context.space_data
return snode.tree_type == 'ShaderNodeTree' and snode.id
def draw(self, context):
material = context.space_data.id
MATERIAL_PT_viewport.draw_shared(self, material)
def node_draw_tree_view(layout, context):
pass
@ -574,6 +613,8 @@ classes = (
NODE_UL_interface_sockets,
NODE_PT_grease_pencil,
NODE_PT_grease_pencil_tools,
EEVEE_NODE_PT_material_settings,
NODE_PT_material_viewport,
)