-
Notifications
You must be signed in to change notification settings - Fork 16
/
Arri_PFE_OFX.dctl
82 lines (64 loc) · 2.87 KB
/
Arri_PFE_OFX.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Arri LogC Print Film Emulation OFX DCTL
// Requires ACES_LIB.h
DEFINE_UI_PARAMS(Exposure, Exposure, DCTLUI_SLIDER_FLOAT, 0, -3, 3, 0.001)
DEFINE_UI_PARAMS(Sat, Saturation, DCTLUI_SLIDER_FLOAT, 1, 0, 2, 0.001)
DEFINE_UI_PARAMS(peak, Peak, DCTLUI_SLIDER_FLOAT, 1, 0, 2, 0.001)
DEFINE_UI_PARAMS(curve, Contrast, DCTLUI_SLIDER_FLOAT, 1, 0, 2, 0.001)
DEFINE_UI_PARAMS(pivot, Pivot, DCTLUI_SLIDER_FLOAT, 0, -1, 1, 0.001)
DEFINE_UI_PARAMS(offset, Offset, DCTLUI_SLIDER_FLOAT, 0, -1, 1, 0.001)
DEFINE_UI_PARAMS(softClip, Sat Softclip, DCTLUI_SLIDER_FLOAT, 0, 0, 1, 0.001)
DEFINE_UI_PARAMS(PFE, Enable PFE, DCTLUI_CHECK_BOX, 1)
#include "ACES_LIB.h"
__CONSTANT__ float AP0_Rec709[9] = {2.52161f, -1.13407f, -0.387538f, -0.276482f, 1.37272f, -0.0962352f, -0.0153831f, -0.152991f, 1.16837f};
__DEVICE__ float3 Sigmoid( float3 In, float peak, float curve, float pivot, float offset) {
float3 out;
pivot = 0.435f - pivot/10.0f;
out.x = peak / (1.0f + _expf(-8.9f * curve * (In.x - pivot))) + offset;
out.y = peak / (1.0f + _expf(-8.9f * curve * (In.y - pivot))) + offset;
out.z = peak / (1.0f + _expf(-8.9f * curve * (In.z - pivot))) + offset;
return out;
}
__DEVICE__ float linLogc(float linVal) {
return linVal > 0.010591f ? 0.247190f * _log10f(5.555556f * linVal + 0.052272f) + 0.385537f : 5.367655f * linVal + 0.092809f;
}
__DEVICE__ float Sat_Soft_Clip( float S, float softclip) {
softclip *= 0.3f;
return S > softclip ? (-1.0f / ((S - softclip) / (1.0f - softclip) + 1.0f) + 1.0f) * (1.0f - softclip) + softclip : S;
}
__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 aces = make_float3(p_R, p_G, p_B);
aces = IDT_Alexa_v3_logC_EI800(aces);
float Saturation = Sat;
if (Exposure != 0.0f)
aces = aces * _exp2f(Exposure);
if (PFE) Saturation = 0.7f * Sat;
aces = scale_C( aces, Saturation);
float3 SLOPE = make_float3(1.0f, 1.0f, 0.94f);
float3 OFFSET = make_float3(0.0f, 0.0f, 0.02f);
float3 POWER = make_float3(1.0f, 1.0f, 1.0f);
if (PFE) {
aces = ASCCDL_inACEScct( aces, SLOPE, OFFSET, POWER, 1.0f);
aces = gamma_adjust_linear( aces, 1.5f, 0.18f);
aces = rotate_H_in_H( aces, 0.0f, 30.0f, 5.0f);
aces = rotate_H_in_H( aces, 80.0f, 60.0f, -15.0f);
aces = rotate_H_in_H( aces, 52.0f, 50.0f, -14.0f);
aces = scale_C_at_H( aces, 45.0f, 40.0f, 1.4f);
aces = rotate_H_in_H( aces, 190.0f, 40.0f, 30.0f);
aces = scale_C_at_H( aces, 240.0f, 120.0f, 1.4f);
}
float3 RGB;
RGB.x = aces.x * AP0_Rec709[0] + aces.y * AP0_Rec709[1] + aces.z * AP0_Rec709[2];
RGB.y = aces.x * AP0_Rec709[3] + aces.y * AP0_Rec709[4] + aces.z * AP0_Rec709[5];
RGB.z = aces.x * AP0_Rec709[6] + aces.y * AP0_Rec709[7] + aces.z * AP0_Rec709[8];
RGB.x = linLogc(RGB.x);
RGB.y = linLogc(RGB.y);
RGB.z = linLogc(RGB.z);
RGB = Sigmoid( RGB, peak, curve, pivot, offset);
if (softClip > 0.0f) {
RGB = rgb_2_ych(RGB);
RGB.y = Sat_Soft_Clip( RGB.y, 1.0f - softClip);
RGB = ych_2_rgb(RGB);
}
return RGB;
}