-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSID_Panel.py
544 lines (463 loc) · 21.9 KB
/
SID_Panel.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
import typing
import os
import bpy
from bpy.types import (
Context,
Panel,
)
from .SID_Settings import SID_DenoiseRenderStatus, SID_Settings, SID_TemporalDenoiserStatus
from .SID_Temporal import is_temporal_supported, is_temporal_optix_supported, is_temporal_nlm_supported
ICON_DIR_NAME = "Icons"
class IconManager:
def __init__(self, additional_paths: typing.Optional[typing.List[str]] = None):
import bpy.utils.previews
self.icon_previews = bpy.utils.previews.new()
self.additional_paths = additional_paths if additional_paths is not None else []
self.load_all()
def load_all(self) -> None:
icons_dir = os.path.join(os.path.dirname(__file__), ICON_DIR_NAME)
self.load_icons_from_directory(icons_dir)
for path in self.additional_paths:
self.load_icons_from_directory(os.path.join(path, ICON_DIR_NAME))
def load_icons_from_directory(self, path: str) -> None:
if not os.path.isdir(path):
raise RuntimeError(f"Cannot load icons from {path}, it is not valid dir")
for icon_filename in os.listdir(path):
self.load_icon(icon_filename, path)
def load_icon(self, filename: str, path: str) -> None:
if not filename.endswith((".png")):
return
icon_basename, _ = os.path.splitext(filename)
if icon_basename in self.icon_previews:
return
self.icon_previews.load(icon_basename, os.path.join(
path, filename), "IMAGE")
def get_icon(self, icon_name: str) -> bpy.types.ImagePreview:
return self.icon_previews[icon_name]
def get_icon_id(self, icon_name: str) -> int:
return self.icon_previews[icon_name].icon_id
icon_manager = IconManager()
class SID_PT_Panel:
bl_label = "Create Super Denoiser"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
bl_options = {"DEFAULT_CLOSED"}
class SID_PT_SID_Panel(SID_PT_Panel, Panel):
bl_label = "Create Super Image Denoiser"
def draw_header(self, context: Context):
layout = self.layout
layout.label(text="", icon='SHADERFX')
def draw(self, context: Context):
layout = self.layout
scene = context.scene
settings: SID_Settings = scene.sid_settings
denoise_render_status: SID_DenoiseRenderStatus = settings.denoise_render_status
temporal_denoiser_status: SID_TemporalDenoiserStatus = settings.temporal_denoiser_status
RenderEngine = scene.render.engine
view_layer = context.view_layer
cycles_view_layer = view_layer.cycles
# do we have to use the old layout engine?
legacy_layout = bpy.app.version < (2, 90)
# currently rendering noisy frames?
is_rendering = denoise_render_status.is_rendering
is_denoising = temporal_denoiser_status.is_running
panel_active = not is_rendering and not is_denoising
layout.use_property_split = True
#######################
### DECIDE DENOISER ###
#######################
denoiser_type = settings.denoiser_type if is_temporal_supported else "SID"
if RenderEngine == "CYCLES" and is_temporal_supported:
denoiser_type_col = layout.column(align=True)
denoiser_type_col.active = panel_active
denoiser_type_col.prop(
settings,
"denoiser_type",
expand=True,
text="Denoiser Type"
)
else:
# Temporal is not supported
# - maybe because the Render Engine is not compatible (only Cycles)
# - maybe because the Blender version is not compatible (removed from 3.0+)
# so don't show the option to use it
denoiser_type = "SID"
if denoiser_type == "SID":
layout.separator()
CompatibleWith = [
'CYCLES'
]
if not RenderEngine in CompatibleWith:
cycles_warning = layout.column(align=True)
cycles_warning.label(
text="SID is not yet compatible with this render engine.", icon='ERROR'
)
cycles_warning.label(
text=" Please change the render engine to a compatible one."
)
layout.separator()
# don't draw any more panel settings
return
quality = layout.column(align=True)
quality.prop(
settings,
"quality",
text="Quality"
)
if settings.quality == 'STANDARD':
quality.label(
text="Denoise the whole image in a single pass.",
icon='INFO'
)
quality.label(
text=" Maximum compositing speed and least memory consumption."
)
elif settings.quality == 'HIGH':
quality.label(
text="Denoise related render passes in groups.", icon='INFO'
)
quality.label(
text=" Moderate compositing speed and increased memory consumption."
)
elif settings.quality == 'SUPER':
if RenderEngine == 'octane':
quality.label(
text="Renderer does not support super quality.", icon='INFO'
)
quality.label(
text=" Will use high quality setting instead"
)
else:
quality.label(
text="Denoise each render pass separately.", icon='INFO'
)
quality.label(
text=" Slowest compositing speed and greatly increased memory consumption."
)
layout.separator()
if settings.quality != "STANDARD":
passes = layout.column(align=True)
passes.label(
text="Render passes:"
)
subpasses = passes.row(align=True)
subpasses.use_property_split = False
subpasses.prop(
settings,
"use_emission",
text="Emission",
toggle=True
)
subpasses.prop(
settings,
"use_transmission",
text="Transmission",
toggle=True
)
subpasses.prop(
settings,
"use_environment",
text="Environment",
toggle=True
)
subpasses.prop(
settings,
"use_volumetric",
text="Volumetric",
toggle=True
)
layout.separator()
advanced = layout.column(align=True)
advanced.label(
text="Advanced:"
)
layout.separator()
if settings.quality != "STANDARD":
advanced.prop(settings, "SID_mlEXR", text="Use Multi-Layer EXR")
layout.separator()
layout.operator("object.superimagedenoise", icon='SHADERFX')
layout.operator("object.superimagedenoise", text="Refresh Super Denoiser", icon='FILE_REFRESH')
elif denoiser_type == "SID TEMPORAL":
layout.separator()
CompatibleWith = [
'CYCLES'
]
if not RenderEngine in CompatibleWith:
cycles_warning = layout.column(align=True)
cycles_warning.label(
text="SID Temporal is not yet compatible with this render engine.", icon='ERROR'
)
cycles_warning.label(
text=" Please change the render engine to a compatible one."
)
layout.separator()
# don't draw any more panel settings
return
quality = layout.column(align=True)
quality.prop(
settings,
"quality",
text="Quality"
)
if settings.quality == 'STANDARD':
quality.label(
text="Denoise the whole image in a single pass.",
icon='INFO'
)
quality.label(
text=" Maximum compositing speed and least memory consumption."
)
elif settings.quality == 'HIGH':
quality.label(
text="Denoise related render passes in groups.", icon='INFO'
)
quality.label(
text=" Moderate compositing speed and increased memory consumption."
)
elif settings.quality == 'SUPER':
if RenderEngine == 'octane':
quality.label(
text="Renderer does not support super quality.", icon='INFO'
)
quality.label(
text=" Will use high quality setting instead"
)
else:
quality.label(
text="Denoise each render pass separately.", icon='INFO'
)
quality.label(
text=" Slowest compositing speed and greatly increased memory consumption."
)
layout.separator()
if settings.quality != "STANDARD":
passes = layout.column(align=True)
passes.label(
text="Render passes:"
)
subpasses = passes.row(align=True)
subpasses.use_property_split = False
##############
### CYCLES ###
##############
if RenderEngine == 'CYCLES':
subpasses.prop(
settings,
"use_emission",
text="Emission",
toggle=True
)
subpasses.prop(
settings,
"use_transmission",
text="Transmission",
toggle=True
)
subpasses.prop(
settings,
"use_environment",
text="Environment",
toggle=True
)
subpasses.prop(
settings,
"use_volumetric",
text="Volumetric",
toggle=True
)
layout.separator()
fileio = layout.column(align=True)
fileio.active = panel_active
fileio.label(text="Image Save:")
fileio.prop(
settings,
"SIDT_File_Format",
expand=False,
text="Final output file format"
)
fileio.separator()
fileio.prop(settings, "inputdir", text="Image directory")
fileio.separator()
fileio.prop(settings, "SID_mlEXR_Compressed")
fileio.separator()
fileio.prop(scene.render, "use_overwrite", text="Overwrite existing files")
fileio.separator()
motion_blur = layout.column(align=True)
motion_blur.active = panel_active
motion_blur.label(text="Motion Blur Settings:")
motion_blur.prop(settings, "SIDT_MB_Toggle")
motion_blur_settings = layout.column(align=True)
motion_blur_settings.active = (panel_active and settings.SIDT_MB_Toggle)
motion_blur_settings.prop(settings, "SIDT_MB_Samples")
motion_blur_settings.prop(settings, "SIDT_MB_Shutter")
motion_blur_settings.separator()
motion_blur_settings.prop(settings, "SIDT_MB_Min")
motion_blur_settings.prop(settings, "SIDT_MB_Max")
motion_blur_settings.separator()
motion_blur_settings.prop(settings, "SIDT_MB_Interpolation")
motion_blur_settings.separator()
sidtrender = layout.column(align=True)
sidtrender.label(text="Advanced:")
#sidtrender.prop(settings, "SIDT_Overscan_Auto")
sidtrender.prop(settings, "SIDT_Overscan_Amount")
sidtrender.separator()
sidtrender.prop(settings, "SIDT_mlEXR", text="Use Multi-Layer EXR")
sidtrender.separator()
sidtrender.prop(settings, "SIDT_Preview", text="Preview Render (not recommended)")
sidtrender.separator()
sidtrender.prop(settings, "SIDT_TED_Filter_Source", text="TED-Filter Source")
sidtrender.separator()
sidtrender.prop(settings, "SIDT_TED_Filter_Threshold", text="TED-Filter Threshold")
sidtrender.separator()
sidtrender.prop(settings, "SIDT_TED_Filter_Distance", text="TED-Filter Radius")
sidtrender.separator()
sidtrender.active = panel_active
if settings.SIDT_Preview:
if is_rendering:
sidtrender.label(text=f"{denoise_render_status.jobs_done} / {denoise_render_status.jobs_total} View Layers completed", icon='INFO')
sidtrender.prop(denoise_render_status, "percent_complete")
sidtrender.operator("object.superimagedenoisetemporal_stop", icon='CANCEL')
else:
sidtrender.operator("object.superimagedenoisetemporal", icon='RENDER_ANIMATION')
sidtrender.separator()
else:
sidtrender.operator("object.superimagedenoisetemporal_bg", icon='RENDER_ANIMATION')
sidtrender.separator()
sidtdenoise = layout.column(align=True)
sidtdenoise.active = panel_active
if settings.SIDT_Preview:
if is_denoising:
sidtdenoise.active = True
sidtdenoise.label(text=f"{temporal_denoiser_status.jobs_done} / {temporal_denoiser_status.jobs_total} View Layers completed", icon='INFO')
sidtdenoise.prop(temporal_denoiser_status, "percent_complete")
sidtdenoise.operator("object.superimagedenoisealign_stop", icon='CANCEL')
else:
sidtdenoise.operator("object.superimagedenoisealign", icon='SHADERFX')
else:
sidtdenoise.operator("object.superimagedenoisealign_bg", icon='SHADERFX')
elif denoiser_type == "TEMPORAL" and is_temporal_supported:
##### TEMPORAL #####
denoiser_col = layout.column(align=True)
denoiser_col.active = panel_active
denoiser_col.label(text="Temporal usually has inferior denoising quality to SID!", icon='INFO')
denoiser_col.separator()
if is_temporal_optix_supported:
denoiser_col.label(text="Will use OptiX Temporal Denoiser")
else:
denoiser_col.label(text="Will use NLM Temporal Denoiser")
denoiser_col.separator()
fileio = layout.column(align=True)
fileio.active = panel_active
fileio.prop(settings, "inputdir", text="Image directory")
fileio.separator()
fileio.label(text="It's recommended to enable Overwrite existing files")
fileio.label(text="unless you know what you are doing")
fileio.prop(scene.render, "use_overwrite", text="Overwrite existing files")
if is_temporal_nlm_supported:
layout.separator()
tdsettings = layout.row()
tdsettings.active = panel_active
tdsettings.prop(cycles_view_layer, "denoising_radius", text="Radius")
tdsettings.prop(cycles_view_layer, "denoising_neighbor_frames", text="Range")
tdsettings = layout.column()
tdsettings.active = panel_active
tdsettings.prop(cycles_view_layer, "denoising_strength", slider=True, text="Strength")
tdsettings.prop(cycles_view_layer, "denoising_feature_strength", slider=True, text="Feature Strength")
tdsettings.prop(cycles_view_layer, "denoising_relative_pca")
tdsettings = layout.column()
tdsettings.active = panel_active and (cycles_view_layer.use_denoising or cycles_view_layer.denoising_store_passes)
if legacy_layout:
split = tdsettings.split(factor=0.5)
col = split.column()
col.alignment = 'RIGHT'
col.label(text="Diffuse")
row = split.row(align=True)
row.use_property_split = False
else:
row = tdsettings.row(heading="Diffuse", align=True)
row.prop(cycles_view_layer, "denoising_diffuse_direct", text="Direct", toggle=True)
row.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect", toggle=True)
if legacy_layout:
split = tdsettings.split(factor=0.5)
col = split.column()
col.alignment = 'RIGHT'
col.label(text="Glossy")
row = split.row(align=True)
row.use_property_split = False
else:
row = tdsettings.row(heading="Glossy", align=True)
row.prop(cycles_view_layer, "denoising_glossy_direct", text="Direct", toggle=True)
row.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect", toggle=True)
if legacy_layout:
split = tdsettings.split(factor=0.5)
col = split.column()
col.alignment = 'RIGHT'
col.label(text="Transmission")
row = split.row(align=True)
row.use_property_split = False
else:
row = tdsettings.row(heading="Transmission", align=True)
row.prop(cycles_view_layer, "denoising_transmission_direct", text="Direct", toggle=True)
row.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect", toggle=True)
layout.separator()
tdrender = layout.column(align=True)
tdrender.active = panel_active
if is_rendering:
tdrender.label(text=f"{denoise_render_status.jobs_done} / {denoise_render_status.jobs_total} View Layers completed", icon='INFO')
tdrender.prop(denoise_render_status, "percent_complete")
tdrender.operator("object.temporaldenoise_render_stop", icon='CANCEL')
else:
tdrender.operator("object.temporaldenoise_render", icon='RENDER_ANIMATION')
tdrender.separator()
tddenoise = layout.column(align=True)
tddenoise.active = panel_active
if is_denoising:
tddenoise.active = True
tddenoise.label(text=f"{temporal_denoiser_status.jobs_done} / {temporal_denoiser_status.jobs_total} View Layers completed", icon='INFO')
tddenoise.prop(temporal_denoiser_status, "percent_complete")
tddenoise.operator("object.temporaldenoise_denoise_stop", icon='CANCEL')
else:
tddenoise.operator("object.temporaldenoise_denoise", icon='SHADERFX')
class SID_PT_SOCIALS_Panel(SID_PT_Panel, Panel):
bl_label = "Our Socials"
bl_parent_id = "SID_PT_SID_Panel"
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon="FUND")
def draw(self, context):
layout = self.layout
col = layout.column()
col.operator(
"wm.url_open",
text="Join our Discord!",
icon_value = icon_manager.get_icon_id("Discord")
).url = "https://discord.gg/cnFdGQP"
layout.separator()
col.operator(
"wm.url_open",
text="Our YouTube Channel!",
icon_value = icon_manager.get_icon_id("Youtube")
).url = "https://www.youtube.com/channel/UCgLo3l_ZzNZ2BCQMYXLiIOg"
col.operator(
"wm.url_open",
text="Our BlenderMarket!",
icon_value = icon_manager.get_icon_id("BlenderMarket")
).url = "https://blendermarket.com/creators/kevin-lorengel"
col.operator(
"wm.url_open",
text="Our Instagram Page!",
icon_value = icon_manager.get_icon_id("Instagram")
).url = "https://www.instagram.com/pidgeontools/"
col.operator(
"wm.url_open",
text="Our Twitter Page!",
icon_value = icon_manager.get_icon_id("Twitter")
).url = "https://twitter.com/PidgeonTools"
layout.separator()
col.operator(
"wm.url_open",
text="Support and Feedback!",
icon="HELP"
).url = "https://discord.gg/cnFdGQP"
preview_collections = {}