-
Notifications
You must be signed in to change notification settings - Fork 30
/
vfx_rendering.py
109 lines (85 loc) · 5.69 KB
/
vfx_rendering.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
"""Demo a complex workflow of a rendering with a series of subsequent actions:
- Render a CG render out of Maya
- Check the resulting images for potential defects caused by potential server glitches
- Register the CG render in the database
- Create and render a slap comp
- Convert the rendered slapcomp to a quicktime
+---------------------------+ +----------------------+ +-------------------------+ +-----------------------+ +-----------------------+
| MayaRender0-10 | | CheckImages0-10 | | CreateSlapComp | | NukeRender0-10 | | Quicktime |
|---------------------------| |----------------------| |-------------------------| |-----------------------| |-----------------------|
o frames<[0, 1, 2, > | +--->o images<> | % images | o frames<[0, 1, 2, > | % images |
o scene_file<"/scene/fo> | | | images o---------->o images.0<> | +--->o scene_file<> | +--->o images.0<> |
| renderings o-----+ +----------------------+ |--->o images.10<> | --+ | renderings o-----+--->o images.10<> |
+---------------------------+ +-----------------------+ |--->o images.20<> | | +-----------------------+ |--->o images.20<> |
+---------------------------+ | CheckImages10-20 | | o template<"nuke_temp> | | +-----------------------+ | | quicktime o
| MayaRender10-20 | |-----------------------| | | slapcomp o--- | | NukeRender10-20 | | +-----------------------+
|---------------------------| +--->o images<> | | +-------------------------+ | |-----------------------| |
o frames<[10, 11, 1> | | | images o-----| +-----------------------+ | o frames<[10, 11, 1> | |
o scene_file<"/scene/fo> | | +-----------------------+ | | UpdateDatabase | +--->o scene_file<> | |
| renderings o-----+ +-----------------------+ | |-----------------------| | | renderings o-----+
+---------------------------+ | CheckImages20-30 | | o id_<123456> | | +-----------------------+ |
+---------------------------+ |-----------------------| | % images | | +-----------------------+ |
| MayaRender20-30 | +--->o images<> | +--->o images.0<> | | | NukeRender20-30 | |
|---------------------------| | | images o-----+--->o images.10<> | | |-----------------------| |
o frames<[20, 21, 2> | | +-----------------------+ +--->o images.20<> | | o frames<[20, 21, 2> | |
o scene_file<"/scene/fo> | | | status o +--->o scene_file<> | |
| renderings o-----+ +-----------------------+ | renderings o-----+
+---------------------------+ +-----------------------+
"""
from flowpipe import Graph, Node
@Node(outputs=["renderings"], metadata={"interpreter": "maya"})
def MayaRender(frames, scene_file):
return {"renderings": "/renderings/file.%04d.exr"}
@Node(outputs=["images"])
def CheckImages(images):
return {"images": images}
@Node(outputs=["slapcomp"])
def CreateSlapComp(images, template):
return {"slapcomp": "slapcomp.nk"}
@Node(outputs=["renderings"], metadata={"interpreter": "nuke"})
def NukeRender(frames, scene_file):
return {"renderings": "/renderings/file.%04d.exr"}
@Node(outputs=["quicktime"])
def Quicktime(images):
return {"quicktime": "resulting.mov"}
@Node(outputs=["status"])
def UpdateDatabase(id_, images):
"""Update the database entries of the given asset with the given data."""
return {"status": True}
def complex_cg_render(frames, batch_size):
graph = Graph(name="Rendering")
slapcomp = CreateSlapComp(graph=graph, template="nuke_template.nk")
update_database = UpdateDatabase(graph=graph, id_=123456)
for i in range(0, frames, batch_size):
maya_render = MayaRender(
name="MayaRender{0}-{1}".format(i, i + batch_size),
graph=graph,
frames=range(i, i + batch_size),
scene_file="/scene/for/rendering.ma",
)
check_images = CheckImages(
name="CheckImages{0}-{1}".format(i, i + batch_size), graph=graph
)
maya_render.outputs["renderings"].connect(
check_images.inputs["images"]
)
check_images.outputs["images"].connect(
slapcomp.inputs["images"][str(i)]
)
check_images.outputs["images"].connect(
update_database.inputs["images"][str(i)]
)
quicktime = Quicktime()
for i in range(0, frames, batch_size):
nuke_render = NukeRender(
name="NukeRender{0}-{1}".format(i, i + batch_size),
graph=graph,
frames=range(i, i + batch_size),
)
slapcomp.outputs["slapcomp"].connect(nuke_render.inputs["scene_file"])
nuke_render.outputs["renderings"].connect(
quicktime.inputs["images"][str(i)]
)
print(graph)
if __name__ == "__main__":
complex_cg_render(30, 10)