Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qssgcputonemapper_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2022 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#ifndef QSSGCPUTONEMAPPER_P_H
6#define QSSGCPUTONEMAPPER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/qvector3d.h>
20
22
23namespace QSSGTonemapper {
24
25inline QVector3D vsqrt(const QVector3D &a)
26{
27 return QVector3D(std::sqrt(a.x()), std::sqrt(a.y()), std::sqrt(a.z()));
28}
29
30inline QVector3D vmax(const QVector3D &a, const QVector3D &b)
31{
32 return QVector3D(std::max(a.x(), b.x()), std::max(a.y(), b.y()), std::max(a.z(), b.z()));
33}
34
35inline QVector3D vclamp(const QVector3D &a, float b, float c)
36{
37 return QVector3D(qBound(b, a.x(), c), qBound(b, a.y(), c), qBound(b, a.z(), c));
38}
39
40inline QVector3D vadd(const QVector3D &a, float b)
41{
42 return QVector3D(a.x() + b, a.y() + b, a.z() + b);
43}
44
45template<typename mType>
46inline QVector3D mad(mType m, const QVector3D &a, float b)
47{
48 return vadd(m * a, b);
49}
50
51// all the implementation here is expected to match tonemapper.glsllib
52
54{
55 const QVector3D S1 = vsqrt(c);
56 const QVector3D S2 = vsqrt(S1);
57 const QVector3D S3 = vsqrt(S2);
58 return 0.58512238f * S1 + 0.78314035f * S2 - 0.36826273f * S3;
59}
60
62{
63 const QVector3D cc = vmax(QVector3D(0.0f, 0.0f, 0.0f), vadd(c, -0.004f));
64 return (cc * mad(6.2f, cc, 0.5f)) / vadd(cc * mad(6.2f, cc, 1.7f), 0.06f);
65}
66
68{
69 const float A = 2.51f;
70 const float B = 0.03f;
71 const float C = 2.43f;
72 const float D = 0.59f;
73 const float E = 0.14f;
74 return tonemapLinearToSrgb(vclamp((c * mad(A, c, B)) / vadd(c * mad(C, c, D), E), 0.0f, 1.0f));
75}
76
78{
79 const float A = 0.15f;
80 const float B = 0.50f;
81 const float C = 0.10f;
82 const float D = 0.20f;
83 const float E = 0.02f;
84 const float F = 0.30f;
85 return vadd(vadd(c * mad(A, c, C * B), D * E) / vadd(c * mad(A, c, B), D * F), -E / F);
86}
87
89{
90 static const QVector3D whiteScale = QVector3D(1.0f, 1.0f, 1.0f) / tonemapFilmicSub(QVector3D(11.2f, 11.2f, 11.2f));
91 return tonemapLinearToSrgb(tonemapFilmicSub(c * 2.0f) * whiteScale);
92}
93
94} // namespace QSSGTonemapper
95
97
98#endif
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
QVector3D vclamp(const QVector3D &a, float b, float c)
QVector3D vadd(const QVector3D &a, float b)
QVector3D tonemapFilmicSub(const QVector3D &c)
QVector3D vmax(const QVector3D &a, const QVector3D &b)
QVector3D mad(mType m, const QVector3D &a, float b)
QVector3D tonemapFilmic(const QVector3D &c)
QVector3D tonemapHejlDawson(const QVector3D &c)
QVector3D tonemapAces(const QVector3D &c)
QVector3D tonemapLinearToSrgb(const QVector3D &c)
QVector3D vsqrt(const QVector3D &a)
Combined button and popup list for selecting options.
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
n varying highp vec2 A
GLboolean GLboolean GLboolean b
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
const GLubyte * c