1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qquick3dbakedlightmap_p.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \qmltype BakedLightmap
10 \inherits QtObject
11 \inqmlmodule QtQuick3D
12 \brief Specifies baked lightmap settings for a model.
13 \since 6.4
14
15 A BakedLightmap object can be used to enable:
16
17 \list
18 \li persistently storing the baked lightmap data - during baking, or
19 \li loading the previously generated and stored lightmaps - at run time.
20 \endlist
21
22 A Model with \l{Model::usedInBakedLighting}{usedInBakedLighting} set to
23 true is considered to be part of the raytraced scene when baking lightmaps,
24 meaning the model's geometry and material contribute to direct and indirect
25 lighting. This on its own does not however enable generating, including
26 full calculation of bounced indirect lighting, and finally saving a
27 lightmap for the model. To do that, the model also needs to be associated
28 with an \l enabled BakedLightmap object with a unique key set.
29
30 When running in normal mode, the same BakedLightmap object indicates that
31 the Model has lightmap data, and that the engine should attempt to load
32 this data (based on the unique key) and use it when rendering.
33
34 For more information on how to bake lightmaps, see the \l Lightmapper
35 documentation.
36
37 \note As of Qt 6.4, lightmap baking is in an early technical preview state.
38 Changes to features, quality, and API are likely happen in future releases.
39
40 \sa Lightmapper, Model::usedInBakedLighting
41 */
42
43/*!
44 \qmlproperty bool BakedLightmap::enabled
45
46 When false, the lightmap generated for the model is not stored during
47 lightmap baking, even though \l key is set to a non-empty value.
48
49 The default value is true.
50 */
51
52/*!
53 \qmlproperty string BakedLightmap::key
54
55 When non-empty and \l enabled is true, the lightmap generated for the model
56 is stored persistently during lightmap baking. The value should be a unique
57 string that is fit to be included in the name of a file in the filesystem.
58 No other Model in the scene must use the same key.
59
60 The default value is empty.
61
62 \sa loadPrefix
63 */
64
65/*!
66 \qmlproperty string BakedLightmap::loadPrefix
67 \deprecated [6.10] This has no effect. See \l Lightmapper documentation.
68 */
69
70bool QQuick3DBakedLightmap::isEnabled() const
71{
72 return m_enabled;
73}
74
75void QQuick3DBakedLightmap::setEnabled(bool enabled)
76{
77 if (m_enabled == enabled)
78 return;
79
80 m_enabled = enabled;
81 emit enabledChanged();
82 emit changed();
83}
84
85QString QQuick3DBakedLightmap::key() const
86{
87 return m_key;
88}
89
90void QQuick3DBakedLightmap::setKey(const QString &key)
91{
92 if (m_key == key)
93 return;
94
95 m_key = key;
96 emit keyChanged();
97 emit changed();
98}
99
100QString QQuick3DBakedLightmap::loadPrefix() const
101{
102 return m_loadPrefix;
103}
104
105void QQuick3DBakedLightmap::setLoadPrefix(const QString &loadPrefix)
106{
107 if (m_loadPrefix == loadPrefix)
108 return;
109
110 m_loadPrefix = loadPrefix;
111 emit loadPrefixChanged();
112 emit changed();
113}
114
115QT_END_NAMESPACE
116

source code of qtquick3d/src/quick3d/qquick3dbakedlightmap.cpp