1- DEFINE_UI_PARAMS(cmethod, method, DCTLUI_COMBO_BOX, 2, {L, R, P, E, A, T}, {log, reinhard, power, exp, arctan, tanh});
2- DEFINE_UI_PARAMS(threshold, threshold, DCTLUI_SLIDER_FLOAT, 0.2f, 0.0f, 0.6f, 0.0f);
1+ DEFINE_UI_PARAMS(threshold_r, threshold r, DCTLUI_SLIDER_FLOAT, 0.2f, 0.0f, 0.6f, 0.0f);
2+ DEFINE_UI_PARAMS(threshold_g, threshold g, DCTLUI_SLIDER_FLOAT, 0.2f, 0.0f, 0.6f, 0.0f);
3+ DEFINE_UI_PARAMS(threshold_b, threshold b, DCTLUI_SLIDER_FLOAT, 0.2f, 0.0f, 0.6f, 0.0f);
34DEFINE_UI_PARAMS(power, power, DCTLUI_SLIDER_FLOAT, 1.2f, 1.0f, 3.0f, 1.0f);
45DEFINE_UI_PARAMS(shd_rolloff, shd rolloff, DCTLUI_SLIDER_FLOAT, 0.03f, 0.0f, 0.1f, 0.0f);
56DEFINE_UI_PARAMS(cyan, cyan, DCTLUI_SLIDER_FLOAT, 0.09f, 0.0f, 1.0f, 0.0f);
67DEFINE_UI_PARAMS(magenta, magenta, DCTLUI_SLIDER_FLOAT, 0.24f, 0.0f, 1.0f, 0.0f);
78DEFINE_UI_PARAMS(yellow, yellow, DCTLUI_SLIDER_FLOAT, 0.12f, 0.0f, 1.0f, 0.0f);
8- DEFINE_UI_PARAMS(compress_secondaries, compress secondaries, DCTLUI_CHECK_BOX, 0 );
9+ DEFINE_UI_PARAMS(cmethod, method, DCTLUI_COMBO_BOX, 2, {L, R, P, E, A, T}, {log, reinhard, power, exp, arctan, tanh} );
910DEFINE_UI_PARAMS(working_colorspace, working space, DCTLUI_COMBO_BOX, 0, {acescct, acescc, acescg}, {acescct, acescc, acescg});
11+ DEFINE_UI_PARAMS(hexagonal, hexagonal, DCTLUI_CHECK_BOX, 0);
1012DEFINE_UI_PARAMS(invert, invert, DCTLUI_CHECK_BOX, 0);
1113
1214__CONSTANT__ float pi = 3.14159265359f;
@@ -221,7 +223,10 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
221223 }
222224
223225 // thr is the percentage of the core gamut to protect: the complement of threshold.
224- float thr = 1.0f - threshold;
226+ float3 thr = make_float3(
227+ 1.0f-_fmaxf(0.00001, threshold_r),
228+ 1.0f-_fmaxf(0.00001, threshold_g),
229+ 1.0f-_fmaxf(0.00001, threshold_b));
225230
226231 // lim is the max distance from the gamut boundary that will be compressed
227232 // 0 is a no-op, 1 will compress colors from a distance of 2.0 from achromatic to the gamut boundary
@@ -236,9 +241,9 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
236241 // Not sure of a way to pre-calculate a constant using the values from the ui parameters in Resolve DCTL...
237242 // This approach might have performance implications
238243 lim = make_float3(
239- bisect(_fmaxf(0.0001f, cyan)+1.0f, thr, method),
240- bisect(_fmaxf(0.0001f, magenta)+1.0f, thr, method),
241- bisect(_fmaxf(0.0001f, yellow)+1.0f, thr, method));
244+ bisect(_fmaxf(0.0001f, cyan)+1.0f, thr.x , method),
245+ bisect(_fmaxf(0.0001f, magenta)+1.0f, thr.y , method),
246+ bisect(_fmaxf(0.0001f, yellow)+1.0f, thr.z , method));
242247 }
243248
244249 // achromatic axis
@@ -256,23 +261,23 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
256261 // compress distance with user controlled parameterized shaper function
257262 float sat;
258263 float3 csat, cdist;
259- if (compress_secondaries ) {
264+ if (hexagonal ) {
260265 // Based on Nick Shaw's variation on the gamut mapping algorithm
261266 // https://community.acescentral.com/t/a-variation-on-jeds-rgb-gamut-mapper/3060
262267 sat = _fmaxf(dist.x, _fmaxf(dist.y, dist.z));
263268 csat = make_float3(
264- compress(sat, lim.x, thr, invert, method, power),
265- compress(sat, lim.y, thr, invert, method, power),
266- compress(sat, lim.z, thr, invert, method, power));
269+ compress(sat, lim.x, thr.x , invert, method, power),
270+ compress(sat, lim.y, thr.y , invert, method, power),
271+ compress(sat, lim.z, thr.z , invert, method, power));
267272 cdist = sat == 0.0f ? dist : make_float3(
268273 dist.x * csat.x / sat,
269274 dist.y * csat.y / sat,
270275 dist.z * csat.z / sat);
271276 } else {
272277 cdist = make_float3(
273- compress(dist.x, lim.x, thr, invert, method, power),
274- compress(dist.y, lim.y, thr, invert, method, power),
275- compress(dist.z, lim.z, thr, invert, method, power));
278+ compress(dist.x, lim.x, thr.x , invert, method, power),
279+ compress(dist.y, lim.y, thr.y , invert, method, power),
280+ compress(dist.z, lim.z, thr.z , invert, method, power));
276281 }
277282
278283 // recalculate rgb from compressed distance and achromatic
@@ -282,10 +287,6 @@ __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p
282287 ach-cdist.y*ach_shd,
283288 ach-cdist.z*ach_shd);
284289
285- crgb.x = isnan(crgb.x) ? 0.0f : crgb.x;
286- crgb.y = isnan(crgb.y) ? 0.0f : crgb.y;
287- crgb.z = isnan(crgb.z) ? 0.0f : crgb.z;
288-
289290 if (working_colorspace == acescct) {
290291 crgb.x = lin_to_acescct(crgb.x);
291292 crgb.y = lin_to_acescct(crgb.y);
0 commit comments