Merge branch 'blender2.7'
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 11 Feb 2019 17:39:31 +0000 (18:39 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 11 Feb 2019 17:39:31 +0000 (18:39 +0100)
1  2 
intern/cycles/blender/addon/operators.py
tests/python/CMakeLists.txt
tests/python/cycles_render_tests.py

@@@ -43,19 -43,19 +43,19 @@@ class CYCLES_OT_use_shading_nodes(Opera
  
  
  class CYCLES_OT_denoise_animation(Operator):
-     """Denoise rendered animation sequence using current scene and view """ \
-     """layer settings. Requires denoising data passes and output to """ \
-     """OpenEXR multilayer files"""
+     "Denoise rendered animation sequence using current scene and view " \
+     "layer settings. Requires denoising data passes and output to " \
+     "OpenEXR multilayer files"
      bl_idname = "cycles.denoise_animation"
      bl_label = "Denoise Animation"
  
 -    input_filepath = StringProperty(
 +    input_filepath: StringProperty(
          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='',
          subtype='FILE_PATH')
  
 -    output_filepath = StringProperty(
 +    output_filepath: StringProperty(
          name='Output Filepath',
          description='If not specified, renders will be denoised in-place',
          default='',
      def execute(self, context):
          import os
  
 -        preferences = context.user_preferences
 +        preferences = context.preferences
          scene = context.scene
 -        render_layer = scene.render.layers.active
 +        view_layer = context.view_layer
  
          in_filepath = self.input_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 = []
          out_filepaths = []
  
-         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 in_filepath != '':
+             # Denoise a single file
+             if out_filepath == '':
+                 out_filepath = in_filepath
+             in_filepaths.append(in_filepath)
+             out_filepaths.append(out_filepath)
+         else:
+             # Denoise animation sequence with expanded frames matching
+             # Blender render output file naming.
+             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
+             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'}
+                 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 = out_filepath
+                 filepath = scene.render.frame_path(frame=frame)
+                 out_filepaths.append(filepath)
  
-         scene.render.filepath = original_filepath
+             scene.render.filepath = original_filepath
  
          # Run denoiser
          # TODO: support cancel and progress reports.
          try:
              _cycles.denoise(preferences.as_pointer(),
                              scene.as_pointer(),
 -                            render_layer.as_pointer(),
 +                            view_layer.as_pointer(),
                              input=in_filepaths,
                              output=out_filepaths)
          except Exception as e:
@@@ -13,6 -13,9 +13,6 @@@
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software Foundation,
  # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 -#
 -# Contributor(s): Jacques Beaurain.
 -#
  # ***** END GPL LICENSE BLOCK *****
  
  # --env-system-scripts allows to run without the install target.
@@@ -528,9 -531,9 +528,9 @@@ function(add_python_test testname tests
        endif()
  endfunction()
  
 -if(WITH_CYCLES)
 -      if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
 -              macro(add_cycles_render_test subject)
 +if(OPENIMAGEIO_IDIFF AND EXISTS "${TEST_SRC_DIR}/render/ctests/shader")
 +      macro(add_cycles_render_test subject)
 +              if(WITH_CYCLES)
                        add_python_test(
                                cycles_${subject}_test
                                ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
                                -idiff "${OPENIMAGEIO_IDIFF}"
                                -outdir "${TEST_OUT_DIR}/cycles"
                        )
 -              endmacro()
 -              if(WITH_OPENGL_RENDER_TESTS)
 -                      add_cycles_render_test(opengl)
                endif()
 -              add_cycles_render_test(bake)
 -              add_cycles_render_test(bsdf)
 -              add_cycles_render_test(denoise)
 -              add_cycles_render_test(denoise_animation)
 -              add_cycles_render_test(displacement)
 -              add_cycles_render_test(hair)
 -              add_cycles_render_test(image_data_types)
 -              add_cycles_render_test(image_mapping)
 -              add_cycles_render_test(image_texture_limit)
 -              add_cycles_render_test(integrator)
 -              add_cycles_render_test(light)
 -              add_cycles_render_test(mesh)
 -              add_cycles_render_test(motion_blur)
 -              add_cycles_render_test(render_layer)
 -              add_cycles_render_test(reports)
 -              add_cycles_render_test(shader)
 -              add_cycles_render_test(shadow_catcher)
 -              add_cycles_render_test(sss)
 -              add_cycles_render_test(volume)
 -      else()
 -              MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist")
 -      endif()
 +
 +              if(WITH_OPENGL_RENDER_TESTS AND (NOT ${subject} MATCHES "bake"))
 +                      add_python_test(
 +                              eevee_${subject}_test
 +                              ${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
 +                              -blender "$<TARGET_FILE:blender>"
 +                              -testdir "${TEST_SRC_DIR}/render/ctests/${subject}"
 +                              -idiff "${OPENIMAGEIO_IDIFF}"
 +                              -outdir "${TEST_OUT_DIR}/eevee"
 +                      )
 +              endif()
 +      endmacro()
 +      add_cycles_render_test(bake)
 +      add_cycles_render_test(bsdf)
 +      add_cycles_render_test(denoise)
++      add_cycles_render_test(denoise_animation)
 +      add_cycles_render_test(displacement)
 +      add_cycles_render_test(hair)
 +      add_cycles_render_test(image_data_types)
 +      add_cycles_render_test(image_mapping)
 +      add_cycles_render_test(image_texture_limit)
 +      add_cycles_render_test(integrator)
 +      add_cycles_render_test(light)
 +      add_cycles_render_test(mesh)
 +      add_cycles_render_test(motion_blur)
 +      add_cycles_render_test(render_layer)
 +      add_cycles_render_test(reports)
 +      add_cycles_render_test(shader)
 +      add_cycles_render_test(shadow_catcher)
 +      add_cycles_render_test(sss)
 +      add_cycles_render_test(volume)
 +elseif(WITH_CYCLES)
 +      MESSAGE(STATUS "Disabling Cycles tests because tests folder does not exist")
  endif()
  
  if(WITH_OPENGL_DRAW_TESTS)
@@@ -635,6 -631,3 +636,6 @@@ if(WITH_CODEC_FFMPEG
  endif()
  
  add_subdirectory(collada)
 +
 +# TODO: disabled for now after collection unification
 +# add_subdirectory(view_layer)
@@@ -14,61 -14,40 +14,40 @@@ def render_file(filepath, output_filepa
      basedir = os.path.dirname(dirname)
      subject = os.path.basename(dirname)
  
-     custom_args = os.getenv('CYCLESTEST_ARGS')
-     custom_args = shlex.split(custom_args) if custom_args else []
+     frame_filepath = output_filepath + '0001.png'
+     common_args = [
+         "-noaudio",
+         "--factory-startup",
+         "--enable-autoexec",
+         filepath,
+         "-E", "CYCLES",
+         "-o", output_filepath,
+         "-F", "PNG"]
  
      # 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.device = 'GPU'"]
-     frame_filepath = output_filepath + '0001.png'
+     custom_args = os.getenv('CYCLESTEST_ARGS')
+     custom_args = shlex.split(custom_args) if custom_args else []
+     common_args += custom_args
  
      if subject == 'opengl':
-         command = [
-             BLENDER,
-             "--window-geometry", "0", "0", "1", "1",
-             "-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")]
+         command = [BLENDER, "--window-geometry", "0", "0", "1", "1"]
+         command += common_args
+         command += ['--python', os.path.join(basedir, "util", "render_opengl.py")]
      elif subject == 'bake':
-         command = [
-             BLENDER,
-             "-b",
-             "-noaudio",
-             "--factory-startup",
-             "--enable-autoexec",
-             filepath,
-             "-E", "CYCLES"]
-         command += custom_args
-         command += [
-             "-o", output_filepath,
-             "-F", "PNG",
-             '--python', os.path.join(basedir,
-                                      "util",
-                                      "render_bake.py")]
+         command = [BLENDER, "--background"]
+         command += common_args
+         command += ['--python', os.path.join(basedir, "util", "render_bake.py")]
+     elif subject == 'denoise_animation':
+         command = [BLENDER, "--background"]
+         command += common_args
+         command += ['--python', os.path.join(basedir, "util", "render_denoise.py")]
      else:
-         command = [
-             BLENDER,
-             "--background",
-             "-noaudio",
-             "--factory-startup",
-             "--enable-autoexec",
-             filepath,
-             "-E", "CYCLES"]
-         command += custom_args
-         command += [
-             "-o", output_filepath,
-             "-F", "PNG",
-             "-f", "1"]
+         command = [BLENDER, "--background"]
+         command += common_args
+         command += ["-f", "1"]
  
      try:
          # Success
@@@ -77,7 -56,6 +56,7 @@@
              shutil.copy(frame_filepath, output_filepath)
              os.remove(frame_filepath)
          if VERBOSE:
 +            print(" ".join(command))
              print(output.decode("utf-8"))
          return None
      except subprocess.CalledProcessError as e:
@@@ -85,7 -63,6 +64,7 @@@
          if os.path.exists(frame_filepath):
              os.remove(frame_filepath)
          if VERBOSE:
 +            print(" ".join(command))
              print(e.output.decode("utf-8"))
          if b"Error: engine not found" in e.output:
              return "NO_ENGINE"
@@@ -97,7 -74,6 +76,7 @@@
          if os.path.exists(frame_filepath):
              os.remove(frame_filepath)
          if VERBOSE:
 +            print(" ".join(command))
              print(e)
          return "CRASH"
  
@@@ -127,7 -103,6 +106,7 @@@ def main()
      from modules import render_report
      report = render_report.Report("Cycles Test Report", output_dir, idiff)
      report.set_pixelated(True)
 +    report.set_compare_engines('cycles', 'eevee')
      ok = report.run(test_dir, render_file)
  
      sys.exit(not ok)