1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGMATERIAL_H
5#define QSSGMATERIAL_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 <QtQuick3D/qquick3dobject.h>
19#include <QtQuick3D/private/qquick3dtexture_p.h>
20
21#include <QtCore/QVector>
22
23QT_BEGIN_NAMESPACE
24
25class QQuick3DSceneManager;
26class Q_QUICK3D_EXPORT QQuick3DMaterial : public QQuick3DObject
27{
28 Q_OBJECT
29 Q_PROPERTY(QQuick3DTexture *lightProbe READ lightProbe WRITE setLightProbe NOTIFY lightProbeChanged)
30 Q_PROPERTY(CullMode cullMode READ cullMode WRITE setCullMode NOTIFY cullModeChanged)
31 Q_PROPERTY(DepthDrawMode depthDrawMode READ depthDrawMode WRITE setDepthDrawMode NOTIFY depthDrawModeChanged)
32
33 QML_NAMED_ELEMENT(Material)
34 QML_UNCREATABLE("Material is Abstract")
35
36public:
37 enum CullMode {
38 BackFaceCulling = 1,
39 FrontFaceCulling = 2,
40 NoCulling = 3
41 };
42 Q_ENUM(CullMode)
43
44 enum TextureChannelMapping {
45 R = 0,
46 G,
47 B,
48 A,
49 };
50 Q_ENUM(TextureChannelMapping)
51
52 enum DepthDrawMode {
53 OpaqueOnlyDepthDraw = 0,
54 AlwaysDepthDraw,
55 NeverDepthDraw,
56 OpaquePrePassDepthDraw,
57 };
58 Q_ENUM(DepthDrawMode)
59
60 ~QQuick3DMaterial() override;
61
62 QQuick3DTexture *lightProbe() const;
63
64 CullMode cullMode() const;
65
66 DepthDrawMode depthDrawMode() const;
67
68public Q_SLOTS:
69 void setLightProbe(QQuick3DTexture *lightProbe);
70 void setCullMode(QQuick3DMaterial::CullMode cullMode);
71 void setDepthDrawMode(QQuick3DMaterial::DepthDrawMode depthDrawMode);
72
73Q_SIGNALS:
74 void lightProbeChanged(QQuick3DTexture *lightProbe);
75 void cullModeChanged(QQuick3DMaterial::CullMode cullMode);
76 void depthDrawModeChanged(QQuick3DMaterial::DepthDrawMode depthDrawMode);
77
78protected:
79 explicit QQuick3DMaterial(QQuick3DObjectPrivate &dd, QQuick3DObject *parent = nullptr);
80 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
81 void itemChange(ItemChange, const ItemChangeData &) override;
82
83private:
84 void updateSceneManager(QQuick3DSceneManager *sceneManager);
85 QQuick3DTexture *m_iblProbe = nullptr;
86
87 CullMode m_cullMode = CullMode::BackFaceCulling;
88 DepthDrawMode m_depthDrawMode = DepthDrawMode::OpaqueOnlyDepthDraw;
89};
90
91QT_END_NAMESPACE
92
93#endif // QSSGMATERIAL_H
94

source code of qtquick3d/src/quick3d/qquick3dmaterial_p.h