1 | // Copyright (C) 2008-2012 NVIDIA Corporation. |
2 | // Copyright (C) 2019 The Qt Company Ltd. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
4 | |
5 | #ifndef QSSG_RENDER_LIGHT_H |
6 | #define QSSG_RENDER_LIGHT_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 <QtQuick3DRuntimeRender/private/qssgrendernode_p.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | struct QSSGRenderImage; |
24 | |
25 | struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderLight : public QSSGRenderNode |
26 | { |
27 | enum class DirtyFlag : quint8 |
28 | { |
29 | LightDirty = 0x1 |
30 | }; |
31 | using FlagT = std::underlying_type_t<DirtyFlag>; |
32 | |
33 | static constexpr DirtyFlag DirtyMask { std::numeric_limits<FlagT>::max() }; |
34 | |
35 | QSSGRenderNode *m_scope; |
36 | QVector3D m_diffuseColor; // colors are 0-1 normalized |
37 | QVector3D m_specularColor; // colors are 0-1 normalized |
38 | QVector3D m_ambientColor; // colors are 0-1 normalized |
39 | |
40 | // The variables below are in the same range as Studio |
41 | // Only valid if node is a point light |
42 | float m_brightness; |
43 | float m_constantFade; |
44 | float m_linearFade; |
45 | float m_quadraticFade; |
46 | |
47 | float m_coneAngle; // 0-180 |
48 | float m_innerConeAngle; // 0-180 |
49 | |
50 | FlagT m_lightDirtyFlags = 0; |
51 | bool m_castShadow; // true if this light produce shadows |
52 | float m_shadowBias; // depth shift to avoid self-shadowing artifacts |
53 | float m_shadowFactor; // Darkening factor for ESMs |
54 | quint32 m_shadowMapRes; // Resolution of shadow map |
55 | float m_shadowMapFar; // Far clip plane for the shadow map |
56 | float m_shadowFilter; // Shadow map filter step size |
57 | |
58 | bool m_bakingEnabled; |
59 | bool m_fullyBaked; // direct+indirect |
60 | |
61 | // Defaults to directional light |
62 | explicit QSSGRenderLight(Type type = Type::DirectionalLight); |
63 | |
64 | [[nodiscard]] inline bool isEnabled() const { return (m_brightness > 0.0f); } |
65 | |
66 | [[nodiscard]] inline bool isDirty(DirtyFlag dirtyFlag = DirtyMask) const |
67 | { |
68 | return ((m_lightDirtyFlags & FlagT(dirtyFlag)) != 0) |
69 | || ((dirtyFlag == DirtyMask) && QSSGRenderNode::isDirty()); |
70 | } |
71 | void markDirty(DirtyFlag dirtyFlag); |
72 | void clearDirty(DirtyFlag dirtyFlag); |
73 | }; |
74 | QT_END_NAMESPACE |
75 | |
76 | #endif |
77 | |