change_sampler_pbrt.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # main imports
  2. import sys, os, argparse
  3. import json
  4. # default Sampler
  5. # 'Sampler "random" "integer pixelsamples" [ 64 ]'
  6. SAMPLER_LINE = 'Sampler "random" "integer pixelsamples" [ 64 ]'
  7. def main():
  8. parser = argparse.ArgumentParser(description="Update sampler params of pbrt scene")
  9. parser.add_argument('--prefix', type=str, help='prefix of filename used', required=True)
  10. parser.add_argument('--pbrt', type=str, help='pbrt scene name (this one to convert)', required=True)
  11. args = parser.parse_args()
  12. p_prefix = args.prefix
  13. p_pbrt = args.pbrt
  14. output_content = ""
  15. # read existing pbrt file
  16. pbrt_file = open(p_pbrt, 'r')
  17. pbrt_lines = pbrt_file.readlines()
  18. for line in pbrt_lines:
  19. output_line = line
  20. # 1. Comment Transform and Camera command
  21. if line.startswith('Sampler'):
  22. output_line = SAMPLER_LINE + '\n'
  23. output_content = output_content + output_line
  24. # close all buffers
  25. pbrt_file.close()
  26. # update content
  27. pbrt_outfile = open(p_pbrt, 'w')
  28. pbrt_outfile.write(output_content)
  29. pbrt_outfile.close()
  30. if __name__== "__main__":
  31. main()