-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.py
95 lines (81 loc) · 2.91 KB
/
callbacks.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import bpy
def set_render_engine(self, context):
engine = str(bpy.context.scene.RenderEngine)
scene = bpy.data.scenes["Scene"]
if engine == "CYCLES":
scene.render.engine = engine
scene.cycles.feature_set = "SUPPORTED"
scene.cycles.device = "GPU"
set_samples(self, context)
else:
scene.render.engine = "BLENDER_EEVEE"
set_samples(self, context)
def set_samples(self, context):
bpy.data.scenes["Scene"].cycles.samples = bpy.context.scene.samples_value
bpy.data.scenes["Scene"].cycles.use_adaptive_sampling = True
bpy.data.scenes["Scene"].cycles.adaptive_threshold = 0.05
def set_resolution(self, context):
scene = bpy.context.scene
if scene.camera_resolution == "2k":
x = 2880
y = 1620
elif scene.camera_resolution == "4k":
x = 3840
y = 2160
elif scene.camera_resolution == "6k":
x = 6144
y = 3321
elif scene.camera_resolution == "8k":
x = 8192
y = 4428
scene = bpy.data.scenes["Scene"]
scene.render.resolution_x = x
scene.render.resolution_y = y
def set_3d_mode(self, context):
set_render_engine(self, context)
format="MULTIVIEW"
scene = bpy.data.scenes["Scene"]
render = scene.render
render.use_multiview = True
render.views_format = format
render.image_settings.views_format = "STEREO_3D"
render.image_settings.stereo_3d_format.display_mode = "SIDEBYSIDE"
render.image_settings.stereo_3d_format.use_sidebyside_crosseyed = False #Right eye should see left image and vice versa, usually an option inside VR players too so we dont need to worry
render.image_settings.stereo_3d_format.use_squeezed_frame = False #Combine L/R to same Image
def set_2d_mode(self, context):
scene = bpy.data.scenes["Scene"]
render = scene.render
render.use_multiview = False
if "Camera3D" in bpy.data.objects and "Camera3D" in bpy.data.cameras:
scene.camera = bpy.data.objects["Camera3D"]
def set_mode(self, context):
if bpy.context.scene.CameraMode == "3D":
set_3d_mode(self, context)
else:
set_2d_mode(self, context)
def return_cameras():
cameras = ["Camera3D","Camera3D_L", "Camera3D_R"]
camera_ = [bpy.data.cameras.get(x) for x in cameras]
if None in camera_:
raise "Camera couldn't be found, Recreate the Camera, This shouldn't happend unless you did something."
return
return camera_
def set_lens_type(self, context):
lens_type = str(bpy.context.scene.LensType)
ocs = return_cameras()
if lens_type == "PANO1":
for cam in ocs:
cam.type = "PANO"
cam.panorama_type = "FISHEYE_EQUISOLID"
cam.fisheye_lens = 15
cam.fisheye_fov = 22/7
elif lens_type == "PANO2":
for cam in ocs:
cam.type = "PANO"
cam.panorama_type = "FISHEYE_LENS_POLYNOMIAL"
#cam.fisheye_lens = 15
cam.fisheye_fov = 22/7
elif lens_type == "PERSP":
for cam in ocs:
cam.type = "PERSP"
cam.lens = 50