4 class MaterialButtonsPanel(bpy.types.Panel):
5 __space_type__ = "BUTTONS_WINDOW"
6 __region_type__ = "WINDOW"
7 __context__ = "material"
9 def poll(self, context):
10 return (context.material != None)
12 class MATERIAL_PT_preview(MaterialButtonsPanel):
13 __idname__= "MATERIAL_PT_preview"
16 def draw(self, context):
18 mat = context.material
20 layout.template_preview(mat)
22 class MATERIAL_PT_context_material(MaterialButtonsPanel):
23 __idname__= "MATERIAL_PT_context_material"
24 __show_header__ = False
26 def poll(self, context):
27 return (context.object)
29 def draw(self, context):
32 mat = context.material
34 slot = context.material_slot
35 space = context.space_data
40 row.template_list(ob, "materials", ob, "active_material_index", rows=2)
42 col = row.column(align=True)
43 col.itemO("object.material_slot_add", icon="ICON_ZOOMIN", text="")
44 col.itemO("object.material_slot_remove", icon="ICON_ZOOMOUT", text="")
46 if context.edit_object:
47 row = layout.row(align=True)
49 row.itemO("object.material_slot_assign", text="Assign")
50 row.itemO("object.material_slot_select", text="Select")
51 row.itemO("object.material_slot_deselect", text="Deselect")
53 split = layout.split(percentage=0.65)
56 split.template_ID(slot, "material", new="material.new")
58 row.itemR(slot, "link", expand=True)
60 split.template_ID(space, "pin_id")
63 class MATERIAL_PT_material(MaterialButtonsPanel):
64 __idname__= "MATERIAL_PT_material"
67 def draw(self, context):
70 mat = context.material
72 slot = context.material_slot
73 space = context.space_data
76 layout.itemR(mat, "type", expand=True)
78 if mat.type in ('SURFACE', 'WIRE', 'VOLUME'):
79 split = layout.split()
82 sub.itemR(mat, "alpha", slider=True)
83 sub.itemR(mat, "ambient", slider=True)
84 sub.itemR(mat, "emit")
85 sub.itemR(mat, "translucency", slider=True)
88 sub.itemR(mat, "z_transparency")
89 sub.itemR(mat, "shadeless")
90 sub.itemR(mat, "tangent_shading")
91 sub.itemR(mat, "cubic", slider=True)
93 elif mat.type == 'HALO':
94 layout.itemR(mat, "alpha", slider=True)
96 class MATERIAL_PT_strand(MaterialButtonsPanel):
97 __idname__= "MATERIAL_PT_strand"
99 __default_closed__ = True
101 def draw(self, context):
103 tan = context.material.strand
104 mat = context.material
106 split = layout.split()
109 sub.itemL(text="Size:")
110 sub.itemR(tan, "start_size", text="Root")
111 sub.itemR(tan, "end_size", text="Tip")
112 sub.itemR(tan, "min_size", text="Minimum")
113 sub.itemR(tan, "blender_units")
114 colsub = sub.column()
115 colsub.active = mat.shadeless== False
116 colsub.itemR(tan, "tangent_shading")
119 sub.itemR(tan, "shape")
120 sub.itemR(tan, "width_fade")
121 sub.itemR(tan, "uv_layer")
122 colsub = sub.column()
123 colsub.active = mat.shadeless== False
124 colsub.itemR(tan, "surface_diffuse")
125 colsubsub = colsub.column()
126 colsubsub.active = tan.surface_diffuse
127 colsubsub.itemR(tan, "blend_distance", text="Distance")
129 class MATERIAL_PT_options(MaterialButtonsPanel):
130 __idname__= "MATERIAL_PT_options"
131 __label__ = "Options"
133 def draw(self, context):
135 mat = context.material
137 split = layout.split()
140 sub.itemR(mat, "traceable")
141 sub.itemR(mat, "full_oversampling")
142 sub.itemR(mat, "sky")
143 sub.itemR(mat, "exclude_mist")
144 sub.itemR(mat, "invert_z")
146 col = sub.column(align=True)
147 col.itemL(text="Light Group:")
148 col.itemR(mat, "light_group", text="")
150 row.active = mat.light_group
151 row.itemR(mat, "light_group_exclusive", text="Exclusive")
154 sub.itemR(mat, "face_texture")
155 colsub = sub.column()
156 colsub.active = mat.face_texture
157 colsub.itemR(mat, "face_texture_alpha")
158 sub.itemR(mat, "vertex_color_paint")
159 sub.itemR(mat, "vertex_color_light")
160 sub.itemR(mat, "object_color")
162 class MATERIAL_PT_shadows(MaterialButtonsPanel):
163 __idname__= "MATERIAL_PT_shadows"
164 __label__ = "Shadows"
166 def draw(self, context):
168 mat = context.material
170 split = layout.split()
173 sub.itemR(mat, "shadows", text="Receive")
174 sub.itemR(mat, "transparent_shadows", text="Receive Transparent")
175 sub.itemR(mat, "only_shadow", text="Shadows Only")
176 sub.itemR(mat, "cast_shadows_only", text="Cast Only")
177 sub.itemR(mat, "shadow_casting_alpha", text="Casting Alpha", slider=True)
179 sub.itemR(mat, "ray_shadow_bias", text="Auto Ray Bias")
180 colsub = sub.column()
181 colsub.active = not mat.ray_shadow_bias
182 colsub.itemR(mat, "shadow_ray_bias", text="Ray Shadow Bias")
183 sub.itemR(mat, "cast_buffer_shadows")
184 sub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias")
187 class MATERIAL_PT_diffuse(MaterialButtonsPanel):
188 __idname__= "MATERIAL_PT_diffuse"
189 __label__ = "Diffuse"
191 def poll(self, context):
192 mat = context.material
193 return (mat and mat.type != 'HALO')
195 def draw(self, context):
197 mat = context.material
199 split = layout.split()
202 sub.itemR(mat, "diffuse_color", text="")
204 row.active = mat.shadeless== False
205 row.itemR(mat, "diffuse_reflection", text="Intensity", slider=True)
208 sub.active = mat.shadeless== False
209 sub.itemR(mat, "diffuse_shader", text="")
210 sub.itemR(mat, "use_diffuse_ramp", text="Ramp")
212 split = layout.split()
213 split.active = mat.shadeless== False
215 if mat.diffuse_shader == 'OREN_NAYAR':
216 sub.itemR(mat, "roughness")
217 if mat.diffuse_shader == 'MINNAERT':
218 sub.itemR(mat, "darkness")
219 if mat.diffuse_shader == 'TOON':
220 sub.itemR(mat, "diffuse_toon_size", text="Size")
222 sub.itemR(mat, "diffuse_toon_smooth", text="Smooth")
223 if mat.diffuse_shader == 'FRESNEL':
224 sub.itemR(mat, "diffuse_fresnel", text="Fresnel")
226 sub.itemR(mat, "diffuse_fresnel_factor", text="Factor")
228 if mat.use_diffuse_ramp:
229 layout.template_color_ramp(mat.diffuse_ramp, expand=True)
231 class MATERIAL_PT_specular(MaterialButtonsPanel):
232 __idname__= "MATERIAL_PT_specular"
233 __label__ = "Specular"
235 def poll(self, context):
236 mat = context.material
237 return (mat and mat.type != 'HALO')
239 def draw(self, context):
241 mat = context.material
243 layout.active = mat.shadeless== False
245 split = layout.split()
248 sub.itemR(mat, "specular_color", text="")
249 sub.itemR(mat, "specular_reflection", text="Intensity", slider=True)
252 sub.itemR(mat, "specular_shader", text="")
253 sub.itemR(mat, "use_specular_ramp", text="Ramp")
255 split = layout.split()
258 if mat.specular_shader in ('COOKTORR', 'PHONG'):
259 sub.itemR(mat, "specular_hardness", text="Hardness")
260 if mat.specular_shader == 'BLINN':
261 sub.itemR(mat, "specular_hardness", text="Hardness")
263 sub.itemR(mat, "specular_ior", text="IOR")
264 if mat.specular_shader == 'WARDISO':
265 sub.itemR(mat, "specular_slope", text="Slope")
266 if mat.specular_shader == 'TOON':
267 sub.itemR(mat, "specular_toon_size", text="Size")
269 sub.itemR(mat, "specular_toon_smooth", text="Smooth")
271 if mat.use_specular_ramp:
272 layout.template_color_ramp(mat.specular_ramp, expand=True)
274 class MATERIAL_PT_sss(MaterialButtonsPanel):
275 __idname__= "MATERIAL_PT_sss"
276 __label__ = "Subsurface Scattering"
277 __default_closed__ = True
279 def poll(self, context):
280 mat = context.material
281 return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
283 def draw_header(self, context):
285 sss = context.material.subsurface_scattering
287 layout.itemR(sss, "enabled", text="")
289 def draw(self, context):
291 sss = context.material.subsurface_scattering
292 mat = context.material
293 layout.active = sss.enabled
295 split = layout.split()
296 split.active = mat.shadeless== False
299 sub.itemR(sss, "color", text="")
300 sub.itemL(text="Blend:")
301 sub.itemR(sss, "color_factor", slider=True)
302 sub.itemR(sss, "texture_factor", slider=True)
303 sub.itemL(text="Scattering Weight:")
304 sub.itemR(sss, "front")
305 sub.itemR(sss, "back")
308 sub.itemR(sss, "ior")
309 sub.itemR(sss, "scale")
310 sub.itemR(sss, "radius", text="RGB Radius")
311 sub.itemR(sss, "error_tolerance")
313 class MATERIAL_PT_raymir(MaterialButtonsPanel):
314 __idname__= "MATERIAL_PT_raymir"
315 __label__ = "Ray Mirror"
316 __default_closed__ = True
318 def poll(self, context):
319 mat = context.material
320 return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
322 def draw_header(self, context):
324 raym = context.material.raytrace_mirror
326 layout.itemR(raym, "enabled", text="")
328 def draw(self, context):
330 raym = context.material.raytrace_mirror
331 mat = context.material
333 layout.active = raym.enabled
335 split = layout.split()
338 sub.itemR(raym, "reflect", text="Reflectivity", slider=True)
339 sub.itemR(mat, "mirror_color", text="")
340 sub.itemR(raym, "fresnel")
341 sub.itemR(raym, "fresnel_fac", text="Fac", slider=True)
344 sub.itemR(raym, "gloss", slider=True)
345 colsub = sub.column()
346 colsub.active = raym.gloss < 1
347 colsub.itemR(raym, "gloss_threshold", slider=True, text="Threshold")
348 colsub.itemR(raym, "gloss_samples", text="Samples")
349 colsub.itemR(raym, "gloss_anisotropic", slider=True, text="Anisotropic")
352 row.itemR(raym, "distance", text="Max Dist")
353 row.itemR(raym, "depth")
355 layout.itemR(raym, "fade_to")
357 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
358 __idname__= "MATERIAL_PT_raytransp"
359 __label__= "Ray Transparency"
360 __default_closed__ = True
362 def poll(self, context):
363 mat = context.material
364 return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
366 def draw_header(self, context):
368 rayt = context.material.raytrace_transparency
370 layout.itemR(rayt, "enabled", text="")
372 def draw(self, context):
374 rayt = context.material.raytrace_transparency
375 mat = context.material
377 layout.active = rayt.enabled
379 split = layout.split()
380 split.active = mat.shadeless== False
383 sub.itemR(rayt, "ior")
384 sub.itemR(rayt, "fresnel")
385 sub.itemR(rayt, "fresnel_fac", text="Fac", slider=True)
388 sub.itemR(rayt, "gloss", slider=True)
389 colsub = sub.column()
390 colsub.active = rayt.gloss < 1
391 colsub.itemR(rayt, "gloss_threshold", slider=True, text="Threshold")
392 colsub.itemR(rayt, "gloss_samples", text="Samples")
394 flow = layout.column_flow()
395 flow.active = mat.shadeless== False
396 flow.itemR(rayt, "filter", slider=True)
397 flow.itemR(rayt, "limit")
398 flow.itemR(rayt, "falloff")
399 flow.itemR(rayt, "specular_opacity", slider=True, text="Spec Opacity")
400 flow.itemR(rayt, "depth")
402 class MATERIAL_PT_halo(MaterialButtonsPanel):
403 __idname__= "MATERIAL_PT_halo"
406 def poll(self, context):
407 mat = context.material
408 return (mat and mat.type == 'HALO')
410 def draw(self, context):
413 mat = context.material
416 split = layout.split()
419 col.itemR(mat, "diffuse_color", text="")
420 col.itemR(halo, "size")
421 col.itemR(halo, "hardness")
422 col.itemR(halo, "add", slider=True)
424 col.itemL(text="Options:")
425 col.itemR(halo, "use_texture", text="Texture")
426 col.itemR(halo, "use_vertex_normal", text="Vertex Normal")
427 col.itemR(halo, "xalpha")
428 col.itemR(halo, "shaded")
429 col.itemR(halo, "soft")
433 col.itemR(halo, "ring")
434 colsub = col.column()
435 colsub.active = halo.ring
436 colsub.itemR(halo, "rings")
437 colsub.itemR(mat, "mirror_color", text="")
438 col.itemR(halo, "lines")
439 colsub = col.column()
440 colsub.active = halo.lines
441 colsub.itemR(halo, "line_number", text="Lines")
442 colsub.itemR(mat, "specular_color", text="")
443 col.itemR(halo, "star")
444 colsub = col.column()
445 colsub.active = halo.star
446 colsub.itemR(halo, "star_tips")
447 col.itemR(halo, "flare_mode")
448 colsub = col.column()
449 colsub.active = halo.flare_mode
450 colsub.itemR(halo, "flare_size", text="Size")
451 colsub.itemR(halo, "flare_subsize", text="Subsize")
452 colsub.itemR(halo, "flare_boost", text="Boost")
453 colsub.itemR(halo, "flare_seed", text="Seed")
454 colsub.itemR(halo, "flares_sub", text="Sub")
457 bpy.types.register(MATERIAL_PT_context_material)
458 bpy.types.register(MATERIAL_PT_preview)
459 bpy.types.register(MATERIAL_PT_material)
460 bpy.types.register(MATERIAL_PT_diffuse)
461 bpy.types.register(MATERIAL_PT_specular)
462 bpy.types.register(MATERIAL_PT_raymir)
463 bpy.types.register(MATERIAL_PT_raytransp)
464 bpy.types.register(MATERIAL_PT_sss)
465 bpy.types.register(MATERIAL_PT_halo)
466 bpy.types.register(MATERIAL_PT_strand)
467 bpy.types.register(MATERIAL_PT_options)
468 bpy.types.register(MATERIAL_PT_shadows)