cycles_render_tests.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python3
  2. # Apache License, Version 2.0
  3. import argparse
  4. import os
  5. import shlex
  6. import shutil
  7. import subprocess
  8. import sys
  9. def get_arguments(filepath, output_filepath):
  10. dirname = os.path.dirname(filepath)
  11. basedir = os.path.dirname(dirname)
  12. subject = os.path.basename(dirname)
  13. args = [
  14. "--background",
  15. "-noaudio",
  16. "--factory-startup",
  17. "--enable-autoexec",
  18. filepath,
  19. "-E", "CYCLES",
  20. "-o", output_filepath,
  21. "-F", "PNG"]
  22. # OSL and GPU examples
  23. # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True"]
  24. # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"]
  25. custom_args = os.getenv('CYCLESTEST_ARGS')
  26. if custom_args:
  27. args.extend(shlex.split(custom_args))
  28. if subject == 'bake':
  29. args.extend(['--python', os.path.join(basedir, "util", "render_bake.py")])
  30. elif subject == 'denoise_animation':
  31. args.extend(['--python', os.path.join(basedir, "util", "render_denoise.py")])
  32. else:
  33. args.extend(["-f", "1"])
  34. return args
  35. def create_argparse():
  36. parser = argparse.ArgumentParser()
  37. parser.add_argument("-blender", nargs="+")
  38. parser.add_argument("-testdir", nargs=1)
  39. parser.add_argument("-outdir", nargs=1)
  40. parser.add_argument("-idiff", nargs=1)
  41. return parser
  42. def main():
  43. parser = create_argparse()
  44. args = parser.parse_args()
  45. blender = args.blender[0]
  46. test_dir = args.testdir[0]
  47. idiff = args.idiff[0]
  48. output_dir = args.outdir[0]
  49. from modules import render_report
  50. report = render_report.Report("Cycles", output_dir, idiff)
  51. report.set_pixelated(True)
  52. report.set_reference_dir("cycles_renders")
  53. report.set_compare_engines('cycles', 'eevee')
  54. ok = report.run(test_dir, blender, get_arguments, batch=True)
  55. sys.exit(not ok)
  56. if __name__ == "__main__":
  57. main()