workbench_render_tests.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 setup():
  10. import bpy
  11. for scene in bpy.data.scenes:
  12. scene.render.engine = 'BLENDER_WORKBENCH'
  13. scene.display.shading.light = 'STUDIO'
  14. scene.display.shading.color_type = 'TEXTURE'
  15. # When run from inside Blender, render and exit.
  16. try:
  17. import bpy
  18. inside_blender = True
  19. except ImportError:
  20. inside_blender = False
  21. if inside_blender:
  22. try:
  23. setup()
  24. except Exception as e:
  25. print(e)
  26. sys.exit(1)
  27. def get_arguments(filepath, output_filepath):
  28. return [
  29. "--background",
  30. "-noaudio",
  31. "--factory-startup",
  32. "--enable-autoexec",
  33. filepath,
  34. "-E", "BLENDER_WORKBENCH",
  35. "-P",
  36. os.path.realpath(__file__),
  37. "-o", output_filepath,
  38. "-F", "PNG",
  39. "-f", "1"]
  40. def create_argparse():
  41. parser = argparse.ArgumentParser()
  42. parser.add_argument("-blender", nargs="+")
  43. parser.add_argument("-testdir", nargs=1)
  44. parser.add_argument("-outdir", nargs=1)
  45. parser.add_argument("-idiff", nargs=1)
  46. return parser
  47. def main():
  48. parser = create_argparse()
  49. args = parser.parse_args()
  50. blender = args.blender[0]
  51. test_dir = args.testdir[0]
  52. idiff = args.idiff[0]
  53. output_dir = args.outdir[0]
  54. from modules import render_report
  55. report = render_report.Report("Workbench", output_dir, idiff)
  56. report.set_pixelated(True)
  57. report.set_reference_dir("workbench_renders")
  58. report.set_compare_engines('workbench', 'eevee')
  59. ok = report.run(test_dir, blender, get_arguments, batch=True)
  60. sys.exit(not ok)
  61. if not inside_blender and __name__ == "__main__":
  62. main()