Updated __init__.py to reflect version no. and new LUT defaults
[OpenColorIO-Configs.git] / spi-anim / makeconfig_anim.py
1 #!/usr/bin/env python
2
3 import SpImport, math, os, sys
4 OCIO = SpImport.SpComp2("PyOpenColorIO",2)
5
6
7
8
9 outputfilename = "config.ocio"
10
11 config = OCIO.Config() 
12
13 LUT_SEARCH_PATH = ['luts']
14 config.setSearchPath(':'.join(LUT_SEARCH_PATH))
15
16 # Set roles
17 config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR, "lnf")
18 config.setRole(OCIO.Constants.ROLE_REFERENCE, "lnf")
19 config.setRole(OCIO.Constants.ROLE_COLOR_TIMING, "lm10")
20 config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG, "lmf")
21 config.setRole(OCIO.Constants.ROLE_COLOR_PICKING,"cpf")
22 config.setRole(OCIO.Constants.ROLE_DATA,"ncf")
23 config.setRole(OCIO.Constants.ROLE_DEFAULT,"ncf")
24 config.setRole(OCIO.Constants.ROLE_MATTE_PAINT,"mp16")
25 config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT,"dt16")
26
27 ## Scene OCIO.Constants.INTERP_LINEAR ###############################################################
28
29 cs = OCIO.ColorSpace(family='ln', name='lnf')
30 cs.setDescription("lnf :linear show space")
31 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
32 cs.setAllocationVars([-13.0,4.0])
33 cs.setAllocation(OCIO.Constants.ALLOCATION_LG2)
34 config.addColorSpace(cs)
35
36 cs = OCIO.ColorSpace(family='ln', name='lnh')
37 cs.setDescription("lnh :linear show space")
38 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F16)
39 cs.setAllocationVars([-13.0,4.0])
40 cs.setAllocation(OCIO.Constants.ALLOCATION_LG2)
41 config.addColorSpace(cs)
42
43 ## Log Monitor ########################################################################
44
45 cs = OCIO.ColorSpace(family='lm',name='lm16')
46 cs.setDescription("lm16 : Log Monitor this space has a log like response and srgb primaries, it is used for color grading ")
47 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
48 t=OCIO.FileTransform('lm16.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR)
49 cs.setTransform(t, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
50 config.addColorSpace(cs)
51
52 cs = OCIO.ColorSpace(family='lm',name='lm10')
53 cs.setDescription("lm10 : Log Monitor this space has a log like response and srgb primaries, it is used for color grading ")
54 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT10)
55 t=OCIO.FileTransform('lm10.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR)
56 cs.setTransform(t, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
57 config.addColorSpace(cs)
58
59 cs = OCIO.ColorSpace(family='lm',name='lmf')
60 cs.setDescription("lmf : Log Monitor this space has a log like response and srgb primaries, it is used as a compositing log")
61 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
62 cs.setAllocationVars([-0.2,2.484])
63 t=OCIO.FileTransform('lmf.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR)
64 cs.setTransform(t, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
65 config.addColorSpace(cs)
66
67 ## VD ########################################################################
68
69 cs = OCIO.ColorSpace(family='vd',name='vd16')
70 cs.setDescription("vd16 : The simple video conversion from a gamma 2.2 srgb space")
71 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
72 groupTransform = OCIO.GroupTransform()
73 groupTransform.push_back(OCIO.FileTransform('vd16.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_NEAREST))
74 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
75 config.addColorSpace(cs)
76
77
78 cs = OCIO.ColorSpace(family='vd',name='vd10')
79 cs.setDescription("vd10 : The simple video conversion from a gamma 2.2 srgb space")
80 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT10)
81 groupTransform = OCIO.GroupTransform()
82 groupTransform.push_back(OCIO.FileTransform('vd10.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_NEAREST))
83 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
84 config.addColorSpace(cs)
85
86 cs = OCIO.ColorSpace(family='vd',name='vd8')
87 cs.setDescription("vd8 : The simple video conversion from a gamma 2.2 srgb space")
88 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT8)
89 groupTransform = OCIO.GroupTransform()
90 groupTransform.push_back(OCIO.FileTransform('vd8.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_NEAREST))
91 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
92 config.addColorSpace(cs)
93
94
95 ## REC709 CONVERSIONS ########################################################################
96 cs = OCIO.ColorSpace(family='hd',name='hd10')
97 cs.setDescription("hd10 : The simple conversion for REC709")
98 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT10)
99 groupTransform = OCIO.GroupTransform()
100 groupTransform.push_back(OCIO.FileTransform('hdOffset.spimtx',direction=OCIO.Constants.TRANSFORM_DIR_INVERSE,interpolation=OCIO.Constants.INTERP_NEAREST))
101 groupTransform.push_back(OCIO.ColorSpaceTransform(src='vd16', dst='lnf'))
102 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
103 config.addColorSpace(cs)
104
105
106 ## TEXTURE PUBLISHING ########################################################################
107
108 cs = OCIO.ColorSpace(family='dt',name='dt16')
109 cs.setDescription("dt16 :diffuse texture conversion")
110 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
111 groupTransform = OCIO.GroupTransform()
112 groupTransform.push_back(OCIO.FileTransform('dt.spimtx',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_NEAREST))
113 groupTransform.push_back(OCIO.ColorSpaceTransform(src='vd16', dst='lnf'))
114 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
115 config.addColorSpace(cs)
116
117
118 ## MATTE PUBLISHING ########################################################################
119 cs = OCIO.ColorSpace(family='mp',name='mp16')
120 cs.setDescription("mp16 : conversion for matte painting")
121 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
122 groupTransform = OCIO.GroupTransform()
123 groupTransform.push_back(OCIO.FileTransform('mp.spimtx',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_NEAREST))
124 groupTransform.push_back(OCIO.ColorSpaceTransform(src='vd16', dst='lnf'))
125 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
126 config.addColorSpace(cs)
127
128
129 ## COLOR PICKER ########################################################################
130
131 cs = OCIO.ColorSpace(family='cp',name='cpf')
132 cs.setDescription("cpf :video like conversion used for color picking ") 
133 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
134 cs.setTransform(OCIO.FileTransform('cpf.spi1d',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_NEAREST), OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
135 config.addColorSpace(cs)
136
137 ## DATA ########################################################################
138
139 cs = OCIO.ColorSpace(family='nc',name='nc8')
140 cs.setDescription("nc8 :nc,Non-color used to store non-color data such as depth or surface normals")
141 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT8)
142 cs.setIsData(True)
143 config.addColorSpace(cs)
144
145 cs = OCIO.ColorSpace(family='nc',name='nc10')
146 cs.setDescription("nc10 :nc,Non-color used to store non-color data such as depth or surface normals")
147 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT10)
148 cs.setIsData(True)
149 config.addColorSpace(cs)
150
151 cs = OCIO.ColorSpace(family='nc',name='nc16')
152 cs.setDescription("nc16 :nc,Non-color used to store non-color data such as depth or surface normals")
153 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
154 cs.setIsData(True)
155 config.addColorSpace(cs)
156
157 cs = OCIO.ColorSpace(family='nc',name='ncf')
158 cs.setDescription("ncf :nc,Non-color used to store non-color data such as depth or surface normals")
159 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
160 cs.setIsData(True)
161 config.addColorSpace(cs)
162
163 ## DISPLAY SPACES ##################################################################
164
165 #
166 # This is not as clean as would be desired.
167 # There is a conversion made from srgb to P3.
168 # Then there is a tone range correction that limits the dynamic range of the DLP to 
169 # be appropriate for material created on the DreamColor display.
170 #
171 cs = OCIO.ColorSpace(family='p3dci',name='p3dci8')
172 cs.setDescription("p3dci8 : 8 Bit int rgb display space for gamma 2.6 P3 projection.")
173 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT8)
174 groupTransform = OCIO.GroupTransform()
175 groupTransform.push_back(OCIO.ColorSpaceTransform(src='lnf', dst='vd16'))
176 groupTransform.push_back(OCIO.ExponentTransform(value=[2.2,2.2,2.2,1.0], direction=OCIO.Constants.TRANSFORM_DIR_FORWARD))
177 groupTransform.push_back(OCIO.FileTransform('srgb_to_p3d65.spimtx',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR))
178 groupTransform.push_back(OCIO.FileTransform('p3d65_to_pdci.spimtx',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR))
179 groupTransform.push_back(OCIO.FileTransform('htr_dlp_tweak.spimtx',direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR))
180 groupTransform.push_back(OCIO.ExponentTransform(value=[2.6,2.6,2.6,1.0], direction=OCIO.Constants.TRANSFORM_DIR_INVERSE))
181 groupTransform.push_back(OCIO.FileTransform('correction.spi1d',OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR))
182 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
183 config.addColorSpace(cs)
184
185 cs = OCIO.ColorSpace(family='xyz',name='xyz16')
186 cs.setDescription("xyz16 : 16 Bit int space for DCP creation.")
187 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
188 groupTransform = OCIO.GroupTransform()
189 groupTransform.push_back(OCIO.ColorSpaceTransform(src='lnf',dst='p3dci8'))
190 groupTransform.push_back(OCIO.ExponentTransform([2.6,2.6,2.6,1.0]))
191 groupTransform.push_back(OCIO.FileTransform('p3_to_xyz16_corrected_wp.spimtx'))
192 groupTransform.push_back(OCIO.ExponentTransform([2.6,2.6,2.6,1.0],direction=OCIO.Constants.TRANSFORM_DIR_INVERSE))
193 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
194 config.addColorSpace(cs)
195
196 ## DISPLAY SPACES ##################################################################
197
198 for name,colorspace in [ ['Film','vd16'], ['Log','lm10'],['Raw','nc10']]:
199     config.addDisplay('sRGB',name,colorspace)
200
201 for name,colorspace in [ ['Film','p3dci8'], ['Log','lm10'], ['Raw','nc10']]:
202     config.addDisplay('DCIP3',name,colorspace)
203
204
205 config.setActiveViews(','.join(['Film','Log','Raw']))
206 config.setActiveDisplays(','.join(['sRGB','DCIP3']))
207
208 try:
209     config.sanityCheck()
210 except Exception,e:
211     print e
212     print "Configuration was not written due to a failed Sanity Check"
213     sys.exit()
214 else:    
215     f = file(outputfilename,"w")
216     f.write(config.serialize())
217     f.close()
218     print "Wrote",outputfilename
219
220
221