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