#!/usr/bin/env python
# -*- coding: utf-8 -*-
-'''
-usage from python
+"""
+usage from python:
-import sys
-sys.path.append( "/path/to/script" )
-import create_aces_config as cac
-acesReleaseCTLDir = "/path/to/github/checkout/releases/v0.7.1/transforms/ctl"
-configDir = "/path/to/config/dir"
-cac.createACESConfig(acesReleaseCTLDir, configDir, 1024, 33, True)
+>>> import sys
+>>> sys.path.append("/path/to/script")
+>>> import create_aces_config as cac
+>>> acesReleaseCTLDir = "/path/to/github/checkout/releases/v0.7.1/transforms/ctl"
+>>> configDir = "/path/to/config/dir"
+>>> cac.createACESConfig(acesReleaseCTLDir, configDir, 1024, 33, True)
-usage from command line, from the directory with 'create_aces_config.py'
-python create_aces_config.py -a "/path/to/github/checkout/releases/v0.7.1/transforms/ctl" -c "/path/to/config/dir" --lutResolution1d 1024 --lutResolution3d 33 --keepTempImages
+usage from command line, from the directory with 'create_aces_config.py':
+$ python create_aces_config.py -a "/path/to/github/checkout/releases/v0.7.1/transforms/ctl" -c "/path/to/config/dir" --lutResolution1d 1024 --lutResolution3d 33 --keepTempImages
build instructions for osx for needed packages.
# this time, 'ociolutimage' will build because openimageio is installed
brew uninstall -vd opencolorio
brew install -vd opencolorio --with-python
-'''
-
+"""
import math
import numpy
from aces_ocio.process import Process
from aces_ocio.util import ColorSpace, mat44FromMat33
+__author__ = 'ACES Developers'
+__copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
+__license__ = ''
+__maintainer__ = 'ACES Developers'
+__email__ = 'aces@oscars.org'
+__status__ = 'Production'
+
+__all__ = ['ACES_OCIO_CTL_DIRECTORY_ENVIRON',
+ 'ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON',
+ 'setConfigDefaultRoles',
+ 'writeConfig',
+ 'generateOCIOTransform',
+ 'createConfig',
+ 'generateLUTs',
+ 'generateBakedLUTs',
+ 'createConfigDir',
+ 'getTransformInfo',
+ 'getODTInfo',
+ 'getLMTInfo',
+ 'createACESConfig',
+ 'main']
+
ACES_OCIO_CTL_DIRECTORY_ENVIRON = 'ACES_OCIO_CTL_DIRECTORY'
ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON = 'ACES_OCIO_CONFIGURATION_DIRECTORY'
-#
-# Utility functions
-#
+
def setConfigDefaultRoles(config,
color_picking="",
color_timing="",
reference="",
scene_linear="",
texture_paint=""):
- # Add Roles
- if color_picking: config.setRole(OCIO.Constants.ROLE_COLOR_PICKING,
- color_picking)
- if color_timing: config.setRole(OCIO.Constants.ROLE_COLOR_TIMING,
- color_timing)
- if compositing_log: config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG,
- compositing_log)
- if data: config.setRole(OCIO.Constants.ROLE_DATA, data)
- if default: config.setRole(OCIO.Constants.ROLE_DEFAULT, default)
- if matte_paint: config.setRole(OCIO.Constants.ROLE_MATTE_PAINT,
- matte_paint)
- if reference: config.setRole(OCIO.Constants.ROLE_REFERENCE, reference)
- if scene_linear: config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR,
- scene_linear)
- if texture_paint: config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT,
- texture_paint)
-
-
-# Write config to disk
+ """
+ Sets given *OCIO* configuration default roles.
+
+ Parameters
+ ----------
+ config : config
+ *OCIO* configuration.
+ color_picking : str or unicode
+ Color picking role title.
+ color_timing : str or unicode
+ Color timing role title.
+ compositing_log : str or unicode
+ Compositing log role title.
+ data : str or unicode
+ Data role title.
+ default : str or unicode
+ Default role title.
+ matte_paint : str or unicode
+ Matte painting role title.
+ reference : str or unicode
+ Reference role title.
+ scene_linear : str or unicode
+ Scene linear role title.
+ texture_paint : str or unicode
+ Texture painting role title.
+
+ Returns
+ -------
+ bool
+ Definition success.
+ """
+
+ if color_picking:
+ config.setRole(OCIO.Constants.ROLE_COLOR_PICKING, color_picking)
+ if color_timing:
+ config.setRole(OCIO.Constants.ROLE_COLOR_TIMING, color_timing)
+ if compositing_log:
+ config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG, compositing_log)
+ if data:
+ config.setRole(OCIO.Constants.ROLE_DATA, data)
+ if default:
+ config.setRole(OCIO.Constants.ROLE_DEFAULT, default)
+ if matte_paint:
+ config.setRole(OCIO.Constants.ROLE_MATTE_PAINT, matte_paint)
+ if reference:
+ config.setRole(OCIO.Constants.ROLE_REFERENCE, reference)
+ if scene_linear:
+ config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR, scene_linear)
+ if texture_paint:
+ config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT, texture_paint)
+
+ return True
+
+
def writeConfig(config, configPath, sanityCheck=True):
+ """
+ Writes the configuration to given path.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
if sanityCheck:
try:
config.sanityCheck()
def generateOCIOTransform(transforms):
- # print( "Generating transforms")
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
+ # print("Generating transforms")
interpolationOptions = {
'linear': OCIO.Constants.INTERP_LINEAR,
for transform in transforms:
if transform['type'] == 'lutFile':
-
- ocioTransform = OCIO.FileTransform(src=transform['path'],
- interpolation=
- interpolationOptions[
- transform['interpolation']],
- direction=directionOptions[
- transform['direction']])
-
+ ocioTransform = OCIO.FileTransform(
+ src=transform['path'],
+ interpolation=interpolationOptions[transform['interpolation']],
+ direction=directionOptions[transform['direction']])
ocioTransforms.append(ocioTransform)
elif transform['type'] == 'matrix':
ocioTransform = OCIO.MatrixTransform()
- # MatrixTransform member variables can't be initialized directly. Each must be set individually
+ # MatrixTransform member variables can't be initialized directly.
+ # Each must be set individually.
ocioTransform.setMatrix(transform['matrix'])
if 'offset' in transform:
ocioTransform.setOffset(transform['offset'])
+
if 'direction' in transform:
ocioTransform.setDirection(
directionOptions[transform['direction']])
elif transform['type'] == 'exponent':
ocioTransform = OCIO.ExponentTransform()
ocioTransform.setValue(transform['value'])
-
ocioTransforms.append(ocioTransform)
elif transform['type'] == 'log':
- ocioTransform = OCIO.LogTransform(base=transform['base'],
- direction=directionOptions[
- transform['direction']])
+ ocioTransform = OCIO.LogTransform(
+ base=transform['base'],
+ direction=directionOptions[transform['direction']])
ocioTransforms.append(ocioTransform)
else:
- print( "Ignoring unknown transform type : %s" % transform['type'] )
+ print("Ignoring unknown transform type : %s" % transform['type'])
# Build a group transform if necessary
if len(ocioTransforms) > 1:
def createConfig(configData, nuke=False):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
# Create the config
config = OCIO.Config()
# Define the reference color space
#
referenceData = configData['referenceColorSpace']
- print( "Adding the reference color space : %s" % referenceData.name)
+ print("Adding the reference color space : %s" % referenceData.name)
# Create a color space
- reference = OCIO.ColorSpace(name=referenceData.name,
- bitDepth=referenceData.bitDepth,
- description=referenceData.description,
- equalityGroup=referenceData.equalityGroup,
- family=referenceData.family,
- isData=referenceData.isData,
- allocation=referenceData.allocationType,
- allocationVars=referenceData.allocationVars)
+ reference = OCIO.ColorSpace(
+ name=referenceData.name,
+ bitDepth=referenceData.bitDepth,
+ description=referenceData.description,
+ equalityGroup=referenceData.equalityGroup,
+ family=referenceData.family,
+ isData=referenceData.isData,
+ allocation=referenceData.allocationType,
+ allocationVars=referenceData.allocationVars)
# Add to config
config.addColorSpace(reference)
# Create the rest of the color spaces
#
for colorspace in sorted(configData['colorSpaces']):
- print( "Creating new color space : %s" % colorspace.name)
-
- ocioColorspace = OCIO.ColorSpace(name=colorspace.name,
- bitDepth=colorspace.bitDepth,
- description=colorspace.description,
- equalityGroup=colorspace.equalityGroup,
- family=colorspace.family,
- isData=colorspace.isData,
- allocation=colorspace.allocationType,
- allocationVars=colorspace.allocationVars)
+ print("Creating new color space : %s" % colorspace.name)
+
+ ocioColorspace = OCIO.ColorSpace(
+ name=colorspace.name,
+ bitDepth=colorspace.bitDepth,
+ description=colorspace.description,
+ equalityGroup=colorspace.equalityGroup,
+ family=colorspace.family,
+ isData=colorspace.isData,
+ allocation=colorspace.allocationType,
+ allocationVars=colorspace.allocationVars)
if colorspace.toReferenceTransforms != []:
- print( "Generating To-Reference transforms")
+ print("Generating To-Reference transforms")
ocioTransform = generateOCIOTransform(
colorspace.toReferenceTransforms)
- ocioColorspace.setTransform(ocioTransform,
- OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
+ ocioColorspace.setTransform(
+ ocioTransform,
+ OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
if colorspace.fromReferenceTransforms != []:
- print( "Generating From-Reference transforms")
+ print("Generating From-Reference transforms")
ocioTransform = generateOCIOTransform(
colorspace.fromReferenceTransforms)
- ocioColorspace.setTransform(ocioTransform,
- OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
+ ocioColorspace.setTransform(
+ ocioTransform,
+ OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
config.addColorSpace(ocioColorspace)
- print( "" )
+ print("")
#
# Define the views and displays
# A Nuke specific set of views and displays
#
# XXX
- # A few names: Output Transform, ACES, ACEScc, are hard-coded here. Would be better to automate
+ # A few names: Output Transform, ACES, ACEScc, are hard-coded here.
+ # Would be better to automate.
#
else:
for display, viewList in configData['displays'].iteritems():
for viewName, colorspace in viewList.iteritems():
- if ( viewName == 'Output Transform'):
+ if (viewName == 'Output Transform'):
viewName = 'View'
config.addDisplay(display, viewName, colorspace.name)
if not (viewName in views):
return config
-#
-# Functions to generate color space definitions and LUTs for transforms for a specific ACES release
-#
-
-# Output is a list of colorspaces and transforms that convert between those
-# colorspaces and reference color space, ACES
-def generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir, lutDir,
- lutResolution1d=4096, lutResolution3d=64, cleanup=True):
- print( "generateLUTs - begin" )
+def generateLUTs(odtInfo,
+ lmtInfo,
+ shaperName,
+ acesCTLReleaseDir,
+ lutDir,
+ lutResolution1d=4096,
+ lutResolution3d=64,
+ cleanup=True):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ dict
+ Colorspaces and transforms converting between those colorspaces and
+ the reference colorspace, *ACES*.
+ """
+
+ print("generateLUTs - begin")
configData = {}
#
# Define the reference color space
#
ACES = ColorSpace('ACES2065-1')
- ACES.description = "The Academy Color Encoding System reference color space"
+ ACES.description = (
+ 'The Academy Color Encoding System reference color space')
ACES.equalityGroup = ''
ACES.family = 'ACES'
ACES.isData = False
#
# ACEScc
#
- def createACEScc(name='ACEScc', minValue=0.0, maxValue=1.0,
+ def createACEScc(name='ACEScc',
+ minValue=0.0,
+ maxValue=1.0,
inputScale=1.0):
cs = ColorSpace(name)
cs.description = "The %s color space" % name
# Remove spaces and parentheses
lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate1dLUTFromCTL(lutDir + "/" + lut,
- ctls,
- lutResolution1d,
- 'float',
- inputScale,
- 1.0,
+ genlut.generate1dLUTFromCTL(
+ lutDir + "/" + lut,
+ ctls,
+ lutResolution1d,
+ 'float',
+ inputScale,
+ 1.0,
{},
- cleanup,
- acesCTLReleaseDir,
- minValue,
- maxValue)
+ cleanup,
+ acesCTLReleaseDir,
+ minValue,
+ maxValue)
cs.toReferenceTransforms = []
cs.toReferenceTransforms.append({
cs.isData = False
ctls = [
- '%s/ACESproxy/ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl' % acesCTLReleaseDir,
+ '%s/ACESproxy/ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl' % (
+ acesCTLReleaseDir),
# This transform gets back to the AP1 primaries
# Useful as the 1d LUT is only covering the transfer function
# The primaries switch is covered by the matrix below
# Remove spaces and parentheses
lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate1dLUTFromCTL(lutDir + "/" + lut,
- ctls,
- lutResolution1d,
- 'uint16',
- 64.0,
- 1.0,
+ genlut.generate1dLUTFromCTL(
+ lutDir + "/" + lut,
+ ctls,
+ lutResolution1d,
+ 'uint16',
+ 64.0,
+ 1.0,
{},
- cleanup,
- acesCTLReleaseDir)
+ cleanup,
+ acesCTLReleaseDir)
cs.toReferenceTransforms = []
cs.toReferenceTransforms.append({
-1.121718645000000,
-0.926545676714876]
- REF_PT = (7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) - math.log(
- 0.18, 10.0)
+ REF_PT = ((7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) -
+ math.log(0.18, 10.0))
def cid_to_rle(x):
if x <= 0.6:
return lut
- # Convert Channel Independent Density values to Relative Log Exposure values
+ # Convert Channel Independent Density values to Relative Log Exposure
+ # values.
lut = createCIDtoRLELUT()
cs.toReferenceTransforms.append({
'type': 'lutFile',
cs.isData = False
ctls = [
- '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl' % acesCTLReleaseDir
+ '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl' % (
+ acesCTLReleaseDir)
]
lut = "%s_to_aces.spi1d" % name
# Remove spaces and parentheses
lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate1dLUTFromCTL(lutDir + "/" + lut,
- ctls,
- lutResolution1d,
- 'float',
- inputScale,
- 1.0,
- {
- 'middleGrey': middleGrey,
- 'minExposure': minExposure,
- 'maxExposure': maxExposure
- },
- cleanup,
- acesCTLReleaseDir,
- minValue,
- maxValue)
+ genlut.generate1dLUTFromCTL(
+ lutDir + "/" + lut,
+ ctls,
+ lutResolution1d,
+ 'float',
+ inputScale,
+ 1.0,
+ {
+ 'middleGrey': middleGrey,
+ 'minExposure': minExposure,
+ 'maxExposure': maxExposure
+ },
+ cleanup,
+ acesCTLReleaseDir,
+ minValue,
+ maxValue)
cs.toReferenceTransforms = []
cs.toReferenceTransforms.append({
#
# Generate the shaper transform
#
- (shaperName, shaperToACESCTL, shaperFromACESCTL, shaperInputScale,
+ (shaperName,
+ shaperToACESCTL,
+ shaperFromACESCTL,
+ shaperInputScale,
shaperParams) = shaperInfo
shaperLut = "%s_to_aces.spi1d" % shaperName
- if ( not os.path.exists(lutDir + "/" + shaperLut) ):
+ if (not os.path.exists(lutDir + "/" + shaperLut)):
ctls = [
shaperToACESCTL % acesCTLReleaseDir
]
# Remove spaces and parentheses
- shaperLut = shaperLut.replace(' ', '_').replace(')', '_').replace(
- '(', '_')
+ shaperLut = shaperLut.replace(
+ ' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate1dLUTFromCTL(lutDir + "/" + shaperLut,
- ctls,
- lutResolution1d,
- 'float',
- 1.0 / shaperInputScale,
- 1.0,
- shaperParams,
- cleanup,
- acesCTLReleaseDir)
+ genlut.generate1dLUTFromCTL(
+ lutDir + "/" + shaperLut,
+ ctls,
+ lutResolution1d,
+ 'float',
+ 1.0 / shaperInputScale,
+ 1.0,
+ shaperParams,
+ cleanup,
+ acesCTLReleaseDir)
shaperOCIOTransform = {
'type': 'lutFile',
# Remove spaces and parentheses
lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
- ctls,
- lutResolution3d,
- 'float',
- 1.0 / shaperInputScale,
- 1.0,
- shaperParams,
- cleanup,
- acesCTLReleaseDir)
+ genlut.generate3dLUTFromCTL(
+ lutDir + "/" + lut,
+ ctls,
+ lutResolution3d,
+ 'float',
+ 1.0 / shaperInputScale,
+ 1.0,
+ shaperParams,
+ cleanup,
+ acesCTLReleaseDir)
cs.fromReferenceTransforms.append(shaperOCIOTransform)
cs.fromReferenceTransforms.append({
# Remove spaces and parentheses
lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
- ctls,
- lutResolution3d,
- 'half',
- 1.0,
- shaperInputScale,
- shaperParams,
- cleanup,
- acesCTLReleaseDir)
+ genlut.generate3dLUTFromCTL(
+ lutDir + "/" + lut,
+ ctls,
+ lutResolution3d,
+ 'half',
+ 1.0,
+ shaperInputScale,
+ shaperParams,
+ cleanup,
+ acesCTLReleaseDir)
cs.toReferenceTransforms.append({
'type': 'lutFile',
]
sortedLMTs = sorted(lmtInfo.iteritems(), key=lambda x: x[1])
- print( sortedLMTs )
+ print(sortedLMTs)
for lmt in sortedLMTs:
(lmtName, lmtValues) = lmt
cs = createACESLMT(
# Generate the shaper transform
#
# if 'shaperCTL' in odtValues:
- (shaperName, shaperToACESCTL, shaperFromACESCTL, shaperInputScale,
+ (shaperName,
+ shaperToACESCTL,
+ shaperFromACESCTL,
+ shaperInputScale,
shaperParams) = shaperInfo
if 'legalRange' in odtValues:
shaperParams['legalRange'] = 0
shaperLut = "%s_to_aces.spi1d" % shaperName
- if ( not os.path.exists(lutDir + "/" + shaperLut) ):
+ if (not os.path.exists(lutDir + "/" + shaperLut)):
ctls = [
shaperToACESCTL % acesCTLReleaseDir
]
# Remove spaces and parentheses
- shaperLut = shaperLut.replace(' ', '_').replace(')', '_').replace(
- '(', '_')
+ shaperLut = shaperLut.replace(
+ ' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate1dLUTFromCTL(lutDir + "/" + shaperLut,
- ctls,
- lutResolution1d,
- 'float',
- 1.0 / shaperInputScale,
- 1.0,
- shaperParams,
- cleanup,
- acesCTLReleaseDir)
+ genlut.generate1dLUTFromCTL(
+ lutDir + "/" + shaperLut,
+ ctls,
+ lutResolution1d,
+ 'float',
+ 1.0 / shaperInputScale,
+ 1.0,
+ shaperParams,
+ cleanup,
+ acesCTLReleaseDir)
shaperOCIOTransform = {
'type': 'lutFile',
# Remove spaces and parentheses
lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
- genlut.generate3dLUTFromCTL(lutDir + "/" + lut,
- # None,
- ctls,
- lutResolution3d,
- 'half',
- 1.0,
- shaperInputScale,
- shaperParams,
- cleanup,
- acesCTLReleaseDir)
+ genlut.generate3dLUTFromCTL(
+ lutDir + "/" + lut,
+ # None,
+ ctls,
+ lutResolution3d,
+ 'half',
+ 1.0,
+ shaperInputScale,
+ shaperParams,
+ cleanup,
+ acesCTLReleaseDir)
cs.toReferenceTransforms.append({
'type': 'lutFile',
# RRT + ODT Combinations
#
sortedOdts = sorted(odtInfo.iteritems(), key=lambda x: x[1])
- print( sortedOdts )
+ print(sortedOdts)
for odt in sortedOdts:
(odtName, odtValues) = odt
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)
+ print("Generating full range ODT for %s" % odtName)
odtNameFull = "%s - Full" % odtValues['transformUserName']
odtFull = odtValues.copy()
fromReferenceValues=[acesAP0toXYZ, xyzToRec2020])
configData['colorSpaces'].append(cs)
- print( "generateLUTs - end" )
+ print("generateLUTs - end")
return configData
-def generateBakedLUTs(odtInfo, shaperName, bakedDir, configPath,
- lutResolution1d, lutResolution3d,
+def generateBakedLUTs(odtInfo,
+ shaperName,
+ bakedDir,
+ configPath,
+ lutResolution1d,
+ lutResolution3d,
lutResolutionShaper=1024):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
# Add the legal and full variations into this list
odtInfoC = dict(odtInfo)
for odtCTLName, odtValues in odtInfo.iteritems():
odtValuesFull["transformUserName"] = "%s - Full" % odtName
odtInfoC["%s - Full" % odtCTLName] = odtValuesFull
- del ( odtInfoC[odtCTLName] )
+ del (odtInfoC[odtCTLName])
for odtCTLName, odtValues in odtInfoC.iteritems():
odtPrefix = odtValues["transformUserNamePrefix"]
def createConfigDir(configDir, bakeSecondaryLUTs):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
dirs = [configDir, "%s/luts" % configDir]
if bakeSecondaryLUTs:
dirs.extend(["%s/baked" % configDir,
def getTransformInfo(ctlTransform):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
fp = open(ctlTransform, 'rb')
# Read lines
# Grab transform ID and User Name
transformID = lines[1][3:].split('<')[1].split('>')[1].lstrip().rstrip()
- # print( transformID )
+ # print(transformID)
transformUserName = '-'.join(
lines[2][3:].split('<')[1].split('>')[1].split('-')[
1:]).lstrip().rstrip()
transformUserNamePrefix = \
lines[2][3:].split('<')[1].split('>')[1].split('-')[
0].lstrip().rstrip()
- # print( transformUserName )
+ # print(transformUserName)
fp.close()
- return (transformID, transformUserName, transformUserNamePrefix)
+ return transformID, transformUserName, transformUserNamePrefix
-# For versions after WGR9
def getODTInfo(acesCTLReleaseDir):
+ """
+ Object description.
+
+ For versions after WGR9.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
# Credit to Alex Fry for the original approach here
odtDir = os.path.join(acesCTLReleaseDir, "odt")
allodt = []
for odtCTL in odtCTLs:
odtTokens = os.path.split(odtCTL)
- # print( odtTokens )
+ # print(odtTokens)
# Handle nested directories
odtPathTokens = os.path.split(odtTokens[-2])
odtDir = os.path.join(odtPathTokens[-1], odtDir)
# Build full name
- # print( "odtDir : %s" % odtDir )
+ # print("odtDir : %s" % odtDir)
transformCTL = odtTokens[-1]
- # print( transformCTL )
+ # print(transformCTL)
odtName = string.join(transformCTL.split('.')[1:-1], '.')
- # print( odtName )
+ # print(odtName)
# Find id, user name and user name prefix
(transformID, transformUserName,
if not os.path.exists(
os.path.join(odtTokens[-2], transformCTLInverse)):
transformCTLInverse = None
- #print( transformCTLInverse )
+ # print(transformCTLInverse)
# Add to list of ODTs
odts[odtName] = {}
odts[odtName]['transformCTL'] = os.path.join(odtDir, transformCTL)
if transformCTLInverse != None:
- odts[odtName]['transformCTLInverse'] = os.path.join(odtDir,
- transformCTLInverse)
+ odts[odtName]['transformCTLInverse'] = os.path.join(
+ odtDir, transformCTLInverse)
odts[odtName]['transformID'] = transformID
odts[odtName]['transformUserNamePrefix'] = transformUserNamePrefix
odts[odtName]['transformUserName'] = transformUserName
- print( "ODT : %s" % odtName )
- print( "\tTransform ID : %s" % transformID )
- print( "\tTransform User Name Prefix : %s" % transformUserNamePrefix )
- print( "\tTransform User Name : %s" % transformUserName )
- print(
- "\tForward ctl : %s" % odts[odtName][
- 'transformCTL'])
+ print("ODT : %s" % odtName)
+ print("\tTransform ID : %s" % transformID)
+ print("\tTransform User Name Prefix : %s" % transformUserNamePrefix)
+ print("\tTransform User Name : %s" % transformUserName)
+ print("\tForward ctl : %s" % (
+ odts[odtName]['transformCTL']))
if 'transformCTLInverse' in odts[odtName]:
- print("\tInverse ctl : %s" % odts[odtName][
- 'transformCTLInverse'])
+ print("\tInverse ctl : %s" % (
+ odts[odtName]['transformCTLInverse']))
else:
- print( "\tInverse ctl : %s" % "None" )
+ print("\tInverse ctl : %s" % "None")
- print( "\n" )
+ print("\n")
return odts
-# For versions after WGR9
def getLMTInfo(acesCTLReleaseDir):
+ """
+ Object description.
+
+ For versions after WGR9.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
# Credit to Alex Fry for the original approach here
lmtDir = os.path.join(acesCTLReleaseDir, "lmt")
alllmt = []
for lmtCTL in lmtCTLs:
lmtTokens = os.path.split(lmtCTL)
- # print( lmtTokens )
+ # print(lmtTokens)
# Handle nested directories
lmtPathTokens = os.path.split(lmtTokens[-2])
lmtDir = os.path.join(lmtPathTokens[-1], lmtDir)
# Build full name
- # print( "lmtDir : %s" % lmtDir )
+ # print("lmtDir : %s" % lmtDir)
transformCTL = lmtTokens[-1]
- # print( transformCTL )
+ # print(transformCTL)
lmtName = string.join(transformCTL.split('.')[1:-1], '.')
- # print( lmtName )
+ # print(lmtName)
# Find id, user name and user name prefix
(transformID, transformUserName,
if not os.path.exists(
os.path.join(lmtTokens[-2], transformCTLInverse)):
transformCTLInverse = None
- #print( transformCTLInverse )
+ # print(transformCTLInverse)
# Add to list of LMTs
lmts[lmtName] = {}
lmts[lmtName]['transformCTL'] = os.path.join(lmtDir, transformCTL)
if transformCTLInverse != None:
# TODO: Check unresolved *odtName* referemce.
- lmts[odtName]['transformCTLInverse'] = os.path.join(lmtDir,
- transformCTLInverse)
+ lmts[odtName]['transformCTLInverse'] = os.path.join(
+ lmtDir, transformCTLInverse)
lmts[lmtName]['transformID'] = transformID
lmts[lmtName]['transformUserNamePrefix'] = transformUserNamePrefix
lmts[lmtName]['transformUserName'] = transformUserName
- print( "LMT : %s" % lmtName )
- print( "\tTransform ID : %s" % transformID )
- print( "\tTransform User Name Prefix : %s" % transformUserNamePrefix )
- print( "\tTransform User Name : %s" % transformUserName )
- print( "\t Forward ctl : %s" % lmts[lmtName]['transformCTL'])
+ print("LMT : %s" % lmtName)
+ print("\tTransform ID : %s" % transformID)
+ print("\tTransform User Name Prefix : %s" % transformUserNamePrefix)
+ print("\tTransform User Name : %s" % transformUserName)
+ print("\t Forward ctl : %s" % lmts[lmtName]['transformCTL'])
if 'transformCTLInverse' in lmts[lmtName]:
- print(
- "\t Inverse ctl : %s" % lmts[lmtName]['transformCTLInverse'])
+ print("\t Inverse ctl : %s" % (
+ lmts[lmtName]['transformCTLInverse']))
else:
- print( "\t Inverse ctl : %s" % "None" )
+ print("\t Inverse ctl : %s" % "None")
- print( "\n" )
+ print("\n")
return lmts
-#
-# Create the ACES config
-#
def createACESConfig(acesCTLReleaseDir,
configDir,
lutResolution1d=4096,
lutResolution3d=64,
bakeSecondaryLUTs=True,
cleanup=True):
+ """
+ Creates the ACES configuration.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
# Get ODT names and CTL paths
odtInfo = getODTInfo(acesCTLReleaseDir)
# Generate config data and LUTs for different transforms
lutDir = "%s/luts" % configDir
shaperName = 'Output Shaper'
- configData = generateLUTs(odtInfo, lmtInfo, shaperName, acesCTLReleaseDir,
- lutDir, lutResolution1d, lutResolution3d,
+ configData = generateLUTs(odtInfo,
+ lmtInfo,
+ shaperName,
+ acesCTLReleaseDir,
+ lutDir,
+ lutResolution1d,
+ lutResolution3d,
cleanup)
# Create the config using the generated LUTs
- print( "Creating generic config")
+ print("Creating generic config")
config = createConfig(configData)
- print( "\n\n\n" )
+ print("\n\n\n")
# Write the config to disk
writeConfig(config, "%s/config.ocio" % configDir)
- # Create a config that will work well with Nuke using the previously generated LUTs
- print( "Creating Nuke-specific config")
+ # Create a config that will work well with Nuke using the previously
+ # generated LUTs.
+ print("Creating Nuke-specific config")
nuke_config = createConfig(configData, nuke=True)
- print( "\n\n\n" )
+ print("\n\n\n")
# Write the config to disk
writeConfig(nuke_config, "%s/nuke_config.ocio" % configDir)
# Bake secondary LUTs using the config
if bakeSecondaryLUTs:
- generateBakedLUTs(odtInfo, shaperName, "%s/baked" % configDir,
- "%s/config.ocio" % configDir, lutResolution1d,
- lutResolution3d, lutResolution1d)
+ generateBakedLUTs(odtInfo,
+ shaperName,
+ "%s/baked" % configDir,
+ "%s/config.ocio" % configDir,
+ lutResolution1d,
+ lutResolution3d,
+ lutResolution1d)
return True
-#
-# Main
-#
def main():
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
import optparse
p = optparse.OptionParser(description='An OCIO config generation script',
#
# Get options
- #
+ #
acesCTLDir = options.acesCTLDir
configDir = options.configDir
lutResolution1d = int(options.lutResolution1d)
argsStart = len(sys.argv) + 1
args = []
- print( "command line : \n%s\n" % " ".join(sys.argv) )
+ print("command line : \n%s\n" % " ".join(sys.argv))
# TODO: Use assertion and mention environment variables.
if not acesCTLDir:
- print( "process: No ACES CTL directory specified" )
+ print("process: No ACES CTL directory specified")
return
if not configDir:
- print( "process: No configuration directory specified" )
+ print("process: No configuration directory specified")
return
#
# Generate the configuration
#
- createACESConfig(acesCTLDir, configDir, lutResolution1d, lutResolution3d,
- bakeSecondaryLUTs, cleanupTempImages)
+ return createACESConfig(acesCTLDir,
+ configDir,
+ lutResolution1d,
+ lutResolution3d,
+ bakeSecondaryLUTs,
+ cleanupTempImages)
-# main
if __name__ == '__main__':
main()