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
+ # *rendering* and *compositing_linear* roles default to the *scene_linear*
+ # value if not set explicitly.
if rendering:
config.setRole('rendering', rendering)
if compositing_linear:
for transform in transforms:
- # lutFile transform
+ # *lutFile* transform
if transform['type'] == 'lutFile':
- # Create transforms
ocio_transform = ocio.FileTransform()
if 'path' in transform:
ocio_transforms.append(ocio_transform)
- # matrix transform
+ # *matrix* transform
elif transform['type'] == 'matrix':
ocio_transform = ocio.MatrixTransform()
- # MatrixTransform member variables can't be initialized directly.
- # Each must be set individually.
+ # `MatrixTransform` member variables can't be initialized directly,
+ # each must be set individually.
ocio_transform.setMatrix(transform['matrix'])
if 'offset' in transform:
ocio_transforms.append(ocio_transform)
- # exponent transform
+ # *exponent* transform
elif transform['type'] == 'exponent':
ocio_transform = ocio.ExponentTransform()
ocio_transforms.append(ocio_transform)
- # log transform
+ # *log* transform
elif transform['type'] == 'log':
ocio_transform = ocio.LogTransform()
ocio_transforms.append(ocio_transform)
- # color space transform
+ # *colorspace* transform
elif transform['type'] == 'colorspace':
ocio_transform = ocio.ColorSpaceTransform()
ocio_transforms.append(ocio_transform)
- # look transform
+ # *look* transform
elif transform['type'] == 'look':
ocio_transform = ocio.LookTransform()
if 'look' in transform:
ocio_transforms.append(ocio_transform)
- # unknown type
+ # *unknown* type
else:
print('Ignoring unknown transform type : %s' % transform['type'])
print('Adding look %s - %s' % (look_name, ', '.join(look)))
- #
- # Copy look lut
- #
+ # Copy *look LUT* if `custom_lut_dir` is provided.
if custom_lut_dir:
if '$' not in look_lut:
print('Getting ready to copy look lut : %s' % look_lut)
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)
+ ocio_look = ocio.Look()
+ ocio_look.setName(look_name)
+ ocio_look.setProcessSpace(look_colorspace)
keys = {'type': 'lutFile',
'path': look_lut,
keys['cccid'] = look_cccid
ocio_transform = generate_OCIO_transform([keys])
- lk1.setTransform(ocio_transform)
+ ocio_look.setTransform(ocio_transform)
- # add to config
- config.addLook(lk1)
+ config.addLook(ocio_look)
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
- #
+ # Creating *OCIO* colorspace referencing the look:
+ # - Needed for implementations that don't process looks properly.
+ # - Needed for implementations that don't expose looks properly.
look_aliases = ['look_%s' % compact(look_name)]
colorspace = ColorSpace(look_name,
aliases=look_aliases,
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()
"""
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
+ # Option 1
+ # - Adding a *look* per *Display*.
+ # - Assuming 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
+ # - Copy each *Output Transform* colorspace.
+ # - For each copy, add a *LookTransform* to the head of the
+ # `from_reference` transform list.
+ # - Add these the copy colorspaces for the *Displays* / *Views*.
else:
for display, view_list in config_data['displays'].iteritems():
- output_colorspace_c = None
+ colorspace_c = 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_c = copy.deepcopy(output_colorspace)
+ colorspace_c = copy.deepcopy(output_colorspace)
- # for look_name in look_names:
for i, look_name in enumerate(look_names):
look_name = look_names[i]
- # Add the LookTransform to the head of the
- # from_reference transform list.
- if output_colorspace_c.from_reference_transforms:
- output_colorspace_c.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_c.to_reference_transforms:
+ # Add the `LookTransform` to the head of the
+ # `from_reference` transform list.
+ if colorspace_c.from_reference_transforms:
+ colorspace_c.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 colorspace_c.to_reference_transforms:
inverse_look_name = look_names[
len(look_names) - 1 - i]
- output_colorspace_c.to_reference_transforms.append(
+ colorspace_c.to_reference_transforms.append(
{'type': 'look',
'look': inverse_look_name,
'src': reference_name,
config_data['looks'].append(look_name)
look_names_string = ', '.join(look_names)
- output_colorspace_c.name = '%s with %s' % (
+ colorspace_c.name = '%s with %s' % (
output_colorspace.name, look_names_string)
- output_colorspace_c.aliases = [
- 'out_%s' % compact(output_colorspace_c.name)]
+ colorspace_c.aliases = [
+ 'out_%s' % compact(colorspace_c.name)]
print('Colorspace that incorporates looks '
- 'created : %s' % output_colorspace_c.name)
+ 'created : %s' % colorspace_c.name)
- config_data['colorSpaces'].append(output_colorspace_c)
+ config_data['colorSpaces'].append(colorspace_c)
- if output_colorspace_c:
+ if colorspace_c:
print('Adding colorspace that incorporates looks '
'into view list')
- # Change the name of the View
+ # Updating the *View* name.
view_list['Output Transform with %s' % look_names_string] = (
- output_colorspace_c)
+ colorspace_c)
config_data['displays'][display] = view_list
- # print('Display : %s, View List : %s' % (
- # display, ', '.join(view_list)) )
-
def create_config(config_data,
aliases=False,
prefixed_names = {}
alias_colorspaces = []
- # Creating the *OCIO* configuration.
config = ocio.Config()
- # Setting configuration description.
config.setDescription('An ACES config generated from python')
- # Setting configuration search path.
search_path = ['luts']
if custom_lut_dir:
search_path.append('custom')
config.setSearchPath(':'.join(search_path))
- # 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
+ # Adding the colorspace *Family* into the name which helps with
+ # applications that presenting colorspaces as one a flat list.
if prefix:
prefixed_name = colorspace_prefixed_name(reference_data)
prefixed_names[reference_data.name] = prefixed_name
config.addColorSpace(reference)
- # Add alias
if aliases:
if reference_data.aliases:
- # add_colorspace_alias(config, reference_data,
- # reference_data, reference_data.aliases)
- # defer adding alias colorspaces until end.
- # Helps with some applications.
+ # TODO: Explain context for following comment.
+ # Deferring adding alias colorspaces until end, which 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'])])
-
- #
- # Add Looks and Look colorspaces
- #
if look_info:
print('Adding looks')
config_data['looks'] = []
- # Add looks and colorspaces
for look in look_info:
add_look(config,
look,
reference_data.name,
config_data)
- # Integrate looks with displays, views
integrate_looks_into_views(look_info,
reference_data.name,
config_data,
print()
- print('Adding the regular color spaces')
+ print('Adding regular colorspaces')
- # 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
+ # Adding the colorspace *Family* into the name which helps with
+ # applications that presenting colorspaces as one a flat list.
if prefix:
prefixed_name = colorspace_prefixed_name(colorspace)
prefixed_names[colorspace.name] = prefixed_name
config.addColorSpace(ocio_colorspace)
- #
- # Add alias to normal colorspace, using compact name
- #
if aliases:
if colorspace.aliases:
- # add_colorspace_alias(config, reference_data,
- # colorspace, colorspace.aliases)
- # defer adding alias colorspaces until end.
- # Helps with some applications.
+ # TODO: Explain context for following comment.
+ # Deferring adding alias colorspaces until end, which helps
+ # with some applications.
alias_colorspaces.append(
[reference_data, colorspace, colorspace.aliases])
print()
- #
- # We add roles early so we can create alias colorspaces with the names
- # of the roles before the rest of the colorspace aliases are added
- # to the config.
+ # Adding roles early so that alias colorspaces can be created
+ # with roles names before remaining colorspace aliases are added
+ # to the configuration.
print('Setting the roles')
if prefix:
texture_paint=prefixed_names[
config_data['roles']['texture_paint']])
- # Not allowed for the moment. role names can not overlap
+ # TODO: Should we remove this dead code path?
+ # Not allowed at the moment as role names can not overlap
# with colorspace names.
"""
# Add the aliased colorspaces for each role
scene_linear=config_data['roles']['scene_linear'],
texture_paint=config_data['roles']['texture_paint'])
- # Not allowed for the moment. role names can not overlap
+ # TODO: Should we remove this dead code path?
+ # Not allowed at the moment as role names can not overlap
# with colorspace names.
"""
# Add the aliased colorspaces for each role
role_colorspace = reference_data
if role_colorspace:
- print( 'Adding an alias colorspace named %s, pointing to %s' % (
+ print('Adding an alias colorspace named %s, pointing to %s' % (
role_name, role_colorspace.name))
add_colorspace_aliases(
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.
+ # Adding alias colorspaces at the end as some applications use
+ # colorspaces definitions order of the configuration to order
+ # the colorspaces in their selection lists, some applications
+ # use alphabetical ordering.
+ # This should keep the alias colorspaces out of the way for applications
+ # using the configuration order.
print('Adding the alias colorspaces')
for reference, colorspace, aliases in alias_colorspaces:
add_colorspace_aliases(config, reference, colorspace, aliases)
print('Adding the diplays and views')
- # Set the color_picking role to be
- # the first Display's Output Transform View.
+ # Setting the *color_picking* role to be the first *Display*'s
+ # *Output Transform* *View*.
default_display_name = config_data['defaultDisplay']
default_display_views = config_data['displays'][default_display_name]
default_display_colorspace = default_display_views['Output Transform']
config,
color_picking=default_display_colorspace.name)
- # Defining the *views* and *displays*.
- displays = []
- views = []
+ # Defining *Displays* and *Views*.
+ displays, views = [], []
- # Defining a *generic* *display* and *view* setup.
+ # Defining a generic *Display* and *View* setup.
if multiple_displays:
- # Built list of looks to add to Displays
looks = config_data['looks'] if ('looks' in config_data) else []
looks = ', '.join(looks)
print('Creating multiple displays, with looks : %s' % looks)
- # Note: We don't reorder the Displays to put the 'defaultDisplay' first
- # because OCIO will order them alphabetically
- # when the config is written to disk.
-
- # Create Displays, Views
+ # *Displays* are not reordered to put the *defaultDisplay* first
+ # because *OCIO* will order them alphabetically when the configuration
+ # is written to disk.
for display, view_list in config_data['displays'].iteritems():
for view_name, colorspace in view_list.iteritems():
config.addDisplay(display, view_name, colorspace.name, looks)
if 'Output Transform' in view_name and looks != '':
- # Add normal View, without looks
+ # *Views* without *Looks*.
config.addDisplay(display, view_name, colorspace.name)
- # Add View with looks
+ # *Views* with *Looks*.
view_name_with_looks = '%s with %s' % (view_name, looks)
config.addDisplay(display, view_name_with_looks,
colorspace.name, looks)
views.append(view_name)
displays.append(display)
- # Defining the set of *views* and *displays* useful in a *GUI* context.
+ # *Displays* and *Views* useful in a *GUI* context.
else:
single_display_name = 'ACES'
- # single_display_name = config_data['roles']['scene_linear']
displays.append(single_display_name)
- # Make sure the default display is first
+ # Ensuring the *defaultDisplay* is first.
display_names = sorted(config_data['displays'])
display_names.insert(0, display_names.pop(
display_names.index(default_display_name)))
- # Built list of looks to add to Displays
looks = config_data['looks'] if ('looks' in config_data) else []
look_names = ', '.join(looks)
displays_views_colorspaces = []
- # Create Displays, Views
for display in display_names:
view_list = config_data['displays'][display]
for view_name, colorspace in view_list.iteritems():
if 'Output Transform' in view_name:
- # print( 'Adding view for %s' % colorspace.name )
- # We use the Display names as the View names in this case
- # as there is a single Display that contains all views.
- # This works for more applications than not,
- # as of the time of this implementation.
+ # We use the *Display* names as the *View* names in this
+ # case as there is a single *Display* containing all the
+ # *Views*.
+ # This works for more applications than not,as of the time
+ # of this implementation.
- # Maya 2016 doesn't like parentheses in View names
- display_cleaned = replace(display, {')': '', '(': ''})
+ # Autodesk Maya 2016 doesn't support parentheses in
+ # *View* names.
+ sanitised_display = replace(display, {')': '', '(': ''})
- # If View includes looks
+ # *View* with *Looks*.
if 'with' in view_name:
- # Integrate looks into view name
- display_cleaned = '%s with %s' % (
- display_cleaned, look_names)
+ sanitised_display = '%s with %s' % (
+ sanitised_display, look_names)
views_with_looks_at_end = False
- # Storing combo of display, view and colorspace name
- # in a list so we can add them to the end of the list.
+ # Storing combo of *Display*, *View* and *Colorspace*
+ # name so they can be added to the end of the list.
if views_with_looks_at_end:
displays_views_colorspaces.append(
- [single_display_name, display_cleaned,
+ [single_display_name, sanitised_display,
colorspace.name])
-
- # Or add as normal
else:
config.addDisplay(single_display_name,
- display_cleaned, colorspace.name)
+ sanitised_display,
+ colorspace.name)
- # Add to views list
- if not (display_cleaned in views):
- views.append(display_cleaned)
+ if not (sanitised_display in views):
+ views.append(sanitised_display)
- # A normal View
+ # *View* without *Looks*.
else:
- config.addDisplay(single_display_name, display_cleaned,
+ config.addDisplay(single_display_name,
+ sanitised_display,
colorspace.name)
- # Add to views list
- if not (display_cleaned in views):
- views.append(display_cleaned)
+ if not (sanitised_display in views):
+ views.append(sanitised_display)
- # Add to config any display, view combinations that were saved
- # for later. This list will be empty unless views_with_looks_at_end is
- # set to True above.
+ # Adding to the configuration any *Display*, *View* combinations that
+ # were saved for later.
+ # This list should be empty unless `views_with_looks_at_end` is
+ # set `True` above.
for display_view_colorspace in displays_views_colorspaces:
- single_display_name, display_cleaned, colorspace_name = (
+ single_display_name, sanitised_display, colorspace_name = (
display_view_colorspace)
- # Add to config
- config.addDisplay(single_display_name, display_cleaned,
+ config.addDisplay(single_display_name,
+ sanitised_display,
colorspace_name)
- # Add to views list
- if not (display_cleaned in views):
- views.append(display_cleaned)
-
-
- # Works with Nuke Studio and Mari, but not Nuke
- # single_display_name = 'Utility'
- # displays.append(single_display_name)
+ if not (sanitised_display in views):
+ views.append(sanitised_display)
raw_display_space_name = config_data['roles']['data']
log_display_space_name = config_data['roles']['compositing_log']
- # Find the newly-prefixed colorspace names
if prefix:
- # print( prefixed_names )
raw_display_space_name = prefixed_names[raw_display_space_name]
log_display_space_name = prefixed_names[log_display_space_name]
config.addDisplay(single_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))
print()
- # Make sure we didn't create a bad config
+ # Ensuring the configuration is valid.
config.sanityCheck()
- # Reset the colorspace names back to their non-prefixed versions
+ # Resetting colorspace names 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
- # Reset the reference colorspace name
reference_data.name = prefixed_names_inverse[reference_data.name]
- # Reset the rest of the colorspace names
try:
for colorspace in config_data['colorSpaces']:
colorspace.name = prefixed_names_inverse[colorspace.name]
print('generateLUTs - begin')
config_data = {}
- # Initialize a few variables
config_data['displays'] = {}
config_data['colorSpaces'] = []
# *Camera Input Transforms*
# -------------------------------------------------------------------------
- # *ARRI Log-C* to *ACES*.
+ # *ARRI Log-C* to *ACES*
arri_colorspaces = arri.create_colorspaces(lut_directory,
lut_resolution_1d)
for cs in arri_colorspaces:
config_data['colorSpaces'].append(cs)
- # *Canon-Log* to *ACES*.
+ # *Canon-Log* to *ACES*
canon_colorspaces = canon.create_colorspaces(lut_directory,
lut_resolution_1d)
for cs in canon_colorspaces:
config_data['colorSpaces'].append(cs)
- # *GoPro Protune* to *ACES*.
+ # *GoPro Protune* to *ACES*
gopro_colorspaces = gopro.create_colorspaces(lut_directory,
lut_resolution_1d)
for cs in gopro_colorspaces:
config_data['colorSpaces'].append(cs)
- # *Panasonic V-Log* to *ACES*.
+ # *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 to *ACES*
red_colorspaces = red.create_colorspaces(lut_directory,
lut_resolution_1d)
for cs in red_colorspaces:
config_data['colorSpaces'].append(cs)
- # *S-Log* to *ACES*.
+ # *S-Log* to *ACES*
sony_colorspaces = sony.create_colorspaces(lut_directory,
lut_resolution_1d)
for cs in sony_colorspaces:
config_data['colorSpaces'].append(cs)
# -------------------------------------------------------------------------
- # General Color Spaces
+ # General Colorspaces
# -------------------------------------------------------------------------
general_colorspaces = general.create_colorspaces(lut_directory,
lut_resolution_1d)
for cs in general_colorspaces:
config_data['colorSpaces'].append(cs)
- # The *Raw* color space
+ # The *Raw* colorspace
raw = general.create_raw()
config_data['colorSpaces'].append(raw)
- # Override certain roles, for now
+ # Overriding various roles
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
odt_info_C = dict(odt_info)
- # Uncomment if you would like to support the older behavior where ODTs
- # that have support for full and legal range output generate
- # a LUT for each.
+ # Older behavior for *ODTs* that have support for full and legal ranges,
+ # generating a LUT for both ranges.
"""
# Create two entries for ODTs that have full and legal range support
for odt_ctl_name, odt_values in odt_info.iteritems():
del (odt_info_C[odt_ctl_name])
"""
- # Generate appropriate LUTs for each ODT
for odt_ctl_name, odt_values in odt_info_C.iteritems():
odt_prefix = odt_values['transformUserNamePrefix']
odt_name = odt_values['transformUserName']
if look_info is None:
look_info = []
- # Directory for custom LUTs
custom_lut_dir = None
if copy_custom_luts:
custom_lut_dir = os.path.join(config_directory, 'custom')
'interpolation': 'linear',
'direction': 'forward'})
- # *AP1* primaries to *AP0* primaries.
+ # *AP1* primaries to *AP0* primaries
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
'interpolation': 'linear',
'direction': 'forward'})
- # *AP1* primaries to *AP0* primaries.
+ # *AP1* primaries to *AP0* primaries
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
cs.to_reference_transforms = []
- # *AP1* primaries to *AP0* primaries.
+ # *AP1* primaries to *AP0* primaries
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
cs.from_reference_transforms = []
- # *AP1* primaries to *AP0* primaries.
+ # *AP1* primaries to *AP0* primaries
cs.from_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(ACES_AP0_TO_AP1),
'offset': offset,
'direction': 'forward'})
- # Convert from Channel-Dependent Density to Channel-Independent Density
+ # Converting from *Channel-Dependent Density* to
+ # *Channel-Independent Density*.
cs.to_reference_transforms.append({
'type': 'matrix',
'matrix': [0.75573, 0.22197, 0.02230, 0,
# -------------------------------------------------------------------------
-# *Generic Log Transform*
+# Generic *Log* Transform
# -------------------------------------------------------------------------
def create_generic_log(aces_ctl_directory,
lut_directory,
# -------------------------------------------------------------------------
-# *base Dolby PQ Transform*
+# Base *Dolby PQ* Transform
# -------------------------------------------------------------------------
def create_Dolby_PQ(aces_ctl_directory,
lut_directory,
# -------------------------------------------------------------------------
-# *Dolby PQ Transform that considers a fixed linear range*
+# *Dolby PQ* Transform - Fixed Linear Range
# -------------------------------------------------------------------------
def create_Dolby_PQ_scaled(aces_ctl_directory,
lut_directory,
# -------------------------------------------------------------------------
-# *Individual LMT*
+# Individual *LMT*
# -------------------------------------------------------------------------
def create_ACES_LMT(lmt_name,
lmt_values,
shaper_input_scale,
shaper_params) = shaper_info
- # Add the shaper transform
shaper_lut = '%s_to_linear.spi1d' % shaper_name
shaper_lut = sanitize(shaper_lut)
else:
shaper_params['legalRange'] = 0
- # Add the shaper transform
shaper_lut = '%s_to_linear.spi1d' % shaper_name
shaper_lut = sanitize(shaper_lut)
generate_3d_LUT_from_CTL(
os.path.join(lut_directory, lut),
- # shaperLUT,
ctls,
lut_resolution_3d,
'float',
generate_3d_LUT_from_CTL(
os.path.join(lut_directory, lut),
- # None,
ctls,
lut_resolution_3d,
'half',
log2_shaper_api1_colorspace.from_reference_transforms = list(
log2_shaper_colorspace.from_reference_transforms)
- # *AP1* primaries to *AP0* primaries.
+ # *AP1* primaries to *AP0* primaries
log2_shaper_api1_colorspace.to_reference_transforms.append({
'type': 'matrix',
'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
})
colorspaces.append(log2_shaper_api1_colorspace)
- # Defining the *Log2 shaper that includes the AP1* primaries.
- # Named with 'shaper_name' variable. Needed for some LUT baking steps.
+ # Defining the *Log2* shaper that includes the *AP1* primaries.
+ # Named with `shaper_name` variable and needed for some *LUT* baking steps.
shaper_api1_name = '%s - AP1' % shaper_name
shaper_api1_colorspace = ColorSpace(shaper_api1_name)
shaper_api1_colorspace.description = (
# Define the base *Dolby PQ Shaper*
#
- dolbypq_shaper_name = 'Dolby PQ 10000'
+ dolby_pq_shaper_name = 'Dolby PQ 10000'
dolbypq_shaper_name_aliases = ['crv_%s' % 'dolbypq_10000']
dolbypq_shaper_colorspace = create_Dolby_PQ(
lut_directory,
lut_resolution_1d,
cleanup,
- name=dolbypq_shaper_name,
+ name=dolby_pq_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,
+ dolby_pq_shaper_name,
os.path.join('%s',
'utilities',
'ACESlib.DolbyPQ_to_Lin.a1.0.0.ctl'),
1.0,
{}]
- shaper_data[dolbypq_shaper_name] = dolbypq_shaper_data
+ shaper_data[dolby_pq_shaper_name] = dolbypq_shaper_data
# Define the *Dolby PQ Shaper that considers a fixed linear range*
- #
- dolbypq_scaled_shaper_name = 'Dolby PQ Scaled'
+ dolby_pq_scaled_shaper_name = 'Dolby PQ Scaled'
dolbypq_scaled_shaper_name_aliases = ['crv_%s' % 'dolbypq_scaled']
dolbypq_scaled_shaper_colorspace = create_Dolby_PQ_scaled(
lut_directory,
lut_resolution_1d,
cleanup,
- name=dolbypq_scaled_shaper_name,
+ name=dolby_pq_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,
+ dolby_pq_scaled_shaper_name,
os.path.join('%s',
'utilities',
'ACESlib.DolbyPQ_to_Lin_param.a1.0.0.ctl'),
1.0,
log2_params]
- shaper_data[dolbypq_scaled_shaper_name] = dolbypq_scaled_shaper_data
+ shaper_data[dolby_pq_scaled_shaper_name] = dolbypq_scaled_shaper_data
- #
- # Pick a specific shaper
- #
rrt_shaper = log2_shaper_data
# rrt_shaper = dolbypq_scaled_shaper_data
for odt in sorted_odts:
(odt_name, odt_values) = odt
- # Generating only full range transform for *ODTs* that can generate
+ # Defining full range transform for *ODTs* that can only generate
# either *legal* or *full* output.
# Uncomment these lines and the lower section and
- # flip the 'legalRange' value to 1 to recover the old behavior,
- # where both legal and full range LUTs were generated.
+ # flip the `legalRange` value to 1 to restore the old behavior,
+ # where both *legal* or *full* range *LUTs* were generated.
if odt_values['transformHasFullLegalSwitch']:
# odt_name_legal = '%s - Legal' % odt_values['transformUserName']
odt_legal['legalRange'] = 0
transform_user_name_prefix = (
lines[2][3:].split('<')[1].split('>')[1].split('-')[0].strip())
- # Figuring out if this transform has options
- # for processing full and legal range.
+ # Figuring out if this transform has options for processing *full* and
+ # *legal* ranges.
transform_full_legal_switch = False
for line in lines:
if line.strip() == 'input varying int legalRange = 0':
odt_path_tokens = os.path.split(odt_path_tokens[-2])
odt_dir = os.path.join(odt_path_tokens[-1], odt_dir)
- # Building full name,
+ # Building full name.
transform_ctl = odt_tokens[-1]
odt_name = string.join(transform_ctl.split('.')[1:-1], '.')
os.path.join(odt_tokens[-2], transform_ctl_inverse)):
transform_ctl_inverse = None
- # Add to list of ODTs
+ # Adding to list of *ODTs*.
odts[odt_name] = {}
odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_ctl)
if transform_ctl_inverse is not None:
ACEScc)
colorspaces.extend(odts)
- # Wish there was an automatic way to get this from the CTL
+ # TODO: Investigate if there is a way to retrieve the value from *CTL*.
default_display = 'sRGB (D60 sim.)'
roles = {'color_picking': ACEScg.name,
cs.family = 'Utility'
cs.is_data = False
- # A linear space needs allocation variables
+ # A linear space needs allocation variables.
cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
cs.allocation_vars = [0, 1]
cs.family = 'Utility'
cs.is_data = False
- # A linear space needs allocation variables
+ # A linear space needs allocation variables.
cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
cs.allocation_vars = [0, 1]
- # Sample the transfer function
+ # Sampling the transfer function.
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
data[c] = transfer_function(c / (lut_resolution_1d - 1))
- # Write the sampled data to a LUT
+ # Writing the sampled data to a *LUT*.
lut = '%s_to_linear.spi1d' % transfer_function_name
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
lut_resolution_1d,
1)
- # Create the 'to_reference' transforms
+ # Creating the *to_reference* transforms.
cs.to_reference_transforms = []
cs.to_reference_transforms.append({
'type': 'lutFile',
'interpolation': 'linear',
'direction': 'forward'})
- # Create the 'from_reference' transforms
+ # Creating the *from_reference* transforms.
cs.from_reference_transforms = []
return cs
-# create_transfer_colorspace
-
# -------------------------------------------------------------------------
# *Transfer Function + Matrix Transform*
# -------------------------------------------------------------------------
cs.family = 'Utility'
cs.is_data = False
- # A linear space needs allocation variables
+ # A linear space needs allocation variables.
cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
cs.allocation_vars = [0, 1]
- # Sample the transfer function
+ # Sampling the transfer function.
data = array.array('f', '\0' * lut_resolution_1d * 4)
for c in range(lut_resolution_1d):
data[c] = transfer_function(c / (lut_resolution_1d - 1))
- # Write the sampled data to a LUT
+ # Writing the sampled data to a *LUT*.
lut = '%s_to_linear.spi1d' % transfer_function_name
genlut.write_SPI_1d(
os.path.join(lut_directory, lut),
lut_resolution_1d,
1)
- # Create the 'to_reference' transforms
+ # Creating the *to_reference* transforms.
cs.to_reference_transforms = []
if to_reference_values:
cs.to_reference_transforms.append({
'matrix': mat44_from_mat33(matrix),
'direction': 'forward'})
- # Create the 'from_reference' transforms
+ # Creating the *from_reference* transforms.
cs.from_reference_transforms = []
if from_reference_values:
for matrix in from_reference_values:
return cs
-# create_matrix_plus_transfer_colorspace
-
-# Transfer functions for standard color spaces
+# Transfer functions for standard colorspaces.
def transfer_function_sRGB_to_linear(v):
a = 1.055
b = 0.04045
Lw = 1
Lb = 0
- # Ignoring legal to full scaling for now
+ # Ignoring legal to full scaling for now.
# v = (1023.0*v - 64.0)/876.0
t = pow(Lw, 1.0 / g) - pow(Lb, 1.0 / g)
colorspaces = []
- #
+ # -------------------------------------------------------------------------
# XYZ
- #
+ # -------------------------------------------------------------------------
cs = create_matrix_colorspace('XYZ-D60',
to_reference_values=[aces.ACES_XYZ_TO_AP0],
from_reference_values=[aces.ACES_AP0_TO_XYZ],
aliases=['lin_xyz_d60'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# P3-D60
- #
- # *ACES* to *Linear*, *P3D60* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *P3D60* primaries
XYZ_to_P3D60 = [2.4027414142, -0.8974841639, -0.3880533700,
-0.8325796487, 1.7692317536, 0.0237127115,
0.0388233815, -0.0824996856, 1.0363685997]
aliases=['lin_p3d60'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# P3-DCI
- #
- # *ACES* to *Linear*, *P3DCI* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *P3DCI* primaries
XYZ_to_P3DCI = [2.7253940305, -1.0180030062, -0.4401631952,
-0.7951680258, 1.6897320548, 0.0226471906,
0.0412418914, -0.0876390192, 1.1009293786]
aliases=['lin_p3dci'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# sRGB
- #
+ # -------------------------------------------------------------------------
# *ACES* to *Linear*, *Rec. 709* primaries.
- # sRGB and Rec 709 use the same gamut
+ # *sRGB* and *Rec 709* use the same gamut.
XYZ_to_Rec709 = [3.2409699419, -1.5373831776, -0.4986107603,
-0.9692436363, 1.8759675015, 0.0415550574,
0.0556300797, -0.2039769589, 1.0569715142]
aliases=['srgb'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# Rec 709
- #
- # *ACES* to *Linear*, *Rec. 709* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *Rec. 709* primaries
XYZ_to_Rec709 = [3.2409699419, -1.5373831776, -0.4986107603,
-0.9692436363, 1.8759675015, 0.0415550574,
0.0556300797, -0.2039769589, 1.0569715142]
aliases=['rec709_camera'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# Rec 2020
- #
- # *ACES* to *Linear*, *Rec. 2020* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *Rec. 2020* primaries
XYZ_to_Rec2020 = [1.7166511880, -0.3556707838, -0.2533662814,
-0.6666843518, 1.6164812366, 0.0157685458,
0.0176398574, -0.0427706133, 0.9421031212]
aliases=['rec2020_camera'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# Rec 1886
- #
-
+ # -------------------------------------------------------------------------
# *Linear* to *Rec.1886* Transfer Function*
cs = create_transfer_colorspace(
'Curve - Rec.1886',
aliases=['rec2020_display'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# ProPhoto
- #
- # *ACES* to *Linear*, *Pro Photo* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *Pro Photo* primaries
AP0_to_RIMM = [1.2412367771, -0.1685692287, -0.0726675484,
0.0061203066, 1.083151174, -0.0892714806,
-0.0032853314, 0.0099796402, 0.9933056912]
aliases=['lin_prophoto', 'lin_rimm'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# Adobe RGB
- #
- # *ACES* to *Linear*, *Adobe RGB* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *Adobe RGB* primaries
AP0_to_ADOBERGB = [1.7245603168, -0.4199935942, -0.3045667227,
-0.2764799142, 1.3727190877, -0.0962391734,
-0.0261255258, -0.0901747807, 1.1163003065]
aliases=['lin_adobergb'])
colorspaces.append(cs)
- #
+ # -------------------------------------------------------------------------
# Adobe Wide Gamut RGB
- #
-
- # *ACES* to *Linear*, *Adobe Wide Gamut RGB* primaries.
+ # -------------------------------------------------------------------------
+ # *ACES* to *Linear*, *Adobe Wide Gamut RGB* primaries
AP0_to_ADOBERGB = [1.3809814778, -0.1158594573, -0.2651220205,
0.0057015535, 1.0402949043, -0.0459964578,
-0.0038908746, -0.0597091815, 1.0636000561]