eevee_render_tests.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_EEVEE'
  13. # Enable Eevee features
  14. scene = bpy.context.scene
  15. eevee = scene.eevee
  16. eevee.use_ssr = True
  17. eevee.use_ssr_refraction = True
  18. eevee.use_gtao = True
  19. eevee.use_volumetric_shadows = True
  20. eevee.volumetric_tile_size = '2'
  21. for mat in bpy.data.materials:
  22. mat.use_screen_refraction = True
  23. mat.use_sss_translucency = True
  24. # When run from inside Blender, render and exit.
  25. try:
  26. import bpy
  27. inside_blender = True
  28. except ImportError:
  29. inside_blender = False
  30. if inside_blender:
  31. try:
  32. setup()
  33. except Exception as e:
  34. print(e)
  35. sys.exit(1)
  36. def get_arguments(filepath, output_filepath):
  37. return [
  38. "--background",
  39. "-noaudio",
  40. "--factory-startup",
  41. "--enable-autoexec",
  42. filepath,
  43. "-E", "BLENDER_EEVEE",
  44. "-P",
  45. os.path.realpath(__file__),
  46. "-o", output_filepath,
  47. "-F", "PNG",
  48. "-f", "1"]
  49. def create_argparse():
  50. parser = argparse.ArgumentParser()
  51. parser.add_argument("-blender", nargs="+")
  52. parser.add_argument("-testdir", nargs=1)
  53. parser.add_argument("-outdir", nargs=1)
  54. parser.add_argument("-idiff", nargs=1)
  55. return parser
  56. def main():
  57. parser = create_argparse()
  58. args = parser.parse_args()
  59. blender = args.blender[0]
  60. test_dir = args.testdir[0]
  61. idiff = args.idiff[0]
  62. output_dir = args.outdir[0]
  63. from modules import render_report
  64. report = render_report.Report("Eevee", output_dir, idiff)
  65. report.set_pixelated(True)
  66. report.set_reference_dir("eevee_renders")
  67. report.set_compare_engines('eevee', 'cycles')
  68. ok = report.run(test_dir, blender, get_arguments, batch=True)
  69. sys.exit(not ok)
  70. if not inside_blender and __name__ == "__main__":
  71. main()