-
Notifications
You must be signed in to change notification settings - Fork 3
/
make_config.py
300 lines (260 loc) · 10.7 KB
/
make_config.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
import os
import PyOpenColorIO as OCIO
__version__ = "0.7.0"
def build_config(output_path):
"""Generate OCIO config"""
config = OCIO.Config()
config.setSearchPath(":".join(["luts", "mtx"]))
# add colorspaces
config.addColorSpace(aces_colorspace())
config.addColorSpace(acescg_colorspace())
config.addColorSpace(acesproxy_colorspace())
config.addColorSpace(acescc_colorspace())
config.addColorSpace(acescct_colorspace())
config.addColorSpace(log248nitsshaper_colorspace())
config.addColorSpace(aces_out_rec709_colorspace())
config.addColorSpace(lin_srgb_colorspace())
config.addColorSpace(srgb_colorspace())
config.addColorSpace(ncd_colorspace())
# add looks
config.addLook(shot_look())
config.addLook(neutral_look())
# add displays
rec709_display_spaces = [
["ACES Rec. 709", "aces_out_rec709", ""],
["Shot", "acesproxy", "+shot"],
["No LUT", "ncd", ""],
]
for name, colorspace, look in rec709_display_spaces:
config.addDisplay("rec709", name, colorspace, look)
config.setActiveViews(",".join(["ACES Rec. 709", "Shot", "No LUT"]))
config.setActiveDisplays(",".join(["rec709"]))
# set roles
config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR, "acescg")
config.setRole(OCIO.Constants.ROLE_REFERENCE, "aces")
config.setRole(OCIO.Constants.ROLE_DATA, "ncd")
config.setRole(OCIO.Constants.ROLE_DEFAULT, "ncd")
config.setRole(OCIO.Constants.ROLE_COLOR_PICKING, "srgb")
config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT, "acescg")
config.setRole(OCIO.Constants.ROLE_MATTE_PAINT, "acesproxy")
config.setRole(OCIO.Constants.ROLE_COLOR_TIMING, "acescct")
config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG, "acescc")
config.setRole("rendering", "acescg")
config.sanityCheck()
with open(output_path, "w") as fhandle:
fhandle.write(config.serialize())
print("Wrote {} successfully".format(output_path))
def aces_colorspace():
"""The Academy Color Encoding System reference color space (ACES 2065-1)"""
col_space = OCIO.ColorSpace(name="aces", family="ACES")
col_space.setDescription(
"The Academy Color Encoding System reference color space (ACES 2065-1)"
)
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([-8.0, 5.0, 0.00390625])
col_space.setAllocation(OCIO.Constants.ALLOCATION_LG2)
return col_space
def acescg_colorspace():
"""The Academy Color Encoding System ACEScg color space"""
col_space = OCIO.ColorSpace(name="acescg", family="ACES")
col_space.setDescription("The Academy Color Encoding System ACEScg color space")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([-8.0, 5.0, 0.00390625])
col_space.setAllocation(OCIO.Constants.ALLOCATION_LG2)
ftransform = OCIO.FileTransform(
"ap1_to_ap0.spimtx", direction=OCIO.Constants.TRANSFORM_DIR_FORWARD
)
col_space.setTransform(ftransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def acesproxy_colorspace():
"""The Academy Color Encoding System ACESproxy color space"""
col_space = OCIO.ColorSpace(name="acesproxy", family="ACES")
col_space.setDescription("The Academy Color Encoding System ACESproxy color space")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([0, 1])
col_space.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
group_xform = OCIO.GroupTransform()
group_xform.push_back(
OCIO.FileTransform(
"ACESproxy_to_linear.spi1d",
interpolation=OCIO.Constants.INTERP_LINEAR,
direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,
)
)
group_xform.push_back(
OCIO.FileTransform(
"ap1_to_ap0.spimtx", direction=OCIO.Constants.TRANSFORM_DIR_FORWARD
)
)
col_space.setTransform(group_xform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def acescc_colorspace():
"""The Academy Color Encoding System ACEScc color space"""
col_space = OCIO.ColorSpace(name="acescc", family="ACES")
col_space.setDescription("The Academy Color Encoding System ACEScc color space")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([-0.3584, 1.468])
col_space.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
group_xform = OCIO.GroupTransform()
group_xform.push_back(
OCIO.FileTransform(
"ACEScc_to_linear.spi1d",
interpolation=OCIO.Constants.INTERP_LINEAR,
direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,
)
)
group_xform.push_back(
OCIO.FileTransform(
"ap1_to_ap0.spimtx", direction=OCIO.Constants.TRANSFORM_DIR_FORWARD
)
)
col_space.setTransform(group_xform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def acescct_colorspace():
"""The Academy Color Encoding System ACEScct color space"""
col_space = OCIO.ColorSpace(name="acescct", family="ACES")
col_space.setDescription("The Academy Color Encoding System ACEScct color space")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([-0.249136, 1.468])
col_space.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
group_xform = OCIO.GroupTransform()
group_xform.push_back(
OCIO.FileTransform(
"ACEScct_to_linear.spi1d",
interpolation=OCIO.Constants.INTERP_LINEAR,
direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,
)
)
group_xform.push_back(
OCIO.FileTransform(
"ap1_to_ap0.spimtx", direction=OCIO.Constants.TRANSFORM_DIR_FORWARD
)
)
col_space.setTransform(group_xform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def log248nitsshaper_colorspace():
"""The Academy Color Encoding System Log2 48 nits Shaper color space"""
col_space = OCIO.ColorSpace(name="log248nitsshaper", family="ACES")
col_space.setDescription(
"The Academy Color Encoding System Log2 48 nits Shaper color space"
)
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([0, 1])
col_space.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
ftransform = OCIO.FileTransform(
"Log2_48_nits_Shaper_to_linear.spi1d",
interpolation=OCIO.Constants.INTERP_LINEAR,
direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,
)
col_space.setTransform(ftransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def aces_out_rec709_colorspace():
"""The Academy Color Encoding System ACES 1.0 Rec. 709 Output Transform color space"""
col_space = OCIO.ColorSpace(name="aces_out_rec709", family="ACES")
col_space.setDescription(
"The Academy Color Encoding System ACES 1.0 Rec. 709 Output Transform color space"
)
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([0, 1])
col_space.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
group_xform_from = OCIO.GroupTransform()
group_xform_from.push_back(
OCIO.ColorSpaceTransform(src="aces", dst="log248nitsshaper")
)
group_xform_from.push_back(
OCIO.FileTransform(
"Log2_48_nits_Shaper.RRT.Rec.709.spi3d",
interpolation=OCIO.Constants.INTERP_TETRAHEDRAL,
)
)
col_space.setTransform(
group_xform_from, OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE
)
group_xform_to = OCIO.GroupTransform()
group_xform_to.push_back(
OCIO.FileTransform(
"InvRRT.Rec.709.Log2_48_nits_Shaper.spi3d",
interpolation=OCIO.Constants.INTERP_TETRAHEDRAL,
)
)
group_xform_to.push_back(
OCIO.ColorSpaceTransform(src="log248nitsshaper", dst="aces")
)
col_space.setTransform(group_xform_to, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def shot_look():
"""
Custom shot look transform controlled by $SHOT environment variable.
Process space is ACESproxy
"""
look = OCIO.Look(name="shot", processSpace="acesproxy")
look.setDescription(
"Custom shot look transform controlled by $SHOT "
"environment variable. Process space is ACESproxy"
)
ftransform = OCIO.FileTransform(
"$SHOT.cube", interpolation=OCIO.Constants.INTERP_TETRAHEDRAL
)
look.setTransform(ftransform)
return look
def neutral_look():
"""
Custom shot neutralization transform controlled by $SHOT environment variable.
Process space is ACEScg"""
look = OCIO.Look(name="neutral_cc", processSpace="acescg")
look.setDescription(
"Custom shot neutralization transform controlled by $SHOT "
"environment variable. Process space is ACEScg"
)
ftransform = OCIO.FileTransform("${SHOT}_neutral.cc")
look.setTransform(ftransform)
return look
def lin_srgb_colorspace():
"""Scene-linear sRGB color space"""
col_space = OCIO.ColorSpace(name="lin_srgb", family="sRGB")
col_space.setDescription("Scene-linear sRGB color space")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([-8.0, 5.0, 0.00390625])
col_space.setAllocation(OCIO.Constants.ALLOCATION_LG2)
ftransform = OCIO.FileTransform(
"srgb_to_ap0.bradford.spimtx", direction=OCIO.Constants.TRANSFORM_DIR_FORWARD
)
col_space.setTransform(ftransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def srgb_colorspace():
"""sRGB color space"""
col_space = OCIO.ColorSpace(name="srgb", family="sRGB")
col_space.setDescription("sRGB color space")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setAllocationVars([0, 1])
col_space.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
group_xform = OCIO.GroupTransform()
group_xform.push_back(
OCIO.FileTransform(
"sRGB_to_linear.spi1d",
interpolation=OCIO.Constants.INTERP_LINEAR,
direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,
)
)
group_xform.push_back(
OCIO.FileTransform(
"srgb_to_ap0.bradford.spimtx",
direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,
)
)
col_space.setTransform(group_xform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
return col_space
def ncd_colorspace():
"""Non-color data"""
col_space = OCIO.ColorSpace(name="ncd", family="Data")
col_space.setDescription("Non-color data")
col_space.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
col_space.setIsData(True)
return col_space
def main():
"""Main function"""
this_dir = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(this_dir, "config.ocio")
build_config(output_path)
if __name__ == "__main__":
main()