-
Notifications
You must be signed in to change notification settings - Fork 109
/
01_cube.py
35 lines (23 loc) · 966 Bytes
/
01_cube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# blender --background --python 01_cube.py --render-frame 1 -- </path/to/output/image> <resolution_percentage> <num_samples>
import bpy
import os
import sys
working_dir_path = os.path.dirname(os.path.abspath(__file__))
sys.path.append(working_dir_path)
import utils
def get_output_file_path() -> str:
return bpy.path.relpath(str(sys.argv[sys.argv.index('--') + 1]))
def get_resolution_percentage() -> int:
return int(sys.argv[sys.argv.index('--') + 2])
def get_num_samples() -> int:
return int(sys.argv[sys.argv.index('--') + 3])
if __name__ == "__main__":
# Args
output_file_path = get_output_file_path()
resolution_percentage = get_resolution_percentage()
num_samples = get_num_samples()
# Setting
scene = bpy.context.scene
camera_object = bpy.data.objects["Camera"]
utils.set_output_properties(scene, resolution_percentage, output_file_path)
utils.set_cycles_renderer(scene, camera_object, num_samples)