-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathFilmicToneCurve.h
129 lines (105 loc) · 2.15 KB
/
FilmicToneCurve.h
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// Copyright (C) Wojciech Jarosz <wjarosz@gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE.txt file.
//
// This file is a modified version of Filmic Worlds' FilmicToneCurve class:
// https://github.com/johnhable/fw-public
// which was released into the public domain through the CC0 Universal license
#pragma once
#include "Common.h"
class FilmicToneCurve
{
public:
struct CurveParamsUser
{
float toeStrength = .25f; ///< as a ratio in [0,1]
float toeLength = .25f; ///< as a ratio in [0,1]
float shoulderStrength = 4.0f; ///< white point, in F stops
float shoulderLength = 0.5f; ///< as a ratio in [0,1]
float shoulderAngle = 0.5f; ///< as a ratio in [0,1]
float gamma = 1.0f;
};
struct CurveParamsDirect
{
CurveParamsDirect()
{
reset();
}
void reset()
{
x0 = .25f;
y0 = .25f;
x1 = .75f;
y1 = .75f;
W = 1.0f;
gamma = 1.0f;
overshootX = 0.0f;
overshootY = 0.0f;
}
float x0;
float y0;
float x1;
float y1;
float W;
float overshootX;
float overshootY;
float gamma;
};
struct CurveSegment
{
CurveSegment()
{
reset();
}
void reset()
{
offsetX = 0.0f;
offsetY = 0.0f;
scaleX = 1.0f; // always 1 or -1
lnA = 0.0f;
B = 1.0f;
}
float eval(float x) const;
float evalInv(float y) const;
float offsetX;
float offsetY;
float scaleX; // always 1 or -1
float scaleY;
float lnA;
float B;
};
struct FullCurve
{
FullCurve()
{
reset();
}
void reset()
{
W = 1.0f;
invW = 1.0f;
x0 = .25f;
y0 = .25f;
x1 = .75f;
y1 = .75f;
for (int i = 0; i < 3; i++)
{
m_segments[i].reset();
m_invSegments[i].reset();
}
}
float eval(float x) const;
float evalInv(float x) const;
float W;
float invW;
float x0;
float x1;
float y0;
float y1;
CurveSegment m_segments[3];
CurveSegment m_invSegments[3];
};
static void createCurve(FullCurve& dstCurve, const CurveParamsDirect& srcParams);
static void calcDirectParamsFromUser(CurveParamsDirect& dstParams, const CurveParamsUser& srcParams);
};