-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3. HueRotation.dctl
36 lines (31 loc) · 1.95 KB
/
3. HueRotation.dctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#line 2 "3. HueRotation.dctl"
#include "_2500.h"
// Rotate hue flight
// mainly rotate red primary, to the right is warmer/orange, and to the left colder/magenta
DEFINE_UI_PARAMS(rot_r, Overall Rotate Hue R -, DCTLUI_SLIDER_FLOAT, 0.05, -0.5, 0.5, 0.1)
// mainly rotate green primary, to the right is warmer/yellow, and to the left colder/cyan
DEFINE_UI_PARAMS(rot_g, G |, DCTLUI_SLIDER_FLOAT, 0.05, -0.5, 0.5, 0.1)
// mainly rotate blue primary, to the right is colder/cyan, and to the left is warmer/magenta
DEFINE_UI_PARAMS(rot_b, B |, DCTLUI_SLIDER_FLOAT, 0.23, -0.5, 0.5, 0.1)
// Highligh rotation direction is the same as the overall hue rotate, but it mainly affect bright values
DEFINE_UI_PARAMS(rot_rh, Highlight Rotate Hue R -, DCTLUI_SLIDER_FLOAT, 0.0, -0.5, 0.5, 0.1)
DEFINE_UI_PARAMS(rot_gh, G |, DCTLUI_SLIDER_FLOAT, 0.3, -0.5, 0.5, 0.1)
DEFINE_UI_PARAMS(rot_bh, B |, DCTLUI_SLIDER_FLOAT, -0.02, -0.5, 0.5, 0.1)
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B) {
float3 rgb = make_float3(p_R, p_G, p_B);
// TODO: Need to figure out what to do about these weights that are hardcoded Rec709
float3 weights = avgweights(matrix_rec709_to_xyz);
float lum = lumMask(rgb, weights.x, weights.y, weights.z);
// Calculate two hue matrices, these matrices can't create negatives as this would break things later one, one will be applied as it
// is and the other one will use the mask apply it
float3x3 M1 = simpleHueMatrix(rot_rh, rot_gh, rot_bh);
float3x3 M2 = simpleHueMatrix(rot_r, rot_g, rot_b);
// apply the "highlight" hue matrix
// mix the pre-highlight matrix and the post-matrix using the lum
float3 m = _mix(rgb, vdot(M1,rgb), lum);
// apply the overall hue matrix
float3 hue = vdot(M2,m);
float3 ec = EnergyCorrection(rgb, hue, matrix_rec709_to_xyz);
float3 out = maxf3(0, ec);
return out;
}