Material buttons now view the active node material shading settings.

Selecting a material in the node tree sets this as the active material and the buttons view redraws.

Added rna prop material.active_node_material

Currently its not clear what settings are used by the node material and the base material (needs some tedious research) so I made most panels use the node material with the exceptions of volumetrics, physics and halo settings.

We'll probably need to split the panels up to do this properly.
This commit is contained in:
Campbell Barton
2009-10-06 15:31:25 +00:00
parent 86307b58c0
commit 8d54982f37
6 changed files with 123 additions and 36 deletions

View File

@@ -1,6 +1,17 @@
import bpy
def active_node_mat(mat):
# TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
# which settings from node-materials are used
if mat:
mat_node = mat.active_node_material
if mat_node:
return mat_node
return None
class MaterialButtonsPanel(bpy.types.Panel):
__space_type__ = 'PROPERTIES'
__region_type__ = 'WINDOW'
@@ -74,14 +85,14 @@ class MATERIAL_PT_shading(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
if mat.type in ('SURFACE', 'WIRE'):
split = layout.split()
@@ -117,7 +128,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
def draw(self, context):
layout = self.layout
mat = context.material
mat = context.material # dont use node material
tan = mat.strand
split = layout.split()
@@ -152,7 +163,7 @@ class MATERIAL_PT_physics(MaterialButtonsPanel):
def draw(self, context):
layout = self.layout
phys = context.material.physics
phys = context.material.physics # dont use node material
split = layout.split()
@@ -171,14 +182,14 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
split = layout.split()
@@ -211,14 +222,14 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
split = layout.split()
@@ -244,14 +255,14 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
split = layout.split()
@@ -298,14 +309,14 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
layout.active = (not mat.shadeless)
@@ -351,12 +362,12 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
def draw_header(self, context):
mat = context.material
mat = active_node_mat(context.material)
sss = mat.subsurface_scattering
self.layout.active = (not mat.shadeless)
@@ -365,7 +376,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
sss = mat.subsurface_scattering
layout.active = sss.enabled
@@ -396,19 +407,19 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
def draw_header(self, context):
raym = context.material.raytrace_mirror
raym = active_node_mat(context.material).raytrace_mirror
self.layout.itemR(raym, "enabled", text="")
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
raym = mat.raytrace_mirror
layout.active = raym.enabled
@@ -451,19 +462,19 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
COMPAT_ENGINES = set(['BLENDER_RENDER'])
def poll(self, context):
mat = context.material
mat = active_node_mat(context.material)
engine = context.scene.render_data.engine
return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
def draw_header(self, context):
mat = context.material
mat = active_node_mat(context.material)
self.layout.itemR(mat, "transparency", text="")
def draw(self, context):
layout = self.layout
mat = context.material
mat = active_node_mat(context.material)
rayt = mat.raytrace_transparency
row = layout.row()
@@ -517,7 +528,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
def draw(self, context):
layout = self.layout
mat = context.material
mat = context.material # dont use node material
halo = mat.halo
split = layout.split()
@@ -569,7 +580,7 @@ class MATERIAL_PT_flare(MaterialButtonsPanel):
def draw(self, context):
layout = self.layout
mat = context.material
mat = context.material # dont use node material
halo = mat.halo
layout.active = halo.flare_mode
@@ -618,8 +629,7 @@ class MATERIAL_PT_volume_density(VolumeButtonsPanel):
def draw(self, context):
layout = self.layout
mat = context.material
vol = context.material.volume
vol = context.material.volume # dont use node material
split = layout.split()
row = split.row()
@@ -635,7 +645,7 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
def draw(self, context):
layout = self.layout
vol = context.material.volume
vol = context.material.volume # dont use node material
split = layout.split()
@@ -660,7 +670,7 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel):
def draw(self, context):
layout = self.layout
vol = context.material.volume
vol = context.material.volume # dont use node material
split = layout.split()
@@ -695,7 +705,7 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel):
def draw(self, context):
layout = self.layout
mat = context.material
mat = context.material # dont use node material
layout.itemR(mat, "transparency_method", expand=True)
@@ -707,7 +717,7 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
def draw(self, context):
layout = self.layout
vol = context.material.volume
vol = context.material.volume # dont use node material
split = layout.split()