Roles now have some assignments
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / create_aces_config.py
index 525da6b..1de65b1 100755 (executable)
@@ -5,6 +5,8 @@
 Defines objects creating the *ACES* configuration.
 """
 
+from __future__ import division
+
 import os
 import sys
 
@@ -13,6 +15,7 @@ import PyOpenColorIO as ocio
 import aces_ocio.create_aces_colorspaces as aces
 import aces_ocio.create_arri_colorspaces as arri
 import aces_ocio.create_canon_colorspaces as canon
+import aces_ocio.create_panasonic_colorspaces as panasonic
 import aces_ocio.create_red_colorspaces as red
 import aces_ocio.create_sony_colorspaces as sony
 import aces_ocio.create_general_colorspaces as general
@@ -152,12 +155,11 @@ def generate_OCIO_transform(transforms):
     interpolation_options = {
         'linear': ocio.Constants.INTERP_LINEAR,
         'nearest': ocio.Constants.INTERP_NEAREST,
-        'tetrahedral': ocio.Constants.INTERP_TETRAHEDRAL
-    }
+        'tetrahedral': ocio.Constants.INTERP_TETRAHEDRAL}
+
     direction_options = {
         'forward': ocio.Constants.TRANSFORM_DIR_FORWARD,
-        'inverse': ocio.Constants.TRANSFORM_DIR_INVERSE
-    }
+        'inverse': ocio.Constants.TRANSFORM_DIR_INVERSE}
 
     ocio_transforms = []
 
@@ -210,7 +212,6 @@ def generate_OCIO_transform(transforms):
                                                       direction_options[
                                                           'forward'])
             ocio_transforms.append(ocio_transform)
-
         # unknown type
         else:
             print("Ignoring unknown transform type : %s" % transform['type'])
@@ -226,7 +227,9 @@ def generate_OCIO_transform(transforms):
     return transform
 
 
-def add_colorspace_alias(config, reference_colorspace, colorspace,
+def add_colorspace_alias(config,
+                         reference_colorspace,
+                         colorspace,
                          colorspace_alias_names):
     """
     Object description.
@@ -246,10 +249,10 @@ def add_colorspace_alias(config, reference_colorspace, colorspace,
         if alias_name == colorspace.name.lower():
             return
 
-        print( "Adding alias colorspace space %s, alias to %s" % (
+        print('Adding alias colorspace space %s, alias to %s' % (
             alias_name, colorspace.name))
 
-        compact_family_name = "Aliases"
+        compact_family_name = 'Aliases'
 
         ocio_colorspace_alias = ocio.ColorSpace(
             name=alias_name,
@@ -261,8 +264,8 @@ def add_colorspace_alias(config, reference_colorspace, colorspace,
             allocation=colorspace.allocation_type,
             allocationVars=colorspace.allocation_vars)
 
-        if colorspace.to_reference_transforms != []:
-            print("Generating To-Reference transforms")
+        if not colorspace.to_reference_transforms:
+            print('Generating To-Reference transforms')
             ocio_transform = generate_OCIO_transform(
                 [{'type': 'colorspace',
                   'src': colorspace.name,
@@ -272,8 +275,8 @@ def add_colorspace_alias(config, reference_colorspace, colorspace,
                 ocio_transform,
                 ocio.Constants.COLORSPACE_DIR_TO_REFERENCE)
 
-        if colorspace.from_reference_transforms != []:
-            print("Generating From-Reference transforms")
+        if not colorspace.from_reference_transforms:
+            print('Generating From-Reference transforms')
             ocio_transform = generate_OCIO_transform(
                 [{'type': 'colorspace',
                   'src': reference_colorspace.name,
@@ -410,15 +413,15 @@ def create_config(config_data, nuke=False):
 
     set_config_default_roles(
         config,
-        color_picking=reference.getName(),
-        color_timing=reference.getName(),
-        compositing_log=reference.getName(),
-        data=reference.getName(),
-        default=reference.getName(),
-        matte_paint=reference.getName(),
-        reference=reference.getName(),
-        scene_linear=reference.getName(),
-        texture_paint=reference.getName())
+        color_picking=config_data['roles']['color_picking'],
+        color_timing=config_data['roles']['color_timing'],
+        compositing_log=config_data['roles']['compositing_log'],
+        data=config_data['roles']['data'],
+        default=config_data['roles']['default'],
+        matte_paint=config_data['roles']['matte_paint'],
+        reference=config_data['roles']['reference'],
+        scene_linear=config_data['roles']['scene_linear'],
+        texture_paint=config_data['roles']['texture_paint'])
 
     config.sanityCheck()
 
@@ -428,7 +431,7 @@ def create_config(config_data, nuke=False):
 def generate_LUTs(odt_info,
                   lmt_info,
                   shaper_name,
-                  aces_CTL_directory,
+                  aces_ctl_directory,
                   lut_directory,
                   lut_resolution_1d=4096,
                   lut_resolution_3d=64,
@@ -463,16 +466,18 @@ def generate_LUTs(odt_info,
     (aces_reference,
      aces_colorspaces,
      aces_displays,
-     aces_log_display_space) = aces.create_colorspaces(aces_CTL_directory,
-                                                       lut_directory,
-                                                       lut_resolution_1d,
-                                                       lut_resolution_3d,
-                                                       lmt_info,
-                                                       odt_info,
-                                                       shaper_name,
-                                                       cleanup)
+     aces_log_display_space,
+     aces_roles) = aces.create_colorspaces(aces_ctl_directory,
+                                           lut_directory,
+                                           lut_resolution_1d,
+                                           lut_resolution_3d,
+                                           lmt_info,
+                                           odt_info,
+                                           shaper_name,
+                                           cleanup)
 
     config_data['referenceColorSpace'] = aces_reference
+    config_data['roles'] = aces_roles
 
     for cs in aces_colorspaces:
         config_data['colorSpaces'].append(cs)
@@ -487,7 +492,7 @@ def generate_LUTs(odt_info,
     # *Camera Input Transforms*
     # -------------------------------------------------------------------------
 
-    # *Log-C* to *ACES*.
+    # *ARRI Log-C* to *ACES*.
     arri_colorSpaces = arri.create_colorspaces(lut_directory,
                                                lut_resolution_1d)
     for cs in arri_colorSpaces:
@@ -499,6 +504,12 @@ def generate_LUTs(odt_info,
     for cs in canon_colorspaces:
         config_data['colorSpaces'].append(cs)
 
+    # *Panasonic V-Log* to *ACES*.
+    panasonic_colorSpaces = panasonic.create_colorspaces(lut_directory,
+                                                         lut_resolution_1d)
+    for cs in panasonic_colorSpaces:
+        config_data['colorSpaces'].append(cs)
+
     # *RED* colorspaces to *ACES*.
     red_colorspaces = red.create_colorspaces(lut_directory,
                                              lut_resolution_1d)
@@ -520,6 +531,18 @@ def generate_LUTs(odt_info,
     for cs in general_colorSpaces:
         config_data['colorSpaces'].append(cs)
 
+    # The *Raw* color space
+    raw = general.create_raw()
+    config_data['colorSpaces'].append(raw)
+
+    # Override 'linear' display
+    config_data['linearDisplaySpace'] = raw
+
+    # Override certain roles, for now
+    config_data['roles']['data'] = raw.name
+    config_data['roles']['reference'] = raw.name
+    config_data['roles']['texture_paint'] = raw.name
+
     print('generateLUTs - end')
     return config_data
 
@@ -547,22 +570,22 @@ def generate_baked_LUTs(odt_info,
 
     # Create two entries for ODTs that have full and legal range support
     odt_info_C = dict(odt_info)
-    for odt_CTL_name, odt_values in odt_info.iteritems():
+    for odt_ctl_name, odt_values in odt_info.iteritems():
         if odt_values['transformHasFullLegalSwitch']:
             odt_name = odt_values['transformUserName']
 
             odt_values_legal = dict(odt_values)
             odt_values_legal['transformUserName'] = '%s - Legal' % odt_name
-            odt_info_C['%s - Legal' % odt_CTL_name] = odt_values_legal
+            odt_info_C['%s - Legal' % odt_ctl_name] = odt_values_legal
 
             odt_values_full = dict(odt_values)
             odt_values_full['transformUserName'] = '%s - Full' % odt_name
-            odt_info_C['%s - Full' % odt_CTL_name] = odt_values_full
+            odt_info_C['%s - Full' % odt_ctl_name] = odt_values_full
 
-            del (odt_info_C[odt_CTL_name])
+            del (odt_info_C[odt_ctl_name])
 
     # Generate appropriate LUTs for each ODT
-    for odt_CTL_name, odt_values in odt_info_C.iteritems():
+    for odt_ctl_name, odt_values in odt_info_C.iteritems():
         odt_prefix = odt_values['transformUserNamePrefix']
         odt_name = odt_values['transformUserName']
 
@@ -585,10 +608,10 @@ def generate_baked_LUTs(odt_info,
                                   'photoshop',
                                   '%s for %s.icc' % (odt_name, input_space))]
 
-            bake_LUT = Process(description='bake a LUT',
+            bake_lut = Process(description='bake a LUT',
                                cmd='ociobakelut',
                                args=args)
-            bake_LUT.execute()
+            bake_lut.execute()
 
         # *Flame*, *Lustre*
         for input_space in ['ACEScc', 'ACESproxy']:
@@ -609,10 +632,10 @@ def generate_baked_LUTs(odt_info,
                          baked_directory,
                          'flame',
                          '%s for %s Flame.3dl' % (odt_name, input_space))]
-            bake_LUT = Process(description='bake a LUT',
+            bake_lut = Process(description='bake a LUT',
                                cmd='ociobakelut',
                                args=(args + fargs))
-            bake_LUT.execute()
+            bake_lut.execute()
 
             largs = ['--format',
                      'lustre',
@@ -620,10 +643,10 @@ def generate_baked_LUTs(odt_info,
                          baked_directory,
                          'lustre',
                          '%s for %s Lustre.3dl' % (odt_name, input_space))]
-            bake_LUT = Process(description='bake a LUT',
+            bake_lut = Process(description='bake a LUT',
                                cmd='ociobakelut',
                                args=(args + largs))
-            bake_LUT.execute()
+            bake_lut.execute()
 
         # *Maya*, *Houdini*
         for input_space in ['ACEScg', 'ACES2065-1']:
@@ -649,10 +672,10 @@ def generate_baked_LUTs(odt_info,
                          baked_directory,
                          'maya',
                          '%s for %s Maya.csp' % (odt_name, input_space))]
-            bake_LUT = Process(description='bake a LUT',
+            bake_lut = Process(description='bake a LUT',
                                cmd='ociobakelut',
                                args=(args + margs))
-            bake_LUT.execute()
+            bake_lut.execute()
 
             hargs = ['--format',
                      'houdini',
@@ -660,10 +683,10 @@ def generate_baked_LUTs(odt_info,
                          baked_directory,
                          'houdini',
                          '%s for %s Houdini.lut' % (odt_name, input_space))]
-            bake_LUT = Process(description='bake a LUT',
+            bake_lut = Process(description='bake a LUT',
                                cmd='ociobakelut',
                                args=(args + hargs))
-            bake_LUT.execute()
+            bake_lut.execute()
 
 
 def create_config_dir(config_directory, bake_secondary_LUTs):
@@ -697,7 +720,7 @@ def create_config_dir(config_directory, bake_secondary_LUTs):
     return lut_directory
 
 
-def create_ACES_config(aces_CTL_directory,
+def create_ACES_config(aces_ctl_directory,
                        config_directory,
                        lut_resolution_1d=4096,
                        lut_resolution_3d=64,
@@ -719,14 +742,14 @@ def create_ACES_config(aces_CTL_directory,
 
     lut_directory = create_config_dir(config_directory, bake_secondary_LUTs)
 
-    odt_info = aces.get_ODT_info(aces_CTL_directory)
-    lmt_info = aces.get_LMT_info(aces_CTL_directory)
+    odt_info = aces.get_ODTs_info(aces_ctl_directory)
+    lmt_info = aces.get_LMTs_info(aces_ctl_directory)
 
     shaper_name = 'Output Shaper'
     config_data = generate_LUTs(odt_info,
                                 lmt_info,
                                 shaper_name,
-                                aces_CTL_directory,
+                                aces_ctl_directory,
                                 lut_directory,
                                 lut_resolution_1d,
                                 lut_resolution_3d,
@@ -790,11 +813,11 @@ def main():
 
     options, arguments = p.parse_args()
 
-    aces_CTL_directory = options.acesCTLDir
+    aces_ctl_directory = options.acesCTLDir
     config_directory = options.configDir
     lut_resolution_1d = int(options.lutResolution1d)
     lut_resolution_3d = int(options.lutResolution3d)
-    bake_secondary_LUTs = not options.dontBakeSecondaryLUTs
+    bake_secondary_luts = not options.dontBakeSecondaryLUTs
     cleanup_temp_images = not options.keepTempImages
 
     # TODO: Investigate the following statements.
@@ -807,7 +830,7 @@ def main():
 
     print('command line : \n%s\n' % ' '.join(sys.argv))
 
-    assert aces_CTL_directory is not None, (
+    assert aces_ctl_directory is not None, (
         'process: No "{0}" environment variable defined or no "ACES CTL" '
         'directory specified'.format(
             ACES_OCIO_CTL_DIRECTORY_ENVIRON))
@@ -817,11 +840,11 @@ def main():
         'directory specified'.format(
             ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON))
 
-    return create_ACES_config(aces_CTL_directory,
+    return create_ACES_config(aces_ctl_directory,
                               config_directory,
                               lut_resolution_1d,
                               lut_resolution_3d,
-                              bake_secondary_LUTs,
+                              bake_secondary_luts,
                               cleanup_temp_images)