Merge branch 'blender2.7'

This commit is contained in:
Brecht Van Lommel 2019-02-11 18:39:31 +01:00
commit d8888b2f48
3 changed files with 60 additions and 72 deletions

@ -43,15 +43,15 @@ class CYCLES_OT_use_shading_nodes(Operator):
class CYCLES_OT_denoise_animation(Operator): class CYCLES_OT_denoise_animation(Operator):
"""Denoise rendered animation sequence using current scene and view """ \ "Denoise rendered animation sequence using current scene and view " \
"""layer settings. Requires denoising data passes and output to """ \ "layer settings. Requires denoising data passes and output to " \
"""OpenEXR multilayer files""" "OpenEXR multilayer files"
bl_idname = "cycles.denoise_animation" bl_idname = "cycles.denoise_animation"
bl_label = "Denoise Animation" bl_label = "Denoise Animation"
input_filepath: StringProperty( input_filepath: StringProperty(
name='Input Filepath', name='Input Filepath',
description='File path for frames to denoise. If not specified, uses the render file path from the scene', description='File path for image to denoise. If not specified, uses the render file path and frame range from the scene',
default='', default='',
subtype='FILE_PATH') subtype='FILE_PATH')
@ -71,33 +71,41 @@ class CYCLES_OT_denoise_animation(Operator):
in_filepath = self.input_filepath in_filepath = self.input_filepath
out_filepath = self.output_filepath out_filepath = self.output_filepath
if in_filepath == '':
in_filepath = scene.render.filepath
if out_filepath == '':
out_filepath = in_filepath
# Backup since we will overwrite the scene path temporarily
original_filepath = scene.render.filepath
# Expand filepaths for each frame so we match Blender render output exactly.
in_filepaths = [] in_filepaths = []
out_filepaths = [] out_filepaths = []
for frame in range(scene.frame_start, scene.frame_end + 1): if in_filepath != '':
scene.render.filepath = in_filepath # Denoise a single file
filepath = scene.render.frame_path(frame=frame) if out_filepath == '':
in_filepaths.append(filepath) out_filepath = in_filepath
if not os.path.isfile(filepath): in_filepaths.append(in_filepath)
scene.render.filepath = original_filepath out_filepaths.append(out_filepath)
self.report({'ERROR'}, f"Frame '{filepath}' not found, animation must be complete.") else:
return {'CANCELLED'} # Denoise animation sequence with expanded frames matching
# Blender render output file naming.
in_filepath = scene.render.filepath
if out_filepath == '':
out_filepath = in_filepath
scene.render.filepath = out_filepath # Backup since we will overwrite the scene path temporarily
filepath = scene.render.frame_path(frame=frame) original_filepath = scene.render.filepath
out_filepaths.append(filepath)
scene.render.filepath = original_filepath for frame in range(scene.frame_start, scene.frame_end + 1):
scene.render.filepath = in_filepath
filepath = scene.render.frame_path(frame=frame)
in_filepaths.append(filepath)
if not os.path.isfile(filepath):
scene.render.filepath = original_filepath
self.report({'ERROR'}, f"Frame '{filepath}' not found, animation must be complete.")
return {'CANCELLED'}
scene.render.filepath = out_filepath
filepath = scene.render.frame_path(frame=frame)
out_filepaths.append(filepath)
scene.render.filepath = original_filepath
# Run denoiser # Run denoiser
# TODO: support cancel and progress reports. # TODO: support cancel and progress reports.

@ -555,6 +555,7 @@ if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
add_cycles_render_test(bake) add_cycles_render_test(bake)
add_cycles_render_test(bsdf) add_cycles_render_test(bsdf)
add_cycles_render_test(denoise) add_cycles_render_test(denoise)
add_cycles_render_test(denoise_animation)
add_cycles_render_test(displacement) add_cycles_render_test(displacement)
add_cycles_render_test(hair) add_cycles_render_test(hair)
add_cycles_render_test(image_data_types) add_cycles_render_test(image_data_types)

@ -14,61 +14,40 @@ def render_file(filepath, output_filepath):
basedir = os.path.dirname(dirname) basedir = os.path.dirname(dirname)
subject = os.path.basename(dirname) subject = os.path.basename(dirname)
custom_args = os.getenv('CYCLESTEST_ARGS') frame_filepath = output_filepath + '0001.png'
custom_args = shlex.split(custom_args) if custom_args else []
common_args = [
"-noaudio",
"--factory-startup",
"--enable-autoexec",
filepath,
"-E", "CYCLES",
"-o", output_filepath,
"-F", "PNG"]
# OSL and GPU examples # OSL and GPU examples
# custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True"] # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True"]
# custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"] # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"]
custom_args = os.getenv('CYCLESTEST_ARGS')
frame_filepath = output_filepath + '0001.png' custom_args = shlex.split(custom_args) if custom_args else []
common_args += custom_args
if subject == 'opengl': if subject == 'opengl':
command = [ command = [BLENDER, "--window-geometry", "0", "0", "1", "1"]
BLENDER, command += common_args
"--window-geometry", "0", "0", "1", "1", command += ['--python', os.path.join(basedir, "util", "render_opengl.py")]
"-noaudio",
"--factory-startup",
"--enable-autoexec",
filepath,
"-E", "CYCLES"]
command += custom_args
command += [
"-o", output_filepath,
"-F", "PNG",
'--python', os.path.join(basedir,
"util",
"render_opengl.py")]
elif subject == 'bake': elif subject == 'bake':
command = [ command = [BLENDER, "--background"]
BLENDER, command += common_args
"-b", command += ['--python', os.path.join(basedir, "util", "render_bake.py")]
"-noaudio", elif subject == 'denoise_animation':
"--factory-startup", command = [BLENDER, "--background"]
"--enable-autoexec", command += common_args
filepath, command += ['--python', os.path.join(basedir, "util", "render_denoise.py")]
"-E", "CYCLES"]
command += custom_args
command += [
"-o", output_filepath,
"-F", "PNG",
'--python', os.path.join(basedir,
"util",
"render_bake.py")]
else: else:
command = [ command = [BLENDER, "--background"]
BLENDER, command += common_args
"--background", command += ["-f", "1"]
"-noaudio",
"--factory-startup",
"--enable-autoexec",
filepath,
"-E", "CYCLES"]
command += custom_args
command += [
"-o", output_filepath,
"-F", "PNG",
"-f", "1"]
try: try:
# Success # Success