def create_ACES_RRT_plus_ODT(odt_name, odt_values, shaper_info, aces_ctl_directory, lut_directory, lut_resolution_3d=64, cleanup=True, aliases=None): """ Object description. Parameters ---------- parameter : type Parameter description. Returns ------- type Return value description. """ if aliases is None: aliases = [] cs = ColorSpace('%s' % odt_name) cs.description = '%s - %s Output Transform' % ( odt_values['transformUserNamePrefix'], odt_name) cs.aliases = aliases cs.equality_group = '' cs.family = 'Output' cs.is_data = False cs.aces_transform_id = odt_values['transformID'] pprint.pprint(odt_values) # Generating the *shaper* transform. (shaper_name, shaper_to_aces_ctl, shaper_from_aces_ctl, shaper_input_scale, shaper_params) = shaper_info if 'legalRange' in odt_values: shaper_params['legalRange'] = odt_values['legalRange'] else: shaper_params['legalRange'] = 0 shaper_lut = '%s_to_linear.spi1d' % shaper_name shaper_lut = sanitize(shaper_lut) shaper_ocio_transform = { 'type': 'lutFile', 'path': shaper_lut, 'interpolation': 'linear', 'direction': 'inverse'} # Generating the *forward* transform. cs.from_reference_transforms = [] if 'transformLUT' in odt_values: transform_lut_file_name = os.path.basename( odt_values['transformLUT']) lut = os.path.join(lut_directory, transform_lut_file_name) shutil.copy(odt_values['transformLUT'], lut) cs.from_reference_transforms.append(shaper_ocio_transform) cs.from_reference_transforms.append({ 'type': 'lutFile', 'path': transform_lut_file_name, 'interpolation': 'tetrahedral', 'direction': 'forward'}) elif 'transformCTL' in odt_values: ctls = [ shaper_to_aces_ctl % aces_ctl_directory, os.path.join(aces_ctl_directory, 'rrt', 'RRT.a1.0.0.ctl'), os.path.join(aces_ctl_directory, 'odt', odt_values['transformCTL'])] lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), ctls, lut_resolution_3d, 'float', 1 / shaper_input_scale, 1, shaper_params, cleanup, aces_ctl_directory) cs.from_reference_transforms.append(shaper_ocio_transform) cs.from_reference_transforms.append({ 'type': 'lutFile', 'path': lut, 'interpolation': 'tetrahedral', 'direction': 'forward'}) # Generating the *inverse* transform. cs.to_reference_transforms = [] if 'transformLUTInverse' in odt_values: transform_lut_inverse_file_name = os.path.basename( odt_values['transformLUTInverse']) lut = os.path.join(lut_directory, transform_lut_inverse_file_name) shutil.copy(odt_values['transformLUTInverse'], lut) cs.to_reference_transforms.append({ 'type': 'lutFile', 'path': transform_lut_inverse_file_name, 'interpolation': 'tetrahedral', 'direction': 'forward'}) shaper_inverse = shaper_ocio_transform.copy() shaper_inverse['direction'] = 'forward' cs.to_reference_transforms.append(shaper_inverse) elif 'transformCTLInverse' in odt_values: ctls = [os.path.join(aces_ctl_directory, 'odt', odt_values['transformCTLInverse']), os.path.join(aces_ctl_directory, 'rrt', 'InvRRT.a1.0.0.ctl'), shaper_from_aces_ctl % aces_ctl_directory] lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), ctls, lut_resolution_3d, 'half', 1, shaper_input_scale, shaper_params, cleanup, aces_ctl_directory) cs.to_reference_transforms.append({ 'type': 'lutFile', 'path': lut, 'interpolation': 'tetrahedral', 'direction': 'forward'}) shaper_inverse = shaper_ocio_transform.copy() shaper_inverse['direction'] = 'forward' cs.to_reference_transforms.append(shaper_inverse) return cs
def create_ACES_RRT_plus_ODT( odt_name, odt_values, shaper_info, aces_ctl_directory, lut_directory, lut_resolution_1d=1024, lut_resolution_3d=64, cleanup=True, aliases=None, ): """ Object description. Parameters ---------- parameter : type Parameter description. Returns ------- type Return value description. """ if aliases is None: aliases = [] cs = ColorSpace("%s" % odt_name) cs.description = "%s - %s Output Transform" % (odt_values["transformUserNamePrefix"], odt_name) cs.aliases = aliases cs.equality_group = "" cs.family = "Output" cs.is_data = False cs.aces_transform_id = odt_values["transformID"] pprint.pprint(odt_values) # Generating the *shaper* transform. (shaper_name, shaper_to_ACES_CTL, shaper_from_ACES_CTL, shaper_input_scale, shaper_params) = shaper_info if "legalRange" in odt_values: shaper_params["legalRange"] = odt_values["legalRange"] else: shaper_params["legalRange"] = 0 # Add the shaper transform shaper_lut = "%s_to_linear.spi1d" % shaper_name shaper_lut = sanitize(shaper_lut) shaper_OCIO_transform = {"type": "lutFile", "path": shaper_lut, "interpolation": "linear", "direction": "inverse"} # Generating the *forward* transform. cs.from_reference_transforms = [] if "transformLUT" in odt_values: transform_LUT_file_name = os.path.basename(odt_values["transformLUT"]) lut = os.path.join(lut_directory, transform_LUT_file_name) shutil.copy(odt_values["transformLUT"], lut) cs.from_reference_transforms.append(shaper_OCIO_transform) cs.from_reference_transforms.append( {"type": "lutFile", "path": transform_LUT_file_name, "interpolation": "tetrahedral", "direction": "forward"} ) elif "transformCTL" in odt_values: ctls = [ shaper_to_ACES_CTL % aces_ctl_directory, os.path.join(aces_ctl_directory, "rrt", "RRT.a1.0.0.ctl"), os.path.join(aces_ctl_directory, "odt", odt_values["transformCTL"]), ] lut = "%s.RRT.a1.0.0.%s.spi3d" % (shaper_name, odt_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), # shaperLUT, ctls, lut_resolution_3d, "float", 1 / shaper_input_scale, 1, shaper_params, cleanup, aces_ctl_directory, ) cs.from_reference_transforms.append(shaper_OCIO_transform) cs.from_reference_transforms.append( {"type": "lutFile", "path": lut, "interpolation": "tetrahedral", "direction": "forward"} ) # Generating the *inverse* transform. cs.to_reference_transforms = [] if "transformLUTInverse" in odt_values: transform_LUT_inverse_file_name = os.path.basename(odt_values["transformLUTInverse"]) lut = os.path.join(lut_directory, transform_LUT_inverse_file_name) shutil.copy(odt_values["transformLUTInverse"], lut) cs.to_reference_transforms.append( { "type": "lutFile", "path": transform_LUT_inverse_file_name, "interpolation": "tetrahedral", "direction": "forward", } ) shaper_inverse = shaper_OCIO_transform.copy() shaper_inverse["direction"] = "forward" cs.to_reference_transforms.append(shaper_inverse) elif "transformCTLInverse" in odt_values: ctls = [ os.path.join(aces_ctl_directory, "odt", odt_values["transformCTLInverse"]), os.path.join(aces_ctl_directory, "rrt", "InvRRT.a1.0.0.ctl"), shaper_from_ACES_CTL % aces_ctl_directory, ] lut = "InvRRT.a1.0.0.%s.%s.spi3d" % (odt_name, shaper_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), # None, ctls, lut_resolution_3d, "half", 1, shaper_input_scale, shaper_params, cleanup, aces_ctl_directory, ) cs.to_reference_transforms.append( {"type": "lutFile", "path": lut, "interpolation": "tetrahedral", "direction": "forward"} ) shaper_inverse = shaper_OCIO_transform.copy() shaper_inverse["direction"] = "forward" cs.to_reference_transforms.append(shaper_inverse) return cs
def create_ACES_LMT(lmt_name, lmt_values, shaper_info, aces_ctl_directory, lut_directory, lut_resolution_3d=64, cleanup=True, aliases=None): """ Creates the *ACES LMT* colorspace. Parameters ---------- parameter : type Parameter description. Returns ------- Colorspace *ACES LMT* colorspace. """ if aliases is None: aliases = [] cs = ColorSpace('%s' % lmt_name) cs.description = 'The ACES Look Transform: %s' % lmt_name cs.aliases = aliases cs.equality_group = '' cs.family = 'Look' cs.is_data = False cs.allocation_type = ocio.Constants.ALLOCATION_LG2 cs.allocation_vars = [-8, 5, 0.00390625] cs.aces_transform_id = lmt_values['transformID'] pprint.pprint(lmt_values) # Generating the *shaper* transform. (shaper_name, shaper_to_aces_ctl, shaper_from_aces_ctl, shaper_input_scale, shaper_params) = shaper_info shaper_lut = '%s_to_linear.spi1d' % shaper_name shaper_lut = sanitize(shaper_lut) shaper_ocio_transform = { 'type': 'lutFile', 'path': shaper_lut, 'interpolation': 'linear', 'direction': 'inverse'} # Generating the forward transform. cs.from_reference_transforms = [] if 'transformCTL' in lmt_values: ctls = [shaper_to_aces_ctl % aces_ctl_directory, os.path.join(aces_ctl_directory, lmt_values['transformCTL'])] lut = '%s.%s.spi3d' % (shaper_name, lmt_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), ctls, lut_resolution_3d, 'float', 1 / shaper_input_scale, 1, shaper_params, cleanup, aces_ctl_directory) cs.from_reference_transforms.append(shaper_ocio_transform) cs.from_reference_transforms.append({ 'type': 'lutFile', 'path': lut, 'interpolation': 'tetrahedral', 'direction': 'forward'}) # Generating the inverse transform. cs.to_reference_transforms = [] if 'transformCTLInverse' in lmt_values: ctls = [os.path.join(aces_ctl_directory, lmt_values['transformCTLInverse']), shaper_from_aces_ctl % aces_ctl_directory] lut = 'Inverse.%s.%s.spi3d' % (lmt_name, shaper_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), ctls, lut_resolution_3d, 'half', 1, shaper_input_scale, shaper_params, cleanup, aces_ctl_directory, 0) cs.to_reference_transforms.append({ 'type': 'lutFile', 'path': lut, 'interpolation': 'tetrahedral', 'direction': 'forward'}) shaper_inverse = shaper_ocio_transform.copy() shaper_inverse['direction'] = 'forward' cs.to_reference_transforms.append(shaper_inverse) return cs
def create_ACES_LMT( lmt_name, lmt_values, shaper_info, aces_ctl_directory, lut_directory, lut_resolution_1d=1024, lut_resolution_3d=64, cleanup=True, aliases=None, ): """ Creates the *ACES LMT* colorspace. Parameters ---------- parameter : type Parameter description. Returns ------- Colorspace *ACES LMT* colorspace. """ if aliases is None: aliases = [] cs = ColorSpace("%s" % lmt_name) cs.description = "The ACES Look Transform: %s" % lmt_name cs.aliases = aliases cs.equality_group = "" cs.family = "Look" cs.is_data = False cs.allocation_type = ocio.Constants.ALLOCATION_LG2 cs.allocation_vars = [-8, 5, 0.00390625] cs.aces_transform_id = lmt_values["transformID"] pprint.pprint(lmt_values) # Generating the *shaper* transform. (shaper_name, shaper_to_ACES_CTL, shaper_from_ACES_CTL, shaper_input_scale, shaper_params) = shaper_info # Add the shaper transform shaper_lut = "%s_to_linear.spi1d" % shaper_name shaper_lut = sanitize(shaper_lut) shaper_OCIO_transform = {"type": "lutFile", "path": shaper_lut, "interpolation": "linear", "direction": "inverse"} # Generating the forward transform. cs.from_reference_transforms = [] if "transformCTL" in lmt_values: ctls = [shaper_to_ACES_CTL % aces_ctl_directory, os.path.join(aces_ctl_directory, lmt_values["transformCTL"])] lut = "%s.%s.spi3d" % (shaper_name, lmt_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), ctls, lut_resolution_3d, "float", 1 / shaper_input_scale, 1, shaper_params, cleanup, aces_ctl_directory, ) cs.from_reference_transforms.append(shaper_OCIO_transform) cs.from_reference_transforms.append( {"type": "lutFile", "path": lut, "interpolation": "tetrahedral", "direction": "forward"} ) # Generating the inverse transform. cs.to_reference_transforms = [] if "transformCTLInverse" in lmt_values: ctls = [ os.path.join(aces_ctl_directory, lmt_values["transformCTLInverse"]), shaper_from_ACES_CTL % aces_ctl_directory, ] lut = "Inverse.%s.%s.spi3d" % (odt_name, shaper_name) lut = sanitize(lut) generate_3d_LUT_from_CTL( os.path.join(lut_directory, lut), ctls, lut_resolution_3d, "half", 1, shaper_input_scale, shaper_params, cleanup, aces_ctl_directory, 0, 1, 1, ) cs.to_reference_transforms.append( {"type": "lutFile", "path": lut, "interpolation": "tetrahedral", "direction": "forward"} ) shaper_inverse = shaper_OCIO_transform.copy() shaper_inverse["direction"] = "forward" cs.to_reference_transforms.append(shaper_inverse) return cs