Skip to content

Commit 1a30aed

Browse files
author
Alex Fry
committed
automated embedded LUTs in the DCTL versions
1 parent d4e8c53 commit 1a30aed

11 files changed

+23
-58
lines changed

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateA rev009 Rec2100 (Rec709 sim).dctl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateA rev009 Rec2100.dctl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;
@@ -25,7 +24,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2524
}
2625

2726

28-
2927
DEFINE_CUBE_LUT(DRTLUT)
3028
{
3129
TITLE "Generated by Foundry::LUT"

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateB rev009 Rec2100 (Rec709 sim).dctl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;
@@ -25,7 +24,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2524
}
2625

2726

28-
2927
DEFINE_CUBE_LUT(DRTLUT)
3028
{
3129
TITLE "Generated by Foundry::LUT"

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateB rev009 Rec2100.dctl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateB rev009 Rec709.dctl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;
@@ -25,7 +24,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2524
}
2625

2726

28-
2927
DEFINE_CUBE_LUT(DRTLUT)
3028
{
3129
TITLE "Generated by Foundry::LUT"

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateC rev009 Rec2100 (Rec709 sim).dctl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;
@@ -28,7 +27,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2827
}
2928

3029

31-
3230
DEFINE_CUBE_LUT(DRTLUT)
3331
{
3432
TITLE "Generated by Foundry::LUT"

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateC rev009 Rec2100.dctl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;
@@ -28,7 +27,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2827
}
2928

3029

31-
3230
DEFINE_CUBE_LUT(DRTLUT)
3331
{
3432
TITLE "Generated by Foundry::LUT"

DaVinci Resolve/ACES Transforms/ODT/ACES2 Candidates rev009/ACES2 CandidateC rev009 Rec709.dctl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
22

3-
43
__DEVICE__ float lin_to_ACEScct(float in) {
54
if (in <= 0.0078125f) {
65
return 10.5402377416545f * in + 0.0729055341958355f;
@@ -28,7 +27,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2827
}
2928

3029

31-
3230
DEFINE_CUBE_LUT(DRTLUT)
3331
{
3432
TITLE "Generated by Foundry::LUT"

python/lutWriteNodeCode.py

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,25 @@ def cubeToCub(cubePath,cubPath):
1818
inputCubePath = cubePath
1919
ouputCubPath = cubPath
2020

21-
22-
23-
24-
2521
# read the cube
2622
with open(inputCubePath) as f:
2723
lines = f.readlines()
2824

29-
30-
31-
32-
3325
# header
3426
tlHeader = '''# Truelight Cube v2.1
3527
# iDims 3
3628
# oDims 3
3729
# width 65 65 65\n
3830
# Cube'''
3931

40-
41-
42-
43-
4432
# footer
4533
tlFooter = '''\n# end\n'''
4634

47-
48-
49-
50-
51-
5235
LUTlines = lines[2:]
5336
LUTlines = [x.replace('\n','').split(' ') for x in LUTlines]
5437
LUTlines = [[float(i) for i in x] for x in LUTlines]
5538
LUTlines = [[str(i) for i in x] for x in LUTlines]
5639

57-
58-
59-
60-
6140
## remove decimal from 0.0 and 1.0
6241
for i, x in enumerate(LUTlines):
6342
for j, a in enumerate(x):
@@ -66,35 +45,19 @@ def cubeToCub(cubePath,cubPath):
6645
if '1.0' == a:
6746
LUTlines[i][j] = '1'
6847

69-
70-
71-
72-
7348
# reconstruct the cube string
7449
stringLUTlines = []
7550
for line in LUTlines:
7651
stringLUTlines.append(' '.join(line))
7752
newLUTStringBlock = '\n'.join(stringLUTlines)
7853

79-
80-
81-
82-
8354
# join it all up
8455
outputContents = tlHeader + '\n' + newLUTStringBlock + '\n' + tlFooter
8556

86-
87-
88-
89-
9057
# check directory for outputCubPath exists, if not, create it
9158
if not os.path.exists(os.path.dirname(ouputCubPath)):
9259
os.makedirs(os.path.dirname(ouputCubPath))
9360

94-
95-
96-
97-
9861
# write the file
9962
with open(ouputCubPath, 'w') as f:
10063
f.write(outputContents)
@@ -165,13 +128,19 @@ def bakeCandidateLUTfromNode(node):
165128
shutil.copy(cubePath,cubePathClean)
166129

167130

131+
# read contents of cube file
132+
with open(cubePathClean) as f:
133+
cubelines = f.readlines()
168134

169135

170136

171137
## write the dctl file
172138
with open(dctltemplatePath) as f:
173139
lines = f.readlines()
174140
newLines = [x.replace('replace.cube',cubeNameClean) for x in lines]
141+
# replace the string REPLACE_WITH_CUBE_DATA with the contents of cubelines
142+
newLines = [x.replace('REPLACE_WITH_CUBE_DATA',''.join(cubelines)) for x in newLines]
143+
175144
with open(dctlPath, 'w') as f:
176145
f.write(''.join(newLines))
177146

@@ -186,10 +155,14 @@ def bakeCandidateLUTfromNode(node):
186155
# copy cubePath to ocioCubePath
187156
shutil.copy(cubePath,ocioCubePath)
188157

189-
# remove original cube if it isnt the same as the clean version
190-
if cubePathClean != cubePath:
191-
# delete cubeName
158+
# # remove original cube if it isnt the same as the clean version
159+
# if cubePathClean != cubePath:
160+
# # delete cubeName
161+
# os.remove(cubePath)
162+
if os.path.exists(cubePath):
192163
os.remove(cubePath)
164+
if os.path.exists(cubePathClean):
165+
os.remove(cubePathClean)
193166

194167

195168

resources/ACES_ApplyLUT_Template_AP0.dctl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
DEFINE_ACES_PARAM(IS_PARAMETRIC_ACES_TRANSFORM: 0)
2-
DEFINE_LUT(DRTLUT, replace.cube)
3-
42

53
__DEVICE__ float lin_to_ACEScct(float in) {
64
if (in <= 0.0078125f) {
@@ -24,3 +22,8 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
2422

2523
return res;
2624
}
25+
26+
27+
DEFINE_CUBE_LUT(DRTLUT)
28+
{
29+
REPLACE_WITH_CUBE_DATA}

0 commit comments

Comments
 (0)