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
qssgrendercustommaterial_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_CUSTOM_MATERIAL_H
8#define QSSG_RENDER_CUSTOM_MATERIAL_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 <QtCore/qurl.h>
22#include <QtCore/qvariant.h>
23#include <QtCore/qvector.h>
24#include <rhi/qrhi.h>
25
26#include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h>
27#include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h>
28#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
29
31
32struct QSSGRenderImage;
33struct QSSGShaderMaterialAdapter;
34class QQuick3DShaderUtilsTextureInput;
35class QQuick3DTexture;
36
37struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderCustomMaterial : public QSSGRenderGraphObject
38{
39 QSSGRenderCustomMaterial();
40 ~QSSGRenderCustomMaterial();
41
42 struct TextureProperty
43 {
44 QQuick3DShaderUtilsTextureInput *texInput = nullptr; // null for a plain Texture property
45 QSSGRenderImage *texImage = nullptr;
46 QByteArray name;
47 QSSGRenderShaderValue::Type shaderDataType;
48 int pid = -1; // index of the tracked property, -1 for a dynamic property
49 QSSGRenderTextureFilterOp minFilterType = QSSGRenderTextureFilterOp::Linear;
50 QSSGRenderTextureFilterOp magFilterType = QSSGRenderTextureFilterOp::Linear;
51 QSSGRenderTextureFilterOp mipFilterType = QSSGRenderTextureFilterOp::Linear;
52 QSSGRenderTextureCoordOp horizontalClampType = QSSGRenderTextureCoordOp::ClampToEdge;
53 QSSGRenderTextureCoordOp verticalClampType = QSSGRenderTextureCoordOp::ClampToEdge;
54 QSSGRenderTextureCoordOp zClampType = QSSGRenderTextureCoordOp::ClampToEdge;
55 QQuick3DTexture *lastConnectedTexture = nullptr;
56 QMetaObject::Connection minFilterChangedConn;
57 QMetaObject::Connection magFilterChangedConn;
58 QMetaObject::Connection mipFilterChangedConn;
59 QMetaObject::Connection horizontalTilingChangedConn;
60 QMetaObject::Connection verticalTilingChangedConn;
61 QMetaObject::Connection depthTilingChangedConn;
62 };
63 using TexturePropertyList = QList<TextureProperty>;
64 using Property = QSSGBaseTypeProperty;
65 using PropertyUniformsList = QList<Property>;
66
67 enum class Flags : quint8
68 {
69 Dirty = 0x1,
70 AlwaysDirty = 0x2
71 };
72 using FlagT = std::underlying_type_t<Flags>;
73
74 enum class ShadingMode // must match QQuick3DCustomMaterial::ShadingMode
75 {
76 Unshaded,
77 Shaded
78 };
79
80 enum class CustomShaderPresenceFlag {
81 Vertex = 1 << 0,
82 Fragment = 1 << 1
83 };
84 Q_DECLARE_FLAGS(CustomShaderPresence, CustomShaderPresenceFlag)
85
86 enum class RenderFlag {
87 Blending = 1 << 0,
88 ScreenTexture = 1 << 1,
89 DepthTexture = 1 << 2,
90 AoTexture = 1 << 3,
91 OverridesPosition = 1 << 4,
92 ProjectionMatrix = 1 << 5,
93 InverseProjectionMatrix = 1 << 6,
94 ScreenMipTexture = 1 << 7,
95 VarColor = 1 << 8,
96 IblOrientation = 1 << 9,
97 Lightmap = 1 << 10,
98 Skinning = 1 << 11,
99 Morphing = 1 << 12,
100 ViewIndex = 1 << 13,
101 Clearcoat = 1 << 14,
102 ClearcoatFresnelScaleBias = 1 << 15,
103 FresnelScaleBias = 1 << 16,
104 Transmission = 1 << 17,
105 NormalTexture = 1 << 18,
106 MotionVectorTexture = 1 << 19,
107 Sheen = 1 << 20,
108 Anisotropy = 1 << 21,
109 Iridescence = 1 << 22,
110 Dispersion = 1 << 23,
111 InstanceIndex = 1 << 24,
112 Fragcoord = 1 << 25
113 };
114 Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
115
116 enum {
117 RegularShaderPathKeyIndex = 0,
118 MultiViewShaderPathKeyIndex = 1
119 };
120 QByteArray m_shaderPathKey[2];
121 CustomShaderPresence m_customShaderPresence;
122
123 TexturePropertyList m_textureProperties;
124 PropertyUniformsList m_properties;
125
126 QSSGRenderImage *m_iblProbe = nullptr;
127 QSSGRenderImage *m_emissiveMap = nullptr;
128 QSSGCullFaceMode m_cullMode = QSSGCullFaceMode::Back;
129 QSSGDepthDrawMode m_depthDrawMode = QSSGDepthDrawMode::OpaqueOnly;
130 RenderFlags m_renderFlags;
131 QRhiGraphicsPipeline::BlendFactor m_srcBlend;
132 QRhiGraphicsPipeline::BlendFactor m_dstBlend;
133 QRhiGraphicsPipeline::BlendFactor m_srcAlphaBlend;
134 QRhiGraphicsPipeline::BlendFactor m_dstAlphaBlend;
135 float m_lineWidth = 1.0f;
136
137 QSSGRenderGraphObject *m_nextSibling = nullptr;
138
139 ShadingMode m_shadingMode = ShadingMode::Shaded;
140
141 FlagT m_flags { FlagT(Flags::Dirty) };
142 bool incompleteBuildTimeObject = false; // Used by the shadergen tool
143 bool m_usesSharedVariables = false;
144
145 void markDirty();
146 void clearDirty();
147 void setAlwaysDirty(bool v);
148 [[nodiscard]] inline bool isDirty() const { return ((m_flags & (FlagT(Flags::Dirty) | FlagT(Flags::AlwaysDirty))) != 0); }
149
150 QSSGShaderMaterialAdapter *adapter = nullptr;
151
152 QString debugObjectName;
153};
154
155
156
157Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderCustomMaterial::CustomShaderPresence)
158
159QT_END_NAMESPACE
160
161#endif
QSSGPickResultProcessResult(const QSSGRenderPickResult &inSrc, bool consumed)
QSSGPickResultProcessResult(const QSSGRenderPickResult &inSrc)
friend class QSSGRenderContextInterface
Combined button and popup list for selecting options.
static QVector3D closestPointOnTriangle(const QVector3D &p, const QVector3D &a, const QVector3D &b, const QVector3D &c, const Dot &dot, float &u, float &v, float &w)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192
static void cleanupResourcesImpl(const QSSGRenderContextInterface &rci, const Container &resources)
static void getPickableRecursive(const QSSGRenderNode &node, RenderableList &renderables, bool pickEverything=false)
static void dfs(const QSSGRenderNode &node, RenderableList &renderables)
static QByteArray rendererLogPrefix()
static QSSGCullFaceMode mirroredCullMode(QSSGCullFaceMode cullMode)
static QSSGCullFaceMode cullModeForSubset(const QSSGRenderModel &model, int subset)
TShaderMapKey< QSSGShaderParticleMaterialKey > QSSGParticleShaderMapKey