make_light_scenes.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. """Copies a scene that has one light (volshadow/point of the live comparison tests) into variants with the other light
  3. kinds, for the coverage runs (coverage_testscenes.sh).
  4. Usage: make_light_scenes.py <scene dir with a light> <out dir>"""
  5. import copy, json, os, shutil, sys
  6. source, out = sys.argv[1:3]
  7. VARIANTS = {
  8. "tube": {"light": "ltube", "controlpoint": "6 9.5 1.5", "castshadow": False},
  9. "tube-volumetric": {"light": "ltube", "controlpoint": "-4 9.5 1.5", "castshadow": False, "castvolumetrics": True},
  10. "directional": {"light": "ldirectional", "castshadow": True, "castvolumetrics": False},
  11. "directional-plain": {"light": "ldirectional", "castshadow": False, "castvolumetrics": False},
  12. "spot-volumetric": {"light": "lspot", "castshadow": False, "castvolumetrics": True, "innercone": 20, "outercone": 40},
  13. "point-plain": {"light": "lpoint", "castshadow": False, "castvolumetrics": False},
  14. }
  15. scene = json.load(open(os.path.join(source, "scene.json")))
  16. for name, changes in VARIANTS.items():
  17. folder = os.path.join(out, name)
  18. shutil.rmtree(folder, ignore_errors=True)
  19. shutil.copytree(source, folder)
  20. variant = copy.deepcopy(scene)
  21. for light in variant["objects"]:
  22. if "light" in light:
  23. light.update(changes)
  24. config = variant["general"].get("lightconfig")
  25. if config is not None:
  26. variant["general"]["lightconfig"] = {"tube": 2, "directional": 2, "directionalshadow": 1, "spot": 2, "point": 2}
  27. json.dump(variant, open(os.path.join(folder, "scene.json"), "w"), indent=1)