# dedicated executable in a /bin directory.
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
-import PyOpenColorIO as OCIO
+import PyOpenColorIO as ocio
import aces_ocio.create_arri_colorspaces as arri
import aces_ocio.create_canon_colorspaces as canon
"""
if color_picking:
- config.setRole(OCIO.Constants.ROLE_COLOR_PICKING, color_picking)
+ config.setRole(ocio.Constants.ROLE_COLOR_PICKING, color_picking)
if color_timing:
- config.setRole(OCIO.Constants.ROLE_COLOR_TIMING, color_timing)
+ config.setRole(ocio.Constants.ROLE_COLOR_TIMING, color_timing)
if compositing_log:
- config.setRole(OCIO.Constants.ROLE_COMPOSITING_LOG, compositing_log)
+ config.setRole(ocio.Constants.ROLE_COMPOSITING_LOG, compositing_log)
if data:
- config.setRole(OCIO.Constants.ROLE_DATA, data)
+ config.setRole(ocio.Constants.ROLE_DATA, data)
if default:
- config.setRole(OCIO.Constants.ROLE_DEFAULT, default)
+ config.setRole(ocio.Constants.ROLE_DEFAULT, default)
if matte_paint:
- config.setRole(OCIO.Constants.ROLE_MATTE_PAINT, matte_paint)
+ config.setRole(ocio.Constants.ROLE_MATTE_PAINT, matte_paint)
if reference:
- config.setRole(OCIO.Constants.ROLE_REFERENCE, reference)
+ config.setRole(ocio.Constants.ROLE_REFERENCE, reference)
if scene_linear:
- config.setRole(OCIO.Constants.ROLE_SCENE_LINEAR, scene_linear)
+ config.setRole(ocio.Constants.ROLE_SCENE_LINEAR, scene_linear)
if texture_paint:
- config.setRole(OCIO.Constants.ROLE_TEXTURE_PAINT, texture_paint)
+ config.setRole(ocio.Constants.ROLE_TEXTURE_PAINT, texture_paint)
return True
# print('Generating transforms')
interpolation_options = {
- 'linear': OCIO.Constants.INTERP_LINEAR,
- 'nearest': OCIO.Constants.INTERP_NEAREST,
- 'tetrahedral': OCIO.Constants.INTERP_TETRAHEDRAL
+ 'linear': ocio.Constants.INTERP_LINEAR,
+ 'nearest': ocio.Constants.INTERP_NEAREST,
+ 'tetrahedral': ocio.Constants.INTERP_TETRAHEDRAL
}
direction_options = {
- 'forward': OCIO.Constants.TRANSFORM_DIR_FORWARD,
- 'inverse': OCIO.Constants.TRANSFORM_DIR_INVERSE
+ 'forward': ocio.Constants.TRANSFORM_DIR_FORWARD,
+ 'inverse': ocio.Constants.TRANSFORM_DIR_INVERSE
}
ocio_transforms = []
for transform in transforms:
if transform['type'] == 'lutFile':
- ocio_transform = OCIO.FileTransform(
+ ocio_transform = ocio.FileTransform(
src=transform['path'],
interpolation=interpolation_options[
transform['interpolation']],
direction=direction_options[transform['direction']])
ocio_transforms.append(ocio_transform)
elif transform['type'] == 'matrix':
- ocio_transform = OCIO.MatrixTransform()
+ ocio_transform = ocio.MatrixTransform()
# MatrixTransform member variables can't be initialized directly.
# Each must be set individually.
ocio_transform.setMatrix(transform['matrix'])
ocio_transforms.append(ocio_transform)
elif transform['type'] == 'exponent':
- ocio_transform = OCIO.ExponentTransform()
+ ocio_transform = ocio.ExponentTransform()
ocio_transform.setValue(transform['value'])
ocio_transforms.append(ocio_transform)
elif transform['type'] == 'log':
- ocio_transform = OCIO.LogTransform(
+ ocio_transform = ocio.LogTransform(
base=transform['base'],
direction=direction_options[transform['direction']])
# Build a group transform if necessary
if len(ocio_transforms) > 1:
- transform_G = OCIO.GroupTransform()
+ transform_G = ocio.GroupTransform()
for transform in ocio_transforms:
transform_G.push_back(transform)
transform = transform_G
"""
# Create the config
- config = OCIO.Config()
+ config = ocio.Config()
#
# Set config wide values
print('Adding the reference color space : %s' % reference_data.name)
# Create a color space
- reference = OCIO.ColorSpace(
+ reference = ocio.ColorSpace(
name=reference_data.name,
bitDepth=reference_data.bit_depth,
description=reference_data.description,
for colorspace in sorted(config_data['colorSpaces']):
print('Creating new color space : %s' % colorspace.name)
- ocio_colorspace = OCIO.ColorSpace(
+ ocio_colorspace = ocio.ColorSpace(
name=colorspace.name,
bitDepth=colorspace.bit_depth,
description=colorspace.description,
colorspace.to_reference_transforms)
ocio_colorspace.setTransform(
ocio_transform,
- OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
+ ocio.Constants.COLORSPACE_DIR_TO_REFERENCE)
if colorspace.from_reference_transforms != []:
print('Generating From-Reference transforms')
colorspace.from_reference_transforms)
ocio_colorspace.setTransform(
ocio_transform,
- OCIO.Constants.COLORSPACE_DIR_FROM_REFERENCE)
+ ocio.Constants.COLORSPACE_DIR_FROM_REFERENCE)
config.addColorSpace(ocio_colorspace)
ACES.equality_group = ''
ACES.family = 'ACES'
ACES.is_data = False
- ACES.allocation_type = OCIO.Constants.ALLOCATION_LG2
+ ACES.allocation_type = ocio.Constants.ALLOCATION_LG2
ACES.allocation_vars = [-15, 6]
config_data['referenceColorSpace'] = ACES
cs.family = 'ACES'
cs.is_data = False
- ctls = [
- '%s/ACEScc/ACEScsc.ACEScc_to_ACES.a1.0.0.ctl' % aces_CTL_directory,
- # 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
- '%s/ACEScg/ACEScsc.ACES_to_ACEScg.a1.0.0.ctl' % aces_CTL_directory
- ]
+ ctls = [os.path.join(aces_CTL_directory,
+ 'ACEScc',
+ 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl'),
+ # 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
+ os.path.join(aces_CTL_directory,
+ 'ACEScg',
+ 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
lut = '%s_to_ACES.spi1d' % name
# Remove spaces and parentheses
cs.is_data = False
ctls = [
- '%s/ACESproxy/ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl' % (
- aces_CTL_directory),
+ os.path.join(aces_CTL_directory,
+ 'ACESproxy',
+ 'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
# 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
- '%s/ACEScg/ACEScsc.ACES_to_ACEScg.a1.0.0.ctl' % aces_CTL_directory
- ]
+ os.path.join(aces_CTL_directory,
+ 'ACEScg',
+ 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
lut = '%s_to_aces.spi1d' % name
# Remove spaces and parentheses
cs.is_data = False
if bit_depth == 10:
- cs.bit_depth = bit_depth = OCIO.Constants.BIT_DEPTH_UINT10
+ cs.bit_depth = bit_depth = ocio.Constants.BIT_DEPTH_UINT10
adx_to_cdd = [1023.0 / 500.0, 0.0, 0.0, 0.0,
0.0, 1023.0 / 500.0, 0.0, 0.0,
0.0, 0.0, 1023.0 / 500.0, 0.0,
0.0, 0.0, 0.0, 1.0]
offset = [-95.0 / 500.0, -95.0 / 500.0, -95.0 / 500.0, 0.0]
elif bit_depth == 16:
- cs.bit_depth = bit_depth = OCIO.Constants.BIT_DEPTH_UINT16
+ cs.bit_depth = bit_depth = ocio.Constants.BIT_DEPTH_UINT16
adx_to_cdd = [65535.0 / 8000.0, 0.0, 0.0, 0.0,
0.0, 65535.0 / 8000.0, 0.0, 0.0,
0.0, 0.0, 65535.0 / 8000.0, 0.0,
cs.is_data = False
ctls = [
- '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl' % (
- aces_CTL_directory)]
+ os.path.join(aces_CTL_directory,
+ 'utilities',
+ 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')]
lut = '%s_to_aces.spi1d' % name
# Remove spaces and parentheses
if 'transformCTL' in lmt_values:
ctls = [
shaper_to_ACES_CTL % aces_CTL_directory,
- '%s/%s' % (aces_CTL_directory, lmt_values['transformCTL'])
- ]
+ os.path.join(aces_CTL_directory, lmt_values['transformCTL'])]
lut = '%s.%s.spi3d' % (shaper_name, lmt_name)
# Remove spaces and parentheses
if 'transformCTLInverse' in lmt_values:
ctls = [
- '%s/%s' % (
- aces_CTL_directory, odt_values['transformCTLInverse']),
+ os.path.join(aces_CTL_directory,
+ odt_values['transformCTLInverse']),
shaper_from_ACES_CTL % aces_CTL_directory
]
lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name)
# Log 2 shaper name and CTL transforms bundled up
lmt_shaper_data = [
lmt_shaper_name,
- '%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',
+ os.path.join('%s',
+ 'utilities',
+ 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
+ os.path.join('%s',
+ 'utilities',
+ 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
shaper_input_scale_generic_log2,
- lmt_params
- ]
+ lmt_params]
sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1])
print(sorted_LMTs)
ctls = [
shaper_to_ACES_CTL % aces_CTL_directory,
- '%s/rrt/RRT.a1.0.0.ctl' % aces_CTL_directory,
- '%s/odt/%s' % (aces_CTL_directory, odt_values['transformCTL'])
- ]
+ os.path.join(aces_CTL_directory,
+ 'rrt',
+ 'RRT.a1.0.0.ctl'),
+ os.path.join(aces_CTL_directory,
+ 'odt',
+ odt_values['transformCTL'])]
lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name)
# Remove spaces and parentheses
cs.to_reference_transforms.append(shaper_inverse)
elif 'transformCTLInverse' in odt_values:
ctls = [
- '%s/odt/%s' % (
- aces_CTL_directory, odt_values['transformCTLInverse']),
- '%s/rrt/InvRRT.a1.0.0.ctl' % aces_CTL_directory,
+ os.path.join(aces_CTL_directory,
+ 'odt',
+ odt_values['transformCTLInverse']),
+ os.path.join(aces_CTL_directory,
+ 'rrt',
+ 'InvRRT.a1.0.0.ctl'),
shaper_from_ACES_CTL % aces_CTL_directory
]
lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name)
# Log 2 shaper name and CTL transforms bundled up
log2_shaper_data = [
log2_shaper_name,
- '%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',
+ os.path.join('%s',
+ 'utilities',
+ 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
+ os.path.join('%s',
+ 'utilities',
+ 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
shaper_input_scale_generic_log2,
- log2_params
- ]
+ log2_params]
shaper_data[log2_shaper_name] = log2_shaper_data
args += ['--cubesize', str(lut_resolution_3d)]
args += ['--format',
'icc',
- '%s/photoshop/%s for %s.icc' % (baked_directory,
- odt_name,
- input_space)]
+ os.path.join(baked_directory,
+ 'photoshop',
+ '%s for %s.icc' % (odt_name, input_space))]
bake_LUT = Process(description='bake a LUT',
cmd='ociobakelut',
'--shapersize', str(lut_resolution_shaper)]
args += ['--cubesize', str(lut_resolution_3d)]
- fargs = ['--format', 'flame', '%s/flame/%s for %s Flame.3dl' % (
- baked_directory, odt_name, input_space)]
+ fargs = ['--format',
+ 'flame',
+ os.path.join(
+ baked_directory,
+ 'flame',
+ '%s for %s Flame.3dl' % (odt_name, input_space))]
bake_LUT = Process(description='bake a LUT',
cmd='ociobakelut',
args=(args + fargs))
bake_LUT.execute()
- largs = ['--format', 'lustre', '%s/lustre/%s for %s Lustre.3dl' % (
- baked_directory, odt_name, input_space)]
+ largs = ['--format',
+ 'lustre',
+ os.path.join(
+ baked_directory,
+ 'lustre',
+ '%s for %s Lustre.3dl' % (odt_name, input_space))]
bake_LUT = Process(description='bake a LUT',
cmd='ociobakelut',
args=(args + largs))
args += ['--cubesize', str(lut_resolution_3d)]
- margs = ['--format', 'cinespace', '%s/maya/%s for %s Maya.csp' % (
- baked_directory, odt_name, input_space)]
+ margs = ['--format',
+ 'cinespace',
+ os.path.join(
+ baked_directory,
+ 'maya',
+ '%s for %s Maya.csp' % (odt_name, input_space))]
bake_LUT = Process(description='bake a LUT',
cmd='ociobakelut',
args=(args + margs))
bake_LUT.execute()
- hargs = ['--format', 'houdini',
- '%s/houdini/%s for %s Houdini.lut' % (
- baked_directory, odt_name, input_space)]
+ hargs = ['--format',
+ 'houdini',
+ os.path.join(
+ baked_directory,
+ 'houdini',
+ '%s for %s Houdini.lut' % (odt_name, input_space))]
bake_LUT = Process(description='bake a LUT',
cmd='ociobakelut',
args=(args + hargs))
Return value description.
"""
- dirs = [config_directory, '%s/luts' % config_directory]
+ dirs = [config_directory, os.path.join(config_directory, 'luts')]
if bake_secondary_LUTs:
- dirs.extend(['%s/baked' % config_directory,
- '%s/baked/flame' % config_directory,
- '%s/baked/photoshop' % config_directory,
- '%s/baked/houdini' % config_directory,
- '%s/baked/lustre' % config_directory,
- '%s/baked/maya' % config_directory])
+ dirs.extend([os.path.join(config_directory, 'baked'),
+ os.path.join(config_directory, 'baked', 'flame'),
+ os.path.join(config_directory, 'baked', 'photoshop'),
+ os.path.join(config_directory, 'baked', 'houdini'),
+ os.path.join(config_directory, 'baked', 'lustre'),
+ os.path.join(config_directory, 'baked', 'maya')])
for d in dirs:
not os.path.exists(d) and os.mkdir(d)
(transform_ID,
transform_user_name,
transform_user_name_prefix) = get_transform_info(
- '%s/odt/%s/%s' % (aces_CTL_directory, odt_dir, transform_CTL))
+ os.path.join(aces_CTL_directory, 'odt', odt_dir, transform_CTL))
# Find inverse
transform_CTL_inverse = 'InvODT.%s.ctl' % odt_name
(transform_ID,
transform_user_name,
transform_user_name_prefix) = get_transform_info(
- '%s/%s/%s' % (aces_CTL_directory, lmt_dir, transform_CTL))
+ os.path.join(aces_CTL_directory, lmt_dir, transform_CTL))
# Find inverse
transform_CTL_inverse = 'InvLMT.%s.ctl' % lmt_name
create_config_dir(config_directory, bake_secondary_LUTs)
# Generate config data and LUTs for different transforms
- lut_directory = '%s/luts' % config_directory
+ lut_directory = os.path.join(config_directory, 'luts')
shaper_name = 'Output Shaper'
config_data = generate_LUTs(odt_info,
lmt_info,
print('\n\n\n')
# Write the config to disk
- write_config(config, '%s/config.ocio' % config_directory)
+ write_config(config,
+ os.path.join(config_directory, 'config.ocio'))
# Create a config that will work well with Nuke using the previously
# generated LUTs.
print('\n\n\n')
# Write the config to disk
- write_config(nuke_config, '%s/nuke_config.ocio' % config_directory)
+ write_config(nuke_config,
+ os.path.join(config_directory, 'nuke_config.ocio'))
# Bake secondary LUTs using the config
if bake_secondary_LUTs:
generate_baked_LUTs(odt_info,
shaper_name,
- '%s/baked' % config_directory,
- '%s/config.ocio' % config_directory,
+ os.path.join(config_directory, 'baked'),
+ os.path.join(config_directory, 'config.ocio'),
lut_resolution_1d,
lut_resolution_3d,
lut_resolution_1d)