-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSFR_Panel.py
More file actions
263 lines (210 loc) · 9.47 KB
/
SFR_Panel.py
File metadata and controls
263 lines (210 loc) · 9.47 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
import typing
import os
import bpy
import bpy.utils.previews
from bpy.types import Panel
from .SFR_Settings import SFR_Settings
from .install_deps import dependencies
ICON_DIR_NAME = "Icons"
class IconManager:
def __init__(self, additional_paths: typing.Optional[typing.List[str]] = None):
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 SFR_PT_Panel:
bl_label = "Super Fast Render"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
bl_options = {"DEFAULT_CLOSED"}
class SFR_PT_B_Panel(SFR_PT_Panel, Panel):
bl_label = "Super Fast Render"
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon='SHADERFX')
def draw(self, context):
layout = self.layout
layout.label(text="Check Complimentary Addons", icon='INFO')
row = layout.row()
row.operator("initalise.complimentary")
# Tell user they need to install dependencies
if not dependencies.checked:
dependencies.check_dependencies()
if dependencies.needs_install:
col = layout.column(align=True)
col.label(
text="Install dependencies",
icon='ERROR'
)
col.label(
text=" Open addon preferences and install dependencies first."
)
col.operator("initialise.sfr_open_addon_prefs", icon='PREFERENCES')
return
class SFR_PT_RSO_Panel(SFR_PT_Panel, Panel):
bl_label = "Render Settings Optimization"
bl_parent_id = "SFR_PT_B_Panel"
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon="OPTIONS")
def draw(self, context):
layout = self.layout
scene = context.scene
settings: SFR_Settings = scene.sfr_settings
RenderEngine = scene.render.engine
if RenderEngine == "CYCLES":
layout.active = not dependencies.needs_install
detection_method = layout.column(align=True)
detection_method.prop(
settings,
"detection_method",
text="Optimization Method"
)
if settings.detection_method == 'MANUAL':
detection_method.label(
text="Sets a general optimization settings.",
icon='INFO'
)
detection_method.label(
text=" General optimization, usually requires manual tweaking."
)
elif settings.detection_method == 'AUTOMATIC':
detection_method.label(
text="Benchmarks your scene and detects which settings you roughly need.",
icon='INFO'
)
layout.separator()
layout = self.layout
if settings.detection_method == 'MANUAL':
layout.label(text="SUPER preset:")
row = layout.row()
row.operator("render.superfastrender_s")
layout.label(text="High preset:")
row = layout.row()
row.operator("render.superfastrender_h")
layout.label(text="Beauty preset:")
row = layout.row()
row.operator("render.superfastrender_b")
else:
layout.label(text="Benchmark Settings")
col = layout.column(align=True)
col.prop(settings, "resolution", text="Benchmark Res", slider=True)
col.prop(settings, "threshold", text="Threshold %", slider=True)
col.separator()
col.prop(settings, "frame_skipped", text="Frame Offset", slider=True)
col.separator()
layout.label(text="Benchmark Passes")
col = layout.column(align=True)
col.prop(settings, "use_diffuse", text="Diffuse",toggle=True)
col.prop(settings, "use_glossy", text="Glossy",toggle=True)
col.prop(settings, "use_transparent", text="Transparency",toggle=True)
col.prop(settings, "use_transmission", text="Transmission",toggle=True)
col.prop(settings, "use_volume", text="Volume",toggle=True)
layout.label(text="Benchmark Light Behaviour")
col = layout.column(align=True)
col.prop(settings, "use_indirect", text="Indirect Brightness",toggle=True)
col.prop(settings, "use_caustics", text="Caustic Blur",toggle=True)
layout.label(text="Start Benchmark")
row = layout.row()
row.operator("render.superfastrender_benchmark", icon="RENDER_STILL")
row.operator("render.superfastrender_animbench", icon="RENDER_ANIMATION")
fileio = layout.column(align=True)
fileio.prop(settings, "inputdir", text="Benchmarking Files")
else:
layout.label(text="This Render Engine is not supported", icon='ERROR')
class SFR_PT_TO_Panel(SFR_PT_Panel, Panel):
bl_label = "Texture Optimizer"
bl_parent_id = "SFR_PT_B_Panel"
def draw_header(self, context):
layout = self.layout
layout.label(text="", icon="TEXTURE")
def draw(self, context):
layout = self.layout
scene = context.scene
settings: SFR_Settings = scene.sfr_settings
layout.active = not dependencies.needs_install
layout.label(text="Texture Optimization Factor")
col = layout.column(align=True)
col.prop(settings, "diffuse_resize", slider=True)
col.prop(settings, "ao_resize", slider=True)
col.prop(settings, "specular_resize", slider=True)
col.prop(settings, "roughness_resize", slider=True)
col.prop(settings, "normal_resize", slider=True)
col.prop(settings, "opacity_resize", slider=True)
col.prop(settings, "translucency_resize", slider=True)
col.separator()
layout.label(text="Optimize Textures")
row = layout.row()
row.operator("render.superfastrender_textureoptim", icon="TEXTURE")
row.prop(settings, "create_backup", toggle=True, icon="COPYDOWN")
layout.label(text='To prevent overwriting existing image files, your files will be copied.', icon='INFO')
layout.label(text='You can find the copied files in the "textures" folder in the location of your .blend file.', icon='INFO')
if settings.create_backup:
layout.label(text='The backup files will be saved in "textures backup".', icon='INFO')
else:
layout.label(text='The optimization step is irreversible, are you sure you do not want a backup?', icon='ERROR')
class SFR_PT_SOCIALS_Panel(SFR_PT_Panel, Panel):
bl_label = "Our Socials"
bl_parent_id = "SFR_PT_B_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 = {}