1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QSSGLIGHTMAPPER_P_H |
5 | #define QSSGLIGHTMAPPER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h> |
19 | |
20 | #include <QString> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | struct QSSGLightmapperPrivate; |
25 | struct QSSGBakedLightingModel; |
26 | class QSSGRhiContext; |
27 | class QSSGRenderer; |
28 | struct QSSGRenderModel; |
29 | |
30 | struct QSSGLightmapperOptions |
31 | { |
32 | float opacityThreshold = 0.5f; |
33 | float bias = 0.005f; |
34 | bool useAdaptiveBias = true; |
35 | bool indirectLightEnabled = true; |
36 | int indirectLightSamples = 256; |
37 | int indirectLightWorkgroupSize = 32; |
38 | int indirectLightBounces = 3; |
39 | float indirectLightFactor = 1.0f; |
40 | }; |
41 | |
42 | class QSSGLightmapper |
43 | { |
44 | public: |
45 | enum class BakingStatus { |
46 | None, |
47 | Progress, |
48 | Warning, |
49 | Error, |
50 | Cancelled, |
51 | Complete |
52 | }; |
53 | |
54 | struct BakingControl { |
55 | bool cancelled = false; |
56 | }; |
57 | |
58 | typedef std::function<void(BakingStatus, std::optional<QString>, BakingControl*)> Callback; |
59 | |
60 | QSSGLightmapper(QSSGRhiContext *rhiCtx, QSSGRenderer *renderer); |
61 | ~QSSGLightmapper(); |
62 | void reset(); |
63 | void setOptions(const QSSGLightmapperOptions &options); |
64 | void setOutputCallback(Callback callback); |
65 | qsizetype add(const QSSGBakedLightingModel &model); |
66 | bool bake(); |
67 | |
68 | enum class LightmapAsset { |
69 | LightmapImage, |
70 | MeshWithLightmapUV, |
71 | LightmapImageList |
72 | }; |
73 | static QString lightmapAssetPathForLoad(const QSSGRenderModel &model, LightmapAsset asset); |
74 | static QString lightmapAssetPathForSave(const QSSGRenderModel &model, LightmapAsset asset, const QString& outputFolder = {}); |
75 | static QString lightmapAssetPathForSave(LightmapAsset asset, const QString& outputFolder = {}); |
76 | |
77 | private: |
78 | #ifdef QT_QUICK3D_HAS_LIGHTMAPPER |
79 | QSSGLightmapperPrivate *d = nullptr; |
80 | #endif |
81 | }; |
82 | |
83 | QT_END_NAMESPACE |
84 | |
85 | #endif |
86 | |