Skip to content

Commit 2b7b2ea

Browse files
committed
Added Knee (Highlight Rolloff) and Inverse Knee
1 parent 792802a commit 2b7b2ea

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

Inverse-Power-Knee.dctl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
DEFINE_UI_PARAMS(p, Power, DCTLUI_SLIDER_FLOAT, 2.4, 0.1, 10.0, 0.001)
2+
DEFINE_UI_PARAMS(t, Toe, DCTLUI_SLIDER_FLOAT, 0.8, 0.0, 1.0, 0.001)
3+
DEFINE_UI_PARAMS(l, Length, DCTLUI_SLIDER_FLOAT, 1.09, 1.01, 13.0, 0.001)
4+
5+
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
6+
{
7+
float3 pRGB = make_float3(p_R,p_G,p_B);
8+
9+
float s = (1.0f - t) / _powf((_powf((1.0f - t) / (l - t), p * -1.0f) - 1.0f), 1.0f / p);
10+
11+
pRGB.x = (pRGB.x > t) ? t + s * _powf(-1.0f * (_powf((pRGB.x - t) / s,p)) / (_powf((pRGB.x - t) / s,p) - 1.0f), 1.0f / p) : pRGB.x;
12+
pRGB.y = (pRGB.y > t) ? t + s * _powf(-1.0f * (_powf((pRGB.y - t) / s,p)) / (_powf((pRGB.y - t) / s,p) - 1.0f), 1.0f / p) : pRGB.y;
13+
pRGB.z = (pRGB.z > t) ? t + s * _powf(-1.0f * (_powf((pRGB.z - t) / s,p)) / (_powf((pRGB.z - t) / s,p) - 1.0f), 1.0f / p) : pRGB.z;
14+
15+
16+
return pRGB;
17+
}

Power-Knee.dctl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
DEFINE_UI_PARAMS(p, Power, DCTLUI_SLIDER_FLOAT, 2.4, 0.1, 10.0, 0.001)
2+
DEFINE_UI_PARAMS(t, Toe, DCTLUI_SLIDER_FLOAT, 0.8, 0.0, 1.0, 0.001)
3+
DEFINE_UI_PARAMS(l, Length, DCTLUI_SLIDER_FLOAT, 1.09, 1.01, 13.0, 0.001)
4+
5+
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
6+
{
7+
float3 pRGB = make_float3(p_R,p_G,p_B);
8+
9+
float s = (1.0f - t) / _powf((_powf((1.0f - t) / (l - t), p * -1.0f) - 1.0f), 1.0f / p);
10+
11+
pRGB.x = (pRGB.x >= t) ? t + s * ( (pRGB.x - t) / s ) / _powf( 1.0f + _powf((pRGB.x - t) / s, p ), (1.0f / p)) : pRGB.x;
12+
pRGB.y = (pRGB.y >= t) ? t + s * ( (pRGB.y - t) / s ) / _powf( 1.0f + _powf((pRGB.y - t) / s, p ), (1.0f / p)) : pRGB.y;
13+
pRGB.z = (pRGB.z >= t) ? t + s * ( (pRGB.z - t) / s ) / _powf( 1.0f + _powf((pRGB.z - t) / s, p ), (1.0f / p)) : pRGB.z;
14+
15+
return pRGB;
16+
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Includes:
1919
* Clamp-Extended - Clamp values between 0 and 1000
2020
* Step-Ramp - Generate linear ramp with up to 4096 steps and custom scale
2121
* Inverse-S-Curves - Generate Inverted S-Curves using various Sigmoid functions
22+
* Power-Knee - Highlight roll-off based on Power function
23+
* Inverse-Power-Knee - Inverse Highlight roll-off based on Power function
2224

2325

2426
Transforms use Rec.709 Color Primaries where applicable.

0 commit comments

Comments
 (0)