1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Menu, Panel, UIList
22 from rna_prop_ui import PropertyPanel
23 from bpy.app.translations import pgettext_iface as iface_
26 def active_node_mat(mat):
27 # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
28 # which settings from node-materials are used
30 mat_node = mat.active_node_material
39 def check_material(mat):
42 if mat.active_node_material is not None:
49 def simple_material(mat):
50 if (mat is not None) and (not mat.use_nodes):
55 class MATERIAL_MT_sss_presets(Menu):
56 bl_label = "SSS Presets"
58 preset_operator = "script.execute_preset"
59 draw = Menu.draw_preset
62 class MATERIAL_MT_specials(Menu):
63 bl_label = "Material Specials"
65 def draw(self, context):
68 layout.operator("object.material_slot_copy", icon='COPY_ID')
69 layout.operator("material.copy", icon='COPYDOWN')
70 layout.operator("material.paste", icon='PASTEDOWN')
73 class MATERIAL_UL_matslots(UIList):
74 def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
75 # assert(isinstance(item, bpy.types.MaterialSlot)
79 if self.layout_type in {'DEFAULT', 'COMPACT'}:
81 layout.prop(ma, "name", text="", emboss=False, icon_value=icon)
83 layout.label(text="", icon_value=icon)
84 if ma and not context.scene.render.use_shading_nodes:
85 manode = ma.active_node_material
87 layout.label(text=iface_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode))
89 layout.label(text="Node <none>")
90 elif self.layout_type == 'GRID':
91 layout.alignment = 'CENTER'
92 layout.label(text="", icon_value=icon)
95 class MaterialButtonsPanel:
96 bl_space_type = 'PROPERTIES'
97 bl_region_type = 'WINDOW'
98 bl_context = "material"
99 # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
102 def poll(cls, context):
103 return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
106 class MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
108 bl_options = {'HIDE_HEADER'}
109 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
112 def poll(cls, context):
113 # An exception, don't call the parent poll func because
114 # this manages materials for all engine types
116 engine = context.scene.render.engine
117 return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
119 def draw(self, context):
122 mat = context.material
124 slot = context.material_slot
125 space = context.space_data
126 is_sortable = (len(ob.material_slots) > 1)
135 row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
137 col = row.column(align=True)
138 col.operator("object.material_slot_add", icon='ZOOMIN', text="")
139 col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
141 col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
146 col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
147 col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
149 if ob.mode == 'EDIT':
150 row = layout.row(align=True)
151 row.operator("object.material_slot_assign", text="Assign")
152 row.operator("object.material_slot_select", text="Select")
153 row.operator("object.material_slot_deselect", text="Deselect")
155 split = layout.split(percentage=0.65)
158 split.template_ID(ob, "active_material", new="material.new")
161 row.prop(mat, "use_nodes", icon='NODETREE', text="")
164 row.prop(slot, "link", text="")
168 split.template_ID(space, "pin_id")
172 layout.prop(mat, "type", expand=True)
175 row.label(text="", icon='NODETREE')
176 if mat.active_node_material:
177 row.prop(mat.active_node_material, "name", text="")
179 row.label(text="No material node selected")
182 class MATERIAL_PT_preview(MaterialButtonsPanel, Panel):
184 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
186 def draw(self, context):
187 self.layout.template_preview(context.material)
190 class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel):
191 bl_label = "Render Pipeline Options"
192 bl_options = {'DEFAULT_CLOSED'}
193 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
196 def poll(cls, context):
197 mat = context.material
198 engine = context.scene.render.engine
199 return mat and (not simple_material(mat)) and (mat.type in {'SURFACE', 'WIRE', 'VOLUME'}) and (engine in cls.COMPAT_ENGINES)
201 def draw(self, context):
202 layout = self. layout
204 mat = context.material
205 mat_type = mat.type in {'SURFACE', 'WIRE'}
208 row.active = mat_type
209 row.prop(mat, "use_transparency")
211 sub.prop(mat, "offset_z")
213 sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
216 row.active = mat.use_transparency or not mat_type
217 row.prop(mat, "transparency_method", expand=True)
221 split = layout.split()
224 col.prop(mat, "use_raytrace")
225 col.prop(mat, "use_full_oversampling")
227 sub.active = mat_type
228 sub.prop(mat, "use_sky")
229 sub.prop(mat, "invert_z")
230 col.prop(mat, "pass_index")
233 col.active = mat_type
235 col.prop(mat, "use_cast_shadows", text="Cast")
236 col.prop(mat, "use_cast_shadows_only", text="Cast Only")
237 col.prop(mat, "use_cast_buffer_shadows")
239 sub.active = mat.use_cast_buffer_shadows
240 sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
241 col.prop(mat, "use_cast_approximate")
244 class MATERIAL_PT_diffuse(MaterialButtonsPanel, Panel):
246 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
249 def poll(cls, context):
250 mat = context.material
251 engine = context.scene.render.engine
252 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
254 def draw(self, context):
257 mat = active_node_mat(context.material)
259 split = layout.split()
262 col.prop(mat, "diffuse_color", text="")
264 sub.active = (not mat.use_shadeless)
265 sub.prop(mat, "diffuse_intensity", text="Intensity")
268 col.active = (not mat.use_shadeless)
269 col.prop(mat, "diffuse_shader", text="")
270 col.prop(mat, "use_diffuse_ramp", text="Ramp")
272 col = layout.column()
273 col.active = (not mat.use_shadeless)
274 if mat.diffuse_shader == 'OREN_NAYAR':
275 col.prop(mat, "roughness")
276 elif mat.diffuse_shader == 'MINNAERT':
277 col.prop(mat, "darkness")
278 elif mat.diffuse_shader == 'TOON':
280 row.prop(mat, "diffuse_toon_size", text="Size")
281 row.prop(mat, "diffuse_toon_smooth", text="Smooth")
282 elif mat.diffuse_shader == 'FRESNEL':
284 row.prop(mat, "diffuse_fresnel", text="Fresnel")
285 row.prop(mat, "diffuse_fresnel_factor", text="Factor")
287 if mat.use_diffuse_ramp:
288 col = layout.column()
289 col.active = (not mat.use_shadeless)
291 col.template_color_ramp(mat, "diffuse_ramp", expand=True)
295 row.prop(mat, "diffuse_ramp_input", text="Input")
296 row.prop(mat, "diffuse_ramp_blend", text="Blend")
298 col.prop(mat, "diffuse_ramp_factor", text="Factor")
301 class MATERIAL_PT_specular(MaterialButtonsPanel, Panel):
302 bl_label = "Specular"
303 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
306 def poll(cls, context):
307 mat = context.material
308 engine = context.scene.render.engine
309 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
311 def draw(self, context):
314 mat = active_node_mat(context.material)
316 layout.active = (not mat.use_shadeless)
318 split = layout.split()
321 col.prop(mat, "specular_color", text="")
322 col.prop(mat, "specular_intensity", text="Intensity")
325 col.prop(mat, "specular_shader", text="")
326 col.prop(mat, "use_specular_ramp", text="Ramp")
328 col = layout.column()
329 if mat.specular_shader in {'COOKTORR', 'PHONG'}:
330 col.prop(mat, "specular_hardness", text="Hardness")
331 elif mat.specular_shader == 'BLINN':
333 row.prop(mat, "specular_hardness", text="Hardness")
334 row.prop(mat, "specular_ior", text="IOR")
335 elif mat.specular_shader == 'WARDISO':
336 col.prop(mat, "specular_slope", text="Slope")
337 elif mat.specular_shader == 'TOON':
339 row.prop(mat, "specular_toon_size", text="Size")
340 row.prop(mat, "specular_toon_smooth", text="Smooth")
342 if mat.use_specular_ramp:
344 layout.template_color_ramp(mat, "specular_ramp", expand=True)
348 row.prop(mat, "specular_ramp_input", text="Input")
349 row.prop(mat, "specular_ramp_blend", text="Blend")
351 layout.prop(mat, "specular_ramp_factor", text="Factor")
354 class MATERIAL_PT_shading(MaterialButtonsPanel, Panel):
356 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
359 def poll(cls, context):
360 mat = context.material
361 engine = context.scene.render.engine
362 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
364 def draw(self, context):
367 mat = active_node_mat(context.material)
369 if mat.type in {'SURFACE', 'WIRE'}:
370 split = layout.split()
374 sub.active = not mat.use_shadeless
375 sub.prop(mat, "emit")
376 sub.prop(mat, "ambient")
378 sub.prop(mat, "translucency")
381 col.prop(mat, "use_shadeless")
383 sub.active = not mat.use_shadeless
384 sub.prop(mat, "use_tangent_shading")
385 sub.prop(mat, "use_cubic")
388 class MATERIAL_PT_transp(MaterialButtonsPanel, Panel):
389 bl_label = "Transparency"
390 COMPAT_ENGINES = {'BLENDER_RENDER'}
393 def poll(cls, context):
394 mat = context.material
395 engine = context.scene.render.engine
396 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
398 def draw_header(self, context):
399 mat = context.material
401 if simple_material(mat):
402 self.layout.prop(mat, "use_transparency", text="")
404 def draw(self, context):
407 base_mat = context.material
408 mat = active_node_mat(context.material)
409 rayt = mat.raytrace_transparency
411 if simple_material(base_mat):
413 row.active = mat.use_transparency
414 row.prop(mat, "transparency_method", expand=True)
416 split = layout.split()
417 split.active = base_mat.use_transparency
420 col.prop(mat, "alpha")
422 row.active = (base_mat.transparency_method != 'MASK') and (not mat.use_shadeless)
423 row.prop(mat, "specular_alpha", text="Specular")
426 col.active = (not mat.use_shadeless)
427 col.prop(rayt, "fresnel")
429 sub.active = (rayt.fresnel > 0.0)
430 sub.prop(rayt, "fresnel_factor", text="Blend")
432 if base_mat.transparency_method == 'RAYTRACE':
434 split = layout.split()
435 split.active = base_mat.use_transparency
438 col.prop(rayt, "ior")
439 col.prop(rayt, "filter")
440 col.prop(rayt, "falloff")
441 col.prop(rayt, "depth_max")
442 col.prop(rayt, "depth")
445 col.label(text="Gloss:")
446 col.prop(rayt, "gloss_factor", text="Amount")
448 sub.active = rayt.gloss_factor < 1.0
449 sub.prop(rayt, "gloss_threshold", text="Threshold")
450 sub.prop(rayt, "gloss_samples", text="Samples")
453 class MATERIAL_PT_mirror(MaterialButtonsPanel, Panel):
455 bl_options = {'DEFAULT_CLOSED'}
456 COMPAT_ENGINES = {'BLENDER_RENDER'}
459 def poll(cls, context):
460 mat = context.material
461 engine = context.scene.render.engine
462 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
464 def draw_header(self, context):
465 raym = active_node_mat(context.material).raytrace_mirror
467 self.layout.prop(raym, "use", text="")
469 def draw(self, context):
472 mat = active_node_mat(context.material)
473 raym = mat.raytrace_mirror
475 layout.active = raym.use
477 split = layout.split()
480 col.prop(raym, "reflect_factor")
481 col.prop(mat, "mirror_color", text="")
484 col.prop(raym, "fresnel")
486 sub.active = (raym.fresnel > 0.0)
487 sub.prop(raym, "fresnel_factor", text="Blend")
489 split = layout.split()
493 col.prop(raym, "depth")
494 col.prop(raym, "distance", text="Max Dist")
496 sub = col.split(percentage=0.4)
497 sub.active = (raym.distance > 0.0)
498 sub.label(text="Fade To:")
499 sub.prop(raym, "fade_to", text="")
502 col.label(text="Gloss:")
503 col.prop(raym, "gloss_factor", text="Amount")
505 sub.active = (raym.gloss_factor < 1.0)
506 sub.prop(raym, "gloss_threshold", text="Threshold")
507 sub.prop(raym, "gloss_samples", text="Samples")
508 sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
511 class MATERIAL_PT_sss(MaterialButtonsPanel, Panel):
512 bl_label = "Subsurface Scattering"
513 bl_options = {'DEFAULT_CLOSED'}
514 COMPAT_ENGINES = {'BLENDER_RENDER'}
517 def poll(cls, context):
518 mat = context.material
519 engine = context.scene.render.engine
520 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
522 def draw_header(self, context):
523 mat = active_node_mat(context.material)
524 sss = mat.subsurface_scattering
526 self.layout.active = (not mat.use_shadeless)
527 self.layout.prop(sss, "use", text="")
529 def draw(self, context):
532 mat = active_node_mat(context.material)
533 sss = mat.subsurface_scattering
535 layout.active = (sss.use) and (not mat.use_shadeless)
537 row = layout.row().split()
538 sub = row.row(align=True).split(align=True, percentage=0.75)
539 sub.menu("MATERIAL_MT_sss_presets", text=bpy.types.MATERIAL_MT_sss_presets.bl_label)
540 sub.operator("material.sss_preset_add", text="", icon='ZOOMIN')
541 sub.operator("material.sss_preset_add", text="", icon='ZOOMOUT').remove_active = True
543 split = layout.split()
547 col.prop(sss, "scale")
548 col.prop(sss, "color", text="")
549 col.prop(sss, "radius", text="RGB Radius", expand=True)
552 sub = col.column(align=True)
553 sub.label(text="Blend:")
554 sub.prop(sss, "color_factor", text="Color")
555 sub.prop(sss, "texture_factor", text="Texture")
556 sub.label(text="Scattering Weight:")
557 sub.prop(sss, "front")
558 sub.prop(sss, "back")
560 col.prop(sss, "error_threshold", text="Error")
563 class MATERIAL_PT_halo(MaterialButtonsPanel, Panel):
565 COMPAT_ENGINES = {'BLENDER_RENDER'}
568 def poll(cls, context):
569 mat = context.material
570 engine = context.scene.render.engine
571 return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
573 def draw(self, context):
576 mat = context.material # don't use node material
579 def number_but(layout, toggle, number, name, color):
580 row = layout.row(align=True)
581 row.prop(halo, toggle, text="")
582 sub = row.column(align=True)
583 sub.active = getattr(halo, toggle)
584 sub.prop(halo, number, text=name, translate=False)
586 sub.prop(mat, color, text="")
588 split = layout.split()
591 col.prop(mat, "alpha")
592 col.prop(mat, "diffuse_color", text="")
593 col.prop(halo, "seed")
596 col.prop(halo, "size")
597 col.prop(halo, "hardness")
598 col.prop(halo, "add")
600 layout.label(text="Options:")
602 split = layout.split()
604 col.prop(halo, "use_texture")
605 col.prop(halo, "use_vertex_normal")
606 col.prop(halo, "use_extreme_alpha")
607 col.prop(halo, "use_shaded")
608 col.prop(halo, "use_soft")
611 number_but(col, "use_ring", "ring_count", iface_("Rings"), "mirror_color")
612 number_but(col, "use_lines", "line_count", iface_("Lines"), "specular_color")
613 number_but(col, "use_star", "star_tip_count", iface_("Star Tips"), "")
616 class MATERIAL_PT_flare(MaterialButtonsPanel, Panel):
618 COMPAT_ENGINES = {'BLENDER_RENDER'}
621 def poll(cls, context):
622 mat = context.material
623 engine = context.scene.render.engine
624 return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
626 def draw_header(self, context):
627 halo = context.material.halo
629 self.layout.prop(halo, "use_flare_mode", text="")
631 def draw(self, context):
634 mat = context.material # don't use node material
637 layout.active = halo.use_flare_mode
639 split = layout.split()
642 col.prop(halo, "flare_size", text="Size")
643 col.prop(halo, "flare_boost", text="Boost")
644 col.prop(halo, "flare_seed", text="Seed")
647 col.prop(halo, "flare_subflare_count", text="Subflares")
648 col.prop(halo, "flare_subflare_size", text="Subsize")
651 class MATERIAL_PT_game_settings(MaterialButtonsPanel, Panel):
652 bl_label = "Game Settings"
653 COMPAT_ENGINES = {'BLENDER_GAME'}
656 def poll(cls, context):
657 return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
659 def draw(self, context):
661 game = context.material.game_settings # don't use node material
664 row.prop(game, "use_backface_culling")
665 row.prop(game, "invisible")
666 row.prop(game, "text")
669 row.label(text="Alpha Blend:")
670 row.label(text="Face Orientation:")
672 row.prop(game, "alpha_blend", text="")
673 row.prop(game, "face_orientation", text="")
676 class MATERIAL_PT_physics(MaterialButtonsPanel, Panel):
678 COMPAT_ENGINES = {'BLENDER_GAME'}
680 def draw_header(self, context):
681 game = context.material.game_settings
682 self.layout.prop(game, "physics", text="")
685 def poll(cls, context):
686 return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
688 def draw(self, context):
690 layout.active = context.material.game_settings.physics
692 phys = context.material.physics # don't use node material
694 split = layout.split()
696 row.prop(phys, "friction")
697 row.prop(phys, "elasticity", slider=True)
700 row.label(text="Force Field:")
703 row.prop(phys, "fh_force")
704 row.prop(phys, "fh_damping", slider=True)
707 row.prop(phys, "fh_distance")
708 row.prop(phys, "use_fh_normal")
711 class MATERIAL_PT_strand(MaterialButtonsPanel, Panel):
713 bl_options = {'DEFAULT_CLOSED'}
714 COMPAT_ENGINES = {'BLENDER_RENDER'}
717 def poll(cls, context):
718 mat = context.material
719 engine = context.scene.render.engine
720 return mat and (mat.type in {'SURFACE', 'WIRE', 'HALO'}) and (engine in cls.COMPAT_ENGINES)
722 def draw(self, context):
725 mat = context.material # don't use node material
728 split = layout.split()
731 sub = col.column(align=True)
732 sub.label(text="Size:")
733 sub.prop(tan, "root_size", text="Root")
734 sub.prop(tan, "tip_size", text="Tip")
735 sub.prop(tan, "size_min", text="Minimum")
736 sub.prop(tan, "use_blender_units")
738 sub.active = (not mat.use_shadeless)
739 sub.prop(tan, "use_tangent_shading")
740 col.prop(tan, "shape")
743 col.label(text="Shading:")
744 col.prop(tan, "width_fade")
746 if ob and ob.type == 'MESH':
747 col.prop_search(tan, "uv_layer", ob.data, "uv_textures", text="")
749 col.prop(tan, "uv_layer", text="")
752 sub.active = (not mat.use_shadeless)
753 sub.label("Surface diffuse:")
755 sub.prop(tan, "blend_distance", text="Distance")
758 class MATERIAL_PT_options(MaterialButtonsPanel, Panel):
760 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
763 def poll(cls, context):
764 mat = context.material
765 engine = context.scene.render.engine
766 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
768 def draw(self, context):
771 base_mat = context.material
772 mat = active_node_mat(base_mat)
774 split = layout.split()
777 if simple_material(base_mat):
778 col.prop(mat, "use_raytrace")
779 col.prop(mat, "use_full_oversampling")
780 col.prop(mat, "use_sky")
781 col.prop(mat, "use_mist")
782 if simple_material(base_mat):
783 col.prop(mat, "invert_z")
785 sub.prop(mat, "offset_z")
786 sub.active = mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
787 sub = col.column(align=True)
788 sub.label(text="Light Group:")
789 sub.prop(mat, "light_group", text="")
790 row = sub.row(align=True)
791 row.active = bool(mat.light_group)
792 row.prop(mat, "use_light_group_exclusive", text="Exclusive")
793 row.prop(mat, "use_light_group_local", text="Local")
796 col.prop(mat, "use_face_texture")
798 sub.active = mat.use_face_texture
799 sub.prop(mat, "use_face_texture_alpha")
801 col.prop(mat, "use_vertex_color_paint")
802 col.prop(mat, "use_vertex_color_light")
803 col.prop(mat, "use_object_color")
804 col.prop(mat, "use_uv_project")
805 if simple_material(base_mat):
806 col.prop(mat, "pass_index")
809 class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel):
811 bl_options = {'DEFAULT_CLOSED'}
812 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
815 def poll(cls, context):
816 mat = context.material
817 engine = context.scene.render.engine
818 return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
820 def draw(self, context):
823 base_mat = context.material
824 mat = active_node_mat(base_mat)
826 split = layout.split()
829 col.prop(mat, "use_shadows", text="Receive")
830 col.prop(mat, "use_transparent_shadows", text="Receive Transparent")
831 col.prop(mat, "use_only_shadow", text="Shadows Only")
833 sub.active = mat.use_only_shadow
834 sub.prop(mat, "shadow_only_type", text="")
836 if not simple_material(base_mat):
839 col.prop(mat, "use_ray_shadow_bias", text="Auto Ray Bias")
841 sub.active = (not mat.use_ray_shadow_bias)
842 sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
844 if simple_material(base_mat):
847 col.prop(mat, "use_cast_shadows", text="Cast")
848 col.prop(mat, "use_cast_shadows_only", text="Cast Only")
849 col.prop(mat, "use_cast_buffer_shadows")
851 sub.active = mat.use_cast_buffer_shadows
852 if simple_material(base_mat):
853 sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
854 sub.prop(mat, "shadow_buffer_bias", text="Buffer Bias")
855 if simple_material(base_mat):
856 col.prop(mat, "use_cast_approximate")
859 class MATERIAL_PT_transp_game(MaterialButtonsPanel, Panel):
860 bl_label = "Transparency"
861 bl_options = {'DEFAULT_CLOSED'}
862 COMPAT_ENGINES = {'BLENDER_GAME'}
865 def poll(cls, context):
866 mat = context.material
867 engine = context.scene.render.engine
868 return check_material(mat) and (engine in cls.COMPAT_ENGINES)
870 def draw_header(self, context):
871 mat = context.material
873 if simple_material(mat):
874 self.layout.prop(mat, "use_transparency", text="")
876 def draw(self, context):
878 base_mat = context.material
879 mat = active_node_mat(base_mat)
881 if simple_material(base_mat):
883 row.active = mat.use_transparency
884 row.prop(mat, "transparency_method", expand=True)
886 layout.prop(mat, "alpha")
889 class VolumeButtonsPanel:
890 bl_space_type = 'PROPERTIES'
891 bl_region_type = 'WINDOW'
892 bl_context = "material"
893 COMPAT_ENGINES = {'BLENDER_RENDER'}
896 def poll(cls, context):
897 mat = context.material
898 engine = context.scene.render.engine
899 return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
902 class MATERIAL_PT_volume_density(VolumeButtonsPanel, Panel):
904 COMPAT_ENGINES = {'BLENDER_RENDER'}
906 def draw(self, context):
909 vol = context.material.volume # don't use node material
912 row.prop(vol, "density")
913 row.prop(vol, "density_scale")
916 class MATERIAL_PT_volume_shading(VolumeButtonsPanel, Panel):
918 COMPAT_ENGINES = {'BLENDER_RENDER'}
920 def draw(self, context):
923 vol = context.material.volume # don't use node material
925 split = layout.split()
928 col.prop(vol, "scattering")
929 col.prop(vol, "asymmetry")
930 col.prop(vol, "transmission_color")
933 sub = col.column(align=True)
934 sub.prop(vol, "emission")
935 sub.prop(vol, "emission_color", text="")
936 sub = col.column(align=True)
937 sub.prop(vol, "reflection")
938 sub.prop(vol, "reflection_color", text="")
941 class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, Panel):
942 bl_label = "Lighting"
943 COMPAT_ENGINES = {'BLENDER_RENDER'}
945 def draw(self, context):
948 vol = context.material.volume # don't use node material
950 split = layout.split()
953 col.prop(vol, "light_method", text="")
957 if vol.light_method == 'SHADED':
958 col.prop(vol, "use_external_shadows")
959 col.prop(vol, "use_light_cache")
961 sub.active = vol.use_light_cache
962 sub.prop(vol, "cache_resolution")
963 elif vol.light_method in {'MULTIPLE_SCATTERING', 'SHADED_PLUS_MULTIPLE_SCATTERING'}:
967 sub.label("Light Cache Enabled")
968 col.prop(vol, "cache_resolution")
970 sub = col.column(align=True)
971 sub.prop(vol, "ms_diffusion")
972 sub.prop(vol, "ms_spread")
973 sub.prop(vol, "ms_intensity")
976 class MATERIAL_PT_volume_transp(VolumeButtonsPanel, Panel):
977 bl_label = "Transparency"
978 COMPAT_ENGINES = {'BLENDER_RENDER'}
981 def poll(cls, context):
982 mat = context.material
983 engine = context.scene.render.engine
984 return mat and simple_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
986 def draw(self, context):
989 mat = context.material # don't use node material
991 layout.prop(mat, "transparency_method", expand=True)
994 class MATERIAL_PT_volume_integration(VolumeButtonsPanel, Panel):
995 bl_label = "Integration"
996 COMPAT_ENGINES = {'BLENDER_RENDER'}
998 def draw(self, context):
1001 vol = context.material.volume # don't use node material
1003 split = layout.split()
1005 col = split.column()
1006 col.label(text="Step Calculation:")
1007 col.prop(vol, "step_method", text="")
1008 col = col.column(align=True)
1009 col.prop(vol, "step_size")
1011 col = split.column()
1013 col.prop(vol, "depth_threshold")
1016 class MATERIAL_PT_volume_options(VolumeButtonsPanel, Panel):
1017 bl_label = "Options"
1018 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1019 bl_options = {'DEFAULT_CLOSED'}
1022 def poll(cls, context):
1023 mat = context.material
1024 engine = context.scene.render.engine
1025 return check_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
1027 def draw(self, context):
1028 layout = self.layout
1030 mat = active_node_mat(context.material)
1032 split = layout.split()
1034 col = split.column()
1035 if simple_material(context.material):
1036 col.prop(mat, "use_raytrace")
1037 col.prop(mat, "use_full_oversampling")
1038 col.prop(mat, "use_mist")
1040 col = split.column()
1041 col.label(text="Light Group:")
1042 col.prop(mat, "light_group", text="")
1044 row.active = bool(mat.light_group)
1045 row.prop(mat, "use_light_group_exclusive", text="Exclusive")
1048 class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, Panel):
1049 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
1050 _context_path = "material"
1051 _property_type = bpy.types.Material
1053 if __name__ == "__main__": # only for live edit.
1054 bpy.utils.register_module(__name__)