X-Git-Url: http://users.mur.at/ms/git/gitweb/?p=OpenColorIO-Configs.git;a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2Faces_config.py;h=1fad4b75b31f7edae06d7863afa72cac7dceb3e0;hp=a63acf718abf325374913dd88507b551cacb7bb0;hb=922767a1d6567ea91b98b1796436e94ada818813;hpb=9404c06b163b18672794ced12638b6063fc2b8dd diff --git a/aces_1.0.0/python/aces_ocio/aces_config.py b/aces_1.0.0/python/aces_ocio/aces_config.py index a63acf7..1fad4b7 100755 --- a/aces_1.0.0/python/aces_ocio/aces_config.py +++ b/aces_1.0.0/python/aces_ocio/aces_config.py @@ -21,6 +21,7 @@ from aces_ocio.colorspaces import red from aces_ocio.colorspaces import sony from aces_ocio.process import Process +from aces_ocio.utilities import replace __author__ = 'ACES Developers' __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers' @@ -55,7 +56,9 @@ def set_config_default_roles(config, matte_paint='', reference='', scene_linear='', - texture_paint=''): + texture_paint='', + rendering='', + compositing_linear=''): """ Sets given *OCIO* configuration default roles. @@ -102,11 +105,22 @@ def set_config_default_roles(config, config.setRole(ocio.Constants.ROLE_MATTE_PAINT, matte_paint) if reference: config.setRole(ocio.Constants.ROLE_REFERENCE, reference) - if scene_linear: - config.setRole(ocio.Constants.ROLE_SCENE_LINEAR, scene_linear) if texture_paint: config.setRole(ocio.Constants.ROLE_TEXTURE_PAINT, texture_paint) + # 'rendering' and 'compositing_linear' roles default to the 'scene_linear' + # value if not set explicitly + if rendering: + config.setRole("rendering", rendering) + if compositing_linear: + config.setRole("compositing_linear", compositing_linear) + if scene_linear: + config.setRole(ocio.Constants.ROLE_SCENE_LINEAR, scene_linear) + if not rendering: + config.setRole("rendering", scene_linear) + if not compositing_linear: + config.setRole("compositing_linear", scene_linear) + return True @@ -246,7 +260,9 @@ def add_colorspace_alias(config, """ for alias_name in colorspace_alias_names: - if alias_name == colorspace.name.lower(): + if alias_name.lower() == colorspace.name.lower(): + print('Skipping alias creation for %s, alias %s, because lower cased names match' % ( + colorspace.name, alias_name) ) return print('Adding alias colorspace space %s, alias to %s' % ( @@ -264,7 +280,7 @@ def add_colorspace_alias(config, allocation=colorspace.allocation_type, allocationVars=colorspace.allocation_vars) - if not colorspace.to_reference_transforms: + if colorspace.to_reference_transforms: print('Generating To-Reference transforms') ocio_transform = generate_OCIO_transform( [{'type': 'colorspace', @@ -275,7 +291,7 @@ def add_colorspace_alias(config, ocio_transform, ocio.Constants.COLORSPACE_DIR_TO_REFERENCE) - if not colorspace.from_reference_transforms: + if colorspace.from_reference_transforms: print('Generating From-Reference transforms') ocio_transform = generate_OCIO_transform( [{'type': 'colorspace', @@ -288,8 +304,11 @@ def add_colorspace_alias(config, config.addColorSpace(ocio_colorspace_alias) +def colorspace_prefixed_name(colorspace): + prefix = colorspace.family.replace("/", " - ") + return "%s - %s" % (prefix, colorspace.name) -def create_config(config_data, nuke=False): +def create_config(config_data, aliases=False, prefix=False): """ Object description. @@ -304,6 +323,9 @@ def create_config(config_data, nuke=False): Return value description. """ + prefixed_names = {} + alias_colorspaces = [] + # Creating the *OCIO* configuration. config = ocio.Config() @@ -313,6 +335,14 @@ def create_config(config_data, nuke=False): # Defining the reference colorspace. reference_data = config_data['referenceColorSpace'] + + # Adding the color space Family into the name + # Helps with applications that present colorspaces as one long list + if prefix: + prefixed_name = colorspace_prefixed_name(reference_data) + prefixed_names[reference_data.name] = prefixed_name + reference_data.name = prefixed_name + print('Adding the reference color space : %s' % reference_data.name) reference = ocio.ColorSpace( @@ -328,15 +358,29 @@ def create_config(config_data, nuke=False): config.addColorSpace(reference) # Add alias - if not nuke: + if aliases: if reference_data.aliases != []: - add_colorspace_alias(config, reference_data, - reference_data, reference_data.aliases) + #add_colorspace_alias(config, reference_data, + # reference_data, reference_data.aliases) + # defer adding alias colorspaces until end. Helps with some applications + alias_colorspaces.append([reference_data, reference_data, reference_data.aliases]) + print("") + #print( "color spaces : %s" % [x.name for x in sorted(config_data['colorSpaces'])]) + + print('Adding the regular color spaces') + # Creating the remaining colorspaces. for colorspace in sorted(config_data['colorSpaces']): + # Adding the color space Family into the name + # Helps with applications that present colorspaces as one long list + if prefix: + prefixed_name = colorspace_prefixed_name(colorspace) + prefixed_names[colorspace.name] = prefixed_name + colorspace.name = prefixed_name + print('Creating new color space : %s' % colorspace.name) ocio_colorspace = ocio.ColorSpace( @@ -370,19 +414,36 @@ def create_config(config_data, nuke=False): # # Add alias to normal colorspace, using compact name # - if not nuke: + if aliases: if colorspace.aliases != []: - add_colorspace_alias(config, reference_data, - colorspace, colorspace.aliases) + #add_colorspace_alias(config, reference_data, + # colorspace, colorspace.aliases) + # defer adding alias colorspaces until end. Helps with some applications + alias_colorspaces.append([reference_data, colorspace, colorspace.aliases]) print('') + print("") + + # We add these at the end as some applications use the order of the colorspaces + # definitions in the config to order the colorspaces in their selection lists. + # Other go alphabetically. This should keep the alias colorspaces out of the way + # for the apps that use the order of definition in the config. + print('Adding the alias colorspaces') + for reference, colorspace, aliases in alias_colorspaces: + add_colorspace_alias(config, reference, colorspace, aliases) + + print("") + + print('Adding the diplays and views') + # Defining the *views* and *displays*. displays = [] views = [] + ''' # Defining a *generic* *display* and *view* setup. - if not nuke: + if not gui: for display, view_list in config_data['displays'].iteritems(): for view_name, colorspace in view_list.iteritems(): config.addDisplay(display, view_name, colorspace.name) @@ -390,50 +451,98 @@ def create_config(config_data, nuke=False): views.append(view_name) displays.append(display) - # Defining the *Nuke* specific set of *views* and *displays*. else: - display_name = 'ACES' - displays.append(display_name) - - display_names = sorted(config_data['displays']) - for display in display_names: - view_list = config_data['displays'][display] - for view_name, colorspace in view_list.iteritems(): - if view_name == 'Output Transform': - config.addDisplay(display_name, display, colorspace.name) - if not (display in views): - views.append(display) - - # Works with Nuke Studio and Mari, but not Nuke - # display_name = 'Utility' - # displays.append(display_name) - - linear_display_space_name = config_data['linearDisplaySpace'].name - log_display_space_name = config_data['logDisplaySpace'].name - - config.addDisplay(display_name, 'Linear', linear_display_space_name) - views.append('Linear') - config.addDisplay(display_name, 'Log', log_display_space_name) - views.append('Log') + ''' + # Defining the set of *views* and *displays* useful in a *GUI* context. + #display_name = 'ACES' + display_name = config_data['roles']['scene_linear'] + displays.append(display_name) + + display_names = sorted(config_data['displays']) + + # Make sure the default display is first + default_display = config_data['defaultDisplay'] + display_names.insert(0, display_names.pop(display_names.index(default_display))) + + for display in display_names: + view_list = config_data['displays'][display] + for view_name, colorspace in view_list.iteritems(): + if view_name == 'Output Transform': + display_cleaned = replace(display, {')': '', '(': ''}) + config.addDisplay(display_name, display_cleaned, colorspace.name) + if not (display_cleaned in views): + views.append(display_cleaned) + + # Works with Nuke Studio and Mari, but not Nuke + # display_name = 'Utility' + # displays.append(display_name) + + linear_display_space_name = config_data['roles']['scene_linear'] + log_display_space_name = config_data['roles']['compositing_log'] + + # Find the newly-prefixed colorspace names + if prefix: + #print( prefixed_names ) + linear_display_space_name = prefixed_names[linear_display_space_name] + log_display_space_name = prefixed_names[log_display_space_name] + + config.addDisplay(display_name, 'Linear', linear_display_space_name) + views.append('Linear') + config.addDisplay(display_name, 'Log', log_display_space_name) + views.append('Log') # Setting the active *displays* and *views*. config.setActiveDisplays(','.join(sorted(displays))) config.setActiveViews(','.join(views)) - set_config_default_roles( - config, - 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']) + print("") + + print('Setting the roles') + + if prefix: + set_config_default_roles( + config, + color_picking=prefixed_names[config_data['roles']['color_picking']], + color_timing=prefixed_names[config_data['roles']['color_timing']], + compositing_log=prefixed_names[config_data['roles']['compositing_log']], + data=prefixed_names[config_data['roles']['data']], + default=prefixed_names[config_data['roles']['default']], + 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']], + texture_paint=prefixed_names[config_data['roles']['texture_paint']]) + else: + set_config_default_roles( + config, + 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']) + + print("") + # Make sure we didn't create a bad config config.sanityCheck() + # Reset the colorspace names back to their non-prefixed versions + if prefix: + # Build the reverse lookup + prefixed_names_inverse = {} + for original, prefixed in prefixed_names.iteritems(): + prefixed_names_inverse[prefixed] = original + + # Reet the reference colorspace name + reference_data.name = prefixed_names_inverse[reference_data.name] + + # Reset the rest of the colorspace names + for colorspace in config_data['colorSpaces']: + colorspace.name = prefixed_names_inverse[colorspace.name] + return config @@ -476,14 +585,15 @@ def generate_LUTs(odt_info, aces_colorspaces, aces_displays, 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) + aces_roles, + aces_default_display) = 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 @@ -494,6 +604,7 @@ def generate_LUTs(odt_info, for name, data in aces_displays.iteritems(): config_data['displays'][name] = data + config_data['defaultDisplay'] = aces_default_display config_data['linearDisplaySpace'] = aces_reference config_data['logDisplaySpace'] = aces_log_display_space @@ -767,19 +878,35 @@ def create_ACES_config(aces_ctl_directory, lut_resolution_3d, cleanup) - print('Creating "generic" config') - config = create_config(config_data) + print('Creating config - with prefixes, with aliases') + gui_config = create_config(config_data, prefix=True, aliases=True) print('\n\n\n') - write_config(config, + write_config(gui_config, os.path.join(config_directory, 'config.ocio')) - print('Creating "Nuke" config') - nuke_config = create_config(config_data, nuke=True) + ''' + print('Creating config - with prefixes, without aliases') + gui_config = create_config(config_data, prefix=True, aliases=False) + print('\n\n\n') + + write_config(gui_config, + os.path.join(config_directory, 'config_w_prefixes_no_aliases.ocio')) + + print('Creating config - without prefixes, with aliases') + gui_config = create_config(config_data, prefix=False, aliases=True) + print('\n\n\n') + + write_config(gui_config, + os.path.join(config_directory, 'config_no_prefixes_w_aliases.ocio')) + + print('Creating config - without prefixes, without aliases') + gui_config = create_config(config_data, prefix=False, aliases=False) print('\n\n\n') - write_config(nuke_config, - os.path.join(config_directory, 'nuke_config.ocio')) + write_config(gui_config, + os.path.join(config_directory, 'config_no_prefixes_no_aliases.ocio')) + ''' if bake_secondary_LUTs: generate_baked_LUTs(odt_info,