Created and used shapers appropriate to HDR Output Transform.
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / generate_config.py
index f16cd29..7d4ea60 100755 (executable)
@@ -685,18 +685,16 @@ def create_config(config_data,
             matte_paint=prefixed_names[config_data['roles']['matte_paint']],
             reference=prefixed_names[config_data['roles']['reference']],
             scene_linear=prefixed_names[config_data['roles']['scene_linear']],
+            compositing_linear=prefixed_names[config_data['roles']['scene_linear']],
+            rendering=prefixed_names[config_data['roles']['scene_linear']],
             texture_paint=prefixed_names[
                 config_data['roles']['texture_paint']])
 
-        # TODO: Pending code path reactivation.
-        # Not allowed at the moment as role names can not overlap
-        # with colorspace names.
-        """
         # Add the aliased colorspaces for each role
         for role_name, role_colorspace_name in config_data['roles'].iteritems():
             role_colorspace_prefixed_name = prefixed_names[role_colorspace_name]
 
-            print( 'Finding colorspace : %s' % role_colorspace_prefixed_name )
+            #print( 'Finding colorspace : %s' % role_colorspace_prefixed_name )
             # Find the colorspace pointed to by the role
             role_colorspaces = [colorspace
                 for colorspace in config_data['colorSpaces']
@@ -709,12 +707,18 @@ def create_config(config_data,
                     role_colorspace = reference_data
 
             if role_colorspace:
-                print( 'Adding an alias colorspace named %s, pointing to %s' % (
-                    role_name, role_colorspace.name))
+                # The alias colorspace shouldn't match the role name exactly
+                role_name_alias1 = "role_%s" % role_name
+                role_name_alias2 = "Role - %s" % role_name
+
+                print( 'Adding a role colorspace named %s, pointing to %s' % (
+                    role_name_alias2, role_colorspace.name))
+
+                alias_colorspaces.append(
+                (reference_data, role_colorspace, [role_name_alias1]))
 
                 add_colorspace_aliases(
-                config, reference_data, role_colorspace, [role_name], 'Roles')
-        """
+                config, reference_data, role_colorspace, [role_name_alias2], 'Roles')
 
     else:
         set_config_roles(
@@ -727,12 +731,10 @@ def create_config(config_data,
             matte_paint=config_data['roles']['matte_paint'],
             reference=config_data['roles']['reference'],
             scene_linear=config_data['roles']['scene_linear'],
+            compositing_linear=config_data['roles']['scene_linear'],
+            rendering=config_data['roles']['scene_linear'],
             texture_paint=config_data['roles']['texture_paint'])
 
-        # TODO: Pending code path reactivation.
-        # Not allowed at the moment as role names can not overlap
-        # with colorspace names.
-        """
         # Add the aliased colorspaces for each role
         for role_name, role_colorspace_name in config_data['roles'].iteritems():
             # Find the colorspace pointed to by the role
@@ -747,12 +749,18 @@ def create_config(config_data,
                     role_colorspace = reference_data
 
             if role_colorspace:
-                print('Adding an alias colorspace named %s, pointing to %s' % (
-                    role_name, role_colorspace.name))
+                # The alias colorspace shouldn't match the role name exactly
+                role_name_alias1 = "role_%s" % role_name
+                role_name_alias2 = "Role - %s" % role_name
+
+                print('Adding a role colorspace named %s, pointing to %s' % (
+                    role_name_alias2, role_colorspace.name))
+
+                alias_colorspaces.append(
+                (reference_data, role_colorspace, [role_name_alias1]))
 
                 add_colorspace_aliases(
-                config, reference_data, role_colorspace, [role_name], 'Roles')
-        """
+                config, reference_data, role_colorspace, [role_name_alias2], 'Roles')
 
     print('')
 
@@ -776,10 +784,6 @@ def create_config(config_data,
     default_display_views = config_data['displays'][default_display_name]
     default_display_colorspace = default_display_views['Output Transform']
 
-    set_config_roles(
-        config,
-        color_picking=default_display_colorspace.name)
-
     # Defining *Displays* and *Views*.
     displays, views = [], []
 
@@ -1129,6 +1133,15 @@ def generate_baked_LUTs(odt_info,
         odt_prefix = odt_values['transformUserNamePrefix']
         odt_name = odt_values['transformUserName']
 
+        if odt_name in ['P3-D60 PQ (1000 nits)']:
+            odt_shaper = shaper_name.replace("48nits", "1000nits")
+        elif odt_name in ['P3-D60 PQ (2000 nits)']:
+            odt_shaper = shaper_name.replace("48nits", "2000nits")
+        elif odt_name in ['P3-D60 PQ (4000 nits)']:
+            odt_shaper = shaper_name.replace("48nits", "4000nits")
+        else:
+            odt_shaper = shaper_name
+
         # *Photoshop*
         for input_space in ['ACEScc', 'ACESproxy']:
             args = ['--iconfig', config_path,
@@ -1145,10 +1158,10 @@ def generate_baked_LUTs(odt_info,
                                               odt_name,
                                               input_space)]
             if prefix:
-                args += ['--shaperspace', 'Utility - %s' % shaper_name,
+                args += ['--shaperspace', 'Utility - %s' % odt_shaper,
                          '--shapersize', str(lut_resolution_shaper)]
             else:
-                args += ['--shaperspace', shaper_name,
+                args += ['--shaperspace', odt_shaper,
                          '--shapersize', str(lut_resolution_shaper)]
             args += ['--cubesize', str(lut_resolution_3d)]
             args += ['--format',
@@ -1176,10 +1189,10 @@ def generate_baked_LUTs(odt_info,
                      '%s - %s for %s data' % (
                          odt_prefix, odt_name, input_space)]
             if prefix:
-                args += ['--shaperspace', 'Utility - %s' % shaper_name,
+                args += ['--shaperspace', 'Utility - %s' % odt_shaper,
                          '--shapersize', str(lut_resolution_shaper)]
             else:
-                args += ['--shaperspace', shaper_name,
+                args += ['--shaperspace', odt_shaper,
                          '--shapersize', str(lut_resolution_shaper)]
             args += ['--cubesize', str(lut_resolution_3d)]
 
@@ -1219,9 +1232,9 @@ def generate_baked_LUTs(odt_info,
                      '%s - %s for %s data' % (
                          odt_prefix, odt_name, input_space)]
             if input_space == 'ACEScg':
-                lin_shaper_name = '%s - AP1' % shaper_name
+                lin_shaper_name = '%s - AP1' % odt_shaper
             else:
-                lin_shaper_name = shaper_name
+                lin_shaper_name = odt_shaper
             if prefix:
                 lin_shaper_name = 'Utility - %s' % lin_shaper_name
             args += ['--shaperspace', lin_shaper_name,
@@ -1298,7 +1311,8 @@ def generate_config(aces_ctl_directory,
                     look_info=None,
                     copy_custom_luts=True,
                     cleanup=True,
-                    prefix_colorspaces_with_family_names=True):
+                    prefix_colorspaces_with_family_names=True,
+                    shaper_base_name='Log2'):
     """
     Creates the ACES configuration.
 
@@ -1327,7 +1341,11 @@ def generate_config(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'
+    if shaper_base_name == 'DolbyPQ':
+        shaper_name = 'Dolby PQ 48nits Shaper'
+    else:
+        shaper_name = 'Log2 48nits Shaper'
+
     config_data = create_config_data(odt_info,
                                      lmt_info,
                                      shaper_name,
@@ -1432,7 +1450,13 @@ def main():
               'ACEScc colorspace, but the user could choose other spaces '
               'by changing the argument after the name of the look. \n')
     usage += '\n'
-
+    usage += ('Create a GUI-friendly ACES 1.0 config using the Dolby PQ '
+              'transfer function as the shaper: \n')
+    usage += ('\tcreate_aces_config -a /path/to/aces-dev/transforms/ctl '
+              '--lutResolution1d 1024 --lutResolution3d 33 -c aces_1.0.0 '
+              '--shaper DolbyPQ')
+    usage += '\n'
     look_info = []
 
     def look_info_callback(option, opt_str, value, parser):
@@ -1473,6 +1497,8 @@ def main():
                  action='callback', callback=look_info_callback)
     p.add_option('--copyCustomLUTs', action='store_true', default=False)
 
+    p.add_option('--shaper', '-s', default='Log2')
+
     options, arguments = p.parse_args()
 
     aces_ctl_directory = options.acesCTLDir
@@ -1483,6 +1509,8 @@ def main():
     cleanup_temp_images = not options.keepTempImages
     multiple_displays = options.createMultipleDisplays
     copy_custom_luts = options.copyCustomLUTs
+    shaper_base_name = options.shaper
+    prefix = True
 
     print(look_info)
 
@@ -1506,7 +1534,9 @@ def main():
                            multiple_displays,
                            look_info,
                            copy_custom_luts,
-                           cleanup_temp_images)
+                           cleanup_temp_images,
+                           prefix,
+                           shaper_base_name)
 
 
 if __name__ == '__main__':