Skip to content

Instantly share code, notes, and snippets.

@zachlewis
Last active July 17, 2021 23:00
Show Gist options
  • Save zachlewis/3275d4893414d2c278487612121ecc68 to your computer and use it in GitHub Desktop.
Save zachlewis/3275d4893414d2c278487612121ecc68 to your computer and use it in GitHub Desktop.
OCIO 2.0 test config
import PyOpenColorIO as ocio
import numpy as np
import colour as colour
from six import string_types
__version__ = "2020.11.08.0"
OUTPUT = "/tmp/test_config.ocio2"
def _rgba_tuple(x, alpha=1.):
return [x] * 3 + [float(alpha)]
def get_name(obj):
"""Retrieve the name of an OCIO object"""
if isinstance(obj, string_types):
return obj
return obj.getName()
def display_cctf(gamma=1., offset=None, direction=None, negative_style=None):
if offset:
cctf = ocio.ExponentWithLinearTransform()
cctf.setGamma(_rgba_tuple(gamma))
cctf.setOffset(_rgba_tuple(offset, alpha=0.))
else:
cctf = ocio.ExponentTransform(_rgba_tuple(gamma))
if direction:
cctf.setDirection(direction)
if negative_style:
cctf.setNegativeStyle(negative_style)
return cctf
def get_camera_colorspaces(family=''):
colorspaces = []
# get Camera Log colorspaces from Builtins
for name, description in ocio.BuiltinTransformRegistry().getBuiltins():
if name.endswith('to_ACES2065-1'):
cs = ocio.ColorSpace(
name=description.split('Convert ')[-1].split(' to ')[0],
family=family,
encoding='log',
toReference=ocio.BuiltinTransform(name))
colorspaces.append(cs)
return colorspaces
def _simplify_transform(transform, optimization=ocio.OPTIMIZATION_VERY_GOOD,
direction=ocio.TRANSFORM_DIR_FORWARD,
config=None, context=None):
config = config or ocio.GetCurrentConfig()
context = context or config.getCurrentContext()
proc = config.getProcessor(transform=transform, context=context, direction=direction)
gt = proc.getOptimizedProcessor(optimization).createGroupTransform()
return gt[0] if len(gt) < 2 else gt
def _convert_numpy_matrix33_to_matrix_transform(matrix33, direction=OCIO.TRANSFORM_DIR_FORWARD):
mtx = np.pad(np.array(matrix33).flatten().reshape(3, 3), [(0, 1), (0, 1)]).flatten()
mtx[-1] = 1
return OCIO.MatrixTransform(matrix=mtx, direction=direction)
def _convert_matrix_transform_to_numpy_matrix33(matrix_transform, direction=OCIO.TRANSFORM_DIR_FORWARD):
mt = (_simplify_transform(matrix_transform, direction=direction))
return np.array(mt.getMatrix()).reshape(4, 4)[:3, :3]
def display_linear_lut_transform(lut, input_colorspace, output_colorspace,
scene_reference_colorspace='ACES2065-1',
display_reference_colorspace='CIE-XYZ D65',
interpolation=ocio.INTERP_BEST):
transform = ocio.GroupTransform([
ocio.ColorSpaceTransform(src=get_name(scene_reference_colorspace),
dst=get_name(input_colorspace)),
ocio.FileTransform(src=lut, interpolation=interpolation),
ocio.ColorSpaceTransform(src=get_name(output_colorspace),
dst=get_name(display_reference_colorspace))
])
return transform
# Builtins
identity = ocio.BuiltinTransform()
# XYZ
ap0_to_xyz = ocio.BuiltinTransform('ACES-AP0_to_CIE-XYZ-D65_BFD')
xyz_to_ap0 = ocio.BuiltinTransform('ACES-AP0_to_CIE-XYZ-D65_BFD', ocio.TRANSFORM_DIR_INVERSE )
ap1_to_xyz = ocio.BuiltinTransform('ACES-AP1_to_CIE-XYZ-D65_BFD')
xyz_to_ap1 = ocio.BuiltinTransform('ACES-AP1_to_CIE-XYZ-D65_BFD', ocio.TRANSFORM_DIR_INVERSE)
# ACES
ap1_to_ap0 = ocio.BuiltinTransform('ACEScg_to_ACES2065-1')
ap0_to_ap1 = ocio.BuiltinTransform('ACEScg_to_ACES2065-1', ocio.TRANSFORM_DIR_INVERSE)
acescct_to_ap0 = ocio.BuiltinTransform('ACEScct_to_ACES2065-1')
acescc_to_ap0 = ocio.BuiltinTransform('ACEScc_to_ACES2065-1')
acesproxy_to_ap0 = ocio.BuiltinTransform('ACESproxy10i_to_ACES2065-1')
adx10_to_ap0 = ocio.BuiltinTransform('ADX10_to_ACES2065-1')
adx16_to_ap0 = ocio.BuiltinTransform('ADX16_to_ACES2065-1')
# Linear
ap1_to_linrec709 = ocio.BuiltinTransform('ACES-AP1_to_LINEAR-REC709_BFD')
linrec709_to_ap1 = ocio.BuiltinTransform('ACES-AP1_to_LINEAR-REC709_BFD', ocio.TRANSFORM_DIR_INVERSE)
# Log
logc_awg_to_ap0 = ocio.BuiltinTransform('ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1')
ap0_to_logc_awg = ocio.BuiltinTransform('ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1', ocio.TRANSFORM_DIR_INVERSE)
rlf_rwg_to_ap0 = ocio.BuiltinTransform('RED_REDLOGFILM-RWG_to_ACES2065-1')
ap0_to_rlf_rwg = ocio.BuiltinTransform('RED_REDLOGFILM-RWG_to_ACES2065-1', ocio.TRANSFORM_DIR_INVERSE)
log3g10_awg_to_ap0 = ocio.BuiltinTransform('RED_LOG3G10-RWG_to_ACES2065-1')
slg3_sgc_to_ap0 = ocio.BuiltinTransform('SONY_SLOG3-SGAMUT3.CINE_to_ACES2065-1')
slg3_sg_to_ap0 = ocio.BuiltinTransform('SONY_SLOG3-SGAMUT3_to_ACES2065-1')
clg2_to_ap0 = ocio.BuiltinTransform('CANON_CLOG2-CGAMUT_to_ACES2065-1')
clg3_to_ap0 = ocio.BuiltinTransform('CANON_CLOG3-CGAMUT_to_ACES2065-1')
pnlg_to_ap0 = ocio.BuiltinTransform('PANASONIC_VLOG-VGAMUT_to_ACES2065-1')
# Shapers
acescct_cctf = ocio.BuiltinTransform('ACEScct-LOG_to_LIN')
SDR_DRTS = {
'ARRI K1S1': ocio.GroupTransform([
ap0_to_logc_awg,
ocio.FileTransform(src="LogCv3_AWG3_to_K1S1_709.spi3d", interpolation=ocio.INTERP_TETRAHEDRAL),
display_cctf(gamma=2.4),
linrec709_to_ap1,
ap1_to_xyz,
]),
'ARRI ALF2': ocio.GroupTransform([
ap0_to_logc_awg,
ocio.FileTransform(src="LogCv3_AWG3_to_ALF2_709.spi3d", interpolation=ocio.INTERP_TETRAHEDRAL),
display_cctf(gamma=2.4),
linrec709_to_ap1,
ap1_to_xyz,
]),
'RED IPP2': ocio.GroupTransform([
ap0_to_rlf_rwg,
ocio.FileTransform(src='Log3G10_RWG_to_IPP2_709.spi3d', interpolation=ocio.INTERP_TETRAHEDRAL),
display_cctf(gamma=2.4),
linrec709_to_ap1,
ap1_to_xyz,
]),
'ACES 1.2': ocio.GroupTransform([
ap0_to_ap1,
ocio.FileTransform('ACEScg_to_ACES_Rec709.csp', interpolation=ocio.INTERP_TETRAHEDRAL),
display_cctf(gamma=2.4),
linrec709_to_ap1,
ap1_to_xyz,
]),
'Filmlight T-CAM': ocio.GroupTransform([
# TODO: double-check matrix
ocio.MatrixTransform(matrix=[0.742249, 0.172616, 0.085135, 0, 0.024648, 1.03823, -0.062878, 0, -0.095295, -0.066945, 1.16224, 0, 0, 0, 0, 1], direction=ocio.TRANSFORM_DIR_INVERSE),
ocio.FileTransform(src='T_Log_to_linear.spi1d', interpolation=ocio.INTERP_LINEAR, direction=ocio.TRANSFORM_DIR_INVERSE),
ocio.FileTransform('T_Log_E_Gamut_to_T_CAM_709.spi3d', interpolation=ocio.INTERP_TETRAHEDRAL),
display_cctf(gamma=2.4),
linrec709_to_ap1,
ap1_to_xyz,
]),
}
## COLOR SPACES
raw = ocio.ColorSpace(
name="raw",
description="Raw / non-color data",
family="Utility",
equalityGroup='nc',
isData=True,
encoding='data',
categories=['utility']
)
# Reference ColorSpaces
ACES = ocio.ColorSpace(
referenceSpace=ocio.ReferenceSpaceType.REFERENCE_SPACE_SCENE,
name="ACES2065-1",
description="Linear with AP0 primaries",
family="Linear",
encoding='scene-linear',
equalityGroup='aces',
bitDepth=ocio.BIT_DEPTH_F16,
# categories=[CategoryNames.Input.value]
)
XYZ = ocio.ColorSpace(
referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
name="CIE-XYZ D65",
description="CIE-XYZ (D65-aligned)",
family="Utility",
equalityGroup='xyz',
encoding='display-linear',
bitDepth=ocio.BIT_DEPTH_UINT16,
)
# Linear ColorSpaces
ACEScg = ocio.ColorSpace(
name="ACEScg",
description="Linear with AP1 primaries",
family="Linear",
encoding='scene-linear',
allocation=ocio.ALLOCATION_LG2,
allocationVars=[-8, 5, 0.00390625],
equalityGroup="acescg",
bitDepth=ocio.BIT_DEPTH_F16,
toReference=ocio.BuiltinTransform('ACEScg_to_ACES2065-1'),
)
LinearRec709 = ocio.ColorSpace(
name="Linear Rec709",
description="Linear with Rec.709 primaries",
family="Linear",
encoding='scene-linear',
equalityGroup="lin709",
allocationVars=[-8, 5, 0.00390625],
allocation=ocio.ALLOCATION_LG2,
bitDepth=ocio.BIT_DEPTH_F16,
fromReference=ocio.GroupTransform([
ocio.BuiltinTransform('ACEScg_to_ACES2065-1', ocio.TRANSFORM_DIR_INVERSE),
ocio.BuiltinTransform("ACES-AP1_to_LINEAR-REC709_BFD")
]),
)
# Log ColorSpaces
ACEScc = ocio.ColorSpace(
name="ACEScc",
description="ACEScc with AP1 primaries",
family="ACES",
encoding='log',
equalityGroup="acescc",
bitDepth=ocio.BIT_DEPTH_UINT12,
toReference=ocio.BuiltinTransform('ACEScc_to_ACES2065-1'),
)
ACEScct = ocio.ColorSpace(
name="ACEScct",
description="ACEScct with AP1 primaries",
family="ACES",
encoding='log',
equalityGroup="acescct",
bitDepth=ocio.BIT_DEPTH_UINT12,
toReference=ocio.BuiltinTransform('ACEScct_to_ACES2065-1'),
)
ACESproxy = ocio.ColorSpace(
name="ACESproxy",
description="ACESproxy 10i with AP1 primaries",
family="ACES",
encoding='log',
equalityGroup="acesproxy",
bitDepth=ocio.BIT_DEPTH_UINT10,
toReference=ocio.BuiltinTransform('ACESproxy10i_to_ACES2065-1'),
)
ADX16 = ocio.ColorSpace(
name="ADX16",
description="ACES ADX 16-bit",
family="ACES",
encoding='log',
equalityGroup="adx16",
bitDepth=ocio.BIT_DEPTH_UINT16,
toReference=ocio.BuiltinTransform('ADX10_to_ACES2065-1'),
)
ADX10 = ocio.ColorSpace(
name="ADX10",
description="ACES ADX 10-bit",
family="ACES",
encoding='log',
equalityGroup="adx10",
bitDepth=ocio.BIT_DEPTH_UINT10,
toReference=ocio.BuiltinTransform('ADX10_to_ACES2065-1'),
)
LogC_AWG = ocio.ColorSpace(
name="LogC",
description="ARRI ALEXA LogC (EI800) ALEXA Wide Gamut",
family="Camera",
encoding='log',
equalityGroup="lgcawg",
bitDepth=ocio.BIT_DEPTH_UINT12,
toReference=ocio.BuiltinTransform('ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1'),
)
SLog3_SGC = ocio.ColorSpace(
name="SLog3-SGC",
description="Sony S-Log3 S-Gamut3.Cine",
family="Camera",
encoding='log',
equalityGroup="slg3sgc",
bitDepth=ocio.BIT_DEPTH_UINT12,
toReference=ocio.BuiltinTransform('SONY_SLOG3-SGAMUT3.CINE_to_ACES2065-1'),
)
SLog3_SG = ocio.ColorSpace(
name="SLog3",
description="Sony S-Log3 S-Gamut3",
family="Camera",
encoding='log',
equalityGroup="slg3",
bitDepth=ocio.BIT_DEPTH_UINT12,
toReference=ocio.BuiltinTransform('SONY_SLOG3-SGAMUT3_to_ACES2065-1'),
)
Log3G10_RWG = ocio.ColorSpace(
name="Log3G10",
description="RED Log3G10 RED Wide Gamut",
family="Camera",
encoding='log',
equalityGroup="lg3g10",
bitDepth=ocio.BIT_DEPTH_UINT10,
toReference=ocio.BuiltinTransform('RED_LOG3G10-RWG_to_ACES2065-1'),
)
RLF_RWG = ocio.ColorSpace(
name="RedLogFilm",
description="RED LogFilm RED Wide Gamut",
family="Camera",
encoding='log',
equalityGroup="rlfrwg",
bitDepth=ocio.BIT_DEPTH_UINT10,
toReference=ocio.BuiltinTransform('RED_REDLOGFILM-RWG_to_ACES2065-1'),
)
VLog = ocio.ColorSpace(
name="V-Log",
description="Panasonic Varicam V-Log V-Gamut",
family="Camera",
encoding='log',
equalityGroup="vlg",
bitDepth=ocio.BIT_DEPTH_UINT12,
toReference=ocio.BuiltinTransform('PANASONIC_VLOG-VGAMUT_to_ACES2065-1'),
)
CLog2 = ocio.ColorSpace(
name="Canon Log 2",
description="Canon Log 2 Cinema Gamut",
family="Camera",
encoding='log',
equalityGroup="clg2",
bitDepth=ocio.BIT_DEPTH_UINT10,
toReference=ocio.BuiltinTransform('CANON_CLOG2-CGAMUT_to_ACES2065-1'),
)
CLog3 = ocio.ColorSpace(
name="Canon Log 3",
description="Canon Log 3 Cinema Gamut",
family="Camera",
encoding='log',
equalityGroup="clg3",
bitDepth=ocio.BIT_DEPTH_UINT10,
toReference=ocio.BuiltinTransform('CANON_CLOG3-CGAMUT_to_ACES2065-1'),
)
def create_tlog_egamut(name='T-Log',
family='Input',
equality_group='tloge',
description='Filmlight T-Log E-Gamut',
categories=[''],
spi1d='T_Log_to_linear.spi1d'):
xform = ocio.GroupTransform([
ocio.FileTransform(src=spi1d, interpolation=ocio.INTERP_LINEAR),
ocio.MatrixTransform(matrix=[0.742249, 0.172616, 0.085135, 0,
0.024648, 1.03823, -0.062878, 0,
-0.095295, -0.066945, 1.16224, 0,
0, 0, 0, 1])])
return ocio.ColorSpace(
name=name, family=family, description=description, equalityGroup=equality_group,
allocationVars=[0,1], allocation=ocio.ALLOCATION_UNIFORM, bitDepth=ocio.BIT_DEPTH_UINT10,
encoding='log', categories=categories, toReference=xform)
TLog = create_tlog_egamut()
# Display ColorSpaces
sRGB = ocio.ColorSpace(
referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
name="sRGB",
description="sRGB with Rec.709 primaries",
family="Display",
encoding='sdr-video',
equalityGroup="srgb",
bitDepth=ocio.BIT_DEPTH_UINT10,
fromReference=ocio.GroupTransform([
ocio.BuiltinTransform('ACES-AP1_to_CIE-XYZ-D65_BFD', ocio.TRANSFORM_DIR_INVERSE),
ocio.BuiltinTransform('ACES-AP1_to_LINEAR-REC709_BFD'),
display_cctf(gamma=2.4, offset=0.055, direction=ocio.TRANSFORM_DIR_INVERSE)
]),
)
Rec709 = ocio.ColorSpace(
referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
name="Rec709",
description="ITU-R BT.1886 with Rec.709 primaries",
family="Display",
encoding='sdr-video',
equalityGroup="rec1886",
bitDepth=ocio.BIT_DEPTH_UINT10,
fromReference=ocio.GroupTransform([
ocio.BuiltinTransform('ACES-AP1_to_CIE-XYZ-D65_BFD', ocio.TRANSFORM_DIR_INVERSE),
ocio.BuiltinTransform('ACES-AP1_to_LINEAR-REC709_BFD'),
display_cctf(gamma=2.4, direction=ocio.TRANSFORM_DIR_INVERSE)
]),
)
P3_D60 = ocio.ColorSpace(
referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
name="P3",
description="Gamma 2.6 with DCI primaries and whitepoint (D60 sim.)",
family="Display",
equalityGroup="dcip3",
encoding='sdr-video',
bitDepth=ocio.BIT_DEPTH_UINT10,
fromReference=ocio.GroupTransform([
ocio.BuiltinTransform('ACES-AP0_to_CIE-XYZ-D65_BFD', ocio.TRANSFORM_DIR_INVERSE),
_convert_numpy_matrix33_to_matrix_transform(
colour.RGB_to_RGB_matrix(input_colourspace=colour.RGB_COLOURSPACES['ACES2065-1'],
output_colourspace=colour.RGB_COLOURSPACES['DCI-P3'],
chromatic_adaptation_transform='Bradford')
),
display_cctf(gamma=2.6, direction=ocio.TRANSFORM_DIR_INVERSE)
]),
)
P3_D65 = ocio.ColorSpace(
referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
name="P3-D65",
description="Gamma 2.6 with DCI primaries and D65 whitepoint",
family="Display",
equalityGroup="p3d65",
encoding='sdr-video',
bitDepth=ocio.BIT_DEPTH_UINT10,
fromReference=ocio.GroupTransform([
ocio.BuiltinTransform('ACES-AP0_to_CIE-XYZ-D65_BFD', ocio.TRANSFORM_DIR_INVERSE),
_convert_numpy_matrix33_to_matrix_transform(
colour.RGB_to_RGB_matrix(input_colourspace=colour.RGB_COLOURSPACES['ACES2065-1'],
output_colourspace=colour.RGB_COLOURSPACES['P3-D65'],
chromatic_adaptation_transform=None)
),
display_cctf(gamma=2.6, direction=ocio.TRANSFORM_DIR_INVERSE)
]),
)
P3_D65_D60 = ocio.ColorSpace(
referenceSpace=ocio.REFERENCE_SPACE_DISPLAY,
name="P3-D65 (D60 sim.)",
description="Gamma 2.6 with DCI primaries and D65 whitepoint simulating D60",
family="Display",
equalityGroup="p3d65_d60sim",
encoding='sdr-video',
bitDepth=ocio.BIT_DEPTH_UINT10,
fromReference=ocio.GroupTransform([
ocio.BuiltinTransform('ACES-AP0_to_CIE-XYZ-D65_BFD',ocio.TRANSFORM_DIR_INVERSE),
_convert_numpy_matrix33_to_matrix_transform(
colour.RGB_to_RGB_matrix(input_colourspace=colour.RGB_COLOURSPACES['ACES2065-1'],
output_colourspace=colour.RGB_COLOURSPACES['P3-D65'],
chromatic_adaptation_transform='Bradford')
),
display_cctf(gamma=2.6, direction=ocio.TRANSFORM_DIR_INVERSE)
]),
)
# Config building
default_colorspaces = [raw, ACES, XYZ, LinearRec709, ACEScg]
aces_colorspaces = [ACEScct, ACEScc, ACESproxy, ADX16, ADX10]
camera_colorspaces = [LogC_AWG, SLog3_SGC, SLog3_SG, Log3G10_RWG, RLF_RWG, VLog, CLog2, CLog3, TLog]
sdr_display_colorspaces = [sRGB, Rec709, P3_D60, P3_D65, P3_D65_D60]
colorspaces = default_colorspaces + aces_colorspaces + camera_colorspaces + sdr_display_colorspaces
roles = {
ocio.ROLE_SCENE_LINEAR : ACEScg,
ocio.ROLE_COMPOSITING_LOG : ACEScct,
ocio.ROLE_TEXTURE_PAINT : sRGB,
ocio.ROLE_MATTE_PAINT : ACEScct,
ocio.ROLE_COLOR_TIMING : LogC_AWG,
ocio.ROLE_COLOR_PICKING : Rec709,
ocio.ROLE_REFERENCE : ACES,
ocio.ROLE_DATA : raw,
ocio.ROLE_DEFAULT : ACEScg,
'aces_interchange' : ACES,
'cie_xyz_d65_interchange' : XYZ,
}
# looks
neutral = ocio.Look(name='neutral', processSpace=ocio.ROLE_SCENE_LINEAR, transform=ocio.FileTransform('neutral/$SHOT.ctf'))
shot = ocio.Look(name='shot', processSpace=ocio.ROLE_COLOR_TIMING, transform=ocio.FileTransform('shot/$SHOT.ctf'))
looks = [neutral, shot]
# view_transforms
colorimetry = ocio.ViewTransform(name='Colorimetry', fromReference=ap0_to_xyz, referenceSpace=ocio.REFERENCE_SPACE_SCENE)
sdr_aces = ocio.ViewTransform(name='ACES 1.2', fromReference=SDR_DRTS['ACES 1.2'], referenceSpace=ocio.REFERENCE_SPACE_SCENE)
sdr_arri_k1s1 = ocio.ViewTransform(name='ARRI K1S1', fromReference=SDR_DRTS['ARRI K1S1'], referenceSpace=ocio.REFERENCE_SPACE_SCENE)
sdr_arri_alf2 = ocio.ViewTransform(name='ARRI ALF2', fromReference=SDR_DRTS['ARRI ALF2'], referenceSpace=ocio.REFERENCE_SPACE_SCENE)
sdr_red_ipp2 = ocio.ViewTransform(name='RED IPP2', fromReference=SDR_DRTS['RED IPP2'], referenceSpace=ocio.REFERENCE_SPACE_SCENE)
sdr_fl_tcam = ocio.ViewTransform(name='Filmlight T-CAM', fromReference=SDR_DRTS['Filmlight T-CAM'], referenceSpace=ocio.REFERENCE_SPACE_SCENE)
show_lut_709 = ocio.ViewTransform(name='Show (SDR)', fromReference=display_linear_lut_transform('show_lut_rec709.ctf', LogC_AWG, Rec709), referenceSpace=ocio.REFERENCE_SPACE_SCENE)
viewtransforms = [
colorimetry,
sdr_aces,
sdr_arri_k1s1,
sdr_arri_alf2,
sdr_red_ipp2,
sdr_fl_tcam,
show_lut_709
]
search_paths = [
'luts/$SEQ/$SHOT',
'luts/$SEQ',
'luts',
]
environment = {
'$SEQ' : '$SEQUENCE',
'$SHOT': '$SHOT',
}
file_rules_data = [
{
'name': 'Default',
'colorspace': 'ACEScg'
},
{
'name': 'Linear - sRGB',
'colorspace': 'Linear Rec.709',
'regex': '_[sS][rR][gG][bB]\\.([eE][xX][rR]|[hH][dD][rR])$'
},
{
'name': 'EOTF - sRGB',
'colorspace': 'sRGB',
'regex': '_[sS][rR][gG][bB]\\.([pP][nN][gG]|[tT][iI][fF])$'
},
]
viewing_rules_data = [
{
'name': 'Data',
'encoding': 'data',
},
{
'name': 'SDR Video',
'encoding': 'sdr-video',
},
]
# Init config
cfg = ocio.Config.CreateRaw()
cfg.clearColorSpaces()
cfg.clearDisplays()
cfg.clearEnvironmentVars()
cfg.clearLooks()
cfg.clearSearchPaths()
cfg.clearViewTransforms()
# Thomas's FileRules bit
file_rules = ocio.FileRules()
rule_index = 0
for file_rule in file_rules_data[::-1]:
name = file_rule['name']
colorspace = file_rule['colorspace']
regex = file_rule.get('regex', '')
pattern = file_rule.get('pattern', '')
extension = file_rule.get('extension', '')
if name == 'Default':
file_rules.setDefaultRuleColorSpace(colorspace)
elif regex:
file_rules.insertRule(rule_index, name, colorspace, regex)
rule_index += 1
else:
file_rules.insertRule(rule_index, name, colorspace, pattern, extension)
rule_index += 1
cfg.setFileRules(file_rules)
# Viewing Rules
rule_index = 0
viewing_rules = ocio.ViewingRules()
for viewing_rule in viewing_rules_data[::-1]:
name = viewing_rule['name']
encoding = viewing_rule['encoding']
viewing_rules.insertRule(rule_index, name)
viewing_rules.addEncoding(rule_index, encoding)
rule_index += 1
cfg.setViewingRules(viewing_rules)
# Displays, Views, Shared Views
## "DRTs" adapted from Rec.709 LUTs
cfg.addSharedView(view='ACES', viewTransformName=sdr_aces.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="ACES 1.2 OutputTransform")
cfg.addSharedView(view='K1S1', viewTransformName=sdr_arri_k1s1.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="ARRI K1S1")
cfg.addSharedView(view='ALF2', viewTransformName=sdr_arri_alf2.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="ARRI ALF2")
cfg.addSharedView(view='IPP2', viewTransformName=sdr_red_ipp2.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="RED IPP2")
cfg.addSharedView(view='TCAM', viewTransformName=sdr_fl_tcam.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="Filmlight TCAM ")
## Hypothetical complex "camera-native" production pipeline
cfg.addSharedView(view='Show LUT', viewTransformName=show_lut_709.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="Default show LUT")
cfg.addSharedView(view='Client Grade', viewTransformName=show_lut_709.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks='+shot|', ruleName="SDR Video", description="DI / editorial view used for client WIPs")
cfg.addSharedView(view='Inv. Neutral', viewTransformName=show_lut_709.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks='-neutral,+shot|+shot|', ruleName="SDR Video", description="Used to evaluate neutral-graded assets in context")
cfg.addSharedView(view='Neutral', viewTransformName=show_lut_709.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks='+neutral|', ruleName="SDR Video", description="Preview ungraded content as if it were neutral-graded, viewed under the Show LUT")
## Handy defaults
cfg.addSharedView(view='Display', viewTransformName=colorimetry.getName(), colorSpaceName='<USE_DISPLAY_NAME>', looks=None, ruleName="SDR Video", description="Display transfer function")
cfg.addSharedView(view='Log', viewTransformName=None, colorSpaceName=ocio.ROLE_COLOR_TIMING, looks=None, ruleName=None, description="Camera-native log encoding")
cfg.addSharedView(view='None', viewTransformName=None, colorSpaceName=ocio.ROLE_DATA, looks=None, ruleName=None, description="No transform; raw output buffer")
displays = [cs.getName() for cs in sdr_display_colorspaces]
shared_views = cfg.getSharedViews()
for d in displays:
for sv in shared_views:
cfg.addDisplaySharedView(display=d, view=sv)
for path in search_paths:
cfg.addSearchPath(path)
for cs in colorspaces:
cfg.addColorSpace(cs)
for role, name in roles.items():
cfg.setRole(role, get_name(name))
for vt in viewtransforms:
cfg.addViewTransform(vt)
for look in looks:
cfg.addLook(look)
cfg.serialize(OUTPUT)
ocio_profile_version: 2
environment:
{}
search_path:
- luts/$SEQ/$SHOT
- luts/$SEQ
- luts
strictparsing: false
luma: [0.2126, 0.7152, 0.0722]
roles:
aces_interchange: ACES2065-1
cie_xyz_d65_interchange: CIE-XYZ D65
color_picking: Rec709
color_timing: LogC
compositing_log: ACEScct
data: raw
default: ACEScg
matte_paint: ACEScct
reference: ACES2065-1
scene_linear: ACEScg
texture_paint: sRGB
file_rules:
- !<Rule> {name: EOTF - sRGB, colorspace: sRGB, regex: "_[sS][rR][gG][bB]\\.([pP][nN][gG]|[tT][iI][fF])$"}
- !<Rule> {name: Linear - sRGB, colorspace: Linear Rec.709, regex: "_[sS][rR][gG][bB]\\.([eE][xX][rR]|[hH][dD][rR])$"}
- !<Rule> {name: Default, colorspace: ACEScg}
viewing_rules:
- !<Rule> {name: SDR Video, encodings: sdr-video}
- !<Rule> {name: Data, encodings: data}
shared_views:
- !<View> {name: ACES, view_transform: ACES 1.2, display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: ACES 1.2 OutputTransform}
- !<View> {name: K1S1, view_transform: ARRI K1S1, display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: ARRI K1S1}
- !<View> {name: ALF2, view_transform: ARRI ALF2, display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: ARRI ALF2}
- !<View> {name: IPP2, view_transform: RED IPP2, display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: RED IPP2}
- !<View> {name: TCAM, view_transform: Filmlight T-CAM, display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: "Filmlight TCAM "}
- !<View> {name: Show LUT, view_transform: Show (SDR), display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: Default show LUT}
- !<View> {name: Client Grade, view_transform: Show (SDR), display_colorspace: <USE_DISPLAY_NAME>, looks: +shot|, rule: SDR Video, description: DI / editorial view used for client WIPs}
- !<View> {name: Inv. Neutral, view_transform: Show (SDR), display_colorspace: <USE_DISPLAY_NAME>, looks: "-neutral,+shot|+shot|", rule: SDR Video, description: Used to evaluate neutral-graded assets in context}
- !<View> {name: Neutral, view_transform: Show (SDR), display_colorspace: <USE_DISPLAY_NAME>, looks: +neutral|, rule: SDR Video, description: "Preview ungraded content as if it were neutral-graded, viewed under the Show LUT"}
- !<View> {name: Display, view_transform: Colorimetry, display_colorspace: <USE_DISPLAY_NAME>, rule: SDR Video, description: Display transfer function}
- !<View> {name: Log, colorspace: color_timing, description: Camera-native log encoding}
- !<View> {name: None, colorspace: data, description: No transform; raw output buffer}
displays:
sRGB:
- !<Views> [ACES, K1S1, ALF2, IPP2, TCAM, Show LUT, Client Grade, Inv. Neutral, Neutral, Display, Log, None]
active_displays: []
active_views: []
looks:
- !<Look>
name: neutral
process_space: scene_linear
transform: !<FileTransform> {src: neutral/$SHOT.ctf}
- !<Look>
name: shot
process_space: color_timing
transform: !<FileTransform> {src: shot/$SHOT.ctf}
view_transforms:
- !<ViewTransform>
name: Colorimetry
from_reference: !<BuiltinTransform> {style: ACES-AP0_to_CIE-XYZ-D65_BFD}
- !<ViewTransform>
name: ACES 1.2
from_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACEScg_to_ACES2065-1, direction: inverse}
- !<FileTransform> {src: ACEScg_to_ACES_Rec709.csp, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD}
- !<ViewTransform>
name: ARRI K1S1
from_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1, direction: inverse}
- !<FileTransform> {src: LogCv3_AWG3_to_K1S1_709.spi3d, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD}
- !<ViewTransform>
name: ARRI ALF2
from_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1, direction: inverse}
- !<FileTransform> {src: LogCv3_AWG3_to_ALF2_709.spi3d, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD}
- !<ViewTransform>
name: RED IPP2
from_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: RED_REDLOGFILM-RWG_to_ACES2065-1, direction: inverse}
- !<FileTransform> {src: Log3G10_RWG_to_IPP2_709.spi3d, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD}
- !<ViewTransform>
name: Filmlight T-CAM
from_reference: !<GroupTransform>
children:
- !<MatrixTransform> {matrix: [0.742249, 0.172616, 0.085135, 0, 0.024648, 1.03823, -0.062878, 0, -0.095295, -0.066945, 1.16224, 0, 0, 0, 0, 1], direction: inverse}
- !<FileTransform> {src: T_Log_to_linear.spi1d, interpolation: linear, direction: inverse}
- !<FileTransform> {src: T_Log_E_Gamut_to_T_CAM_709.spi3d, interpolation: tetrahedral}
- !<ExponentTransform> {value: 2.4}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD}
- !<ViewTransform>
name: Show (SDR)
from_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: ACES2065-1, dst: LogC}
- !<FileTransform> {src: show_lut_rec709.ctf, interpolation: best}
- !<ColorSpaceTransform> {src: Rec709, dst: CIE-XYZ D65}
display_colorspaces:
- !<ColorSpace>
name: CIE-XYZ D65
family: Utility
equalitygroup: xyz
bitdepth: 16ui
description: |
CIE-XYZ (D65-aligned)
isdata: false
encoding: display-linear
allocation: uniform
- !<ColorSpace>
name: sRGB
family: Display
equalitygroup: srgb
bitdepth: 10ui
description: |
sRGB with Rec.709 primaries
isdata: false
encoding: sdr-video
allocation: uniform
from_display_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD}
- !<ExponentWithLinearTransform> {gamma: 2.4, offset: 0.055, direction: inverse}
- !<ColorSpace>
name: Rec709
family: Display
equalitygroup: rec1886
bitdepth: 10ui
description: |
ITU-R BT.1886 with Rec.709 primaries
isdata: false
encoding: sdr-video
allocation: uniform
from_display_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACES-AP1_to_CIE-XYZ-D65_BFD, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD}
- !<ExponentTransform> {value: 2.4, direction: inverse}
- !<ColorSpace>
name: P3
family: Display
equalitygroup: dcip3
bitdepth: 10ui
description: |
Gamma 2.6 with DCI primaries and whitepoint (D60 sim.)
isdata: false
encoding: sdr-video
allocation: uniform
from_display_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACES-AP0_to_CIE-XYZ-D65_BFD, direction: inverse}
- !<MatrixTransform> {matrix: [2.15460351682917, -0.808496046374252, -0.346107470661378, 0, -0.178877556399727, 1.28056541401808, -0.10168785755967, 0, 0.00862345330683089, -0.0610453897972114, 1.05242193653785, 0, 0, 0, 0, 1]}
- !<ExponentTransform> {value: 2.6, direction: inverse}
- !<ColorSpace>
name: P3-D65
family: Display
equalitygroup: p3d65
bitdepth: 10ui
description: |
Gamma 2.6 with DCI primaries and D65 whitepoint
isdata: false
encoding: sdr-video
allocation: uniform
from_display_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACES-AP0_to_CIE-XYZ-D65_BFD, direction: inverse}
- !<MatrixTransform> {matrix: [2.05482174118154, -0.678201973497355, -0.338848122047797, 0, -0.183834406310746, 1.28351220841912, -0.103389974433019, 0, 0.00794428517242961, -0.0554661513620058, 0.970827072772031, 0, 0, 0, 0, 1]}
- !<ExponentTransform> {value: 2.6, direction: inverse}
- !<ColorSpace>
name: P3-D65 (D60 sim.)
family: Display
equalitygroup: p3d65_d60sim
bitdepth: 10ui
description: |
Gamma 2.6 with DCI primaries and D65 whitepoint simulating D60
isdata: false
encoding: sdr-video
allocation: uniform
from_display_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACES-AP0_to_CIE-XYZ-D65_BFD, direction: inverse}
- !<MatrixTransform> {matrix: [2.02490528583951, -0.689069761022005, -0.335835525009256, 0, -0.18359703216255, 1.28950620773514, -0.105909175513408, 0, 0.00905856111801875, -0.0592796840564543, 1.05022112298584, 0, 0, 0, 0, 1]}
- !<ExponentTransform> {value: 2.6, direction: inverse}
colorspaces:
- !<ColorSpace>
name: raw
family: Utility
equalitygroup: nc
bitdepth: unknown
description: |
Raw / non-color data
isdata: true
categories: [utility]
encoding: data
allocation: uniform
- !<ColorSpace>
name: ACES2065-1
family: Linear
equalitygroup: aces
bitdepth: 16f
description: |
Linear with AP0 primaries
isdata: false
encoding: scene-linear
allocation: uniform
- !<ColorSpace>
name: Linear Rec709
family: Linear
equalitygroup: lin709
bitdepth: 16f
description: |
Linear with Rec.709 primaries
isdata: false
encoding: scene-linear
allocation: lg2
allocationvars: [-8, 5, 0.00390625]
from_reference: !<GroupTransform>
children:
- !<BuiltinTransform> {style: ACEScg_to_ACES2065-1, direction: inverse}
- !<BuiltinTransform> {style: ACES-AP1_to_LINEAR-REC709_BFD}
- !<ColorSpace>
name: ACEScg
family: Linear
equalitygroup: acescg
bitdepth: 16f
description: |
Linear with AP1 primaries
isdata: false
encoding: scene-linear
allocation: lg2
allocationvars: [-8, 5, 0.00390625]
to_reference: !<BuiltinTransform> {style: ACEScg_to_ACES2065-1}
- !<ColorSpace>
name: ACEScct
family: ACES
equalitygroup: acescct
bitdepth: 12ui
description: |
ACEScct with AP1 primaries
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: ACEScct_to_ACES2065-1}
- !<ColorSpace>
name: ACEScc
family: ACES
equalitygroup: acescc
bitdepth: 12ui
description: |
ACEScc with AP1 primaries
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: ACEScc_to_ACES2065-1}
- !<ColorSpace>
name: ACESproxy
family: ACES
equalitygroup: acesproxy
bitdepth: 10ui
description: |
ACESproxy 10i with AP1 primaries
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: ACESproxy10i_to_ACES2065-1}
- !<ColorSpace>
name: ADX16
family: ACES
equalitygroup: adx16
bitdepth: 16ui
description: |
ACES ADX 16-bit
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: ADX10_to_ACES2065-1}
- !<ColorSpace>
name: ADX10
family: ACES
equalitygroup: adx10
bitdepth: 10ui
description: |
ACES ADX 10-bit
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: ADX10_to_ACES2065-1}
- !<ColorSpace>
name: LogC
family: Camera
equalitygroup: lgcawg
bitdepth: 12ui
description: |
ARRI ALEXA LogC (EI800) ALEXA Wide Gamut
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1}
- !<ColorSpace>
name: SLog3-SGC
family: Camera
equalitygroup: slg3sgc
bitdepth: 12ui
description: |
Sony S-Log3 S-Gamut3.Cine
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: SONY_SLOG3-SGAMUT3.CINE_to_ACES2065-1}
- !<ColorSpace>
name: SLog3
family: Camera
equalitygroup: slg3
bitdepth: 12ui
description: |
Sony S-Log3 S-Gamut3
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: SONY_SLOG3-SGAMUT3_to_ACES2065-1}
- !<ColorSpace>
name: Log3G10
family: Camera
equalitygroup: lg3g10
bitdepth: 10ui
description: |
RED Log3G10 RED Wide Gamut
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: RED_LOG3G10-RWG_to_ACES2065-1}
- !<ColorSpace>
name: RedLogFilm
family: Camera
equalitygroup: rlfrwg
bitdepth: 10ui
description: |
RED LogFilm RED Wide Gamut
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: RED_REDLOGFILM-RWG_to_ACES2065-1}
- !<ColorSpace>
name: V-Log
family: Camera
equalitygroup: vlg
bitdepth: 12ui
description: |
Panasonic Varicam V-Log V-Gamut
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: PANASONIC_VLOG-VGAMUT_to_ACES2065-1}
- !<ColorSpace>
name: Canon Log 2
family: Camera
equalitygroup: clg2
bitdepth: 10ui
description: |
Canon Log 2 Cinema Gamut
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: CANON_CLOG2-CGAMUT_to_ACES2065-1}
- !<ColorSpace>
name: Canon Log 3
family: Camera
equalitygroup: clg3
bitdepth: 10ui
description: |
Canon Log 3 Cinema Gamut
isdata: false
encoding: log
allocation: uniform
to_reference: !<BuiltinTransform> {style: CANON_CLOG3-CGAMUT_to_ACES2065-1}
- !<ColorSpace>
name: T-Log
family: Input
equalitygroup: tloge
bitdepth: 10ui
description: |
Filmlight T-Log E-Gamut
isdata: false
categories: [""]
encoding: log
allocation: uniform
allocationvars: [0, 1]
to_reference: !<GroupTransform>
children:
- !<FileTransform> {src: T_Log_to_linear.spi1d, interpolation: linear}
- !<MatrixTransform> {matrix: [0.742249, 0.172616, 0.085135, 0, 0.024648, 1.03823, -0.062878, 0, -0.095295, -0.066945, 1.16224, 0, 0, 0, 0, 1]}
@KelSolaar
Copy link

Thanks this is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment