+def add_look(config,
+ look,
+ prefix,
+ custom_lut_dir,
+ reference_name,
+ config_data,
+ multiple_displays=False):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+
+ look_name = look[0]
+ look_colorspace = look[1]
+ look_lut = look[2]
+ look_cccid = None
+ if len(look) == 4:
+ look_cccid = look[3]
+
+ print('Adding look %s - %s' % (look_name, ", ".join(look)) )
+
+ #
+ # Copy look lut
+ #
+ if custom_lut_dir:
+ if not '$' in look_lut:
+ print( "Getting ready to copy look lut : %s" % look_lut )
+ shutil.copy2(look_lut, custom_lut_dir)
+ look_lut = os.path.split(look_lut)[1]
+ else:
+ print( "Skipping LUT copy because path contains a context variable" )
+
+ #
+ # Create OCIO Look
+ #
+ # Look 1
+ print('Adding look to config' )
+ lk1 = ocio.Look()
+ lk1.setName( look_name )
+ lk1.setProcessSpace( look_colorspace )
+
+ keys = {'type': 'lutFile',
+ 'path': look_lut,
+ 'direction': 'forward'}
+ if look_cccid:
+ keys['cccid'] = look_cccid
+
+ ocio_transform = generate_OCIO_transform([keys])
+ lk1.setTransform( ocio_transform )
+
+ # add to config
+ config.addLook( lk1 )
+
+ print( "Creating aliased colorspace")
+
+ #
+ # Create OCIO colorspace that references that look
+ # - Needed for some implementations that don't process looks well
+ # - Also needed for some implementations that don't expose looks well
+ #
+ look_aliases = ["look_%s" % compact(look_name)]
+ colorspace = ColorSpace(look_name,
+ aliases=look_aliases,
+ description="The %s Look colorspace" % look_name,
+ family='Look')
+
+ colorspace.from_reference_transforms = [{'type': 'look',
+ 'look': look_name,
+ 'src': reference_name,
+ 'dst': reference_name,
+ 'direction': 'forward'}]
+
+ print('Adding colorspace %s, alias to look %s to config data' % (
+ look_name, look_name))
+
+ # Add this colorspace into the main list of colorspaces
+ config_data['colorSpaces'].append(colorspace)
+
+ print("")
+
+def integrate_looks_into_views(config,
+ looks,
+ reference_name,
+ config_data,
+ multiple_displays=False):
+ """
+ Object description.
+
+ Parameters
+ ----------
+ parameter : type
+ Parameter description.
+
+ Returns
+ -------
+ type
+ Return value description.
+ """
+ look_names = [look[0] for look in looks]
+
+ # Option 1 - Add a 'look' to each Display
+ # - Assumes there is a Display for each ACES Output Transform
+ if multiple_displays:
+ for look_name in look_names:
+ config_data['looks'].append(look_name)
+
+ # Option 2
+ # - Copy each Output Transform colorspace
+ # - For each copy, add a LookTransform at the head of the from_reference
+ # transform list
+ # - Add these new copied colorspaces for the Displays / Views
+ else:
+ for display, view_list in config_data['displays'].iteritems():
+ output_colorspace_copy = None
+ look_names_string = ""
+ for view_name, output_colorspace in view_list.iteritems():
+ if view_name == "Output Transform":
+
+ print( "Adding new View that incorporates looks" )
+
+ # Make a copy of the output colorspace
+ output_colorspace_copy = copy.deepcopy(output_colorspace)
+
+ #for look_name in look_names:
+ for i in range(len(look_names)):
+ look_name = look_names[i]
+
+ # Add the LookTransform to the head of the from_reference transform list
+ if output_colorspace_copy.from_reference_transforms:
+ output_colorspace_copy.from_reference_transforms.insert(i, {'type': 'look',
+ 'look': look_name,
+ 'src': reference_name,
+ 'dst': reference_name,
+ 'direction': 'forward'})
+
+ # Add the LookTransform to the end of the to_reference transform list
+ if output_colorspace_copy.to_reference_transforms:
+ inverse_look_name = look_names[len(look_names) -1 -i]
+
+ output_colorspace_copy.to_reference_transforms.append({'type': 'look',
+ 'look': inverse_look_name,
+ 'src': reference_name,
+ 'dst': reference_name,
+ 'direction': 'inverse'})
+
+ if not look_name in config_data['looks']:
+ config_data['looks'].append(look_name)
+
+ look_names_string = ", ".join(look_names)
+ output_colorspace_copy.name = "%s with %s" % (output_colorspace.name, look_names_string)
+ output_colorspace_copy.aliases = ["out_%s" % compact(output_colorspace_copy.name)]
+
+ print( "Colorspace that incorporates looks created : %s" % output_colorspace_copy.name )
+
+ config_data['colorSpaces'].append(output_colorspace_copy)
+
+ if output_colorspace_copy:
+ print( "Adding colorspace that incorporates looks into view list" )
+
+ # Change the name of the View
+ view_list["Output Transform with %s" % look_names_string] = output_colorspace_copy
+ config_data['displays'][display] = view_list
+
+ #print( "Display : %s, View List : %s" % (display, ", ".join(view_list)) )
+