@@ -12,12 +12,19 @@ class SFR_Benchmark_cy(Operator):
1212 bl_label = "Frame Benchmark"
1313 bl_description = "Tests your scene to detect the best optimization settings."
1414
15+ insert_keyframes : bpy .props .BoolProperty (
16+ name = "Insert keyframes" ,
17+ description = "Inserts keyframes for each property to the current frame (used for benchmarking animations)" ,
18+ default = False ,
19+ options = set (), # Not animatable!
20+ )
21+
1522 @classmethod
16- def poll (cls , context ):
23+ def poll (cls , context : Context ):
1724 if not dependencies .checked or dependencies .needs_install :
1825 dependencies .check_dependencies ()
1926
20- return not dependencies .needs_install
27+ return context . scene . render . engine == 'CYCLES' and not dependencies .needs_install
2128
2229 def execute (self , context : Context ):
2330
@@ -28,8 +35,8 @@ def execute(self, context: Context):
2835 scene = context .scene
2936 cycles = scene .cycles
3037 settings : SFR_Settings = scene .sfr_settings
38+ keyframe_insert = scene .keyframe_insert
3139
32- # return {'FINISHED'}
3340 prefs = context .preferences .addons ['cycles' ].preferences
3441
3542 for device_type in prefs .get_device_types (context ):
@@ -76,6 +83,25 @@ def execute(self, context: Context):
7683 cycles .volume_preview_step_rate = 5
7784 cycles .volume_max_steps = 256
7885
86+ if self .insert_keyframes :
87+ keyframe_insert ('cycles.max_bounces' )
88+ if settings .use_diffuse :
89+ keyframe_insert ('cycles.diffuse_bounces' )
90+ if settings .use_glossy :
91+ keyframe_insert ('cycles.glossy_bounces' )
92+ if settings .use_transmission :
93+ keyframe_insert ('cycles.transmission_bounces' )
94+ if settings .use_transparent :
95+ keyframe_insert ('cycles.transparent_max_bounces' )
96+ if settings .use_volume :
97+ keyframe_insert ('cycles.volume_bounces' )
98+ if settings .use_indirect :
99+ keyframe_insert ('cycles.sample_clamp_indirect' )
100+ if settings .use_caustics :
101+ keyframe_insert ('cycles.blur_glossy' )
102+ keyframe_insert ('cycles.caustics_reflective' )
103+ keyframe_insert ('cycles.caustics_refractive' )
104+
79105 # simplfy the scene
80106 scene .render .use_simplify = True
81107 # viewport
@@ -124,13 +150,17 @@ def execute(self, context: Context):
124150 # set settings
125151 print ("Diffuse Bounces Pre: " , cycles .diffuse_bounces )
126152 cycles .diffuse_bounces += 1
153+ if self .insert_keyframes :
154+ keyframe_insert ('cycles.diffuse_bounces' )
127155 # set next
128156 iteration += 1
129157 print ("Diffuse Iteration: " , iteration )
130158 # start second render
131159 repeat = TestRender (path , iteration , settings )
132160 print ("Diffuse Bounces Post: " , cycles .diffuse_bounces )
133161 cycles .diffuse_bounces -= 1
162+ if self .insert_keyframes :
163+ keyframe_insert ('cycles.diffuse_bounces' )
134164 print ("Diffuse Bounces Final: " , cycles .diffuse_bounces )
135165
136166 ### GLOSS1 ###
@@ -142,12 +172,16 @@ def execute(self, context: Context):
142172 while repeat :
143173 # set settings
144174 cycles .glossy_bounces += 1
175+ if self .insert_keyframes :
176+ keyframe_insert ('cycles.glossy_bounces' )
145177 # set next
146178 iteration += 1
147179 print ("Glossy Iteration: " , iteration )
148180 # start second render
149181 repeat = TestRender (path , iteration , settings )
150182 cycles .glossy_bounces -= 1
183+ if self .insert_keyframes :
184+ keyframe_insert ('cycles.glossy_bounces' )
151185
152186 ### TRANSMISSION1 ###
153187 if settings .use_transmission :
@@ -158,12 +192,16 @@ def execute(self, context: Context):
158192 while repeat :
159193 # set settings
160194 cycles .transmission_bounces += 1
195+ if self .insert_keyframes :
196+ keyframe_insert ('cycles.transmission_bounces' )
161197 # set next
162198 iteration += 1
163199 print ("Transmission Iteration: " , iteration )
164200 # start second render
165201 repeat = TestRender (path , iteration , settings )
166202 cycles .transmission_bounces -= 1
203+ if self .insert_keyframes :
204+ keyframe_insert ('cycles.transmission_bounces' )
167205
168206 ### GLOSS2 ###
169207 if settings .use_transmission and settings .use_glossy :
@@ -174,12 +212,16 @@ def execute(self, context: Context):
174212 while repeat :
175213 # set settings
176214 cycles .glossy_bounces += 1
215+ if self .insert_keyframes :
216+ keyframe_insert ('cycles.glossy_bounces' )
177217 # set next
178218 iteration += 1
179219 print ("Glossy2 Iteration: " , iteration )
180220 # start second render
181221 repeat = TestRender (path , iteration , settings )
182222 cycles .glossy_bounces -= 1
223+ if self .insert_keyframes :
224+ keyframe_insert ('cycles.glossy_bounces' )
183225
184226 ### TRANSMISSION2 ###
185227 if settings .use_transmission and settings .use_glossy :
@@ -190,12 +232,16 @@ def execute(self, context: Context):
190232 while repeat :
191233 # set settings
192234 cycles .transmission_bounces += 1
235+ if self .insert_keyframes :
236+ keyframe_insert ('cycles.transmission_bounces' )
193237 # set next
194238 iteration += 1
195239 print ("Transmission2 Iteration: " , iteration )
196240 # start second render
197241 repeat = TestRender (path , iteration , settings )
198242 cycles .transmission_bounces -= 1
243+ if self .insert_keyframes :
244+ keyframe_insert ('cycles.transmission_bounces' )
199245
200246 ### TRANSPARENT ###
201247 if settings .use_transparent :
@@ -206,12 +252,16 @@ def execute(self, context: Context):
206252 while repeat :
207253 # set settings
208254 cycles .transparent_max_bounces += 1
255+ if self .insert_keyframes :
256+ keyframe_insert ('cycles.transparent_max_bounces' )
209257 # set next
210258 iteration += 1
211259 print ("Transparent Iteration: " , iteration )
212260 # start second render
213261 repeat = TestRender (path , iteration , settings )
214262 cycles .transparent_max_bounces -= 1
263+ if self .insert_keyframes :
264+ keyframe_insert ('cycles.transparent_max_bounces' )
215265
216266 ### VOLUME ###
217267 if settings .use_volume :
@@ -222,12 +272,16 @@ def execute(self, context: Context):
222272 while repeat :
223273 # set settings
224274 cycles .volume_bounces += 1
275+ if self .insert_keyframes :
276+ keyframe_insert ('cycles.volume_bounces' )
225277 # set next
226278 iteration += 1
227279 print ("Volume Iteration: " , iteration )
228280 # start second render
229281 repeat = TestRender (path , iteration , settings )
230282 cycles .volume_bounces -= 1
283+ if self .insert_keyframes :
284+ keyframe_insert ('cycles.volume_bounces' )
231285
232286 ### INDIRECT ###
233287 if settings .use_indirect :
@@ -238,12 +292,16 @@ def execute(self, context: Context):
238292 while repeat :
239293 # set settings
240294 cycles .sample_clamp_indirect += 1
295+ if self .insert_keyframes :
296+ keyframe_insert ('cycles.sample_clamp_indirect' )
241297 # set next
242298 iteration += 1
243299 print ("Indirect Clamp Iteration: " , iteration )
244300 # start second render
245301 repeat = TestRender (path , iteration , settings )
246302 cycles .sample_clamp_indirect -= 1
303+ if self .insert_keyframes :
304+ keyframe_insert ('cycles.sample_clamp_indirect' )
247305
248306 ### CAUSTIC BLUR ###
249307 if settings .use_caustics :
@@ -253,12 +311,16 @@ def execute(self, context: Context):
253311 while repeat :
254312 # set settings
255313 cycles .blur_glossy += 1
314+ if self .insert_keyframes :
315+ keyframe_insert ('cycles.blur_glossy' )
256316 # set next
257317 iteration += 1
258318 print ("Caustic Blur Iteration: " , iteration )
259319 # start second render
260320 repeat = TestRender (path , iteration , settings )
261321 cycles .blur_glossy -= 1
322+ if self .insert_keyframes :
323+ keyframe_insert ('cycles.blur_glossy' )
262324
263325 ### CAUSTIC REFL ###
264326 # start first render
@@ -287,6 +349,8 @@ def execute(self, context: Context):
287349
288350 ### TOTAL ###
289351 cycles .max_bounces = cycles .diffuse_bounces + cycles .glossy_bounces + cycles .transmission_bounces + cycles .volume_bounces
352+ if self .insert_keyframes :
353+ keyframe_insert ('cycles.max_bounces' )
290354
291355 self .report ({'INFO' }, "Benchmark complete" )
292356
0 commit comments