Repository navigation
Expand file tree
/
Copy pathui.py
More file actions
806 lines (650 loc) · 29.5 KB
/
Copy pathui.py
File metadata and controls
806 lines (650 loc) · 29.5 KB
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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This file is part of the Blender addon "Renderlayer Manager".
#
# The addon "Renderlayer Manager" 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 version 3 of the License or
# any later version.
#
# The addon "Renderlayer Manager" 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 the addon. If not, see <http://www.gnu.org/licenses/>.
#
# ##### END GPL LICENSE BLOCK #####
import os
import shutil
import bpy
from . import utils
from bl_operators.presets import AddPresetBase
from bl_ui.utils import PresetPanel
import cycles
from cycles.ui import CYCLES_RENDER_PT_filter
import bl_ui
from bl_ui.properties_view_layer import ViewLayerButtonsPanel
if bpy.app.version >= (3, 2, 0):
from bl_ui.properties_output import RENDER_PT_output_color_management
if bpy in locals():
import importlib
importlib.reload(utils)
def draw_image_format_settings(layout, item):
if item.file_format != '---':
layout.prop(item, 'color_mode', expand=True)
if item.file_format in ['PNG', 'JPEG2000', 'DPX', 'OPEN_EXR_MULTILAYER', 'OPEN_EXR', 'TIFF']:
layout.prop(item, 'color_depth', expand=True)
if item.file_format in ['PNG']:
layout.prop(item, 'compression', slider=True)
if item.file_format in ['JPEG', 'JPEG2000', 'WEBP']:
layout.prop(item, 'quality', slider=True)
if item.file_format in ['JPEG2000']:
layout.prop(item, 'jpeg2k_codec')
layout.prop(item, 'use_jpeg2k_cinema_preset')
layout.prop(item, 'use_jpeg2k_cinema_48')
layout.prop(item, 'use_jpeg2k_ycc')
if item.file_format in ['DPX']:
layout.prop(item, 'use_cineon_log')
if 'OPEN_EXR' in str(item.file_format):
layout.prop(item, 'exr_codec')
layout.prop(item, 'use_zbuffer')
layout.prop(item, 'use_preview')
if item.file_format in ['TIFF']:
layout.prop(item, 'tiff_codec')
if item != bpy.context.view_layer.image_settings and item.file_format != 'OPEN_EXR':
layout.prop(item, 'save_as_render')
layout.separator()
col = layout.column()
col.label(text='Color Management')
if item.file_format == '---':
file_format = bpy.context.scene.render.image_settings.file_format
else:
file_format = item.file_format
if file_format in ['CINEON', 'DPX', 'OPEN_EXR_MULTILAYER', 'OPEN_EXR', 'HDR']:
col.prop(item, 'color_space')
else:
col.prop(item, 'display_device')
col.prop(item, 'view_transform')
def draw_ui_list(self, context):
enabled = False
idx = context.scene.rlm.active_renderlayer_index
active_viewlayer = context.view_layer
viewlayers = context.scene.view_layers
window = context.window
if idx == viewlayers.values().index(active_viewlayer):
enabled = True
layout = self.layout
layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
if not enabled:
row = layout.row()
row.operator('rlm.set_active_viewlayer', icon='FILE_REFRESH')
row = layout.row()
row.enabled = enabled
row.template_list('RLM_UL_renderlayer', '', context.scene, "view_layers", context.scene.rlm, 'active_renderlayer_index', rows=7)
col = row.column(align=True)
col.operator("rlm.ui_list_action", icon='ADD', text="").action = 'ADD'
col.operator("rlm.ui_list_action", icon='REMOVE', text="").action = 'REMOVE'
col.separator()
col.operator('rlm.edit_renderlayer_settings', icon='COPYDOWN', text='', text_ctxt='Test').action = 'COPY'
col.operator('rlm.edit_renderlayer_settings', icon='PASTEDOWN', text='').action = 'PASTE'
col.menu("RLM_MT_edit_renderlayer_settings", text='', icon='DOWNARROW_HLT')
col.separator()
col.operator("rlm.ui_list_action", icon='TRIA_UP', text="").action = 'UP'
col.operator("rlm.ui_list_action", icon='TRIA_DOWN', text="").action = 'DOWN'
class RLM_UL_renderlayer(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
row = layout.row(align=True)
split = row.split(factor=0.2, align=True)
split.prop(item, 'color', text='')
split.prop(item, 'name', text='', emboss=False, translate=False)
row.active = item.use
row.prop(item, 'composite', text='', icon='NODETREE')
op = row.operator(
'rlm.toggle_viewlayer_mute',
text='',
icon='RESTRICT_RENDER_OFF' if item.use else 'RESTRICT_RENDER_ON',
emboss=False,
)
op.view_layer_name = item.name
def filter_items(self, context, data, propname):
filtered = []
ordered = []
items = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
_sort = [(idx, i) for idx, i in enumerate(items)]
ordered = helper_funcs.sort_items_helper(_sort, lambda i: i[1].order, False)
return filtered, ordered
def draw_filter(self, context, layout):
return
class EditRenderlayerSettingsMenu(bpy.types.Menu):
bl_idname = 'RLM_MT_edit_renderlayer_settings'
bl_label = 'Edit'
def draw(self, context):
layout = self.layout
layout.operator('rlm.edit_renderlayer_settings', text='Copy Settings to All Active Layer').action = 'COPY_TO_ALL'
layout.operator("rlm.auto_rename_renderlayer", icon='OUTLINER_OB_FONT')
layout.operator("rlm.random_color_renderlayer", icon='COLOR')
layout.operator('rlm.add_viewlayer_from_collections', icon='COLLECTION_NEW')
class RenderlayerManagerTokensMenu(bpy.types.Menu):
bl_idname = 'RLM_MT_renderlayer_tokens'
bl_label = 'Tokens'
def draw(self, context):
layout = self.layout
layout.label(text='Tokens')
tokens = utils.list_tokens()
for token in tokens:
if token[0] == 'CLEAR':
layout.operator('rlm.renderlayer_tokens', text=token[1], icon='PANEL_CLOSE').token = token[0]
break
layout.operator('rlm.renderlayer_tokens', text=token[1]).token = token[0]
class RenderlayerManagerPanel(bpy.types.Panel):
bl_space_type = 'NODE_EDITOR'
bl_region_type = "UI"
bl_category = "Renderlayer Manager"
class RenderlayerManagerLayer(RenderlayerManagerPanel, bpy.types.Panel):
bl_idname = "RLM_PT_renderlayer"
bl_label = "Layer Overview"
bl_order = 1
def draw(self, context):
draw_ui_list(self, context)
class RenderlayerManagerGeneral(RenderlayerManagerPanel, bpy.types.Panel):
bl_idname = "RLM_PT_general"
bl_label = "General Settings"
bl_order = 10
changes: bpy.props.BoolProperty(default=False)
@classmethod
def poll(cls, context):
if utils.VIEWLAYER_SETTINGS:
if not utils.check_viewlayer_settings(context):
cls.changes = True
else:
cls.changes = False
return True
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
col.prop(context.scene.render, 'engine', text='Render Engine')
col.separator()
if utils.VIEWLAYER_SETTINGS:
if self.changes:
sub = col.column()
sub.alert = True
sub.label(text="Nodes need to be recreated!", icon='ERROR')
row = col.row(align=True)
row.operator('rlm.create_nodes', text='Create Nodes')
row.prop(context.scene.rlm, 'include_all_scenes', text='', icon='SCENE_DATA')
class RenderlayerManagerGeneral_output(RenderlayerManagerPanel, bpy.types.Panel):
bl_idname = "RLM_PT_general_output"
bl_parent_id = "RLM_PT_general"
bl_label = 'Output Settings'
def draw(self, context):
idx = context.scene.rlm.active_renderlayer_index
view_layers = context.scene.view_layers
active_renderlayer = view_layers[idx].name
img_settings = context.scene.render.image_settings
file_format = img_settings.file_format
media_type = img_settings.media_type
if context.scene.camera:
camera_name = context.scene.camera.name
else:
camera_name = ''
ext = utils.convert_ext(file_format)
rpass = 'Image'
scene_name = context.scene.name
version = 'v%02d' % context.scene.rlm.version
blend_name = os.path.splitext(os.path.basename(bpy.data.filepath))[0]
if not blend_name:
blend_name = 'Unsaved'
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
col.prop(context.scene.rlm, 'output_dir', text='')
row = col.row(align=True)
row.prop(context.scene.rlm, 'output_name', text='')
row.menu("RLM_MT_renderlayer_tokens", text='', icon='DOWNARROW_HLT')
col.prop(context.scene.rlm, 'version')
col = layout.column(align=True)
col.use_property_split = False
col.prop(context.scene.rlm, 'auto_update_paths', toggle=True)
row = col.row(align=True)
op = row.operator('rlm.set_output_paths')
row.enabled = 0 if context.scene.rlm.auto_update_paths else 1
col = layout.column()
if file_format not in utils.list_excluded_file_formats():
col.enabled = False
if media_type != 'IMAGE':
rpass = ''
else:
rpass = 'Image_'
try:
col.label(text='Output Path Example: ../%s%s%s.%s' % (
context.scene.rlm.output_name.format(
camera_name=camera_name,
rlayer=active_renderlayer,
ext=ext,
rpass=rpass,
scene_name=scene_name,
version=version,
blend_name=blend_name
).replace(os.sep, '/'),
rpass,
str(context.scene.frame_current).zfill(4),
ext.lower()
),
)
except (KeyError, ValueError):
col.alert = True
col.label(text='ERROR: Output path cant be generated!')
else:
col.alert = True
col.label(text=f'Format {file_format} is not supported!')
col.separator()
col = layout.column()
col.template_image_settings(context.scene.render.image_settings, color_management=False)
col.separator()
col = layout.column(heading="Image Sequence")
col.prop(context.scene.render, "use_overwrite")
col.prop(context.scene.render, "use_placeholder")
col.separator()
col.prop(context.scene.rlm, 'use_exr_for_data_pass')
col.prop(context.scene.rlm, 'use_cryptomatte_multilayer_exr')
col.prop(context.scene.render, 'film_transparent', text='Transparent Background')
class RenderlayerManagerGeneral_output_colormanagement(RenderlayerManagerPanel, bpy.types.Panel):
bl_idname = "RLM_PT_general_output_colormanagement"
bl_parent_id = "RLM_PT_general_output"
bl_label = 'Color Management'
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
RENDER_PT_output_color_management.draw(self, context)
class RLM_UL_available_passes(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
self.use_filter_sort_alpha = True
self.use_filter_sort_lock = True
layout.use_property_split = False
row = layout.row(align=True)
row.prop(item, 'selected', text=item.name, toggle=True)
def filter_items(self, context, data, propname):
filtered = []
ordered = []
items = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
rl_passes = context.view_layer.passes
filtered = [self.bitflag_filter_item] * len(items)
for i, item in enumerate(items):
if item.name == 'Image' or item.name == 'Lightgroup':
filtered[i] &= ~self.bitflag_filter_item
if item.name in rl_passes:
filtered[i] &= ~self.bitflag_filter_item
return filtered, ordered
def draw_filter(self, context, layout):
return
class RLM_UL_active_passes(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
self.use_filter_sort_alpha = True
self.use_filter_sort_lock = True
layout.use_property_split = False
row = layout.row(align=True)
row.prop(item, 'selected', text=item.name, toggle=True)
if context.engine == 'CYCLES':
row.prop(item, 'denoise', text='Denoise')
def draw_filter(self, context, layout):
return
class RLM_MT_RenderlayerManagerPassesPresets(bpy.types.Menu):
bl_label = 'Passes Presets'
preset_subdir = 'rlm/passes'
preset_operator = 'script.execute_preset'
draw = bpy.types.Menu.draw_preset
class AddRenderlayerManagerPassesPreset(AddPresetBase, bpy.types.Operator):
bl_idname = 'rlm.add_renderlayer_passes_preset'
bl_label = 'Add preset'
preset_menu = 'RLM_MT_RenderlayerManagerPassesPresets'
preset_defines = [
'rlayer = bpy.context.view_layer',
'image_settings = bpy.context.view_layer.image_settings',
]
preset_values = [
'rlayer.passes',
'rlayer.override_file_format',
'rlayer.pass_alpha_threshold',
'rlayer.pass_cryptomatte_depth',
'rlayer.use_pass_cryptomatte_accurate',
'rlayer.image',
'rlayer.samples',
'rlayer.use_sky',
'rlayer.use_solid',
'rlayer.use_strand',
'rlayer.use_volumes',
'rlayer.use_motion_blur',
'rlayer.cycles.use_denoising',
'image_settings.file_format',
'image_settings.color_mode',
'image_settings.color_depth',
]
preset_subdir = 'rlm/passes'
class RLM_PT_RenderlayerManagerPassesPresets(PresetPanel, bpy.types.Panel):
bl_label = 'Passes Presets'
preset_subdir = 'rlm/passes'
preset_operator = 'script.execute_preset'
preset_add_operator = 'rlm.add_renderlayer_passes_preset'
@classmethod
def poll(cls, context):
presets_dir = os.path.join(bpy.utils.script_path_user(), 'presets', 'rlm', 'passes')
if not os.path.isdir(presets_dir):
return False
return True
class EditRenderpassesSettingsMenu(bpy.types.Menu):
bl_idname = 'RLM_MT_edit_renderpasses_settings'
bl_label = 'Edit'
def draw(self, context):
layout = self.layout
layout.operator('rlm.edit_renderlayer_settings', icon='COPYDOWN', text='Copy Settings', text_ctxt='Test').action = 'COPY'
layout.operator('rlm.edit_renderlayer_settings', icon='PASTEDOWN', text='Paste Settings').action = 'PASTE'
layout.operator('rlm.edit_renderlayer_settings', text='Copy Settings to All Active Layer').action = 'COPY_TO_ALL'
class RenderlayerManagerPasses(RenderlayerManagerPanel, bpy.types.Panel):
bl_label = "Renderlayer Passes"
bl_idname = "RLM_PT_passes"
bl_order = 20
COMPAT_ENGINES = {'BLENDER_EEVEE', 'CYCLES'}
@classmethod
def poll(cls, context):
return (context.engine in cls.COMPAT_ENGINES)
def draw_header_preset(self, _context):
RLM_PT_RenderlayerManagerPassesPresets.draw_panel_header(self.layout)
def draw(self, context):
addon_prefs = context.preferences.addons[__package__].preferences
rlayer = context.view_layer
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
row = col.row()
row.label(text='Active Renderlayer: "{}"'.format(context.view_layer.name))
#row.operator('rlm.set_renderpasses', icon='FILE_REFRESH', text='')
row.menu('RLM_MT_edit_renderpasses_settings', text='', icon='DOWNARROW_HLT')
row=col.row()
row.label(text='Available')
row.label(text='Active')
row = col.row()
row.template_list('RLM_UL_available_passes', '', addon_prefs, 'output_passes', context.scene.rlm, 'active_pass_idx', rows=10)
row.template_list('RLM_UL_active_passes', '', context.view_layer, 'passes', context.view_layer, 'active_pass_idx', rows=10)
row = col.row()
row.operator('rlm.edit_renderlayer_passes', text='>>').action = 'ADD'
op = row.operator('rlm.edit_renderlayer_passes', text='<<').action = 'REMOVE_MULTI'
row = col.row()
row.operator('rlm.edit_renderlayer_passes', text='Add All').action = 'ADD_ALL'
row.operator('rlm.edit_renderlayer_passes', text='Remove All').action = 'REMOVE_ALL'
col.separator()
row = col.row(align=True)
row.prop(rlayer.image, 'custom_name', text='Image')
row.prop(rlayer.image.image_settings, 'file_format', text='')
op = row.operator('rlm.image_settings_dialog', icon='SETTINGS', text='')
op.file_format = rlayer.image.image_settings.file_format
op.rl_pass_idx = -1
col.separator()
for idx, rl_pass in enumerate(rlayer.passes):
row = col.row(align=True)
row.prop(rl_pass, 'custom_name', text=rl_pass.name)
row.prop(rl_pass.image_settings, 'file_format', text='')
op = row.operator('rlm.image_settings_dialog', icon='SETTINGS', text='')
op.file_format = rl_pass.image_settings.file_format
op.rl_pass_idx = idx
op = row.operator('rlm.edit_renderlayer_passes', icon='X', text='')
op.action = 'REMOVE'
op.pass_index = idx
class RenderlayerManagerPassesOptions(RenderlayerManagerPanel, bpy.types.Panel):
bl_label = "Options"
bl_idname = "RLM_PT_passes_options"
bl_parent_id = "RLM_PT_passes"
def draw(self, context):
rlayer = context.view_layer
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
if context.engine == 'CYCLES':
layout.prop(rlayer, 'pass_alpha_threshold')
if context.engine in ['BLENDER_EEVEE', 'BLENDER_EEVEE']:
col = layout.column()
col.prop(context.view_layer.eevee, 'ambient_occlusion_distance', text='Occlusion Distance')
col = layout.column(align=True)
col.prop(rlayer, 'pass_cryptomatte_depth')
if context.engine in ['BLENDER_EEVEE', 'BLENDER_EEVEE']:
col.prop(rlayer, 'use_pass_cryptomatte_accurate')
class RenderlayerManagerPassesFileFormat(RenderlayerManagerPanel, bpy.types.Panel):
bl_label = "Override Scene File Format"
bl_idname = "RLM_PT_passes_file_format"
bl_parent_id = "RLM_PT_passes_options"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
view_layer = context.scene.view_layers[context.scene.rlm.active_renderlayer_index]
layout = self.layout
layout.prop(view_layer, "override_file_format", text="")
def draw(self, context):
view_layer = context.scene.view_layers[context.scene.rlm.active_renderlayer_index]
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
layout.active = view_layer.override_file_format
layout.prop(view_layer.image_settings, 'file_format')
draw_image_format_settings(layout, view_layer.image_settings)
class ViewlayerPropertiesPassesOptions(ViewLayerButtonsPanel, bpy.types.Panel):
bl_label = 'Options'
bl_idname = "RLM_VIEWLAYER_PT_passes_options"
bl_parent_id = "VIEWLAYER_PT_layer_passes"
draw = RenderlayerManagerPassesOptions.draw
COMPAT_ENGINES = {'BLENDER_EEVEE'}
class ViewlayerPropertiesPassesFileFormat(ViewLayerButtonsPanel, bpy.types.Panel):
bl_label = 'Override Scene File Format'
bl_idname = "RLM_VIEWLAYER_PT_passes_file_format"
bl_parent_id = "RLM_VIEWLAYER_PT_passes_options"
bl_options = {'DEFAULT_CLOSED'}
draw_header = RenderlayerManagerPassesFileFormat.draw_header
draw = RenderlayerManagerPassesFileFormat.draw
COMPAT_ENGINES = {'BLENDER_EEVEE'}
class ViewlayerPropertiesCyclesPassesOptions(ViewLayerButtonsPanel, bpy.types.Panel):
bl_label = 'Options'
bl_idname = "RLM_CYCLES_PT_passes_options"
bl_parent_id = "CYCLES_RENDER_PT_passes"
draw = RenderlayerManagerPassesOptions.draw
COMPAT_ENGINES = {'CYCLES'}
class ViewlayerPropertiesCyclesPassesFileFormat(ViewLayerButtonsPanel, bpy.types.Panel):
bl_label = 'Override Scene File Format'
bl_idname = "RLM_CYCLES_PT_passes_file_format"
bl_parent_id = "RLM_CYCLES_PT_passes_options"
bl_options = {'DEFAULT_CLOSED'}
draw_header = RenderlayerManagerPassesFileFormat.draw_header
draw = RenderlayerManagerPassesFileFormat.draw
COMPAT_ENGINES = {'CYCLES'}
class RenderlayerManagerPassesAOVs(RenderlayerManagerPanel, bpy.types.Panel):
bl_label = "Shader AOV"
bl_idname = "RLM_PT_passes_aovs"
bl_parent_id = "RLM_PT_passes"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
rlayer = context.view_layer
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
row = col.row()
row.template_list("VIEWLAYER_UL_aov", "aovs", rlayer,
"aovs", rlayer, "active_aov_index", rows=2)
row = col.row(align=True)
row.operator("scene.view_layer_add_aov", icon='ADD', text="Add AOV")
row.operator("scene.view_layer_remove_aov", icon='REMOVE', text="Remove AOV")
class RenderlayerManagerPassesLightgroups(RenderlayerManagerPanel, bpy.types.Panel):
bl_label = "Light Groups"
bl_idname = "RLM_PT_passes_lightgroups"
bl_parent_id = "RLM_PT_passes"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'CYCLES'}
@classmethod
def poll(cls, context):
return (context.engine in cls.COMPAT_ENGINES)
def draw(self, context):
if bpy.app.version >= (3, 2, 0):
rlayer = context.view_layer
try:
utils.sync_lightgroups(rlayer)
except Exception:
pass
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
sub = col.row()
col = sub.column(align=True)
col.template_list(
"UI_UL_list",
"lightgroups",
rlayer,
"lightgroup_settings",
rlayer,
"rlm_active_lightgroup_index",
rows=3,
)
if len(rlayer.lightgroup_settings) > 0:
for lg in rlayer.lightgroup_settings:
row = col.row(align=True)
row.prop(lg, "name", text="")
row.prop(lg, "denoise", text="Denoise")
row.prop(lg, "file_format", text="File Format")
row = col.row(align=True)
row.operator("rlm.add_lightgroup", icon='ADD', text="Add Lightgroup")
row.operator("rlm.remove_lightgroup", icon='REMOVE', text="Remove Lightgroup")
sub.menu("VIEWLAYER_MT_lightgroup_sync", icon='DOWNARROW_HLT', text="")
synced = False
try:
synced = utils.are_lightgroups_in_sync(rlayer)
except Exception:
synced = False
row = col.row(align=True)
if not synced:
row.alert = True
icon = 'CHECKMARK' if synced else 'ERROR'
text = "Sync Lightgroups (Synced)" if synced else "Sync Lightgroups (Not Synced)"
row.operator("rlm.sync_lightgroups", icon=icon, text=text)
else:
layout = self.layout
layout.label(text='This feature is only available in Blender 3.2.0 or later!')
class VIEWLAYER_MT_lightgroup_sync(bpy.types.Menu):
bl_idname = "VIEWLAYER_MT_lightgroup_sync"
bl_label = 'Edit'
def draw(self, context):
layout = self.layout
layout.operator("rlm.sync_lightgroups_add_used", text="Add Used Lightgroups", icon='ADD')
layout.operator("rlm.sync_lightgroups_remove_unused", text="Remove Unused Lightgroups", icon='REMOVE')
class RenderlayerManagerPassesCyclesFilter(RenderlayerManagerPanel, bpy.types.Panel):
bl_label = "Filter"
bl_idname = "RLM_PT_passes_cycles_filter"
bl_parent_id = "RLM_PT_passes"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'CYCLES'}
@classmethod
def poll(cls, context):
return context.engine in cls.COMPAT_ENGINES
def draw(self, context):
CYCLES_RENDER_PT_filter.draw(self, context)
classes = (
RLM_UL_renderlayer,
RLM_UL_available_passes,
RLM_UL_active_passes,
EditRenderlayerSettingsMenu,
RenderlayerManagerTokensMenu,
RenderlayerManagerLayer,
RenderlayerManagerGeneral,
RenderlayerManagerGeneral_output,
RenderlayerManagerGeneral_output_colormanagement,
RLM_MT_RenderlayerManagerPassesPresets,
AddRenderlayerManagerPassesPreset,
RLM_PT_RenderlayerManagerPassesPresets,
EditRenderpassesSettingsMenu,
RenderlayerManagerPasses,
RenderlayerManagerPassesOptions,
RenderlayerManagerPassesFileFormat,
ViewlayerPropertiesPassesOptions,
ViewlayerPropertiesPassesFileFormat,
ViewlayerPropertiesCyclesPassesOptions,
ViewlayerPropertiesCyclesPassesFileFormat,
RenderlayerManagerPassesAOVs,
RenderlayerManagerPassesLightgroups,
VIEWLAYER_MT_lightgroup_sync,
RenderlayerManagerPassesCyclesFilter,
)
def register():
from bl_ui.properties_view_layer import VIEWLAYER_PT_layer_passes
from cycles.ui import CYCLES_RENDER_PT_passes
# register add-on classes
for cls in classes:
if 'ViewlayerProperties' in cls.__name__:
continue
bpy.utils.register_class(cls)
# add add-on ui to blender properties panel
bpy.types.VIEWLAYER_PT_layer.prepend(draw_ui_list)
bpy.types.VIEWLAYER_PT_layer_passes.prepend(RenderlayerManagerPasses.draw)
bpy.types.CYCLES_RENDER_PT_passes.prepend(RenderlayerManagerPasses.draw)
# remove default viewlayer property panels and add preset menu
excl_prop_panel_names = [
'VIEWLAYER_PT_eevee_next_layer_passes_data',
'VIEWLAYER_PT_eevee_layer_passes_data',
'VIEWLAYER_PT_eevee_layer_passes_light',
'VIEWLAYER_PT_eevee_next_layer_passes_light',
'VIEWLAYER_PT_eevee_layer_passes_effects',
'VIEWLAYER_PT_layer_passes_cryptomatte',
'CYCLES_RENDER_PT_passes_data',
'CYCLES_RENDER_PT_passes_light',
'CYCLES_RENDER_PT_passes_crypto',
]
prop_panels = [cls for cls in bl_ui.properties_view_layer.classes
if issubclass(cls, bpy.types.Panel)]
cycles_prop_panels = [cls for cls in cycles.ui.classes
if issubclass(cls, cycles.ui.CyclesButtonsPanel)]
prop_panels.extend(cycles_prop_panels)
for panel in prop_panels:
if panel.is_registered and panel.bl_context == 'view_layer':
bpy.utils.unregister_class(panel)
VIEWLAYER_PT_layer_passes.draw_header_preset = RenderlayerManagerPasses.draw_header_preset
CYCLES_RENDER_PT_passes.draw_header_preset = RenderlayerManagerPasses.draw_header_preset
for panel in prop_panels:
if not panel.is_registered and panel.__name__ not in excl_prop_panel_names:
bpy.utils.register_class(panel)
if panel.__name__ == 'VIEWLAYER_PT_layer_passes':
bpy.utils.register_class(ViewlayerPropertiesPassesOptions)
bpy.utils.register_class(ViewlayerPropertiesPassesFileFormat)
elif panel.__name__ == 'CYCLES_RENDER_PT_passes':
bpy.utils.register_class(ViewlayerPropertiesCyclesPassesOptions)
bpy.utils.register_class(ViewlayerPropertiesCyclesPassesFileFormat)
# copy addon preset files to users preset directory
rlm_presets = os.path.join(os.path.dirname(__file__), 'presets')
presets_dir = os.path.join(bpy.utils.script_path_user(), 'presets', 'rlm', 'passes')
if not os.path.isdir(presets_dir):
try:
os.makedirs(presets_dir)
files = os.listdir(rlm_presets)
[shutil.copy2(os.path.join(rlm_presets, f), presets_dir) for f in files]
except FileNotFoundError:
print('Preset directory "%s" could not be found!' % presets_dir)
pass
def unregister():
from bl_ui.properties_view_layer import VIEWLAYER_PT_layer_passes
from cycles.ui import CYCLES_RENDER_PT_passes
# add default viewlayer property panels
prop_panels = [cls for cls in bl_ui.properties_view_layer.classes
if issubclass(cls, bpy.types.Panel)]
cycles_prop_panels = [cls for cls in cycles.ui.classes
if issubclass(cls, cycles.ui.CyclesButtonsPanel)]
prop_panels.extend(cycles_prop_panels)
for panel in prop_panels:
if not panel.is_registered:
bpy.utils.register_class(panel)
# remove custom ui
bpy.types.CYCLES_RENDER_PT_passes.remove(RenderlayerManagerPasses.draw)
bpy.types.VIEWLAYER_PT_layer_passes.remove(RenderlayerManagerPasses.draw)
bpy.types.VIEWLAYER_PT_layer.remove(draw_ui_list)
# unregister add-on classes
for cls in classes:
bpy.utils.unregister_class(cls)