- cs.toReferenceTransforms = []
-
- if 'transformLUTInverse' in odtValues:
- # Copy into the lut dir
- transformLUTInverseFileName = os.path.basename(
- odtValues['transformLUTInverse'])
- lut = lutDir + "/" + transformLUTInverseFileName
- shutil.copy(odtValues['transformLUTInverse'], lut)
-
- cs.toReferenceTransforms.append({
- 'type': 'lutFile',
- 'path': transformLUTInverseFileName,
- 'interpolation': 'tetrahedral',
- 'direction': 'forward'
- })
-
- shaperInverse = shaperOCIOTransform.copy()
- shaperInverse['direction'] = 'forward'
- cs.toReferenceTransforms.append(shaperInverse)
- elif 'transformCTLInverse' in odtValues:
- ctls = [
- '%s/odt/%s' % (
- acesCTLReleaseDir, odtValues['transformCTLInverse']),
- '%s/rrt/InvRRT.a1.0.0.ctl' % acesCTLReleaseDir,
- shaperFromACESCTL % acesCTLReleaseDir
- ]
- lut = "InvRRT.a1.0.0.%s.%s.spi3d" % (odtName, shaperName)
-
- # Remove spaces and parentheses
- lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
-
- genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
- # None,
- ctls,
- lutResolution3d,
- 'half',
- 1.0,
- shaperInputScale,
- shaperParams,
- cleanup,
- acesCTLReleaseDir)
-
- cs.toReferenceTransforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'tetrahedral',
- 'direction': 'forward'
- })
-
- shaperInverse = shaperOCIOTransform.copy()
- shaperInverse['direction'] = 'forward'
- cs.toReferenceTransforms.append(shaperInverse)
-
- return cs
-
- #
- # RRT/ODT shaper options
- #
- shaperData = {}
-
- # Log 2 shaper
- log2ShaperName = shaperName
- log2Params = {
- 'middleGrey': 0.18,
- 'minExposure': -6.0,
- 'maxExposure': 6.5
- }
- log2Shaper = createGenericLog(name=log2ShaperName,
- middleGrey=log2Params['middleGrey'],
- minExposure=log2Params['minExposure'],
- maxExposure=log2Params['maxExposure'])
- configData['colorSpaces'].append(log2Shaper)
-
- shaperInputScale_genericLog2 = 1.0
-
- # Log 2 shaper name and CTL transforms bundled up
- log2ShaperData = [
- log2ShaperName,
- '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl',
- '%s/utilities/ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl',
- shaperInputScale_genericLog2,
- log2Params
- ]
-
- shaperData[log2ShaperName] = log2ShaperData
-
- #
- # Shaper that also includes the AP1 primaries
- # - Needed for some LUT baking steps
- #
- log2ShaperAP1 = createGenericLog(name=log2ShaperName,
- middleGrey=log2Params['middleGrey'],
- minExposure=log2Params['minExposure'],
- maxExposure=log2Params['maxExposure'])
- log2ShaperAP1.name = "%s - AP1" % log2ShaperAP1.name
- # AP1 primaries to AP0 primaries
- log2ShaperAP1.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': mat44FromMat33(acesAP1toAP0),
- 'direction': 'forward'
- })
- configData['colorSpaces'].append(log2ShaperAP1)
-
- #
- # Choose your shaper
- #
- rrtShaperName = log2ShaperName
- rrtShaper = log2ShaperData
-
- #
- # RRT + ODT Combinations
- #
- sortedOdts = sorted(odtInfo.iteritems(), key=lambda x: x[1])
- print( sortedOdts )
- for odt in sortedOdts:
- (odtName, odtValues) = odt
-
- # Have to handle ODTs that can generate either legal or full output
- if odtName in ['Academy.Rec2020_100nits_dim.a1.0.0',
- 'Academy.Rec709_100nits_dim.a1.0.0',
- 'Academy.Rec709_D60sim_100nits_dim.a1.0.0']:
- odtNameLegal = '%s - Legal' % odtValues['transformUserName']
- else:
- odtNameLegal = odtValues['transformUserName']
-
- odtLegal = odtValues.copy()
- odtLegal['legalRange'] = 1
-
- cs = createACESRRTplusODT(
- odtNameLegal,
- odtLegal,
- rrtShaper,
- lutResolution1d,
- lutResolution3d,
- cleanup)
- configData['colorSpaces'].append(cs)
-
- # Create a display entry using this color space
- configData['displays'][odtNameLegal] = {
- 'Linear': ACES,
- 'Log': ACEScc,
- 'Output Transform': cs}
-
- if odtName in ['Academy.Rec2020_100nits_dim.a1.0.0',
- 'Academy.Rec709_100nits_dim.a1.0.0',
- 'Academy.Rec709_D60sim_100nits_dim.a1.0.0']:
- print( "Generating full range ODT for %s" % odtName)
-
- odtNameFull = "%s - Full" % odtValues['transformUserName']
- odtFull = odtValues.copy()
- odtFull['legalRange'] = 0
-
- csFull = createACESRRTplusODT(
- odtNameFull,
- odtFull,
- rrtShaper,
- lutResolution1d,
- lutResolution3d,
- cleanup)
- configData['colorSpaces'].append(csFull)
-
- # Create a display entry using this color space
- configData['displays'][odtNameFull] = {
- 'Linear': ACES,
- 'Log': ACEScc,
- 'Output Transform': csFull}
-
- #
- # Generic Matrix transform
- #
- def createGenericMatrix(name='matrix',
- fromReferenceValues=[],
- toReferenceValues=[]):
- cs = ColorSpace(name)
- cs.description = "The %s color space" % name
- cs.equalityGroup = name
- cs.family = 'Utility'
- cs.isData = False
-
- cs.toReferenceTransforms = []
- if toReferenceValues != []:
- for matrix in toReferenceValues:
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': mat44FromMat33(matrix),
- 'direction': 'forward'
- })
-
- cs.fromReferenceTransforms = []
- if fromReferenceValues != []:
- for matrix in fromReferenceValues:
- cs.fromReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': mat44FromMat33(matrix),
- 'direction': 'forward'
- })
-
- return cs
-
- cs = createGenericMatrix('XYZ', fromReferenceValues=[acesAP0toXYZ])
- configData['colorSpaces'].append(cs)
-
- cs = createGenericMatrix('Linear - AP1', toReferenceValues=[acesAP1toAP0])
- configData['colorSpaces'].append(cs)
-
- # ACES to Linear, P3D60 primaries
- xyzToP3D60 = [2.4027414142, -0.8974841639, -0.3880533700,
- -0.8325796487, 1.7692317536, 0.0237127115,
- 0.0388233815, -0.0824996856, 1.0363685997]
-
- cs = createGenericMatrix('Linear - P3-D60',
- fromReferenceValues=[acesAP0toXYZ, xyzToP3D60])
- configData['colorSpaces'].append(cs)
-
- # ACES to Linear, P3D60 primaries
- xyzToP3DCI = [2.7253940305, -1.0180030062, -0.4401631952,
- -0.7951680258, 1.6897320548, 0.0226471906,
- 0.0412418914, -0.0876390192, 1.1009293786]
-
- cs = createGenericMatrix('Linear - P3-DCI',
- fromReferenceValues=[acesAP0toXYZ, xyzToP3DCI])
- configData['colorSpaces'].append(cs)
-
- # ACES to Linear, Rec 709 primaries
- xyzToRec709 = [3.2409699419, -1.5373831776, -0.4986107603,
- -0.9692436363, 1.8759675015, 0.0415550574,
- 0.0556300797, -0.2039769589, 1.0569715142]
-
- cs = createGenericMatrix('Linear - Rec.709',
- fromReferenceValues=[acesAP0toXYZ, xyzToRec709])
- configData['colorSpaces'].append(cs)
-
- # ACES to Linear, Rec 2020 primaries
- xyzToRec2020 = [1.7166511880, -0.3556707838, -0.2533662814,
- -0.6666843518, 1.6164812366, 0.0157685458,
- 0.0176398574, -0.0427706133, 0.9421031212]
-
- cs = createGenericMatrix('Linear - Rec.2020',
- fromReferenceValues=[acesAP0toXYZ, xyzToRec2020])
- configData['colorSpaces'].append(cs)
-
- print( "generateLUTs - end" )
- return configData
-
-
-def generateBakedLUTs(odtInfo, shaperName, bakedDir, configPath,
- lutResolution1d, lutResolution3d,
- lutResolutionShaper=1024):
- # Add the legal and full variations into this list
- odtInfoC = dict(odtInfo)
- for odtCTLName, odtValues in odtInfo.iteritems():
- if odtCTLName in ['Academy.Rec2020_100nits_dim.a1.0.0',
- 'Academy.Rec709_100nits_dim.a1.0.0',
- 'Academy.Rec709_D60sim_100nits_dim.a1.0.0']:
- odtName = odtValues["transformUserName"]
-
- odtValuesLegal = dict(odtValues)
- odtValuesLegal["transformUserName"] = "%s - Legal" % odtName
- odtInfoC["%s - Legal" % odtCTLName] = odtValuesLegal
-
- odtValuesFull = dict(odtValues)
- odtValuesFull["transformUserName"] = "%s - Full" % odtName
- odtInfoC["%s - Full" % odtCTLName] = odtValuesFull
-
- del ( odtInfoC[odtCTLName] )
-
- for odtCTLName, odtValues in odtInfoC.iteritems():
- odtPrefix = odtValues["transformUserNamePrefix"]
- odtName = odtValues["transformUserName"]
-
- # For Photoshop
- for inputspace in ["ACEScc", "ACESproxy"]:
- args = ["--iconfig", configPath, "-v", "--inputspace", inputspace]
- args += ["--outputspace", "%s" % odtName]
- args += ["--description",
- "%s - %s for %s data" % (odtPrefix, odtName, inputspace)]
- args += ["--shaperspace", shaperName, "--shapersize",
- str(lutResolutionShaper)]
- args += ["--cubesize", str(lutResolution3d)]
- args += ["--format", "icc", "%s/photoshop/%s for %s.icc" % (
- bakedDir, odtName, inputspace)]
-
- bakeLUT = Process(description="bake a LUT", cmd="ociobakelut",
- args=args)
- bakeLUT.execute()
-
- # For Flame, Lustre
- for inputspace in ["ACEScc", "ACESproxy"]:
- args = ["--iconfig", configPath, "-v", "--inputspace", inputspace]
- args += ["--outputspace", "%s" % odtName]
- args += ["--description",
- "%s - %s for %s data" % (odtPrefix, odtName, inputspace)]
- args += ["--shaperspace", shaperName, "--shapersize",
- str(lutResolutionShaper)]
- args += ["--cubesize", str(lutResolution3d)]
-
- fargs = ["--format", "flame", "%s/flame/%s for %s Flame.3dl" % (
- bakedDir, odtName, inputspace)]
- bakeLUT = Process(description="bake a LUT", cmd="ociobakelut",
- args=(args + fargs))
- bakeLUT.execute()
-
- largs = ["--format", "lustre", "%s/lustre/%s for %s Lustre.3dl" % (
- bakedDir, odtName, inputspace)]
- bakeLUT = Process(description="bake a LUT", cmd="ociobakelut",
- args=(args + largs))
- bakeLUT.execute()
-
- # For Maya, Houdini
- for inputspace in ["ACEScg", "ACES2065-1"]:
- args = ["--iconfig", configPath, "-v", "--inputspace", inputspace]
- args += ["--outputspace", "%s" % odtName]
- args += ["--description",
- "%s - %s for %s data" % (odtPrefix, odtName, inputspace)]
- if inputspace == 'ACEScg':
- linShaperName = "%s - AP1" % shaperName
- else:
- linShaperName = shaperName
- args += ["--shaperspace", linShaperName, "--shapersize",
- str(lutResolutionShaper)]
-
- args += ["--cubesize", str(lutResolution3d)]
-
- margs = ["--format", "cinespace", "%s/maya/%s for %s Maya.csp" % (
- bakedDir, odtName, inputspace)]
- bakeLUT = Process(description="bake a LUT", cmd="ociobakelut",
- args=(args + margs))
- bakeLUT.execute()
-
- hargs = ["--format", "houdini",
- "%s/houdini/%s for %s Houdini.lut" % (
- bakedDir, odtName, inputspace)]
- bakeLUT = Process(description="bake a LUT", cmd="ociobakelut",
- args=(args + hargs))
- bakeLUT.execute()
-
-
-def createConfigDir(configDir, bakeSecondaryLUTs):
- dirs = [configDir, "%s/luts" % configDir]
- if bakeSecondaryLUTs:
- dirs.extend(["%s/baked" % configDir,
- "%s/baked/flame" % configDir,
- "%s/baked/photoshop" % configDir,
- "%s/baked/houdini" % configDir,
- "%s/baked/lustre" % configDir,
- "%s/baked/maya" % configDir])