Compare commits

..

11 Commits

4 changed files with 106 additions and 42 deletions

View File

@@ -21,7 +21,7 @@
bl_info = {
'name': 'Blender Cloud',
"author": "Sybren A. Stüvel, Francesco Siddi, Inês Almeida, Antony Riakiotakis",
'version': (1, 5, 99999),
'version': (1, 6, 0),
'blender': (2, 77, 0),
'location': 'Addon Preferences panel, and Ctrl+Shift+Alt+A anywhere for texture browser',
'description': 'Texture library browser and Blender Sync. Requires the Blender ID addon '

View File

@@ -390,9 +390,13 @@ class BlenderCloudPreferences(AddonPreferences):
path_box = job_output_box.row(align=True)
output_path = render_output_path(context)
path_box.label(str(output_path))
props = path_box.operator('flamenco.explore_file_path', text='', icon='DISK_DRIVE')
props.path = str(output_path.parent)
if output_path:
path_box.label(str(output_path))
props = path_box.operator('flamenco.explore_file_path', text='', icon='DISK_DRIVE')
props.path = str(output_path.parent)
else:
path_box.label('Blend file is not in your project path, '
'unable to give output path example.')
flamenco_box.prop(self, 'flamenco_open_browser_after_submit')

View File

@@ -128,24 +128,13 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
if not await self.authenticate(context):
return
from pillarsdk import exceptions as sdk_exceptions
from ..blender import preferences
scene = context.scene
# The file extension should be determined by the render settings, not necessarily
# by the setttings in the output panel.
scene.render.use_file_extension = True
# Save to a different file, specifically for Flamenco. We shouldn't overwrite
# the artist's file. We can compress, since this file won't be managed by SVN
# and doesn't need diffability.
# Save to a different file, specifically for Flamenco.
context.window_manager.flamenco_status = 'PACKING'
filepath = Path(context.blend_data.filepath).with_suffix('.flamenco.blend')
self.log.info('Saving copy to temporary file %s', filepath)
bpy.ops.wm.save_as_mainfile(filepath=str(filepath),
compress=True,
copy=True)
filepath = await self._save_blendfile(context)
# Determine where the render output will be stored.
render_output = render_output_path(context, filepath)
@@ -165,11 +154,22 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
context.window_manager.flamenco_status = 'COMMUNICATING'
settings = {'blender_cmd': '{blender}',
'chunk_size': scene.flamenco_render_chunk_size,
'chunk_size': scene.flamenco_render_fchunk_size,
'filepath': str(outfile),
'frames': scene.flamenco_render_frame_range,
'render_output': str(render_output),
}
# Add extra settings specific to the job type
if scene.flamenco_render_job_type == 'blender-render-progressive':
samples = scene.cycles.samples
if scene.cycles.use_square_samples:
samples **= 2
settings['cycles_num_chunks'] = scene.flamenco_render_schunk_count
settings['cycles_sample_count'] = samples
settings['format'] = 'EXR'
try:
job_info = await create_job(self.user_id,
prefs.attract_project.project,
@@ -178,7 +178,7 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
settings,
'Render %s' % filepath.name,
priority=scene.flamenco_render_job_priority)
except sdk_exceptions.ResourceInvalid as ex:
except Exception as ex:
self.report({'ERROR'}, 'Error creating Flamenco job: %s' % ex)
self.quit()
return
@@ -219,6 +219,43 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
self.quit()
async def _save_blendfile(self, context):
"""Save to a different file, specifically for Flamenco.
We shouldn't overwrite the artist's file.
We can compress, since this file won't be managed by SVN and doesn't need diffability.
"""
render = context.scene.render
# Remember settings we need to restore after saving.
old_use_file_extension = render.use_file_extension
old_use_overwrite = render.use_overwrite
old_use_placeholder = render.use_placeholder
try:
# The file extension should be determined by the render settings, not necessarily
# by the setttings in the output panel.
render.use_file_extension = True
# Rescheduling should not overwrite existing frames.
render.use_overwrite = False
render.use_placeholder = False
filepath = Path(context.blend_data.filepath).with_suffix('.flamenco.blend')
self.log.info('Saving copy to temporary file %s', filepath)
bpy.ops.wm.save_as_mainfile(filepath=str(filepath),
compress=True,
copy=True)
finally:
# Restore the settings we changed, even after an exception.
render.use_file_extension = old_use_file_extension
render.use_overwrite = old_use_overwrite
render.use_placeholder = old_use_placeholder
return filepath
def quit(self):
super().quit()
bpy.context.window_manager.flamenco_status = 'IDLE'
@@ -395,7 +432,11 @@ def _render_output_path(
is fast.
"""
project_path = Path(bpy.path.abspath(local_project_path)).resolve()
try:
project_path = Path(bpy.path.abspath(local_project_path)).resolve()
except FileNotFoundError:
# Path.resolve() will raise a FileNotFoundError if the project path doesn't exist.
return None
try:
proj_rel = blend_filepath.parent.relative_to(project_path)
@@ -404,15 +445,22 @@ def _render_output_path(
rel_parts = proj_rel.parts[flamenco_job_output_strip_components:]
output_top = Path(flamenco_job_output_path)
dir_components = output_top.joinpath(*rel_parts) / blend_filepath.stem
# Strip off '.flamenco' too; we use 'xxx.flamenco.blend' as job file, but
# don't want to have all the output paths ending in '.flamenco'.
stem = blend_filepath.stem
if stem.endswith('.flamenco'):
stem = stem[:-9]
dir_components = output_top.joinpath(*rel_parts) / stem
# Blender will have to append the file extensions by itself.
if is_image_type(render_image_format):
return dir_components / '#####'
return dir_components / '######'
return dir_components / flamenco_render_frame_range
def render_output_path(context, filepath: Path=None) -> typing.Optional[PurePath]:
def render_output_path(context, filepath: Path = None) -> typing.Optional[PurePath]:
"""Returns the render output path to be sent to Flamenco.
:param context: the Blender context (used to find Flamenco preferences etc.)
@@ -453,9 +501,6 @@ class FLAMENCO_PT_render(bpy.types.Panel):
prefs = preferences()
layout.prop(context.scene, 'flamenco_render_job_priority')
layout.prop(context.scene, 'flamenco_render_chunk_size')
labeled_row = layout.split(0.25, align=True)
labeled_row.label('Job Type:')
labeled_row.prop(context.scene, 'flamenco_render_job_type', text='')
@@ -466,6 +511,12 @@ class FLAMENCO_PT_render(bpy.types.Panel):
prop_btn_row.prop(context.scene, 'flamenco_render_frame_range', text='')
prop_btn_row.operator('flamenco.scene_to_frame_range', text='', icon='ARROW_LEFTRIGHT')
layout.prop(context.scene, 'flamenco_render_job_priority')
layout.prop(context.scene, 'flamenco_render_fchunk_size')
if getattr(context.scene, 'flamenco_render_job_type', None) == 'blender-render-progressive':
layout.prop(context.scene, 'flamenco_render_schunk_count')
readonly_stuff = layout.column(align=True)
labeled_row = readonly_stuff.split(0.25, align=True)
labeled_row.label('Storage:')
@@ -500,11 +551,6 @@ class FLAMENCO_PT_render(bpy.types.Panel):
else:
layout.label('Unknown Flamenco status %s' % flamenco_status)
if not context.scene.render.use_overwrite:
warnbox = layout.box().column(align=True)
warnbox.label('Please enable "Overwrite" in the Output panel,')
warnbox.label('or re-queueing this job might not do anything.')
def register():
from ..utils import redraw
@@ -518,24 +564,34 @@ def register():
bpy.utils.register_class(FLAMENCO_PT_render)
scene = bpy.types.Scene
scene.flamenco_render_chunk_size = IntProperty(
name='Chunk size',
scene.flamenco_render_fchunk_size = IntProperty(
name='Frame Chunk Size',
description='Maximum number of frames to render per task',
default=10,
min=1,
default=1,
)
scene.flamenco_render_schunk_count = IntProperty(
name='Number of Sample Chunks',
description='Number of Cycles samples chunks to use per frame',
min=2,
default=3,
soft_max=10,
)
scene.flamenco_render_frame_range = StringProperty(
name='Frame range',
name='Frame Range',
description='Frames to render, in "printer range" notation'
)
scene.flamenco_render_job_type = EnumProperty(
name='Job type',
name='Job Type',
items=[
('blender-render', 'Simple Blender render', 'Not tiled, not resumable, just render'),
],
description='Flamenco render job type',
('blender-render', 'Simple Render', 'Simple frame-by-frame render'),
('blender-render-progressive', 'Progressive Render',
'Each frame is rendered multiple times with different Cycles sample chunks, then combined'),
]
)
scene.flamenco_render_job_priority = IntProperty(
name='Job priority',
name='Job Priority',
min=0,
default=50,
max=100,
@@ -558,7 +614,11 @@ def unregister():
bpy.utils.unregister_module(__name__)
try:
del bpy.types.Scene.flamenco_render_chunk_size
del bpy.types.Scene.flamenco_render_fchunk_size
except AttributeError:
pass
try:
del bpy.types.Scene.flamenco_render_schunk_count
except AttributeError:
pass
try:

View File

@@ -227,7 +227,7 @@ setup(
'wheels': BuildWheels},
name='blender_cloud',
description='The Blender Cloud addon allows browsing the Blender Cloud from Blender.',
version='1.5.99999',
version='1.6.0',
author='Sybren A. Stüvel',
author_email='sybren@stuvel.eu',
packages=find_packages('.'),