Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrenderlight_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
5
6
7#ifndef QSSG_RENDER_LIGHT_H
8#define QSSG_RENDER_LIGHT_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtQuick3DRuntimeRender/private/qssgrendernode_p.h>
22
23QT_BEGIN_NAMESPACE
24
25struct QSSGRenderImage;
26
27struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderLight : public QSSGRenderNode
28{
29 enum class DirtyFlag : quint8
30 {
31 LightDirty = 0x1
32 };
33 using FlagT = std::underlying_type_t<DirtyFlag>;
34
35 // Must match QQuick3DAbstractLight::QSSGSoftShadowQuality
36 enum class SoftShadowQuality {
37 Hard = 0,
38 PCF4,
39 PCF8,
40 PCF16,
41 PCF32,
42 PCF64,
43 };
44
45 static constexpr DirtyFlag DirtyMask { std::numeric_limits<FlagT>::max() };
46
47 QSSGRenderNode *m_scope;
48 QVector3D m_diffuseColor; // colors are 0-1 normalized
49 QVector3D m_specularColor; // colors are 0-1 normalized
50 QVector3D m_ambientColor; // colors are 0-1 normalized
51
52 // The variables below are in the same range as Studio
53 // Only valid if node is a point light
54 float m_brightness;
55 float m_constantFade;
56 float m_linearFade;
57 float m_quadraticFade;
58
59 float m_coneAngle; // 0-180
60 float m_innerConeAngle; // 0-180
61
62 FlagT m_lightDirtyFlags = 0;
63 bool m_castShadow; // true if this light produce shadows
64 float m_shadowBias; // depth shift to avoid self-shadowing artifacts
65 float m_shadowFactor; // Darkening factor for ESMs
66 quint32 m_shadowMapRes; // Resolution of shadow map
67 float m_shadowMapFar; // Far clip plane for the shadow map
68 float m_shadowFilter; // Shadow map filter step size
69 SoftShadowQuality m_softShadowQuality = SoftShadowQuality::PCF4;
70
71 float m_pcfFactor = 2.0f;
72 bool m_use32BitShadowmap = false;
73
74 bool m_bakingEnabled = false;
75 bool m_fullyBaked = false; // direct+indirect
76
77 // Cascading shadow map options
78 float m_csmSplit1 = 0.1f;
79 float m_csmSplit2 = 0.25f;
80 float m_csmSplit3 = 0.5f;
81 int m_csmNumSplits = 0;
82 float m_csmBlendRatio = 0.05f;
83 bool m_lockShadowmapTexels = false;
84
85 // Defaults to directional light
86 explicit QSSGRenderLight(Type type = Type::DirectionalLight);
87
88 [[nodiscard]] inline bool isEnabled() const { return (m_brightness > 0.0f); }
89
90 [[nodiscard]] inline bool isDirty(DirtyFlag dirtyFlag = DirtyMask) const
91 {
92 return ((m_lightDirtyFlags & FlagT(dirtyFlag)) != 0)
93 || ((dirtyFlag == DirtyMask) && QSSGRenderNode::isDirty());
94 }
95 void markDirty(DirtyFlag dirtyFlag);
96 void clearDirty(DirtyFlag dirtyFlag);
97};
98QT_END_NAMESPACE
99
100#endif