forked from prman-pixar/RenderManForBlender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
2413 lines (1947 loc) · 84.3 KB
/
ui.py
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
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ##### BEGIN MIT LICENSE BLOCK #####
#
# Copyright (c) 2015 Brian Savery
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
# ##### END MIT LICENSE BLOCK #####
import bpy
import math
import blf
from bpy.types import Panel
from .nodes import NODE_LAYOUT_SPLIT
from . import engine
# global dictionaries
from .shader_parameters import exclude_lamp_params
from bl_ui.properties_particle import ParticleButtonsPanel
# helper functions for parameters
from .shader_parameters import tex_optimised_path
from .shader_parameters import tex_source_path
from .nodes import draw_nodes_properties_ui, draw_node_properties_recursive, load_tree_from_lib
# Use some of the existing buttons.
import bl_ui.properties_render as properties_render
# properties_render.RENDER_PT_render.COMPAT_ENGINES.add('PRMAN_RENDER')
properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add('PRMAN_RENDER')
# properties_render.RENDER_PT_output.COMPAT_ENGINES.add('PRMAN_RENDER')
properties_render.RENDER_PT_post_processing.COMPAT_ENGINES.add('PRMAN_RENDER')
del properties_render
import bl_ui.properties_material as properties_material
properties_material.MATERIAL_PT_context_material.COMPAT_ENGINES.add(
'PRMAN_RENDER')
# properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add('PRMAN_RENDER')
properties_material.MATERIAL_PT_custom_props.COMPAT_ENGINES.add('PRMAN_RENDER')
del properties_material
import bl_ui.properties_scene as properties_scene
properties_scene.SCENE_PT_scene.COMPAT_ENGINES.add('PRMAN_RENDER')
properties_scene.SCENE_PT_unit.COMPAT_ENGINES.add('PRMAN_RENDER')
properties_scene.SCENE_PT_physics.COMPAT_ENGINES.add('PRMAN_RENDER')
del properties_scene
import bl_ui.properties_data_lamp as properties_data_lamp
properties_data_lamp.DATA_PT_context_lamp.COMPAT_ENGINES.add('PRMAN_RENDER')
properties_data_lamp.DATA_PT_spot.COMPAT_ENGINES.add('PRMAN_RENDER')
del properties_data_lamp
# enable all existing panels for these contexts
import bl_ui.properties_data_mesh as properties_data_mesh
for member in dir(properties_data_mesh):
subclass = getattr(properties_data_mesh, member)
try:
subclass.COMPAT_ENGINES.add('PRMAN_RENDER')
except:
pass
del properties_data_mesh
import bl_ui.properties_object as properties_object
for member in dir(properties_object):
subclass = getattr(properties_object, member)
try:
subclass.COMPAT_ENGINES.add('PRMAN_RENDER')
except:
pass
del properties_object
import bl_ui.properties_data_mesh as properties_data_mesh
for member in dir(properties_data_mesh):
subclass = getattr(properties_data_mesh, member)
try:
subclass.COMPAT_ENGINES.add('PRMAN_RENDER')
except:
pass
del properties_data_mesh
import bl_ui.properties_data_camera as properties_data_camera
for member in dir(properties_data_camera):
subclass = getattr(properties_data_camera, member)
try:
if subclass != properties_data_camera.DATA_PT_camera_dof:
subclass.COMPAT_ENGINES.add('PRMAN_RENDER')
pass
except:
pass
del properties_data_camera
import bl_ui.properties_particle as properties_particle
for member in dir(properties_particle):
subclass = getattr(properties_particle, member)
try:
subclass.COMPAT_ENGINES.add('PRMAN_RENDER')
except:
pass
del properties_particle
# icons
import os
from . icons.icons import load_icons
from bpy.props import PointerProperty, StringProperty, BoolProperty, \
EnumProperty, IntProperty, FloatProperty, FloatVectorProperty, \
CollectionProperty
# ------- Subclassed Panel Types -------
class CollectionPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@classmethod
def poll(cls, context):
rd = context.scene.render
return rd.engine == 'PRMAN_RENDER'
def _draw_collection(self, context, layout, ptr, name, operator,
opcontext, prop_coll, collection_index):
layout.label(name)
row = layout.row()
row.template_list("UI_UL_list", "PRMAN", ptr, prop_coll, ptr,
collection_index, rows=1)
col = row.column(align=True)
op = col.operator(operator, icon="ZOOMIN", text="")
op.context = opcontext
op.collection = prop_coll
op.collection_index = collection_index
op.defaultname = ''
op.action = 'ADD'
op = col.operator(operator, icon="ZOOMOUT", text="")
op.context = opcontext
op.collection = prop_coll
op.collection_index = collection_index
op.action = 'REMOVE'
if hasattr(ptr, prop_coll) and len(getattr(ptr, prop_coll)) > 0 and \
getattr(ptr, collection_index) >= 0:
item = getattr(ptr, prop_coll)[getattr(ptr, collection_index)]
self.draw_item(layout, context, item)
# ------- UI panel definitions -------
narrowui = 180
class PRManButtonsPanel():
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "render"
@classmethod
def poll(cls, context):
rd = context.scene.render
return rd.engine == 'PRMAN_RENDER'
class RENDER_PT_renderman_render(PRManButtonsPanel, Panel):
bl_label = "Render"
def draw(self, context):
if context.scene.render.engine != "PRMAN_RENDER":
return
icons = load_icons()
layout = self.layout
rd = context.scene.render
rm = context.scene.renderman
# Render
row = layout.row(align=True)
rman_render = icons.get("render")
row.operator("render.render", text="Render",
icon_value=rman_render.icon_id)
# IPR
if engine.ipr:
# Stop IPR
rman_batch_cancel = icons.get("stop_ipr")
row.operator('lighting.start_interactive',
text="Stop IPR", icon_value=rman_batch_cancel.icon_id)
else:
# Start IPR
rman_rerender_controls = icons.get("start_ipr")
row.operator('lighting.start_interactive', text="Start IPR",
icon_value=rman_rerender_controls.icon_id)
# Batch Render
rman_batch = icons.get("batch_render")
row.operator("render.render", text="Render Animation",
icon_value=rman_batch.icon_id).animation = True
layout.separator()
split = layout.split(percentage=0.33)
split.label(text="Display:")
row = split.row(align=True)
row.prop(rd, "display_mode", text="")
row.prop(rd, "use_lock_interface", icon_only=True)
col = layout.column()
row = col.row()
row.prop(rm, "render_into", text="Render To")
layout.separator()
col = layout.column()
col.prop(context.scene.renderman, "render_selected_objects_only")
col.prop(rm, "do_denoise")
class RENDER_PT_renderman_spooling(PRManButtonsPanel, Panel):
bl_label = "External Rendering"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
scene = context.scene
rm = scene.renderman
# note
row = layout.row()
row.label(
'Note: External Rendering will render outside of Blender, images will not show up in the Image Editor.')
row = layout.row()
row.prop(rm, 'enable_external_rendering')
if not rm.enable_external_rendering:
return
# button
icons = load_icons()
row = layout.row()
rman_batch = icons.get("batch_render")
row.operator("renderman.external_render",
text="External Render", icon_value=rman_batch.icon_id)
layout.separator()
row = layout.row()
split = row.split(percentage=0.33)
col = split.column()
col.prop(rm, "external_denoise")
sub_row = col.row()
sub_row.enabled = rm.external_denoise
sub_row.prop(rm, "crossframe_denoise")
# display driver
split = split.split()
col = split.column()
col.prop(rm, "display_driver", text='Render To')
# sub_row = col.row()
# if rm.display_driver == 'openexr':
# sub_row = col.row()
# sub_row.prop(rm, "exr_format_options")
# sub_row = col.row()
# sub_row.prop(rm, "exr_compression")
layout.separator()
layout.separator()
split = layout.split(percentage=0.33)
# do animation
split.prop(rm, "external_animation")
sub_row = split.row()
sub_row.enabled = rm.external_animation
sub_row.prop(scene, "frame_start", text="Start")
sub_row.prop(scene, "frame_end", text="End")
# queue Renders
layout.separator()
split = layout.split(percentage=0.33)
# spool render
split.prop(rm, "external_action")
sub_row = split.row()
sub_row.enabled = rm.external_action == 'spool'
sub_row.prop(rm, "queuing_system")
# checkpointing
layout.separator()
row = layout.row()
row.prop(rm, 'enable_checkpoint')
row = layout.row()
row.enabled = rm.enable_checkpoint
row.prop(rm, 'checkpoint_type')
row = layout.row(align=True)
row.enabled = rm.enable_checkpoint
row.prop(rm, 'checkpoint_interval')
row.prop(rm, 'render_limit')
class RENDER_PT_renderman_sampling(PRManButtonsPanel, Panel):
bl_label = "Sampling"
# bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
scene = context.scene
rm = scene.renderman
# layout.prop(rm, "display_driver")
col = layout.column()
row = col.row(align=True)
row.menu("presets", text=bpy.types.presets.bl_label)
row.operator("render.renderman_preset_add", text="", icon='ZOOMIN')
row.operator("render.renderman_preset_add", text="",
icon='ZOOMOUT').remove_active = True
col.prop(rm, "pixel_variance")
row = col.row(align=True)
row.prop(rm, "min_samples", text="Min Samples")
row.prop(rm, "max_samples", text="Max Samples")
row = col.row(align=True)
row.prop(rm, "max_specular_depth", text="Specular Depth")
row.prop(rm, "max_diffuse_depth", text="Diffuse Depth")
row = col.row(align=True)
row.prop(rm, 'incremental')
row = col.row(align=True)
layout.separator()
col.prop(rm, "integrator")
# find args for integrators here!
integrator_settings = getattr(rm, "%s_settings" % rm.integrator)
# for each property add it to ui
def draw_props(prop_names, layout):
for prop_name in prop_names:
prop_meta = integrator_settings.prop_meta[prop_name]
prop = getattr(integrator_settings, prop_name)
row = layout.row()
if prop_meta['renderman_type'] == 'page':
ui_prop = prop_name + "_ui_open"
ui_open = getattr(integrator_settings, ui_prop)
icon = 'TRIA_DOWN' if ui_open \
else 'TRIA_RIGHT'
split = layout.split(NODE_LAYOUT_SPLIT)
row = split.row()
row.prop(integrator_settings, ui_prop, icon=icon, text=text,
icon_only=True, emboss=True)
row.label(prop_name + ':')
if ui_open:
draw_props(prop, layout)
else:
row.label('', icon='BLANK1')
# indented_label(row, socket.name+':')
row.prop(integrator_settings, prop_name)
icon = 'TRIA_DOWN' if rm.show_integrator_settings \
else 'TRIA_RIGHT'
text = rm.integrator + " Settings:"
row = col.row()
row.prop(rm, "show_integrator_settings", icon=icon, text=text,
icon_only=True, emboss=False)
if rm.show_integrator_settings:
draw_props(integrator_settings.prop_names, col)
class RENDER_PT_renderman_motion_blur(PRManButtonsPanel, Panel):
bl_label = "Motion Blur"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
rm = context.scene.renderman
layout = self.layout
row = layout.row()
row.prop(rm, "motion_blur")
sub = layout.row()
sub.enabled = rm.motion_blur
sub.prop(rm, "motion_segments")
row = layout.row()
row.enabled = rm.motion_blur
row.prop(rm, "shutter_timing")
row = layout.row()
row.enabled = rm.motion_blur
row.prop(rm, "shutter_angle")
row = layout.row()
row.enabled = rm.motion_blur
row.prop(rm, "shutter_efficiency_open")
row.prop(rm, "shutter_efficiency_close")
class RENDER_PT_renderman_sampling_preview(PRManButtonsPanel, Panel):
bl_label = "Interactive and Preview Sampling"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
scene = context.scene
rm = scene.renderman
col = layout.column()
col.prop(rm, "preview_pixel_variance")
row = col.row(align=True)
row.prop(rm, "preview_min_samples", text="Min Samples")
row.prop(rm, "preview_max_samples", text="Max Samples")
row = col.row(align=True)
row.prop(rm, "preview_max_specular_depth", text="Specular Depth")
row.prop(rm, "preview_max_diffuse_depth", text="Diffuse Depth")
row = col.row(align=True)
class RENDER_PT_renderman_advanced_settings(PRManButtonsPanel, Panel):
bl_label = "Advanced"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
scene = context.scene
rm = scene.renderman
if rm.render_into == 'blender':
row = layout.row()
row.prop(rm, "update_frequency",
text='Display Update Interval (seconds)')
row = layout.row()
row.prop(rm, "import_images")
layout.separator()
row = layout.row()
row.prop(rm, "shadingrate")
layout.separator()
row = layout.row()
row.prop(rm, "texture_cache_size")
row = layout.row()
row.prop(rm, "geo_cache_size")
row = layout.row()
row.prop(rm, "opacity_cache_size")
layout.separator()
row = layout.row()
row.label("Pixel Filter:")
row.prop(rm, "pixelfilter", text="")
row = layout.row()
row.prop(rm, "pixelfilter_x", text="Size X")
row.prop(rm, "pixelfilter_y", text="Size Y")
layout.separator()
row = layout.row()
row.prop(rm, 'light_localization')
row = layout.row()
row.prop(rm, "sample_motion_blur")
row = layout.row(align=True)
row.prop(rm, "use_separate_path_depths")
layout.separator()
row = layout.row()
row.prop(rm, "dark_falloff")
layout.separator()
row = layout.row()
row.prop(rm, "bucket_shape")
if rm.bucket_shape == 'SPIRAL':
row = layout.row(align=True)
row.prop(rm, "bucket_sprial_x", text="X")
row.prop(rm, "bucket_sprial_y", text="Y")
row = layout.row()
row.prop(rm, "use_statistics", text="Output stats")
row.operator('rman.open_stats')
layout.separator()
row = layout.row()
row.operator('rman.open_rib')
row.prop(rm, "editor_override")
layout.separator()
layout.prop(rm, "always_generate_textures")
layout.prop(rm, "lazy_rib_gen")
layout.prop(rm, "threads")
class MESH_PT_renderman_prim_vars(CollectionPanel, Panel):
bl_context = "data"
bl_label = "Primitive Variables"
def draw_item(self, layout, context, item):
ob = context.object
if context.mesh:
geo = context.mesh
layout.prop(item, "name")
row = layout.row()
row.prop(item, "data_source", text="Source")
if item.data_source == 'VERTEX_COLOR':
row.prop_search(item, "data_name", geo, "vertex_colors", text="")
elif item.data_source == 'UV_TEXTURE':
row.prop_search(item, "data_name", geo, "uv_textures", text="")
elif item.data_source == 'VERTEX_GROUP':
row.prop_search(item, "data_name", ob, "vertex_groups", text="")
@classmethod
def poll(cls, context):
rd = context.scene.render
if not context.mesh:
return False
return rd.engine == 'PRMAN_RENDER'
def draw(self, context):
layout = self.layout
mesh = context.mesh
rm = mesh.renderman
self._draw_collection(context, layout, rm, "Primitive Variables:",
"collection.add_remove", "mesh", "prim_vars",
"prim_vars_index")
layout.prop(rm, "export_default_uv")
layout.prop(rm, "export_default_vcol")
class MATERIAL_PT_renderman_preview(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_options = {'DEFAULT_CLOSED'}
bl_context = "material"
bl_label = "Preview"
COMPAT_ENGINES = {'PRMAN_RENDER'}
@classmethod
def poll(cls, context):
return (context.scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.material
row = layout.row()
if mat:
row.template_preview(context.material, show_buttons=1)
if mat.renderman.nodetree != '':
layout.prop_search(
mat.renderman, "nodetree", bpy.data, "node_groups")
class ShaderNodePanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_label = 'Node Panel'
bl_context = ""
COMPAT_ENGINES = {'PRMAN_RENDER'}
@classmethod
def poll(cls, context):
if context.scene.render.engine not in cls.COMPAT_ENGINES:
return False
if cls.bl_context == 'material':
if context.material and context.material.renderman.nodetree != '':
return True
if cls.bl_context == 'data':
if not context.lamp:
return False
if context.lamp.renderman.nodetree != '':
return True
return False
class ShaderPanel():
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
COMPAT_ENGINES = {'PRMAN_RENDER'}
shader_type = 'surface'
param_exclude = {}
@classmethod
def poll(cls, context):
rd = context.scene.render
if cls.bl_context == 'data' and cls.shader_type == 'light':
return (hasattr(context, "lamp") and context.lamp is not None
and rd.engine in {'PRMAN_RENDER'})
elif cls.bl_context == 'world':
return (hasattr(context, "world") and context.world is not None and
rd.engine in {'PRMAN_RENDER'})
elif cls.bl_context == 'material':
return (hasattr(context, "material") and context.material is not None and
rd.engine in {'PRMAN_RENDER'})
class MATERIAL_PT_renderman_shader_surface(ShaderPanel, Panel):
bl_context = "material"
bl_label = "Bxdf"
shader_type = 'Bxdf'
def draw(self, context):
mat = context.material
if context.material.renderman and context.material.renderman.nodetree:
if context.material.renderman.nodetree not in bpy.data.node_groups:
load_tree_from_lib(context.material)
nt = bpy.data.node_groups[context.material.renderman.nodetree]
draw_nodes_properties_ui(
self.layout, context, nt, input_name=self.shader_type)
else:
# if no nodetree we use pxrdisney
layout = self.layout
mat = context.material
rm = mat.renderman
row = layout.row()
row.prop(mat, "diffuse_color")
layout.separator()
if mat and mat.renderman.nodetree == '':
layout.operator(
'shading.add_renderman_nodetree').idtype = "material"
# self._draw_shader_menu_params(layout, context, rm)
class MATERIAL_PT_renderman_shader_light(ShaderPanel, Panel):
bl_context = "material"
bl_label = "Light Emission"
shader_type = 'Light'
def draw(self, context):
if context.material.renderman.nodetree:
if context.material.renderman.nodetree not in bpy.data.node_groups:
load_tree_from_lib(context.material)
nt = bpy.data.node_groups[context.material.renderman.nodetree]
draw_nodes_properties_ui(
self.layout, context, nt, input_name=self.shader_type)
class MATERIAL_PT_renderman_shader_displacement(ShaderPanel, Panel):
bl_context = "material"
bl_label = "Displacement"
shader_type = 'Displacement'
def draw(self, context):
if context.material.renderman.nodetree != "":
if context.material.renderman.nodetree not in bpy.data.node_groups:
load_tree_from_lib(context.material)
nt = bpy.data.node_groups[context.material.renderman.nodetree]
draw_nodes_properties_ui(
self.layout, context, nt, input_name=self.shader_type)
# BBM addition begin
row = self.layout.row()
row.prop(context.material.renderman, "displacementbound")
# BBM addition end
# self._draw_shader_menu_params(layout, context, rm)
class RENDER_PT_layers(PRManButtonsPanel, Panel):
bl_label = "Layer List"
bl_context = "render_layer"
bl_options = {'HIDE_HEADER'}
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
rl = rd.layers.active
row = layout.row()
row.template_list("RENDERLAYER_UL_renderlayers", "",
rd, "layers", rd.layers, "active_index", rows=2)
col = row.column(align=True)
col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
row = layout.row()
if rl:
row.prop(rl, "name")
row.prop(rd, "use_single_layer", text="", icon_only=True)
class RENDER_PT_layer_options(PRManButtonsPanel, Panel):
bl_label = "Layer"
bl_context = "render_layer"
def draw(self, context):
layout = self.layout
scene = context.scene
rd = scene.render
rl = rd.layers.active
split = layout.split()
col = split.column()
col.prop(scene, "layers", text="Scene")
rm = scene.renderman
rm_rl = None
active_layer = scene.render.layers.active
for l in rm.render_layers:
if l.render_layer == active_layer.name:
rm_rl = l
break
if rm_rl is None:
return
# layout.operator('renderman.add_pass_list')
else:
split = layout.split()
col = split.column()
# cutting this for now until we can export multiple cameras
#col.prop_search(rm_rl, 'camera', bpy.data, 'cameras')
col.prop_search(rm_rl, 'light_group',
scene.renderman, 'light_groups')
col.prop_search(rm_rl, 'object_group',
scene.renderman, 'object_groups')
col.prop(rm_rl, 'export_multilayer')
if rm_rl.export_multilayer:
col.prop(rm_rl, 'use_deep')
col.prop(rm_rl, "exr_format_options")
col.prop(rm_rl, "exr_compression")
col.prop(rm_rl, "exr_storage")
# class RENDER_PT_layer_passes(PRManButtonsPanel, Panel):
# bl_label = "Passes"
# bl_context = "render_layer"
# # bl_options = {'DEFAULT_CLOSED'}
# def draw(self, context):
# layout = self.layout
# scene = context.scene
# rd = scene.render
# rl = rd.layers.active
# rm = rl.renderman
# layout.prop(rm, "combine_outputs")
# split = layout.split()
# col = split.column()
# col.prop(rl, "use_pass_combined")
# col.prop(rl, "use_pass_z")
# col.prop(rl, "use_pass_normal")
# col.prop(rl, "use_pass_vector")
# col.prop(rl, "use_pass_uv")
# col.prop(rl, "use_pass_object_index")
# #col.prop(rl, "use_pass_shadow")
# #col.prop(rl, "use_pass_reflection")
# col = split.column()
# col.label(text="Diffuse:")
# row = col.row(align=True)
# row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
# row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
# row.prop(rl, "use_pass_diffuse_color", text="Albedo", toggle=True)
# col.label(text="Specular:")
# row = col.row(align=True)
# row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
# row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
# col.prop(rl, "use_pass_subsurface_indirect", text="Subsurface")
# col.prop(rl, "use_pass_refraction", text="Refraction")
# col.prop(rl, "use_pass_emit", text="Emission")
# layout.separator()
# row = layout.row()
# row.label('Holdouts')
# rm = scene.renderman.holdout_settings
# layout.prop(rm, 'do_collector_shadow')
# layout.prop(rm, 'do_collector_reflection')
# layout.prop(rm, 'do_collector_refraction')
# layout.prop(rm, 'do_collector_indirectdiffuse')
# layout.prop(rm, 'do_collector_subsurface')
# col.prop(rl, "use_pass_ambient_occlusion")
class DATA_PT_renderman_camera(ShaderPanel, Panel):
bl_context = "data"
bl_label = "RenderMan Camera"
@classmethod
def poll(cls, context):
rd = context.scene.render
if not context.camera:
return False
return rd.engine == 'PRMAN_RENDER'
def draw(self, context):
layout = self.layout
cam = context.camera
scene = context.scene
dof_options = cam.gpu_dof
row = layout.row()
row.prop(scene.renderman, "depth_of_field")
sub = row.row()
sub.enabled = scene.renderman.depth_of_field
sub.prop(scene.renderman, "fstop")
split = layout.split()
col = split.column()
col.label(text="Focus:")
col.prop(cam, "dof_object", text="")
sub = col.column()
sub.active = (cam.dof_object is None)
sub.prop(cam, "dof_distance", text="Distance")
col = split.column()
sub = col.column(align=True)
sub.label("Aperture Controls:")
sub.prop(cam.renderman, "dof_aspect", text="Aspect")
sub.prop(cam.renderman, "aperture_sides", text="Sides")
sub.prop(cam.renderman, "aperture_angle", text="Angle")
sub.prop(cam.renderman, "aperture_roundness", text="Roundness")
sub.prop(cam.renderman, "aperture_density", text="Density")
layout.prop(cam.renderman, "use_physical_camera")
if cam.renderman.use_physical_camera:
pxrcamera = getattr(cam.renderman, "PxrCamera_settings")
# for each property add it to ui
def draw_props(prop_names, layout):
for prop_name in prop_names:
prop_meta = pxrcamera.prop_meta[prop_name]
prop = getattr(pxrcamera, prop_name)
row = layout.row()
if prop_meta['renderman_type'] == 'page':
ui_prop = prop_name + "_ui_open"
ui_open = getattr(pxrcamera, ui_prop)
icon = 'TRIA_DOWN' if ui_open \
else 'TRIA_RIGHT'
split = layout.split(NODE_LAYOUT_SPLIT)
row = split.row()
row.prop(pxrcamera, ui_prop, icon=icon, text='',
icon_only=True, emboss=False)
row.label(prop_name + ':')
if ui_open:
draw_props(prop, layout)
else:
row.label('', icon='BLANK1')
# indented_label(row, socket.name+':')
row.prop(pxrcamera, prop_name)
draw_props(pxrcamera.prop_names, layout)
class DATA_PT_renderman_world(ShaderPanel, Panel):
bl_context = "world"
bl_label = "World"
shader_type = 'world'
param_exclude = exclude_lamp_params
def draw(self, context):
layout = self.layout
world = context.scene.world
if world.renderman.nodetree == '':
layout.operator('shading.add_renderman_nodetree').idtype = 'world'
return
else:
layout.prop(world.renderman, "renderman_type", expand=True)
if world.renderman.renderman_type == 'NONE':
return
nt = bpy.data.node_groups[world.renderman.nodetree]
output_node = next(
(n for n in nt.nodes if n.renderman_node_type == 'output'), None)
lamp_node = output_node.inputs['Light'].links[0].from_node
if lamp_node:
layout.prop(lamp_node, 'light_primary_visibility')
layout.prop(lamp_node, 'light_shading_rate')
draw_node_properties_recursive(
self.layout, context, nt, lamp_node)
class DATA_PT_renderman_lamp(ShaderPanel, Panel):
bl_context = "data"
bl_label = "Lamp"
shader_type = 'light'
param_exclude = exclude_lamp_params
def draw(self, context):
layout = self.layout
lamp = context.lamp
if lamp.renderman.nodetree == '':
layout.prop(lamp, "type", expand=True)
layout.operator('shading.add_renderman_nodetree').idtype = 'lamp'
return
else:
layout.prop(lamp.renderman, "renderman_type", expand=True)
if lamp.renderman.renderman_type == "AREA":
layout.prop(lamp.renderman, "area_shape", expand=True)
row = layout.row()
if lamp.renderman.area_shape == "rect":
row.prop(lamp, 'size', text="Size X")
row.prop(lamp, 'size_y')
else:
row.prop(lamp, 'size', text="Radius")
if lamp.renderman.area_shape == "cylinder":
row.prop(lamp, 'size_y', text="Length")
layout.prop(lamp.renderman, "shadingrate")
layout.prop_search(lamp.renderman, "nodetree", bpy.data, "node_groups")
layout.prop(lamp.renderman, 'illuminates_by_default')
class DATA_PT_renderman_node_shader_lamp(ShaderNodePanel, Panel):
bl_label = "Light Shader"
bl_context = 'data'
def draw(self, context):
layout = self.layout
lamp = context.lamp
nt = bpy.data.node_groups[lamp.renderman.nodetree]
output_node = next(
(n for n in nt.nodes if n.renderman_node_type == 'output'), None)
lamp_node = output_node.inputs['Light'].links[0].from_node
if lamp_node:
layout.prop(lamp_node, 'light_primary_visibility')
layout.prop(lamp_node, 'light_shading_rate')
draw_node_properties_recursive(self.layout, context, nt, lamp_node)
class OBJECT_PT_renderman_object_geometry(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
bl_label = "Renderman Geometry"
@classmethod
def poll(cls, context):
rd = context.scene.render
return (context.object and rd.engine in {'PRMAN_RENDER'})
def draw(self, context):
layout = self.layout
ob = context.object
rm = ob.renderman
anim = rm.archive_anim_settings
col = layout.column()
col.prop(rm, "geometry_source")
if rm.geometry_source in ('ARCHIVE', 'DELAYED_LOAD_ARCHIVE'):
col.prop(rm, "path_archive")
col.prop(anim, "animated_sequence")
if anim.animated_sequence:
col.prop(anim, "blender_start")
row = col.row()
row.prop(anim, "sequence_in")
row.prop(anim, "sequence_out")
elif rm.geometry_source == 'PROCEDURAL_RUN_PROGRAM':
col.prop(rm, "path_runprogram")
col.prop(rm, "path_runprogram_args")
elif rm.geometry_source == 'DYNAMIC_LOAD_DSO':
col.prop(rm, "path_dso")
col.prop(rm, "path_dso_initial_data")
if rm.geometry_source in ('DELAYED_LOAD_ARCHIVE',
'PROCEDURAL_RUN_PROGRAM',
'DYNAMIC_LOAD_DSO'):
col.prop(rm, "procedural_bounds")
if rm.procedural_bounds == 'MANUAL':
colf = layout.column_flow()
colf.prop(rm, "procedural_bounds_min")
colf.prop(rm, "procedural_bounds_max")
if rm.geometry_source == 'BLENDER_SCENE_DATA':