X-Git-Url: http://users.mur.at/ms/git/gitweb/?a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2Fcreate_aces_colorspaces.py;h=54b6708cdc902bebe077b353b53ffe171ec178c8;hb=24460c4f42d9e44101d414ef15579e5f7d250bb7;hp=0a79ec6d98ecf9af235444db35e11fcd424e8a28;hpb=1c4efc5c67e2313dfadf4a0786baaabd8d6489a6;p=OpenColorIO-Configs.git diff --git a/aces_1.0.0/python/aces_ocio/create_aces_colorspaces.py b/aces_1.0.0/python/aces_ocio/create_aces_colorspaces.py index 0a79ec6..54b6708 100644 --- a/aces_1.0.0/python/aces_ocio/create_aces_colorspaces.py +++ b/aces_1.0.0/python/aces_ocio/create_aces_colorspaces.py @@ -5,6 +5,8 @@ Implements support for *ACES* colorspaces conversions and transfer functions. """ +from __future__ import division + import math import numpy import os @@ -49,16 +51,26 @@ __all__ = ['ACES_AP1_TO_AP0', 'get_LMTs_info', 'create_colorspaces'] -# Matrix converting *ACES AP1* primaries to *AP0*. +# Matrix converting *ACES AP1* primaries to *ACES AP0*. ACES_AP1_TO_AP0 = [0.6954522414, 0.1406786965, 0.1638690622, 0.0447945634, 0.8596711185, 0.0955343182, -0.0055258826, 0.0040252103, 1.0015006723] +# Matrix converting *ACES AP0* primaries to *ACES AP1*. +ACES_AP0_TO_AP1 = [1.4514393161, -0.2365107469, -0.2149285693, + -0.0765537734, 1.1762296998, -0.0996759264, + 0.0083161484, -0.0060324498, 0.9977163014] + # Matrix converting *ACES AP0* primaries to *XYZ*. ACES_AP0_TO_XYZ = [0.9525523959, 0.0000000000, 0.0000936786, 0.3439664498, 0.7281660966, -0.0721325464, 0.0000000000, 0.0000000000, 1.0088251844] +# Matrix converting *ACES AP0* primaries to *XYZ*. +ACES_XYZ_TO_AP0 = [1.0498110175, 0.0000000000, -0.0000974845, + -0.4959030231, 1.3733130458, 0.0982400361, + 0.0000000000, 0.0000000000, 0.9912520182] + def create_ACES(): """ @@ -84,7 +96,7 @@ def create_ACES(): aces2065_1.family = 'ACES' aces2065_1.is_data = False aces2065_1.allocation_type = ocio.Constants.ALLOCATION_LG2 - aces2065_1.allocation_vars = [-15, 6] + aces2065_1.allocation_vars = [-8, 5, 0.00390625] return aces2065_1 @@ -94,9 +106,9 @@ def create_ACEScc(aces_ctl_directory, lut_resolution_1d, cleanup, name='ACEScc', - min_value=0.0, - max_value=1.0, - input_scale=1.0): + min_value=0, + max_value=1, + input_scale=1): """ Creates the *ACEScc* colorspace. @@ -117,17 +129,13 @@ def create_ACEScc(aces_ctl_directory, cs.equality_group = '' cs.family = 'ACES' cs.is_data = False + cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM + cs.allocation_vars = [min_value, max_value] 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 + 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl')] + lut = '%s_to_linear.spi1d' % name lut = sanitize(lut) @@ -137,12 +145,13 @@ def create_ACEScc(aces_ctl_directory, lut_resolution_1d, 'float', input_scale, - 1.0, - {}, + 1, + {'transferFunctionOnly':1}, cleanup, aces_ctl_directory, min_value, - max_value) + max_value, + 1) cs.to_reference_transforms = [] cs.to_reference_transforms.append({ @@ -190,13 +199,13 @@ def create_ACESproxy(aces_ctl_directory, ctls = [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: - os.path.join(aces_ctl_directory, - 'ACEScg', - 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')] - lut = '%s_to_aces.spi1d' % name + # 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_linear.spi1d' % name lut = sanitize(lut) @@ -205,11 +214,14 @@ def create_ACESproxy(aces_ctl_directory, ctls, lut_resolution_1d, 'uint16', - 64.0, - 1.0, + 64, + 1, {}, cleanup, - aces_ctl_directory) + aces_ctl_directory, + 0, + 1, + 1) cs.to_reference_transforms = [] cs.to_reference_transforms.append({ @@ -256,6 +268,8 @@ def create_ACEScg(aces_ctl_directory, cs.equality_group = '' cs.family = 'ACES' cs.is_data = False + cs.allocation_type = ocio.Constants.ALLOCATION_LG2 + cs.allocation_vars = [-8, 5, 0.00390625] cs.to_reference_transforms = [] @@ -300,18 +314,18 @@ def create_ADX(lut_directory, if bit_depth == 10: cs.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] + ADX_to_CDD = [1023 / 500, 0, 0, 0, + 0, 1023 / 500, 0, 0, + 0, 0, 1023 / 500, 0, + 0, 0, 0, 1] + offset = [-95 / 500, -95 / 500, -95 / 500, 0] elif bit_depth == 16: cs.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, - 0.0, 0.0, 0.0, 1.0] - offset = [-1520.0 / 8000.0, -1520.0 / 8000.0, -1520.0 / 8000.0, 0.0] + ADX_to_CDD = [65535 / 8000, 0, 0, 0, + 0, 65535 / 8000, 0, 0, + 0, 0, 65535 / 8000, 0, + 0, 0, 0, 1] + offset = [-1520 / 8000, -1520 / 8000, -1520 / 8000, 0] cs.to_reference_transforms = [] @@ -328,7 +342,7 @@ def create_ADX(lut_directory, 'matrix': [0.75573, 0.22197, 0.02230, 0, 0.05901, 0.96928, -0.02829, 0, 0.16134, 0.07406, 0.76460, 0, - 0.0, 0.0, 0.0, 1.0], + 0, 0, 0, 1], 'direction': 'forward'}) # Copied from *Alex Fry*'s *adx_cid_to_rle.py* @@ -361,13 +375,13 @@ def create_ADX(lut_directory, -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 - 1520) / 8000 * (100 / 55) - + math.log(0.18, 10)) def cid_to_rle(x): if x <= 0.6: return interpolate_1D(x, LUT_1D_xp, LUT_1D_fp) - return (100.0 / 55.0) * x - REF_PT + return (100 / 55) * x - REF_PT def fit(value, from_min, from_max, to_min, to_max): if from_min == from_max: @@ -376,11 +390,11 @@ def create_ADX(lut_directory, to_max - to_min) + to_min num_samples = 2 ** 12 - domain = (-0.19, 3.0) + domain = (-0.19, 3) data = [] for i in xrange(num_samples): - x = i / (num_samples - 1.0) - x = fit(x, 0.0, 1.0, domain[0], domain[1]) + x = i / (num_samples - 1) + x = fit(x, 0, 1, domain[0], domain[1]) data.append(cid_to_rle(x)) lut = 'ADX_CID_to_RLE.spi1d' @@ -414,13 +428,190 @@ def create_ADX(lut_directory, 'matrix': [0.72286, 0.12630, 0.15084, 0, 0.11923, 0.76418, 0.11659, 0, 0.01427, 0.08213, 0.90359, 0, - 0.0, 0.0, 0.0, 1.0], + 0, 0, 0, 1], + 'direction': 'forward'}) + + cs.from_reference_transforms = [] + return cs + +# ------------------------------------------------------------------------- +# *Generic Log Transform* +# ------------------------------------------------------------------------- +def create_generic_log(aces_ctl_directory, + lut_directory, + lut_resolution_1d, + cleanup, + name='log', + aliases=[], + min_value=0, + max_value=1, + input_scale=1, + middle_grey=0.18, + min_exposure=-6, + max_exposure=6.5): + """ + Creates the *Generic Log* colorspace. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + Colorspace + *Generic Log* colorspace. + """ + + cs = ColorSpace(name) + cs.description = 'The %s color space' % name + cs.aliases = aliases + cs.equality_group = name + cs.family = 'Utility' + cs.is_data = False + + ctls = [os.path.join( + aces_ctl_directory, + 'utilities', + 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')] + lut = '%s_to_linear.spi1d' % name + + lut = sanitize(lut) + + generate_1d_LUT_from_CTL( + os.path.join(lut_directory, lut), + ctls, + lut_resolution_1d, + 'float', + input_scale, + 1, + {'middleGrey': middle_grey, + 'minExposure': min_exposure, + 'maxExposure': max_exposure}, + cleanup, + aces_ctl_directory, + min_value, + max_value, + 1) + + cs.to_reference_transforms = [] + cs.to_reference_transforms.append({ + 'type': 'lutFile', + 'path': lut, + 'interpolation': 'linear', + 'direction': 'forward'}) + + cs.from_reference_transforms = [] + return cs + +# ------------------------------------------------------------------------- +# *base Dolby PQ Transform* +# ------------------------------------------------------------------------- +def create_dolbypq(aces_CTL_directory, + lut_directory, + lut_resolution_1d, + cleanup, + name='pq', + aliases=[], + min_value=0.0, + max_value=1.0, + input_scale=1.0): + cs = ColorSpace(name) + cs.description = 'The %s color space' % name + cs.aliases = aliases + cs.equality_group = name + cs.family = 'Utility' + cs.is_data = False + + ctls = [os.path.join( + aces_CTL_directory, + 'utilities', + 'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl')] + lut = '%s_to_linear.spi1d' % name + + lut = sanitize(lut) + + generate_1d_LUT_from_CTL( + os.path.join(lut_directory, lut), + ctls, + lut_resolution_1d, + 'float', + input_scale, + 1.0, + {}, + cleanup, + aces_CTL_directory, + min_value, + max_value) + + cs.to_reference_transforms = [] + cs.to_reference_transforms.append({ + 'type': 'lutFile', + 'path': lut, + 'interpolation': 'linear', 'direction': 'forward'}) cs.from_reference_transforms = [] return cs +# ------------------------------------------------------------------------- +# *Dolby PQ Transform that considers a fixed linear range* +# ------------------------------------------------------------------------- +def create_dolbypq_scaled(aces_CTL_directory, + lut_directory, + lut_resolution_1d, + cleanup, + name='pq', + aliases=[], + min_value=0.0, + max_value=1.0, + input_scale=1.0, + middle_grey=0.18, + min_exposure=-6.0, + max_exposure=6.5): + cs = ColorSpace(name) + cs.description = 'The %s color space' % name + cs.aliases = aliases + cs.equality_group = name + cs.family = 'Utility' + cs.is_data = False + + ctls = [os.path.join( + aces_CTL_directory, + 'utilities', + 'ACESlib.OCIO_shaper_dolbypq_to_lin_param.a1.0.0.ctl')] + lut = '%s_to_linear.spi1d' % name + + lut = sanitize(lut) + + generate_1d_LUT_from_CTL( + os.path.join(lut_directory, lut), + ctls, + lut_resolution_1d, + 'float', + input_scale, + 1.0, + {'middleGrey': middle_grey, + 'minExposure': min_exposure, + 'maxExposure': max_exposure}, + cleanup, + aces_CTL_directory, + min_value, + max_value) + + cs.to_reference_transforms = [] + cs.to_reference_transforms.append({ + 'type': 'lutFile', + 'path': lut, + 'interpolation': 'linear', + 'direction': 'forward'}) + + cs.from_reference_transforms = [] + return cs +# ------------------------------------------------------------------------- +# *Individual LMT* +# ------------------------------------------------------------------------- def create_ACES_LMT(lmt_name, lmt_values, shaper_info, @@ -429,7 +620,7 @@ def create_ACES_LMT(lmt_name, lut_resolution_1d=1024, lut_resolution_3d=64, cleanup=True, - aliases=[]): + aliases=None): """ Creates the *ACES LMT* colorspace. @@ -444,12 +635,17 @@ def create_ACES_LMT(lmt_name, *ACES LMT* colorspace. """ + if aliases is None: + aliases = [] + cs = ColorSpace('%s' % lmt_name) cs.description = 'The ACES Look Transform: %s' % lmt_name cs.aliases = aliases cs.equality_group = '' cs.family = 'Look' cs.is_data = False + cs.allocation_type = ocio.Constants.ALLOCATION_LG2 + cs.allocation_vars = [-8, 5, 0.00390625] pprint.pprint(lmt_values) @@ -460,22 +656,9 @@ def create_ACES_LMT(lmt_name, shaper_input_scale, shaper_params) = shaper_info - shaper_lut = '%s_to_aces.spi1d' % shaper_name - if not os.path.exists(os.path.join(lut_directory, shaper_lut)): - ctls = [shaper_to_ACES_CTL % aces_ctl_directory] - - shaper_lut = sanitize(shaper_lut) - - generate_1d_LUT_from_CTL( - os.path.join(lut_directory, shaper_lut), - ctls, - lut_resolution_1d, - 'float', - 1.0 / shaper_input_scale, - 1.0, - shaper_params, - cleanup, - aces_ctl_directory) + # Add the shaper transform + shaper_lut = '%s_to_linear.spi1d' % shaper_name + shaper_lut = sanitize(shaper_lut) shaper_OCIO_transform = { 'type': 'lutFile', @@ -499,8 +682,8 @@ def create_ACES_LMT(lmt_name, ctls, lut_resolution_3d, 'float', - 1.0 / shaper_input_scale, - 1.0, + 1 / shaper_input_scale, + 1, shaper_params, cleanup, aces_ctl_directory) @@ -517,9 +700,7 @@ def create_ACES_LMT(lmt_name, if 'transformCTLInverse' in lmt_values: ctls = [os.path.join(aces_ctl_directory, - # TODO: Investigate "odt_values" undeclared - # variable. - odt_values['transformCTLInverse']), + lmt_values['transformCTLInverse']), shaper_from_ACES_CTL % aces_ctl_directory] lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name) @@ -530,11 +711,14 @@ def create_ACES_LMT(lmt_name, ctls, lut_resolution_3d, 'half', - 1.0, + 1, shaper_input_scale, shaper_params, cleanup, - aces_ctl_directory) + aces_ctl_directory, + 0, + 1, + 1) cs.to_reference_transforms.append({ 'type': 'lutFile', @@ -548,7 +732,93 @@ def create_ACES_LMT(lmt_name, return cs +# ------------------------------------------------------------------------- +# *LMTs* +# ------------------------------------------------------------------------- +def create_LMTs(aces_ctl_directory, + lut_directory, + lut_resolution_1d, + lut_resolution_3d, + lmt_info, + shaper_name, + cleanup): + """ + Object description. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + + colorspaces = [] + + # ------------------------------------------------------------------------- + # *LMT Shaper* + # ------------------------------------------------------------------------- + lmt_lut_resolution_1d = max(4096, lut_resolution_1d) + lmt_lut_resolution_3d = max(65, lut_resolution_3d) + + # Defining the *Log 2* shaper. + lmt_shaper_name = 'LMT Shaper' + lmt_shaper_name_aliases = ['crv_lmtshaper'] + lmt_params = { + 'middleGrey': 0.18, + 'minExposure': -10, + 'maxExposure': 6.5} + + lmt_shaper = create_generic_log(aces_ctl_directory, + lut_directory, + lmt_lut_resolution_1d, + cleanup, + name=lmt_shaper_name, + middle_grey=lmt_params['middleGrey'], + min_exposure=lmt_params['minExposure'], + max_exposure=lmt_params['maxExposure'], + aliases=lmt_shaper_name_aliases) + colorspaces.append(lmt_shaper) + + shaper_input_scale_generic_log2 = 1 + + # *Log 2* shaper name and *CTL* transforms bundled up. + lmt_shaper_data = [ + lmt_shaper_name, + 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] + + sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1]) + print(sorted_LMTs) + for lmt in sorted_LMTs: + lmt_name, lmt_values = lmt + lmt_aliases = ["look_%s" % compact(lmt_values['transformUserName'])] + cs = create_ACES_LMT( + lmt_values['transformUserName'], + lmt_values, + lmt_shaper_data, + aces_ctl_directory, + lut_directory, + lmt_lut_resolution_1d, + lmt_lut_resolution_3d, + cleanup, + lmt_aliases) + colorspaces.append(cs) + return colorspaces + +# ------------------------------------------------------------------------- +# *ACES RRT* with supplied *ODT*. +# ------------------------------------------------------------------------- def create_ACES_RRT_plus_ODT(odt_name, odt_values, shaper_info, @@ -557,7 +827,7 @@ def create_ACES_RRT_plus_ODT(odt_name, lut_resolution_1d=1024, lut_resolution_3d=64, cleanup=True, - aliases=[]): + aliases=None): """ Object description. @@ -572,6 +842,9 @@ def create_ACES_RRT_plus_ODT(odt_name, Return value description. """ + if aliases is None: + aliases = [] + cs = ColorSpace('%s' % odt_name) cs.description = '%s - %s Output Transform' % ( odt_values['transformUserNamePrefix'], odt_name) @@ -594,22 +867,9 @@ def create_ACES_RRT_plus_ODT(odt_name, else: shaper_params['legalRange'] = 0 - shaper_lut = '%s_to_aces.spi1d' % shaper_name - if not os.path.exists(os.path.join(lut_directory, shaper_lut)): - ctls = [shaper_to_ACES_CTL % aces_ctl_directory] - - shaper_lut = sanitize(shaper_lut) - - generate_1d_LUT_from_CTL( - os.path.join(lut_directory, shaper_lut), - ctls, - lut_resolution_1d, - 'float', - 1.0 / shaper_input_scale, - 1.0, - shaper_params, - cleanup, - aces_ctl_directory) + # Add the shaper transform + shaper_lut = '%s_to_linear.spi1d' % shaper_name + shaper_lut = sanitize(shaper_lut) shaper_OCIO_transform = { 'type': 'lutFile', @@ -651,8 +911,8 @@ def create_ACES_RRT_plus_ODT(odt_name, ctls, lut_resolution_3d, 'float', - 1.0 / shaper_input_scale, - 1.0, + 1 / shaper_input_scale, + 1, shaper_params, cleanup, aces_ctl_directory) @@ -700,7 +960,7 @@ def create_ACES_RRT_plus_ODT(odt_name, ctls, lut_resolution_3d, 'half', - 1.0, + 1, shaper_input_scale, shaper_params, cleanup, @@ -718,156 +978,9 @@ def create_ACES_RRT_plus_ODT(odt_name, return cs - -def create_generic_log(aces_ctl_directory, - lut_directory, - lut_resolution_1d, - cleanup, - name='log', - aliases=[], - min_value=0.0, - max_value=1.0, - input_scale=1.0, - middle_grey=0.18, - min_exposure=-6.0, - max_exposure=6.5): - """ - Creates the *Generic Log* colorspace. - - Parameters - ---------- - parameter : type - Parameter description. - - Returns - ------- - Colorspace - *Generic Log* colorspace. - """ - - cs = ColorSpace(name) - cs.description = 'The %s color space' % name - cs.aliases = aliases - cs.equality_group = name - cs.family = 'Utility' - cs.is_data = False - - ctls = [os.path.join( - aces_ctl_directory, - 'utilities', - 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')] - lut = '%s_to_aces.spi1d' % name - - lut = sanitize(lut) - - generate_1d_LUT_from_CTL( - os.path.join(lut_directory, lut), - ctls, - lut_resolution_1d, - 'float', - input_scale, - 1.0, - {'middleGrey': middle_grey, - 'minExposure': min_exposure, - 'maxExposure': max_exposure}, - cleanup, - aces_ctl_directory, - min_value, - max_value) - - cs.to_reference_transforms = [] - cs.to_reference_transforms.append({ - 'type': 'lutFile', - 'path': lut, - 'interpolation': 'linear', - 'direction': 'forward'}) - - cs.from_reference_transforms = [] - return cs - - -def create_LMTs(aces_ctl_directory, - lut_directory, - lut_resolution_1d, - lut_resolution_3d, - lmt_info, - shaper_name, - cleanup): - """ - Object description. - - Parameters - ---------- - parameter : type - Parameter description. - - Returns - ------- - type - Return value description. - """ - - colorspaces = [] - - # ------------------------------------------------------------------------- - # *LMT Shaper* - # ------------------------------------------------------------------------- - lmt_lut_resolution_1d = max(4096, lut_resolution_1d) - lmt_lut_resolution_3d = max(65, lut_resolution_3d) - - # Defining the *Log 2* shaper. - lmt_shaper_name = 'LMT Shaper' - lmt_shaper_name_aliases = ['crv_lmtshaper'] - lmt_params = { - 'middleGrey': 0.18, - 'minExposure': -10.0, - 'maxExposure': 6.5} - - lmt_shaper = create_generic_log(aces_ctl_directory, - lut_directory, - lmt_lut_resolution_1d, - cleanup, - name=lmt_shaper_name, - middle_grey=lmt_params['middleGrey'], - min_exposure=lmt_params['minExposure'], - max_exposure=lmt_params['maxExposure'], - aliases=lmt_shaper_name_aliases) - colorspaces.append(lmt_shaper) - - shaper_input_scale_generic_log2 = 1.0 - - # *Log 2* shaper name and *CTL* transforms bundled up. - lmt_shaper_data = [ - lmt_shaper_name, - 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] - - sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1]) - print(sorted_LMTs) - for lmt in sorted_LMTs: - lmt_name, lmt_values = lmt - lmt_aliases = ["look_%s" % compact(lmt_values['transformUserName'])] - cs = create_ACES_LMT( - lmt_values['transformUserName'], - lmt_values, - lmt_shaper_data, - aces_ctl_directory, - lut_directory, - lmt_lut_resolution_1d, - lmt_lut_resolution_3d, - cleanup, - lmt_aliases) - colorspaces.append(cs) - - return colorspaces - - +# ------------------------------------------------------------------------- +# *ODTs* +# ------------------------------------------------------------------------- def create_ODTs(aces_ctl_directory, lut_directory, lut_resolution_1d, @@ -901,13 +1014,13 @@ def create_ODTs(aces_ctl_directory, # Defining the *Log 2* shaper. log2_shaper_name = shaper_name - log2_shaper_name_aliases = ["crv_%s" % compact(shaper_name)] + log2_shaper_name_aliases = ["crv_%s" % compact(log2_shaper_name)] log2_params = { 'middleGrey': 0.18, - 'minExposure': -6.0, + 'minExposure': -6, 'maxExposure': 6.5} - log2_shaper = create_generic_log( + log2_shaper_colorspace = create_generic_log( aces_ctl_directory, lut_directory, lut_resolution_1d, @@ -917,9 +1030,9 @@ def create_ODTs(aces_ctl_directory, min_exposure=log2_params['minExposure'], max_exposure=log2_params['maxExposure'], aliases=log2_shaper_name_aliases) - colorspaces.append(log2_shaper) + colorspaces.append(log2_shaper_colorspace) - shaper_input_scale_generic_log2 = 1.0 + shaper_input_scale_generic_log2 = 1 # *Log 2* shaper name and *CTL* transforms bundled up. log2_shaper_data = [ @@ -935,30 +1048,99 @@ def create_ODTs(aces_ctl_directory, shaper_data[log2_shaper_name] = log2_shaper_data - # Shaper that also includes the AP1 primaries. + # Space with a more user-friendly name. Direct copy otherwise. + log2_shaper_copy_name = "Log2 Shaper" + log2_shaper_copy_colorspace = ColorSpace(log2_shaper_copy_name) + log2_shaper_copy_colorspace.description = 'The %s color space' % log2_shaper_copy_name + log2_shaper_copy_colorspace.aliases = [compact(log2_shaper_copy_name)] + log2_shaper_copy_colorspace.equality_group = log2_shaper_copy_name + log2_shaper_copy_colorspace.family = log2_shaper_colorspace.family + log2_shaper_copy_colorspace.is_data = log2_shaper_colorspace.is_data + log2_shaper_copy_colorspace.to_reference_transforms = list(log2_shaper_colorspace.to_reference_transforms) + log2_shaper_copy_colorspace.from_reference_transforms = list(log2_shaper_colorspace.from_reference_transforms) + colorspaces.append(log2_shaper_copy_colorspace) + + # Defining the *Log2 shaper that includes the AP1* primaries. # Needed for some LUT baking steps. - log2_shaper_api1_name_aliases = ["%s_ap1" % compact(shaper_name)] - log2_shaper_ap1 = create_generic_log( - aces_ctl_directory, - lut_directory, - lut_resolution_1d, - cleanup, - name=log2_shaper_name, - middle_grey=log2_params['middleGrey'], - min_exposure=log2_params['minExposure'], - max_exposure=log2_params['maxExposure'], - aliases=log2_shaper_api1_name_aliases) - log2_shaper_ap1.name = '%s - AP1' % log2_shaper_ap1.name + log2_shaper_api1_name = "%s - AP1" % "Log2 Shaper" + log2_shaper_api1_colorspace = ColorSpace(log2_shaper_api1_name) + log2_shaper_api1_colorspace.description = 'The %s color space' % log2_shaper_api1_name + log2_shaper_api1_colorspace.aliases = ["%s_ap1" % compact(log2_shaper_copy_name)] + log2_shaper_api1_colorspace.equality_group = log2_shaper_api1_name + log2_shaper_api1_colorspace.family = log2_shaper_colorspace.family + log2_shaper_api1_colorspace.is_data = log2_shaper_colorspace.is_data + log2_shaper_api1_colorspace.to_reference_transforms = list(log2_shaper_colorspace.to_reference_transforms) + log2_shaper_api1_colorspace.from_reference_transforms = list(log2_shaper_colorspace.from_reference_transforms) # *AP1* primaries to *AP0* primaries. - log2_shaper_ap1.to_reference_transforms.append({ + log2_shaper_api1_colorspace.to_reference_transforms.append({ 'type': 'matrix', 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0), 'direction': 'forward' }) - colorspaces.append(log2_shaper_ap1) + colorspaces.append(log2_shaper_api1_colorspace) + + # Define the base *Dolby PQ Shaper* + # + dolbypq_shaper_name = "Dolby PQ 10000" + dolbypq_shaper_name_aliases = ["crv_%s" % "dolbypq_10000"] + + dolbypq_shaper_colorspace = create_dolbypq( + aces_ctl_directory, + lut_directory, + lut_resolution_1d, + cleanup, + name=dolbypq_shaper_name, + aliases=dolbypq_shaper_name_aliases) + colorspaces.append(dolbypq_shaper_colorspace) + + # *Dolby PQ* shaper name and *CTL* transforms bundled up. + dolbypq_shaper_data = [ + dolbypq_shaper_name, + os.path.join('%s', + 'utilities', + 'ACESlib.OCIO_shaper_dolbypq_to_lin.a1.0.0.ctl'), + os.path.join('%s', + 'utilities', + 'ACESlib.OCIO_shaper_lin_to_dolbypq.a1.0.0.ctl'), + 1.0, + {}] + + shaper_data[dolbypq_shaper_name] = dolbypq_shaper_data + + # Define the *Dolby PQ Shaper that considers a fixed linear range* + # + dolbypq_scaled_shaper_name = "Dolby PQ Scaled" + dolbypq_scaled_shaper_name_aliases = ["crv_%s" % "dolbypq_scaled"] + dolbypq_scaled_shaper_colorspace = create_dolbypq_scaled( + aces_ctl_directory, + lut_directory, + lut_resolution_1d, + cleanup, + name=dolbypq_scaled_shaper_name, + aliases=dolbypq_scaled_shaper_name_aliases) + colorspaces.append(dolbypq_scaled_shaper_colorspace) + + # *Dolby PQ* shaper name and *CTL* transforms bundled up. + dolbypq_scaled_shaper_data = [ + dolbypq_scaled_shaper_name, + os.path.join('%s', + 'utilities', + 'ACESlib.OCIO_shaper_dolbypq_to_lin_param.a1.0.0.ctl'), + os.path.join('%s', + 'utilities', + 'ACESlib.OCIO_shaper_lin_to_dolbypq_param.a1.0.0.ctl'), + 1.0, + log2_params] + + shaper_data[dolbypq_scaled_shaper_name] = dolbypq_scaled_shaper_data + + # + # Pick a specific shaper + # rrt_shaper = log2_shaper_data + #rrt_shaper = dolbypq_scaled_shaper_data # *RRT + ODT* combinations. sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1]) @@ -1268,7 +1450,8 @@ def create_colorspaces(aces_ctl_directory, ACES = create_ACES() ACEScc = create_ACEScc(aces_ctl_directory, lut_directory, - lut_resolution_1d, cleanup) + lut_resolution_1d, cleanup, + min_value=-0.35840, max_value=1.468) colorspaces.append(ACEScc) ACESproxy = create_ACESproxy(aces_ctl_directory, lut_directory, @@ -1305,4 +1488,15 @@ def create_colorspaces(aces_ctl_directory, ACEScc) colorspaces.extend(odts) - return ACES, colorspaces, displays, ACEScc + roles = {'color_picking' : ACEScg.name, + 'color_timing' : ACEScc.name, + 'compositing_log' : ACEScc.name, + 'data' : '', + 'default' : ACES.name, + 'matte_paint' : ACEScc.name, + 'reference' : '', + 'scene_linear' : ACEScg.name, + 'texture_paint' : ''} + + + return ACES, colorspaces, displays, ACEScc, roles