3 import SpImport, math, os, sys
4 OCIO = SpImport.SpComp2("PyOpenColorIO",1)
9 outputfilename = "spi-anim.ocio"
11 config = OCIO.Config()
13 LUT_SEARCH_PATH = ['luts']
14 config.setSearchPath(':'.join(LUT_SEARCH_PATH))
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")
27 ## Scene OCIO.Constants.INTERP_LINEAR ###############################################################
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)
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)
43 ## Log Monitor ########################################################################
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)
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)
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)
67 ## VD ########################################################################
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)
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)
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)
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)
106 ## TEXTURE PUBLISHING ########################################################################
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)
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)
129 ## COLOR PICKER ########################################################################
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)
137 ## DATA ########################################################################
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)
143 config.addColorSpace(cs)
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)
149 config.addColorSpace(cs)
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)
155 config.addColorSpace(cs)
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)
161 config.addColorSpace(cs)
163 ## DISPLAY SPACES ##################################################################
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 appropaite for material created on the DreamColor display.
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)
186 cs = OCIO.ColorSpace(family='xyz',name='xyz16')
187 cs.setDescription("xyz16 : 16 Bit int space for DCP creation.")
188 cs.setBitDepth(OCIO.Constants.BIT_DEPTH_UINT16)
189 groupTransform = OCIO.GroupTransform()
190 groupTransform.push_back(OCIO.ColorSpaceTransform(src='lnf',dst='vd16'))
191 groupTransform.push_back(OCIO.FileTransform('hdOffset.spimtx' ,direction= OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR))
192 groupTransform.push_back(OCIO.FileTransform('hd10_to_xyz16.spi3d' ,direction=OCIO.Constants.TRANSFORM_DIR_FORWARD,interpolation=OCIO.Constants.INTERP_LINEAR))
193 cs.setTransform(groupTransform, OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
194 config.addColorSpace(cs)
196 ## DISPLAY SPACES ##################################################################
198 for name,colorspace in [ ['Film','vd16'], ['Log','lm10'],['Raw','nc10']]:
199 config.addDisplay('sRGB',name,colorspace)
201 for name,colorspace in [ ['Film','p3dci8'], ['Log','lm10'], ['Raw','nc10']]:
202 config.addDisplay('DCIP3',name,colorspace)
205 config.setActiveViews(','.join(['Film','Log','Raw']))
206 config.setActiveDisplays(','.join(['sRGB','DCIP3']))
212 print "Configuration was not written due to a failed Sanity Check"
215 f = file(outputfilename,"w")
216 f.write(config.serialize())
218 print "Wrote",outputfilename