Skip to content

Commit

Permalink
Fixed render time computation when output is turned off
Browse files Browse the repository at this point in the history
Now updates total render time even when auto saving is disabled in the output panel
  • Loading branch information
John Einselen VF committed Jul 15, 2021
1 parent 15af01f commit dbabea1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# VF-BlenderAutoSaveRender
# VF Auto Save Render

Automatically saves a numbered or dated image after every render. This Blender Add-on is designed to make test renders easier to review, saving what would otherwise be lost when quitting the app. It's also good for creating a progression timelapse after a project is complete, or naming rendered files with the currently selected object or other custom settings.

![screenshot of Blender's Render Output user interface with the add-on installed](images/screenshot.jpg)
Expand Down Expand Up @@ -34,7 +35,7 @@ Project settings are found at the bottom of the Render Output panel and are uniq
- This uses the name of the blender file and the local date and time (formatted YYYY-MM-DD HH-MM-SS using 24 hour time)
- `Project Name + Render Engine + Render Time`
- This uses the name of the blender file, the name of the render engine, and the time it took to render
- If a sequence is rendered, only the final frame will be saved and this value will be the total sequence render time, not the per-frame render time
- When a sequence is rendered, only the final frame will be saved and this value will be the total sequence render time, not the per-frame render time
- `Custom String`
- This uses pattern replacement to allow for entirely unique file naming patterns
- Supported variables:
Expand All @@ -61,9 +62,11 @@ _Warning_: using a custom string may result in overwriting files or failing to s

### Total Time Spent Rendering

- This simply displays the total number of hours, minutes, and seconds spent rendering the current project, and must be enabled in the Add-on Preferences (see above)
- This tracks the total number of hours, minutes, and seconds spent rendering the current project, and the output panel display can be turned on in the Add-on Preferences (see above)

## Notes

- Auto Save Render depends on the Blender file having been saved at least once, otherwise there is no project name or directory for the Add-on to work with
- Auto Save Render will only save the final frame when rendering sequences, preventing mass dupliation, but still allowing for total render time to be saved
- Auto Save Render depends on the Blender file having been saved at least once in order to save images, otherwise there is no project name or directory for the Add-on to work with
- Only the final frame will be atuo saved when rendering sequences, preventing mass dupliation but still allowing for total render time to be saved in the file name (depending on settings)
- Total render time will continue to increment even when auto file saving is toggled off in the output panel
- Total render time will _not_ increment when rendering files from the command line, since it depends on being saved within the project file (and rendering from the command line typically doesn't save the project file after rendering finishes)
16 changes: 9 additions & 7 deletions VF_auto_save_render.py → VF_autoSaveRender.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bl_info = {
"name": "VF Auto Save Render",
"author": "John Einselen - Vectorform LLC, based on work by tstscr(florianfelix)",
"version": (1, 4),
"version": (1, 4, 1),
"blender": (2, 80, 0),
"location": "Rendertab > Output Panel > Subpanel",
"description": "Automatically saves rendered images with custom naming convention",
Expand Down Expand Up @@ -59,15 +59,15 @@

@persistent
def auto_save_render(scene):
if not bpy.context.scene.auto_save_render_settings.enable_auto_save_render or not bpy.data.filepath:
return

# Calculate elapsed render time
render_time = round(time.time() - float(bpy.context.scene.auto_save_render_settings.start_date), 2)

# Update total render time
bpy.context.scene.auto_save_render_settings.total_render_time = bpy.context.scene.auto_save_render_settings.total_render_time + render_time

if not bpy.context.scene.auto_save_render_settings.enable_auto_save_render or not bpy.data.filepath:
return {'CANCELLED'}

# Save original file format settings
original_format = scene.render.image_settings.file_format
original_colormode = scene.render.image_settings.color_mode
Expand Down Expand Up @@ -171,6 +171,8 @@ def save_number_from_files(files):
scene.render.image_settings.color_mode = original_colormode
scene.render.image_settings.color_depth = original_colordepth

return {'FINISHED'}

###########################################################################
# Start time function

Expand Down Expand Up @@ -226,7 +228,7 @@ def draw(self, context):
# layout.label(text="Addon Default Preferences")
grid = layout.grid_flow(row_major=True)
grid.prop(self, "show_total_render_time")
if bpy.context.preferences.addons['VF_auto_save_render'].preferences.show_total_render_time:
if bpy.context.preferences.addons['VF_autoSaveRender'].preferences.show_total_render_time:
grid.prop(context.scene.auto_save_render_settings, 'total_render_time')
# layout.prop(self, 'default_file_name_custom')

Expand Down Expand Up @@ -310,14 +312,14 @@ def draw(self, context):
if bpy.context.scene.auto_save_render_settings.file_name_type == 'CUSTOM':
# this is intended as a semi-hacky way to override the initial custom string with a global preset instead of relying on get/set
# if '{unset}' in bpy.context.scene.auto_save_render_settings.file_name_custom:
# bpy.context.scene.auto_save_render_settings.file_name_custom = bpy.context.preferences.addons['VF_auto_save_render'].preferences.default_file_name_custom
# bpy.context.scene.auto_save_render_settings.file_name_custom = bpy.context.preferences.addons['VF_autoSaveRender'].preferences.default_file_name_custom
layout.use_property_split = True
layout.prop(context.scene.auto_save_render_settings, 'file_name_custom')
if '{serial}' in bpy.context.scene.auto_save_render_settings.file_name_custom:
layout.use_property_split = True
layout.prop(context.scene.auto_save_render_settings, 'file_name_serial')
layout.prop(context.scene.auto_save_render_settings, 'file_format', icon='FILE_IMAGE')
if bpy.context.preferences.addons['VF_auto_save_render'].preferences.show_total_render_time:
if bpy.context.preferences.addons['VF_autoSaveRender'].preferences.show_total_render_time:
box = layout.box()
box.label(text="Total time spent rendering: "+secondsToReadable(bpy.context.scene.auto_save_render_settings.total_render_time))

Expand Down

0 comments on commit dbabea1

Please sign in to comment.