- print("generateLUTs - begin")
- configData = {}
-
- #
- # Define the reference color space
- #
- ACES = ColorSpace('ACES2065-1')
- ACES.description = (
- 'The Academy Color Encoding System reference color space')
- ACES.equalityGroup = ''
- ACES.family = 'ACES'
- ACES.isData = False
- ACES.allocationType = OCIO.Constants.ALLOCATION_LG2
- ACES.allocationVars = [-15, 6]
-
- configData['referenceColorSpace'] = ACES
-
- #
- # Define the displays
- #
- configData['displays'] = {}
-
- #
- # Define the other color spaces
- #
- configData['colorSpaces'] = []
-
- # Matrix converting ACES AP1 primaries to AP0
- acesAP1toAP0 = [0.6954522414, 0.1406786965, 0.1638690622,
- 0.0447945634, 0.8596711185, 0.0955343182,
- -0.0055258826, 0.0040252103, 1.0015006723]
-
- # Matrix converting ACES AP0 primaries to XYZ
- acesAP0toXYZ = [0.9525523959, 0.0000000000, 0.0000936786,
- 0.3439664498, 0.7281660966, -0.0721325464,
- 0.0000000000, 0.0000000000, 1.0088251844]
-
- #
- # ACEScc
- #
- def createACEScc(name='ACEScc',
- minValue=0.0,
- maxValue=1.0,
- inputScale=1.0):
- cs = ColorSpace(name)
- cs.description = "The %s color space" % name
- cs.equalityGroup = ''
- cs.family = 'ACES'
- cs.isData = False
-
- ctls = [
- '%s/ACEScc/ACEScsc.ACEScc_to_ACES.a1.0.0.ctl' % acesCTLReleaseDir,
- # This transform gets back to the AP1 primaries
- # Useful as the 1d LUT is only covering the transfer function
- # The primaries switch is covered by the matrix below
- '%s/ACEScg/ACEScsc.ACES_to_ACEScg.a1.0.0.ctl' % acesCTLReleaseDir
- ]
- lut = "%s_to_ACES.spi1d" % name
-
- # Remove spaces and parentheses
- lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
-
- genlut.generate1dLUTFromCTL(
- lutDir + "/" + lut,
- ctls,
- lutResolution1d,
- 'float',
- inputScale,
- 1.0,
- {},
- cleanup,
- acesCTLReleaseDir,
- minValue,
- maxValue)
-
- cs.toReferenceTransforms = []
- cs.toReferenceTransforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- # AP1 primaries to AP0 primaries
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': mat44FromMat33(acesAP1toAP0),
- 'direction': 'forward'
- })
-
- cs.fromReferenceTransforms = []
- return cs
-
- ACEScc = createACEScc()
- configData['colorSpaces'].append(ACEScc)
-
- #
- # ACESproxy
- #
- def createACESProxy(name='ACESproxy'):
- cs = ColorSpace(name)
- cs.description = "The %s color space" % name
- cs.equalityGroup = ''
- cs.family = 'ACES'
- cs.isData = False
-
- ctls = [
- '%s/ACESproxy/ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl' % (
- acesCTLReleaseDir),
- # This transform gets back to the AP1 primaries
- # Useful as the 1d LUT is only covering the transfer function
- # The primaries switch is covered by the matrix below
- '%s/ACEScg/ACEScsc.ACES_to_ACEScg.a1.0.0.ctl' % acesCTLReleaseDir
- ]
- lut = "%s_to_aces.spi1d" % name
-
- # Remove spaces and parentheses
- lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
-
- genlut.generate1dLUTFromCTL(
- lutDir + "/" + lut,
- ctls,
- lutResolution1d,
- 'uint16',
- 64.0,
- 1.0,
- {},
- cleanup,
- acesCTLReleaseDir)
-
- cs.toReferenceTransforms = []
- cs.toReferenceTransforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- # AP1 primaries to AP0 primaries
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': mat44FromMat33(acesAP1toAP0),
- 'direction': 'forward'
- })
-
- cs.fromReferenceTransforms = []
- return cs
-
- ACESproxy = createACESProxy()
- configData['colorSpaces'].append(ACESproxy)
-
- #
- # ACEScg
- #
- def createACEScg(name='ACEScg'):
- cs = ColorSpace(name)
- cs.description = "The %s color space" % name
- cs.equalityGroup = ''
- cs.family = 'ACES'
- cs.isData = False
-
- cs.toReferenceTransforms = []
-
- # AP1 primaries to AP0 primaries
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': mat44FromMat33(acesAP1toAP0),
- 'direction': 'forward'
- })
-
- cs.fromReferenceTransforms = []
- return cs
-
- ACEScg = createACEScg()
- configData['colorSpaces'].append(ACEScg)
-
- #
- # ADX
- #
- def createADX(bitdepth=10, name='ADX'):
- name = "%s%s" % (name, bitdepth)
- cs = ColorSpace(name)
- cs.description = "%s color space - used for film scans" % name
- cs.equalityGroup = ''
- cs.family = 'ADX'
- cs.isData = False
-
- if bitdepth == 10:
- cs.bitDepth = bitDepth = OCIO.Constants.BIT_DEPTH_UINT10
- adx_to_cdd = [1023.0 / 500.0, 0.0, 0.0, 0.0,
- 0.0, 1023.0 / 500.0, 0.0, 0.0,
- 0.0, 0.0, 1023.0 / 500.0, 0.0,
- 0.0, 0.0, 0.0, 1.0]
- offset = [-95.0 / 500.0, -95.0 / 500.0, -95.0 / 500.0, 0.0]
- elif bitdepth == 16:
- cs.bitDepth = bitDepth = OCIO.Constants.BIT_DEPTH_UINT16
- adx_to_cdd = [65535.0 / 8000.0, 0.0, 0.0, 0.0,
- 0.0, 65535.0 / 8000.0, 0.0, 0.0,
- 0.0, 0.0, 65535.0 / 8000.0, 0.0,
- 0.0, 0.0, 0.0, 1.0]
- offset = [-1520.0 / 8000.0, -1520.0 / 8000.0, -1520.0 / 8000.0,
- 0.0]
-
- cs.toReferenceTransforms = []
-
- # Convert from ADX to Channel-Dependent Density
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': adx_to_cdd,
- 'offset': offset,
- 'direction': 'forward'
- })
-
- # Convert from Channel-Dependent Density to Channel-Independent Density
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': [0.75573, 0.22197, 0.02230, 0,
- 0.05901, 0.96928, -0.02829, 0,
- 0.16134, 0.07406, 0.76460, 0,
- 0.0, 0.0, 0.0, 1.0],
- 'direction': 'forward'
- })
-
- # Copied from Alex Fry's adx_cid_to_rle.py
- def createCIDtoRLELUT():
- def interpolate1D(x, xp, fp):
- return numpy.interp(x, xp, fp)
-
- LUT_1D_xp = [-0.190000000000000,
- 0.010000000000000,
- 0.028000000000000,
- 0.054000000000000,
- 0.095000000000000,
- 0.145000000000000,
- 0.220000000000000,
- 0.300000000000000,
- 0.400000000000000,
- 0.500000000000000,
- 0.600000000000000]
-
- LUT_1D_fp = [-6.000000000000000,
- -2.721718645000000,
- -2.521718645000000,
- -2.321718645000000,
- -2.121718645000000,
- -1.921718645000000,
- -1.721718645000000,
- -1.521718645000000,
- -1.321718645000000,
- -1.121718645000000,
- -0.926545676714876]
-
- REF_PT = ((7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) -
- math.log(0.18, 10.0))
-
- def cid_to_rle(x):
- if x <= 0.6:
- return interpolate1D(x, LUT_1D_xp, LUT_1D_fp)
- return (100.0 / 55.0) * x - REF_PT
-
- def Fit(value, fromMin, fromMax, toMin, toMax):
- if fromMin == fromMax:
- raise ValueError("fromMin == fromMax")
- return (value - fromMin) / (fromMax - fromMin) * (
- toMax - toMin) + toMin
-
- NUM_SAMPLES = 2 ** 12
- RANGE = (-0.19, 3.0)
- data = []
- for i in xrange(NUM_SAMPLES):
- x = i / (NUM_SAMPLES - 1.0)
- x = Fit(x, 0.0, 1.0, RANGE[0], RANGE[1])
- data.append(cid_to_rle(x))
-
- lut = 'ADX_CID_to_RLE.spi1d'
- genlut.writeSPI1D(lutDir + "/" + lut, RANGE[0], RANGE[1], data,
- NUM_SAMPLES, 1)
-
- return lut
-
- # Convert Channel Independent Density values to Relative Log Exposure
- # values.
- lut = createCIDtoRLELUT()
- cs.toReferenceTransforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- # Convert Relative Log Exposure values to Relative Exposure values
- cs.toReferenceTransforms.append({
- 'type': 'log',
- 'base': 10,
- 'direction': 'inverse'
- })
-
- # Convert Relative Exposure values to ACES values
- cs.toReferenceTransforms.append({
- 'type': 'matrix',
- 'matrix': [0.72286, 0.12630, 0.15084, 0,
- 0.11923, 0.76418, 0.11659, 0,
- 0.01427, 0.08213, 0.90359, 0,
- 0.0, 0.0, 0.0, 1.0],
- 'direction': 'forward'
- })
-
- cs.fromReferenceTransforms = []
- return cs
-
- ADX10 = createADX(bitdepth=10)
- configData['colorSpaces'].append(ADX10)
-
- ADX16 = createADX(bitdepth=16)
- configData['colorSpaces'].append(ADX16)
-
- #
- # Camera Input Transforms
- #
-
- # RED color spaces to ACES
- redColorSpaces = red.createColorSpaces(lutDir, lutResolution1d)
- for cs in redColorSpaces:
- configData['colorSpaces'].append(cs)
-
- # Canon-Log to ACES
- canonColorSpaces = canon.createColorSpaces(lutDir, lutResolution1d)
- for cs in canonColorSpaces:
- configData['colorSpaces'].append(cs)
-
- # SLog to ACES
- sonyColorSpaces = sony.createColorSpaces(lutDir, lutResolution1d)
- for cs in sonyColorSpaces:
- configData['colorSpaces'].append(cs)
-
- # LogC to ACES
- arriColorSpaces = arri.createColorSpaces(lutDir, lutResolution1d)
- for cs in arriColorSpaces:
- configData['colorSpaces'].append(cs)
-
- #
- # Generic log transform
- #
- def createGenericLog(name='log',
- minValue=0.0,
- maxValue=1.0,
- inputScale=1.0,
- middleGrey=0.18,
- minExposure=-6.0,
- maxExposure=6.5,
- lutResolution1d=lutResolution1d):
- cs = ColorSpace(name)
- cs.description = "The %s color space" % name
- cs.equalityGroup = name
- cs.family = 'Utility'
- cs.isData = False
-
- ctls = [
- '%s/utilities/ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl' % (
- acesCTLReleaseDir)
- ]
- lut = "%s_to_aces.spi1d" % name
-
- # Remove spaces and parentheses
- lut = lut.replace(' ', '_').replace(')', '_').replace('(', '_')
-
- genlut.generate1dLUTFromCTL(
- lutDir + "/" + lut,
- ctls,
- lutResolution1d,
- 'float',
- inputScale,
- 1.0,
- {
- 'middleGrey': middleGrey,
- 'minExposure': minExposure,
- 'maxExposure': maxExposure
- },
- cleanup,
- acesCTLReleaseDir,
- minValue,
- maxValue)
-
- cs.toReferenceTransforms = []
- cs.toReferenceTransforms.append({
- 'type': 'lutFile',
- 'path': lut,
- 'interpolation': 'linear',
- 'direction': 'forward'
- })
-
- cs.fromReferenceTransforms = []
- return cs
-
- #
- # ACES LMTs
- #
- def createACESLMT(lmtName,
- lmtValues,
- shaperInfo,
- lutResolution1d=1024,
- lutResolution3d=64,
- cleanup=True):
- cs = ColorSpace("%s" % lmtName)
- cs.description = "The ACES Look Transform: %s" % lmtName
- cs.equalityGroup = ''
- cs.family = 'Look'
- cs.isData = False
-
- import pprint
-
- pprint.pprint(lmtValues)