* projection paint options in the toolbar
[blender.git] / release / ui / buttons_material.py
1         
2 import bpy
3
4 class MaterialButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "material"
8
9         def poll(self, context):
10                 return (context.material != None)
11
12 class MATERIAL_PT_preview(MaterialButtonsPanel):
13         __idname__= "MATERIAL_PT_preview"
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18                 mat = context.material
19                 
20                 layout.template_preview(mat)
21                 
22 class MATERIAL_PT_context_material(MaterialButtonsPanel):
23         __idname__= "MATERIAL_PT_context_material"
24         __show_header__ = False
25
26         def poll(self, context):
27                 return (context.object)
28
29         def draw(self, context):
30                 layout = self.layout
31                 
32                 mat = context.material
33                 ob = context.object
34                 slot = context.material_slot
35                 space = context.space_data
36
37                 if ob:
38                         row = layout.row()
39
40                         row.template_list(ob, "materials", ob, "active_material_index", rows=2)
41
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="")
45
46                         if context.edit_object:
47                                 row = layout.row(align=True)
48
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")
52
53                 split = layout.split(percentage=0.65)
54
55                 if ob and slot:
56                         split.template_ID(slot, "material", new="material.new")
57                         row = split.row()
58                         row.itemR(slot, "link", expand=True)
59                 elif mat:
60                         split.template_ID(space, "pin_id")
61                         split.itemS()
62         
63 class MATERIAL_PT_material(MaterialButtonsPanel):
64         __idname__= "MATERIAL_PT_material"
65         __label__ = "Shading"
66
67         def draw(self, context):
68                 layout = self.layout
69                 
70                 mat = context.material
71                 ob = context.object
72                 slot = context.material_slot
73                 space = context.space_data
74
75                 if mat:
76                         layout.itemR(mat, "type", expand=True)
77
78                         if mat.type in ('SURFACE', 'WIRE', 'VOLUME'):
79                                 split = layout.split()
80         
81                                 sub = split.column()
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)
86                                 
87                                 sub = split.column()
88                                 sub.itemR(mat, "z_transparency")
89                                 sub.itemR(mat, "shadeless")     
90                                 sub.itemR(mat, "tangent_shading")
91                                 sub.itemR(mat, "cubic", slider=True)
92                                 
93                         elif mat.type == 'HALO':
94                                 layout.itemR(mat, "alpha", slider=True)
95                         
96 class MATERIAL_PT_strand(MaterialButtonsPanel):
97         __idname__= "MATERIAL_PT_strand"
98         __label__ = "Strand"
99         __default_closed__ = True
100         
101         def draw(self, context):
102                 layout = self.layout
103                 tan = context.material.strand
104                 mat = context.material
105                 
106                 split = layout.split()
107                 
108                 sub = split.column()
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")
117                 
118                 sub = split.column()
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")
128                 
129 class MATERIAL_PT_options(MaterialButtonsPanel):
130         __idname__= "MATERIAL_PT_options"
131         __label__ = "Options"
132
133         def draw(self, context):
134                 layout = self.layout
135                 mat = context.material
136                 
137                 split = layout.split()
138                 
139                 sub = split.column()
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")
145
146                 col = sub.column(align=True)
147                 col.itemL(text="Light Group:")
148                 col.itemR(mat, "light_group", text="")
149                 row = col.row()
150                 row.active = mat.light_group
151                 row.itemR(mat, "light_group_exclusive", text="Exclusive")
152
153                 sub = split.column()
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")
161
162 class MATERIAL_PT_shadows(MaterialButtonsPanel):
163         __idname__= "MATERIAL_PT_shadows"
164         __label__ = "Shadows"
165
166         def draw(self, context):
167                 layout = self.layout
168                 mat = context.material
169                 
170                 split = layout.split()
171                 
172                 sub = split.column()
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)
178                 sub = split.column()
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")
185
186
187 class MATERIAL_PT_diffuse(MaterialButtonsPanel):
188         __idname__= "MATERIAL_PT_diffuse"
189         __label__ = "Diffuse"
190
191         def poll(self, context):
192                 mat = context.material
193                 return (mat and mat.type != 'HALO')
194
195         def draw(self, context):
196                 layout = self.layout
197                 mat = context.material  
198                 
199                 split = layout.split()
200                 
201                 sub = split.column()
202                 sub.itemR(mat, "diffuse_color", text="")
203                 row = sub.row()
204                 row.active = mat.shadeless== False
205                 row.itemR(mat, "diffuse_reflection", text="Intensity", slider=True)
206                 
207                 sub = split.column()
208                 sub.active = mat.shadeless== False
209                 sub.itemR(mat, "diffuse_shader", text="")
210                 sub.itemR(mat, "use_diffuse_ramp", text="Ramp")
211                 
212                 split = layout.split()
213                 split.active = mat.shadeless== False
214                 sub = split.column()
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")
221                         sub = split.column()
222                         sub.itemR(mat, "diffuse_toon_smooth", text="Smooth")
223                 if mat.diffuse_shader == 'FRESNEL':
224                         sub.itemR(mat, "diffuse_fresnel", text="Fresnel")
225                         sub = split.column()
226                         sub.itemR(mat, "diffuse_fresnel_factor", text="Factor")
227                 
228                 if mat.use_diffuse_ramp:
229                         layout.template_color_ramp(mat.diffuse_ramp, expand=True)
230                 
231 class MATERIAL_PT_specular(MaterialButtonsPanel):
232         __idname__= "MATERIAL_PT_specular"
233         __label__ = "Specular"
234
235         def poll(self, context):
236                 mat = context.material
237                 return (mat and mat.type != 'HALO')
238
239         def draw(self, context):
240                 layout = self.layout
241                 mat = context.material
242                 
243                 layout.active = mat.shadeless== False
244                 
245                 split = layout.split()
246                 
247                 sub = split.column()
248                 sub.itemR(mat, "specular_color", text="")
249                 sub.itemR(mat, "specular_reflection", text="Intensity", slider=True)
250
251                 sub = split.column()
252                 sub.itemR(mat, "specular_shader", text="")
253                 sub.itemR(mat, "use_specular_ramp", text="Ramp")
254                 
255                 split = layout.split()
256                 
257                 sub = split.column()
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")
262                         sub = split.column()
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")
268                         sub = split.column()
269                         sub.itemR(mat, "specular_toon_smooth", text="Smooth")
270                 
271                 if mat.use_specular_ramp:
272                         layout.template_color_ramp(mat.specular_ramp, expand=True)
273                 
274 class MATERIAL_PT_sss(MaterialButtonsPanel):
275         __idname__= "MATERIAL_PT_sss"
276         __label__ = "Subsurface Scattering"
277         __default_closed__ = True
278         
279         def poll(self, context):
280                 mat = context.material
281                 return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
282
283         def draw_header(self, context):
284                 layout = self.layout
285                 sss = context.material.subsurface_scattering
286
287                 layout.itemR(sss, "enabled", text="")
288         
289         def draw(self, context):
290                 layout = self.layout
291                 sss = context.material.subsurface_scattering
292                 mat = context.material
293                 layout.active = sss.enabled     
294                 
295                 split = layout.split()
296                 split.active = mat.shadeless== False
297                 
298                 sub = split.column()
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")
306                 
307                 sub = split.column()
308                 sub.itemR(sss, "ior")
309                 sub.itemR(sss, "scale")
310                 sub.itemR(sss, "radius", text="RGB Radius")
311                 sub.itemR(sss, "error_tolerance")
312
313 class MATERIAL_PT_raymir(MaterialButtonsPanel):
314         __idname__= "MATERIAL_PT_raymir"
315         __label__ = "Ray Mirror"
316         __default_closed__ = True
317         
318         def poll(self, context):
319                 mat = context.material
320                 return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
321         
322         def draw_header(self, context):
323                 layout = self.layout
324                 raym = context.material.raytrace_mirror
325
326                 layout.itemR(raym, "enabled", text="")
327         
328         def draw(self, context):
329                 layout = self.layout
330                 raym = context.material.raytrace_mirror
331                 mat = context.material
332                 
333                 layout.active = raym.enabled
334                 
335                 split = layout.split()
336                 
337                 sub = split.column()
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)
342                 
343                 sub = split.column()
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")
350                 
351                 row = layout.row()
352                 row.itemR(raym, "distance", text="Max Dist")
353                 row.itemR(raym, "depth")
354                 
355                 layout.itemR(raym, "fade_to")
356                 
357 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
358         __idname__= "MATERIAL_PT_raytransp"
359         __label__= "Ray Transparency"
360         __default_closed__ = True
361                 
362         def poll(self, context):
363                 mat = context.material
364                 return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
365
366         def draw_header(self, context):
367                 layout = self.layout
368                 rayt = context.material.raytrace_transparency
369
370                 layout.itemR(rayt, "enabled", text="")
371
372         def draw(self, context):
373                 layout = self.layout
374                 rayt = context.material.raytrace_transparency
375                 mat = context.material
376                 
377                 layout.active = rayt.enabled    
378                 
379                 split = layout.split()
380                 split.active = mat.shadeless== False
381                 
382                 sub = split.column()
383                 sub.itemR(rayt, "ior")
384                 sub.itemR(rayt, "fresnel")
385                 sub.itemR(rayt, "fresnel_fac", text="Fac", slider=True)
386                 
387                 sub = split.column()
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")
393                 
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")
401                 
402 class MATERIAL_PT_halo(MaterialButtonsPanel):
403         __idname__= "MATERIAL_PT_halo"
404         __label__= "Halo"
405         
406         def poll(self, context):
407                 mat = context.material
408                 return (mat and mat.type == 'HALO')
409         
410         def draw(self, context):
411                 layout = self.layout
412                 
413                 mat = context.material
414                 halo = mat.halo
415
416                 split = layout.split()
417                 
418                 col = split.column()
419                 col.itemR(mat, "diffuse_color", text="")
420                 col.itemR(halo, "size")
421                 col.itemR(halo, "hardness")
422                 col.itemR(halo, "add", slider=True)
423                 
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")
430
431                 col = split.column()
432                 col = col.column()
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")
455
456
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)