-
Notifications
You must be signed in to change notification settings - Fork 1
/
startup.py
45 lines (34 loc) · 1.36 KB
/
startup.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
import os
import bpy.ops
import logging
logger = logging.getLogger()
logger.setLevel(20)
bpy.ops.wm.addon_enable(module="netrender")
bpy.context.scene.render.engine = 'NET_RENDER'
# NONE, CUDA, OPENCL
deviceType = os.getenv('RENDER_DEVICE_TYPE', 'NONE')
bpy.context.user_preferences.addons['cycles'].preferences.compute_device_type = deviceType
if deviceType != 'NONE':
bpy.context.user_preferences.addons['cycles'].preferences.devices[0].use = True
# CPU, GPU
device = os.getenv('RENDER_DEVICE', 'CPU')
bpy.context.scene.cycles.device = device
# lower values for CPU, higher values for GPU
tileX = os.getenv('RENDER_TILE_SIZE_X', 16)
tileY = os.getenv('RENDER_TILE_SIZE_Y', 16)
bpy.context.scene.render.tile_x = int(tileX)
bpy.context.scene.render.tile_y = int(tileY)
masterIp = os.getenv('MASTER_PORT_8000_TCP_ADDR', False)
if masterIp == False:
masterIp = os.getenv('MASTER_IP', '127.0.0.1')
renderMode = os.getenv('RENDER_MODE', False)
if renderMode == False:
logger.warning('No RENDER_MODE environment variable detected. Set default to SLAVE')
renderMode = 'SLAVE'
if renderMode == 'MASTER':
bpy.context.scene.network_render.mode = 'RENDER_MASTER'
if renderMode == 'SLAVE':
bpy.context.scene.network_render.mode = 'RENDER_SLAVE'
bpy.context.scene.network_render.server_address = masterIp
# start network render instance
bpy.ops.render.netclientstart()