1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
|
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
from rna_prop_ui import PropertyPanel
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 is not None:
mat_node = mat.active_node_material
if mat_node:
return mat_node
else:
return mat
return None
def check_material(mat):
if mat is not None:
if mat.use_nodes:
if mat.active_node_material is not None:
return True
return False
return True
return False
def simple_material(mat):
if (mat is not None) and (not mat.use_nodes):
return True
return False
class MATERIAL_MT_sss_presets(bpy.types.Menu):
bl_label = "SSS Presets"
preset_subdir = "sss"
preset_operator = "script.execute_preset"
draw = bpy.types.Menu.draw_preset
class MATERIAL_MT_specials(bpy.types.Menu):
bl_label = "Material Specials"
def draw(self, context):
layout = self.layout
layout.operator("object.material_slot_copy", icon='COPY_ID')
layout.operator("material.copy", icon='COPYDOWN')
layout.operator("material.paste", icon='PASTEDOWN')
class MaterialButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
@classmethod
def poll(cls, context):
return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
class MATERIAL_PT_context_material(MaterialButtonsPanel, bpy.types.Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
# An exception, dont call the parent poll func because
# this manages materials for all engine types
engine = context.scene.render.engine
return (context.material or context.object) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
ob = context.object
slot = context.material_slot
space = context.space_data
if ob:
row = layout.row()
row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
if ob.mode == 'EDIT':
row = layout.row(align=True)
row.operator("object.material_slot_assign", text="Assign")
row.operator("object.material_slot_select", text="Select")
row.operator("object.material_slot_deselect", text="Deselect")
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "active_material", new="material.new")
row = split.row()
if mat:
row.prop(mat, "use_nodes", icon="NODETREE", text="")
if slot:
row.prop(slot, "link", text="")
else:
row.label()
elif mat:
split.template_ID(space, "pin_id")
split.separator()
if mat:
layout.prop(mat, "type", expand=True)
if mat.use_nodes:
row = layout.row()
row.label(text="", icon='NODETREE')
if mat.active_node_material:
row.prop(mat.active_node_material, "name", text="")
else:
row.label(text="No material node selected")
class MATERIAL_PT_preview(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Preview"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
def draw(self, context):
self.layout.template_preview(context.material)
class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Render Pipeline Options"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (not simple_material(mat)) and (mat.type in {'SURFACE', 'WIRE', 'VOLUME'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self. layout
mat = context.material
mat_type = mat.type in {'SURFACE', 'WIRE'}
row = layout.row()
row.active = mat_type
row.prop(mat, "use_transparency")
sub = row.column()
sub.prop(mat, "offset_z")
sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
row = layout.row()
row.active = mat.use_transparency or not mat_type
row.prop(mat, "transparency_method", expand=True)
layout.separator()
split = layout.split()
col = split.column()
col.prop(mat, "use_raytrace")
col.prop(mat, "use_full_oversampling")
sub = col.column()
sub.active = mat_type
sub.prop(mat, "use_sky")
sub.prop(mat, "invert_z")
col = split.column()
col.active = mat_type
col.prop(mat, "use_cast_shadows_only", text="Cast Only")
col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
col.prop(mat, "use_cast_buffer_shadows")
col.prop(mat, "use_cast_approximate")
class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Diffuse"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
split = layout.split()
col = split.column()
col.prop(mat, "diffuse_color", text="")
sub = col.column()
sub.active = (not mat.use_shadeless)
sub.prop(mat, "diffuse_intensity", text="Intensity")
col = split.column()
col.active = (not mat.use_shadeless)
col.prop(mat, "diffuse_shader", text="")
col.prop(mat, "use_diffuse_ramp", text="Ramp")
col = layout.column()
col.active = (not mat.use_shadeless)
if mat.diffuse_shader == 'OREN_NAYAR':
col.prop(mat, "roughness")
elif mat.diffuse_shader == 'MINNAERT':
col.prop(mat, "darkness")
elif mat.diffuse_shader == 'TOON':
row = col.row()
row.prop(mat, "diffuse_toon_size", text="Size")
row.prop(mat, "diffuse_toon_smooth", text="Smooth")
elif mat.diffuse_shader == 'FRESNEL':
row = col.row()
row.prop(mat, "diffuse_fresnel", text="Fresnel")
row.prop(mat, "diffuse_fresnel_factor", text="Factor")
if mat.use_diffuse_ramp:
layout.separator()
layout.template_color_ramp(mat, "diffuse_ramp", expand=True)
layout.separator()
row = layout.row()
row.prop(mat, "diffuse_ramp_input", text="Input")
row.prop(mat, "diffuse_ramp_blend", text="Blend")
layout.prop(mat, "diffuse_ramp_factor", text="Factor")
class MATERIAL_PT_specular(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Specular"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
layout.active = (not mat.use_shadeless)
split = layout.split()
col = split.column()
col.prop(mat, "specular_color", text="")
col.prop(mat, "specular_intensity", text="Intensity")
col = split.column()
col.prop(mat, "specular_shader", text="")
col.prop(mat, "use_specular_ramp", text="Ramp")
col = layout.column()
if mat.specular_shader in {'COOKTORR', 'PHONG'}:
col.prop(mat, "specular_hardness", text="Hardness")
elif mat.specular_shader == 'BLINN':
row = col.row()
row.prop(mat, "specular_hardness", text="Hardness")
row.prop(mat, "specular_ior", text="IOR")
elif mat.specular_shader == 'WARDISO':
col.prop(mat, "specular_slope", text="Slope")
elif mat.specular_shader == 'TOON':
row = col.row()
row.prop(mat, "specular_toon_size", text="Size")
row.prop(mat, "specular_toon_smooth", text="Smooth")
if mat.use_specular_ramp:
layout.separator()
layout.template_color_ramp(mat, "specular_ramp", expand=True)
layout.separator()
row = layout.row()
row.prop(mat, "specular_ramp_input", text="Input")
row.prop(mat, "specular_ramp_blend", text="Blend")
layout.prop(mat, "specular_ramp_factor", text="Factor")
class MATERIAL_PT_shading(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Shading"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
if mat.type in {'SURFACE', 'WIRE'}:
split = layout.split()
col = split.column()
sub = col.column()
sub.active = not mat.use_shadeless
sub.prop(mat, "emit")
sub.prop(mat, "ambient")
sub = col.column()
sub.prop(mat, "translucency")
col = split.column()
col.prop(mat, "use_shadeless")
sub = col.column()
sub.active = not mat.use_shadeless
sub.prop(mat, "use_tangent_shading")
sub.prop(mat, "use_cubic")
class MATERIAL_PT_transp(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Transparency"
# bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
mat = context.material
if simple_material(mat):
self.layout.prop(mat, "use_transparency", text="")
def draw(self, context):
layout = self.layout
base_mat = context.material
mat = active_node_mat(context.material)
rayt = mat.raytrace_transparency
if simple_material(base_mat):
row = layout.row()
row.active = mat.use_transparency
row.prop(mat, "transparency_method", expand=True)
split = layout.split()
split.active = base_mat.use_transparency
col = split.column()
col.prop(mat, "alpha")
row = col.row()
row.active = (base_mat.transparency_method != 'MASK') and (not mat.use_shadeless)
row.prop(mat, "specular_alpha", text="Specular")
col = split.column()
col.active = (not mat.use_shadeless)
col.prop(rayt, "fresnel")
sub = col.column()
sub.active = rayt.fresnel > 0
sub.prop(rayt, "fresnel_factor", text="Blend")
if base_mat.transparency_method == 'RAYTRACE':
layout.separator()
split = layout.split()
split.active = base_mat.use_transparency
col = split.column()
col.prop(rayt, "ior")
col.prop(rayt, "filter")
col.prop(rayt, "falloff")
col.prop(rayt, "depth_max")
col.prop(rayt, "depth")
col = split.column()
col.label(text="Gloss:")
col.prop(rayt, "gloss_factor", text="Amount")
sub = col.column()
sub.active = rayt.gloss_factor < 1.0
sub.prop(rayt, "gloss_threshold", text="Threshold")
sub.prop(rayt, "gloss_samples", text="Samples")
class MATERIAL_PT_mirror(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Mirror"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
raym = active_node_mat(context.material).raytrace_mirror
self.layout.prop(raym, "use", text="")
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
raym = mat.raytrace_mirror
layout.active = raym.use
split = layout.split()
col = split.column()
col.prop(raym, "reflect_factor")
col.prop(mat, "mirror_color", text="")
col = split.column()
col.prop(raym, "fresnel")
sub = col.column()
sub.active = raym.fresnel > 0
sub.prop(raym, "fresnel_factor", text="Blend")
split = layout.split()
col = split.column()
col.separator()
col.prop(raym, "depth")
col.prop(raym, "distance", text="Max Dist")
col.separator()
sub = col.split(percentage=0.4)
sub.active = raym.distance > 0.0
sub.label(text="Fade To:")
sub.prop(raym, "fade_to", text="")
col = split.column()
col.label(text="Gloss:")
col.prop(raym, "gloss_factor", text="Amount")
sub = col.column()
sub.active = raym.gloss_factor < 1.0
sub.prop(raym, "gloss_threshold", text="Threshold")
sub.prop(raym, "gloss_samples", text="Samples")
sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
class MATERIAL_PT_sss(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Subsurface Scattering"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
mat = active_node_mat(context.material)
sss = mat.subsurface_scattering
self.layout.active = (not mat.use_shadeless)
self.layout.prop(sss, "use", text="")
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
sss = mat.subsurface_scattering
layout.active = (sss.use) and (not mat.use_shadeless)
row = layout.row().split()
sub = row.row(align=True).split(percentage=0.75)
sub.menu("MATERIAL_MT_sss_presets", text=bpy.types.MATERIAL_MT_sss_presets.bl_label)
sub.operator("material.sss_preset_add", text="", icon="ZOOMIN")
sub.operator("material.sss_preset_add", text="", icon="ZOOMOUT").remove_active = True
split = layout.split()
col = split.column()
col.prop(sss, "ior")
col.prop(sss, "scale")
col.prop(sss, "color", text="")
col.prop(sss, "radius", text="RGB Radius", expand=True)
col = split.column()
sub = col.column(align=True)
sub.label(text="Blend:")
sub.prop(sss, "color_factor", text="Color")
sub.prop(sss, "texture_factor", text="Texture")
sub.label(text="Scattering Weight:")
sub.prop(sss, "front")
sub.prop(sss, "back")
col.separator()
col.prop(sss, "error_threshold", text="Error")
class MATERIAL_PT_halo(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Halo"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material # dont use node material
halo = mat.halo
def number_but(layout, toggle, number, name, color):
row = layout.row(align=True)
row.prop(halo, toggle, text="")
sub = row.column()
sub.active = getattr(halo, toggle)
sub.prop(halo, number, text=name)
if not color == "":
sub.prop(mat, color, text="")
split = layout.split()
col = split.column()
col.prop(mat, "alpha")
col.prop(mat, "diffuse_color", text="")
col.prop(halo, "seed")
col = split.column()
col.prop(halo, "size")
col.prop(halo, "hardness")
col.prop(halo, "add")
layout.label(text="Options:")
split = layout.split()
col = split.column()
col.prop(halo, "use_texture")
col.prop(halo, "use_vertex_normal")
col.prop(halo, "use_extreme_alpha")
col.prop(halo, "use_shaded")
col.prop(halo, "use_soft")
col = split.column()
number_but(col, "use_ring", "ring_count", "Rings", "mirror_color")
number_but(col, "use_lines", "line_count", "Lines", "specular_color")
number_but(col, "use_star", "star_tip_count", "Star tips", "")
class MATERIAL_PT_flare(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Flare"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
halo = context.material.halo
self.layout.prop(halo, "use_flare_mode", text="")
def draw(self, context):
layout = self.layout
mat = context.material # dont use node material
halo = mat.halo
layout.active = halo.use_flare_mode
split = layout.split()
col = split.column()
col.prop(halo, "flare_size", text="Size")
col.prop(halo, "flare_boost", text="Boost")
col.prop(halo, "flare_seed", text="Seed")
col = split.column()
col.prop(halo, "flare_subflare_count", text="Subflares")
col.prop(halo, "flare_subflare_size", text="Subsize")
class MATERIAL_PT_physics(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Physics"
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
return context.material and (context.scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
phys = context.material.physics # dont use node material
split = layout.split()
row = split.row()
row.prop(phys, "friction")
row.prop(phys, "elasticity", slider=True)
row = layout.row()
row.label(text="Force Field:")
row = layout.row()
row.prop(phys, "fh_force")
row.prop(phys, "fh_damping", slider=True)
row = layout.row()
row.prop(phys, "fh_distance")
row.prop(phys, "use_fh_normal")
class MATERIAL_PT_strand(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Strand"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type in {'SURFACE', 'WIRE', 'HALO'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material # dont use node material
tan = mat.strand
split = layout.split()
col = split.column()
sub = col.column(align=True)
sub.label(text="Size:")
sub.prop(tan, "root_size", text="Root")
sub.prop(tan, "tip_size", text="Tip")
sub.prop(tan, "size_min", text="Minimum")
sub.prop(tan, "use_blender_units")
sub = col.column()
sub.active = (not mat.use_shadeless)
sub.prop(tan, "use_tangent_shading")
col.prop(tan, "shape")
col = split.column()
col.label(text="Shading:")
col.prop(tan, "width_fade")
ob = context.object
if ob and ob.type == 'MESH':
col.prop_search(tan, "uv_layer", ob.data, "uv_textures", text="")
else:
col.prop(tan, "uv_layer", text="")
col.separator()
sub = col.column()
sub.active = (not mat.use_shadeless)
sub.label("Surface diffuse:")
sub = col.column()
sub.prop(tan, "blend_distance", text="Distance")
class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
base_mat = context.material
mat = active_node_mat(base_mat)
split = layout.split()
col = split.column()
if simple_material(base_mat):
col.prop(mat, "use_raytrace")
col.prop(mat, "use_full_oversampling")
col.prop(mat, "use_sky")
col.prop(mat, "use_mist")
if simple_material(base_mat):
col.prop(mat, "invert_z")
sub = col.row()
sub.prop(mat, "offset_z")
sub.active = mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY'
sub = col.column(align=True)
sub.label(text="Light Group:")
sub.prop(mat, "light_group", text="")
row = sub.row()
row.active = bool(mat.light_group)
row.prop(mat, "use_light_group_exclusive", text="Exclusive")
col = split.column()
col.prop(mat, "use_face_texture")
sub = col.column()
sub.active = mat.use_face_texture
sub.prop(mat, "use_face_texture_alpha")
col.separator()
col.prop(mat, "use_vertex_color_paint")
col.prop(mat, "use_vertex_color_light")
col.prop(mat, "use_object_color")
col.prop(mat, "pass_index")
class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Shadow"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type in {'SURFACE', 'WIRE'}) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
base_mat = context.material
mat = active_node_mat(base_mat)
split = layout.split()
col = split.column()
col.prop(mat, "use_shadows", text="Receive")
col.prop(mat, "use_transparent_shadows", text="Receive Transparent")
if simple_material(base_mat):
col.prop(mat, "use_cast_shadows_only", text="Cast Only")
col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
col.prop(mat, "use_only_shadow", text="Shadows Only")
sub = col.column()
sub.active = mat.use_only_shadow
sub.prop(mat, "shadow_only_type", text="")
col = split.column()
if simple_material(base_mat):
col.prop(mat, "use_cast_buffer_shadows")
sub = col.column()
sub.active = mat.use_cast_buffer_shadows
sub.prop(mat, "shadow_buffer_bias", text="Buffer Bias")
col.prop(mat, "use_ray_shadow_bias", text="Auto Ray Bias")
sub = col.column()
sub.active = (not mat.use_ray_shadow_bias)
sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
if simple_material(base_mat):
col.prop(mat, "use_cast_approximate")
class MATERIAL_PT_transp_game(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "Transparency"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_GAME'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
mat = context.material
if simple_material(mat):
self.layout.prop(mat, "use_transparency", text="")
def draw(self, context):
layout = self.layout
base_mat = context.material
mat = active_node_mat(base_mat)
if simple_material(base_mat):
row = layout.row()
row.active = mat.use_transparency
row.prop(mat, "transparency_method", expand=True)
layout.prop(mat, "alpha")
class VolumeButtonsPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
class MATERIAL_PT_volume_density(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Density"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
vol = context.material.volume # dont use node material
row = layout.row()
row.prop(vol, "density")
row.prop(vol, "density_scale")
class MATERIAL_PT_volume_shading(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Shading"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
vol = context.material.volume # dont use node material
split = layout.split()
col = split.column()
col.prop(vol, "scattering")
col.prop(vol, "asymmetry")
col.prop(vol, "transmission_color")
col = split.column()
sub = col.column(align=True)
sub.prop(vol, "emission")
sub.prop(vol, "emission_color", text="")
sub = col.column(align=True)
sub.prop(vol, "reflection")
sub.prop(vol, "reflection_color", text="")
class MATERIAL_PT_volume_lighting(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Lighting"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
vol = context.material.volume # dont use node material
split = layout.split()
col = split.column()
col.prop(vol, "light_method", text="")
col = split.column()
if vol.light_method == 'SHADED':
col.prop(vol, "use_external_shadows")
col.prop(vol, "use_light_cache")
sub = col.column()
sub.active = vol.use_light_cache
sub.prop(vol, "cache_resolution")
elif vol.light_method in {'MULTIPLE_SCATTERING', 'SHADED_PLUS_MULTIPLE_SCATTERING'}:
sub = col.column()
sub.enabled = True
sub.active = False
sub.label("Light Cache Enabled")
col.prop(vol, "cache_resolution")
sub = col.column(align=True)
sub.prop(vol, "ms_diffusion")
sub.prop(vol, "ms_spread")
sub.prop(vol, "ms_intensity")
class MATERIAL_PT_volume_transp(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Transparency"
COMPAT_ENGINES = {'BLENDER_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return mat and simple_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material # dont use node material
layout.prop(mat, "transparency_method", expand=True)
class MATERIAL_PT_volume_integration(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Integration"
COMPAT_ENGINES = {'BLENDER_RENDER'}
def draw(self, context):
layout = self.layout
vol = context.material.volume # dont use node material
split = layout.split()
col = split.column()
col.label(text="Step Calculation:")
col.prop(vol, "step_method", text="")
col = col.column(align=True)
col.prop(vol, "step_size")
col = split.column()
col.label()
col.prop(vol, "depth_threshold")
class MATERIAL_PT_volume_options(VolumeButtonsPanel, bpy.types.Panel):
bl_label = "Options"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return check_material(mat) and (mat.type == 'VOLUME') and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = active_node_mat(context.material)
split = layout.split()
col = split.column()
if simple_material(context.material):
col.prop(mat, "use_raytrace")
col.prop(mat, "use_full_oversampling")
col.prop(mat, "use_mist")
col = split.column()
col.label(text="Light Group:")
col.prop(mat, "light_group", text="")
row = col.row()
row.active = bool(mat.light_group)
row.prop(mat, "use_light_group_exclusive", text="Exclusive")
class MATERIAL_PT_custom_props(MaterialButtonsPanel, PropertyPanel, bpy.types.Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
_context_path = "material"
_property_type = bpy.types.Material
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)
|