4 class MaterialButtonsPanel(bpy.types.Panel):
5 __space_type__ = 'PROPERTIES'
6 __region_type__ = 'WINDOW'
7 __context__ = "material"
8 # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
10 def poll(self, context):
11 return (context.material) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
13 class MATERIAL_PT_preview(MaterialButtonsPanel):
15 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
17 def draw(self, context):
20 mat = context.material
22 layout.template_preview(mat)
24 class MATERIAL_PT_context_material(MaterialButtonsPanel):
25 __show_header__ = False
26 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
28 def poll(self, context):
29 # An exception, dont call the parent poll func because
30 # this manages materials for all engine types
32 engine = context.scene.render_data.engine
33 return (context.object) and (engine in self.COMPAT_ENGINES)
35 def draw(self, context):
38 mat = context.material
40 slot = context.material_slot
41 space = context.space_data
46 row.template_list(ob, "materials", ob, "active_material_index", rows=2)
48 col = row.column(align=True)
49 col.itemO("object.material_slot_add", icon='ICON_ZOOMIN', text="")
50 col.itemO("object.material_slot_remove", icon='ICON_ZOOMOUT', text="")
53 row = layout.row(align=True)
54 row.itemO("object.material_slot_assign", text="Assign")
55 row.itemO("object.material_slot_select", text="Select")
56 row.itemO("object.material_slot_deselect", text="Deselect")
58 split = layout.split(percentage=0.65)
61 split.template_ID(ob, "active_material", new="material.new")
64 row.itemR(slot, "link", text="")
68 split.template_ID(space, "pin_id")
71 layout.itemR(mat, "type", expand=True)
73 class MATERIAL_PT_shading(MaterialButtonsPanel):
75 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
77 def poll(self, context):
78 mat = context.material
79 engine = context.scene.render_data.engine
80 return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
82 def draw(self, context):
85 mat = context.material
87 slot = context.material_slot
88 space = context.space_data
92 if mat.type in ('SURFACE', 'WIRE'):
93 split = layout.split()
97 sub.active = not mat.shadeless
98 sub.itemR(mat, "emit")
99 sub.itemR(mat, "ambient")
101 sub.itemR(mat, "translucency")
104 col.itemR(mat, "shadeless")
106 sub.active = not mat.shadeless
107 sub.itemR(mat, "tangent_shading")
108 sub.itemR(mat, "cubic")
110 elif mat.type == 'HALO':
111 layout.itemR(mat, "alpha")
113 class MATERIAL_PT_strand(MaterialButtonsPanel):
115 __default_closed__ = True
116 COMPAT_ENGINES = set(['BLENDER_RENDER'])
118 def poll(self, context):
119 mat = context.material
120 engine = context.scene.render_data.engine
121 return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
123 def draw(self, context):
126 mat = context.material
129 split = layout.split()
131 col = split.column(align=True)
132 col.itemL(text="Size:")
133 col.itemR(tan, "start_size", text="Root")
134 col.itemR(tan, "end_size", text="Tip")
135 col.itemR(tan, "min_size", text="Minimum")
136 col.itemR(tan, "blender_units")
138 sub.active = (not mat.shadeless)
139 sub.itemR(tan, "tangent_shading")
140 col.itemR(tan, "shape")
143 col.itemL(text="Shading:")
144 col.itemR(tan, "width_fade")
145 col.itemR(tan, "uv_layer")
148 sub.active = (not mat.shadeless)
149 sub.itemR(tan, "surface_diffuse")
151 sub.active = tan.surface_diffuse
152 sub.itemR(tan, "blend_distance", text="Distance")
154 class MATERIAL_PT_physics(MaterialButtonsPanel):
155 __label__ = "Physics"
156 COMPAT_ENGINES = set(['BLENDER_GAME'])
158 def draw(self, context):
161 mat = context.material
164 split = layout.split()
167 col.itemR(phys, "distance")
168 col.itemR(phys, "friction")
169 col.itemR(phys, "align_to_normal")
172 col.itemR(phys, "force", slider=True)
173 col.itemR(phys, "elasticity", slider=True)
174 col.itemR(phys, "damp", slider=True)
176 class MATERIAL_PT_options(MaterialButtonsPanel):
177 __label__ = "Options"
178 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
180 def poll(self, context):
181 mat = context.material
182 engine = context.scene.render_data.engine
183 return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
185 def draw(self, context):
188 mat = context.material
190 split = layout.split()
193 col.itemR(mat, "traceable")
194 col.itemR(mat, "full_oversampling")
195 col.itemR(mat, "sky")
196 col.itemR(mat, "exclude_mist")
197 col.itemR(mat, "invert_z")
198 sub = col.column(align=True)
199 sub.itemL(text="Light Group:")
200 sub.itemR(mat, "light_group", text="")
202 row.active = mat.light_group
203 row.itemR(mat, "light_group_exclusive", text="Exclusive")
206 col.itemR(mat, "face_texture")
208 sub.active = mat.face_texture
209 sub.itemR(mat, "face_texture_alpha")
211 col.itemR(mat, "vertex_color_paint")
212 col.itemR(mat, "vertex_color_light")
213 col.itemR(mat, "object_color")
215 class MATERIAL_PT_shadow(MaterialButtonsPanel):
217 __default_closed__ = True
218 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
220 def poll(self, context):
221 mat = context.material
222 engine = context.scene.render_data.engine
223 return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
225 def draw(self, context):
228 mat = context.material
230 split = layout.split()
233 col.itemR(mat, "shadows", text="Receive")
234 col.itemR(mat, "transparent_shadows", text="Receive Transparent")
235 col.itemR(mat, "only_shadow", text="Shadows Only")
236 col.itemR(mat, "cast_shadows_only", text="Cast Only")
237 col.itemR(mat, "shadow_casting_alpha", text="Casting Alpha")
240 col.itemR(mat, "cast_buffer_shadows")
242 sub.active = mat.cast_buffer_shadows
243 sub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias")
244 col.itemR(mat, "ray_shadow_bias", text="Auto Ray Bias")
246 sub.active = (not mat.ray_shadow_bias)
247 sub.itemR(mat, "shadow_ray_bias", text="Ray Bias")
249 class MATERIAL_PT_diffuse(MaterialButtonsPanel):
250 __label__ = "Diffuse"
251 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
253 def poll(self, context):
254 mat = context.material
255 engine = context.scene.render_data.engine
256 return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
258 def draw(self, context):
261 mat = context.material
263 split = layout.split()
266 col.itemR(mat, "diffuse_color", text="")
268 sub.active = (not mat.shadeless)
269 sub.itemR(mat, "diffuse_reflection", text="Intensity")
272 col.active = (not mat.shadeless)
273 col.itemR(mat, "diffuse_shader", text="")
274 col.itemR(mat, "use_diffuse_ramp", text="Ramp")
276 col = layout.column()
277 col.active = (not mat.shadeless)
278 if mat.diffuse_shader == 'OREN_NAYAR':
279 col.itemR(mat, "roughness")
280 elif mat.diffuse_shader == 'MINNAERT':
281 col.itemR(mat, "darkness")
282 elif mat.diffuse_shader == 'TOON':
284 row.itemR(mat, "diffuse_toon_size", text="Size")
285 row.itemR(mat, "diffuse_toon_smooth", text="Smooth")
286 elif mat.diffuse_shader == 'FRESNEL':
288 row.itemR(mat, "diffuse_fresnel", text="Fresnel")
289 row.itemR(mat, "diffuse_fresnel_factor", text="Factor")
291 if mat.use_diffuse_ramp:
293 layout.template_color_ramp(mat.diffuse_ramp, expand=True)
296 split = row.split(percentage=0.3)
297 split.itemL(text="Input:")
298 split.itemR(mat, "diffuse_ramp_input", text="")
299 split = row.split(percentage=0.3)
300 split.itemL(text="Blend:")
301 split.itemR(mat, "diffuse_ramp_blend", text="")
303 class MATERIAL_PT_specular(MaterialButtonsPanel):
304 __label__ = "Specular"
305 COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
307 def poll(self, context):
308 mat = context.material
309 engine = context.scene.render_data.engine
310 return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
312 def draw(self, context):
315 mat = context.material
317 layout.active = (not mat.shadeless)
319 split = layout.split()
322 col.itemR(mat, "specular_color", text="")
323 col.itemR(mat, "specular_reflection", text="Intensity")
326 col.itemR(mat, "specular_shader", text="")
327 col.itemR(mat, "use_specular_ramp", text="Ramp")
329 col = layout.column()
330 if mat.specular_shader in ('COOKTORR', 'PHONG'):
331 col.itemR(mat, "specular_hardness", text="Hardness")
332 elif mat.specular_shader == 'BLINN':
334 row.itemR(mat, "specular_hardness", text="Hardness")
335 row.itemR(mat, "specular_ior", text="IOR")
336 elif mat.specular_shader == 'WARDISO':
337 col.itemR(mat, "specular_slope", text="Slope")
338 elif mat.specular_shader == 'TOON':
340 row.itemR(mat, "specular_toon_size", text="Size")
341 row.itemR(mat, "specular_toon_smooth", text="Smooth")
343 if mat.use_specular_ramp:
345 layout.template_color_ramp(mat.specular_ramp, expand=True)
348 split = row.split(percentage=0.3)
349 split.itemL(text="Input:")
350 split.itemR(mat, "specular_ramp_input", text="")
351 split = row.split(percentage=0.3)
352 split.itemL(text="Blend:")
353 split.itemR(mat, "specular_ramp_blend", text="")
355 class MATERIAL_PT_sss(MaterialButtonsPanel):
356 __label__ = "Subsurface Scattering"
357 __default_closed__ = True
358 COMPAT_ENGINES = set(['BLENDER_RENDER'])
360 def poll(self, context):
361 mat = context.material
362 engine = context.scene.render_data.engine
363 return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
365 def draw_header(self, context):
367 sss = context.material.subsurface_scattering
368 mat = context.material
370 layout.active = (not mat.shadeless)
371 layout.itemR(sss, "enabled", text="")
373 def draw(self, context):
376 mat = context.material
377 sss = context.material.subsurface_scattering
379 layout.active = sss.enabled
381 split = layout.split()
382 split.active = (not mat.shadeless)
385 col.itemR(sss, "ior")
386 col.itemR(sss, "scale")
387 col.itemR(sss, "color", text="")
388 col.itemR(sss, "radius", text="RGB Radius")
391 sub = col.column(align=True)
392 sub.itemL(text="Blend:")
393 sub.itemR(sss, "color_factor", text="Color")
394 sub.itemR(sss, "texture_factor", text="Texture")
395 sub.itemL(text="Scattering Weight:")
396 sub.itemR(sss, "front")
397 sub.itemR(sss, "back")
399 col.itemR(sss, "error_tolerance", text="Error")
401 class MATERIAL_PT_mirror(MaterialButtonsPanel):
403 __default_closed__ = True
404 COMPAT_ENGINES = set(['BLENDER_RENDER'])
406 def poll(self, context):
407 mat = context.material
408 engine = context.scene.render_data.engine
409 return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
411 def draw_header(self, context):
414 raym = context.material.raytrace_mirror
416 layout.itemR(raym, "enabled", text="")
418 def draw(self, context):
421 mat = context.material
422 raym = context.material.raytrace_mirror
424 layout.active = raym.enabled
426 split = layout.split()
429 col.itemR(raym, "reflect", text="Reflectivity")
430 col.itemR(mat, "mirror_color", text="")
433 col.itemR(raym, "fresnel")
435 sub.active = raym.fresnel > 0
436 sub.itemR(raym, "fresnel_factor", text="Blend")
438 split = layout.split()
442 col.itemR(raym, "distance", text="Max Dist")
443 col.itemR(raym, "depth")
445 sub = col.split(percentage=0.4)
446 sub.itemL(text="Fade To:")
447 sub.itemR(raym, "fade_to", text="")
450 col.itemL(text="Gloss:")
451 col.itemR(raym, "gloss", text="Amount")
453 sub.active = raym.gloss < 1
454 sub.itemR(raym, "gloss_threshold", text="Threshold")
455 sub.itemR(raym, "gloss_samples", text="Samples")
456 sub.itemR(raym, "gloss_anisotropic", text="Anisotropic")
458 class MATERIAL_PT_transp(MaterialButtonsPanel):
459 __label__= "Transparency"
460 __default_closed__ = True
461 COMPAT_ENGINES = set(['BLENDER_RENDER'])
463 def poll(self, context):
464 mat = context.material
465 engine = context.scene.render_data.engine
466 return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
468 def draw_header(self, context):
471 mat = context.material
472 layout.itemR(mat, "transparency", text="")
474 def draw(self, context):
477 mat = context.material
478 rayt = context.material.raytrace_transparency
481 row.itemR(mat, "transparency_method", expand=True)
482 row.active = mat.transparency and (not mat.shadeless)
484 split = layout.split()
488 row.itemR(mat, "alpha")
490 row.active = mat.transparency and (not mat.shadeless)
491 row.itemR(mat, "specular_alpha", text="Specular")
494 col.active = (not mat.shadeless)
495 col.itemR(rayt, "fresnel")
497 sub.active = rayt.fresnel > 0
498 sub.itemR(rayt, "fresnel_factor", text="Blend")
500 if mat.transparency_method == 'RAYTRACE':
502 split = layout.split()
503 split.active = mat.transparency
506 col.itemR(rayt, "ior")
507 col.itemR(rayt, "filter")
508 col.itemR(rayt, "falloff")
509 col.itemR(rayt, "limit")
510 col.itemR(rayt, "depth")
513 col.itemL(text="Gloss:")
514 col.itemR(rayt, "gloss", text="Amount")
516 sub.active = rayt.gloss < 1
517 sub.itemR(rayt, "gloss_threshold", text="Threshold")
518 sub.itemR(rayt, "gloss_samples", text="Samples")
520 class MATERIAL_PT_volume_shading(MaterialButtonsPanel):
521 __label__ = "Shading"
522 __default_closed__ = False
523 COMPAT_ENGINES = set(['BLENDER_RENDER'])
525 def poll(self, context):
526 mat = context.material
527 engine = context.scene.render_data.engine
528 return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES)
530 def draw(self, context):
533 mat = context.material
534 vol = context.material.volume
536 split = layout.split()
539 row.itemR(vol, "density")
540 row.itemR(vol, "scattering")
542 split = layout.split()
544 col.itemR(vol, "absorption")
545 col.itemR(vol, "absorption_color", text="")
548 col.itemR(vol, "emission")
549 col.itemR(vol, "emission_color", text="")
551 class MATERIAL_PT_volume_scattering(MaterialButtonsPanel):
552 __label__ = "Scattering"
553 __default_closed__ = False
554 COMPAT_ENGINES = set(['BLENDER_RENDER'])
556 def poll(self, context):
557 mat = context.material
558 engine = context.scene.render_data.engine
559 return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES)
561 def draw(self, context):
564 mat = context.material
565 vol = context.material.volume
567 split = layout.split()
570 col.itemR(vol, "scattering_mode", text="")
571 if vol.scattering_mode == 'SINGLE_SCATTERING':
572 col.itemR(vol, "light_cache")
574 sub.active = vol.light_cache
575 sub.itemR(vol, "cache_resolution")
576 elif vol.scattering_mode in ('MULTIPLE_SCATTERING', 'SINGLE_PLUS_MULTIPLE_SCATTERING'):
577 col.itemR(vol, "cache_resolution")
579 col = col.column(align=True)
580 col.itemR(vol, "ms_diffusion")
581 col.itemR(vol, "ms_spread")
582 col.itemR(vol, "ms_intensity")
585 # col.itemL(text="Anisotropic Scattering:")
586 col.itemR(vol, "phase_function", text="")
587 if vol.phase_function in ('SCHLICK', 'HENYEY-GREENSTEIN'):
588 col.itemR(vol, "asymmetry")
590 class MATERIAL_PT_volume_transp(MaterialButtonsPanel):
591 __label__= "Transparency"
592 COMPAT_ENGINES = set(['BLENDER_RENDER'])
594 def poll(self, context):
595 mat = context.material
596 engine = context.scene.render_data.engine
597 return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES)
599 def draw_header(self, context):
602 def draw(self, context):
605 mat = context.material
606 rayt = context.material.raytrace_transparency
609 row.itemR(mat, "transparency_method", expand=True)
610 row.active = mat.transparency and (not mat.shadeless)
612 class MATERIAL_PT_volume_integration(MaterialButtonsPanel):
613 __label__ = "Integration"
614 __default_closed__ = False
615 COMPAT_ENGINES = set(['BLENDER_RENDER'])
617 def poll(self, context):
618 mat = context.material
619 engine = context.scene.render_data.engine
620 return mat and (mat.type == 'VOLUME') and (engine in self.COMPAT_ENGINES)
622 def draw(self, context):
625 mat = context.material
626 vol = context.material.volume
628 split = layout.split()
631 col.itemL(text="Step Calculation:")
632 col.itemR(vol, "step_calculation", text="")
633 col = col.column(align=True)
634 col.itemR(vol, "step_size")
635 col.itemR(vol, "shading_step_size")
639 col.itemR(vol, "depth_cutoff")
640 col.itemR(vol, "density_scale")
643 class MATERIAL_PT_halo(MaterialButtonsPanel):
645 COMPAT_ENGINES = set(['BLENDER_RENDER'])
647 def poll(self, context):
648 mat = context.material
649 engine = context.scene.render_data.engine
650 return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES)
652 def draw(self, context):
655 mat = context.material
658 split = layout.split()
661 col.itemR(mat, "diffuse_color", text="")
662 col.itemR(halo, "size")
663 col.itemR(halo, "hardness")
664 col.itemR(halo, "add")
665 col.itemL(text="Options:")
666 col.itemR(halo, "use_texture", text="Texture")
667 col.itemR(halo, "use_vertex_normal", text="Vertex Normal")
668 col.itemR(halo, "xalpha")
669 col.itemR(halo, "shaded")
670 col.itemR(halo, "soft")
673 col.itemR(halo, "ring")
675 sub.active = halo.ring
676 sub.itemR(halo, "rings")
677 sub.itemR(mat, "mirror_color", text="")
679 col.itemR(halo, "lines")
681 sub.active = halo.lines
682 sub.itemR(halo, "line_number", text="Lines")
683 sub.itemR(mat, "specular_color", text="")
685 col.itemR(halo, "star")
687 sub.active = halo.star
688 sub.itemR(halo, "star_tips")
690 class MATERIAL_PT_flare(MaterialButtonsPanel):
692 COMPAT_ENGINES = set(['BLENDER_RENDER'])
694 def poll(self, context):
695 mat = context.material
696 engine = context.scene.render_data.engine
697 return mat and (mat.type == 'HALO') and (engine in self.COMPAT_ENGINES)
699 def draw_header(self, context):
702 mat = context.material
704 layout.itemR(halo, "flare_mode", text="")
706 def draw(self, context):
709 mat = context.material
712 layout.active = halo.flare_mode
714 split = layout.split()
717 col.itemR(halo, "flare_size", text="Size")
718 col.itemR(halo, "flare_boost", text="Boost")
719 col.itemR(halo, "flare_seed", text="Seed")
721 col.itemR(halo, "flares_sub", text="Subflares")
722 col.itemR(halo, "flare_subsize", text="Subsize")
724 bpy.types.register(MATERIAL_PT_context_material)
725 bpy.types.register(MATERIAL_PT_preview)
726 bpy.types.register(MATERIAL_PT_diffuse)
727 bpy.types.register(MATERIAL_PT_specular)
728 bpy.types.register(MATERIAL_PT_shading)
729 bpy.types.register(MATERIAL_PT_transp)
730 bpy.types.register(MATERIAL_PT_mirror)
731 bpy.types.register(MATERIAL_PT_sss)
732 bpy.types.register(MATERIAL_PT_volume_shading)
733 bpy.types.register(MATERIAL_PT_volume_scattering)
734 bpy.types.register(MATERIAL_PT_volume_transp)
735 bpy.types.register(MATERIAL_PT_volume_integration)
736 bpy.types.register(MATERIAL_PT_halo)
737 bpy.types.register(MATERIAL_PT_flare)
738 bpy.types.register(MATERIAL_PT_physics)
739 bpy.types.register(MATERIAL_PT_strand)
740 bpy.types.register(MATERIAL_PT_options)
741 bpy.types.register(MATERIAL_PT_shadow)