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
qquick3ddebugsettings.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
7
9
10/*!
11 \qmltype DebugSettings
12 \inherits QtObject
13 \inqmlmodule QtQuick3D
14 \brief Used to configure debug settings.
15
16 The renderer can be configured to output many different views to facilitate
17 debugging. This component is used to configure these debug views.
18
19 In addition to programatic control, properties such as \l materialOverride
20 and \l wireframeEnabled can also be controlled interactively via the \l
21 DebugView item if an instance of that is added to the Qt Quick scene by the
22 application.
23*/
24
25/*!
26 \qmlproperty enumeration QtQuick3D::DebugSettings::materialOverride
27 \since 6.5
28
29 This property changes how all materials are rendered to only reflect a
30 particular aspect of the overall rendering process. This can be used as
31 a debugging tool to get a better understanding of why a material looks
32 the way it does.
33
34 The default value is \c DebugSettings.None
35
36 \value DebugSettings.None
37 Material overriding is bypassed, rendering occurs as normal.
38 \value DebugSettings.BaseColor
39 The BaseColor or Diffuse color of a material is passed through
40 without any lighting.
41 \value DebugSettings.Roughness
42 The Roughness of a material is passed through as an unlit
43 greyscale value.
44 \value DebugSettings.Metalness
45 The Metalness of a material is passed through as an unlit
46 greyscale value.
47 \value DebugSettings.Diffuse
48 Only the diffuse contribution of the material after all lighting.
49 \value DebugSettings.Specular
50 Only the specular contribution of the material after all lighting.
51 \value DebugSettings.ShadowOcclusion
52 The Occlusion caused by shadows as a greyscale value.
53 \value DebugSettings.Emission
54 Only the emissive contribution of the material
55 \value DebugSettings.AmbientOcclusion
56 Only the Ambient Occlusion of the material
57 \value DebugSettings.Normals
58 The interpolated world space Normal value of the material mapped to an
59 RGB color.
60 \value DebugSettings.Tangents
61 The interpolated world space Tangent value of the material mapped to an
62 RGB color. This will only be visible if the Tangent value is used.
63 \value DebugSettings.Binormals
64 The interpolated world space Binormal value of the material mapped to an
65 RGB color. This will only be visible if the Binormal value is used.
66 \value DebugSettings.F0
67 This represents the Fresnel Reflectance at 0 Degrees. This will only be
68 visible for materials that calculate an F0 value.
69
70 As an example, take the following scene with the
71 \l{https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Sponza}{Sponza}
72 model. The scene uses image-based lighting via
73 \l{SceneEnvironment::lightProbe} and also has a directional light.
74
75 \image debugsettings_default.jpg
76 {Scene with default debug settings}
77
78 Setting \c{DebugSettings.BaseColor}:
79
80 \image debugsettings_basecolor.jpg
81 {Scene showing base colors without lighting}
82
83 Setting \c{DebugSettings.Roughness}:
84
85 \image debugsettings_roughness.jpg
86 {Scene showing roughness values}
87
88 Setting \c{DebugSettings.Metalness}:
89
90 \image debugsettings_metalness.jpg
91 {Scene highlighting metalness values}
92
93 Setting \c{DebugSettings.Diffuse}:
94
95 \image debugsettings_diffuse.jpg
96 {Scene showing diffuse lighting only}
97
98 Setting \c{DebugSettings.Specular}:
99
100 \image debugsettings_specular.jpg
101 {Scene showing specular lighting only}
102
103 Setting \c{DebugSettings.Normals}:
104
105 \image debugsettings_normals.jpg
106 {Scene showing normal vectors as colors}
107*/
108
109
110QQuick3DDebugSettings::QQuick3DDebugSettings(QObject *parent)
111 : QObject(parent)
112{
113
114}
115
116QQuick3DDebugSettings::QQuick3DMaterialOverrides QQuick3DDebugSettings::materialOverride() const
117{
118 return m_materialOverride;
119}
120
121void QQuick3DDebugSettings::setMaterialOverride(QQuick3DMaterialOverrides newMaterialOverride)
122{
123 if (m_materialOverride == newMaterialOverride)
124 return;
125 m_materialOverride = newMaterialOverride;
126 emit materialOverrideChanged();
127 update();
128}
129
130void QQuick3DDebugSettings::update()
131{
132 emit changed();
133}
134
135/*!
136 \qmlproperty bool QtQuick3D::DebugSettings::wireframeEnabled
137 \since 6.5
138
139 This property changes how all materials are rendered by changing the polygon
140 fill mode to be lines instead of filled. This appears as a wireframe, but the
141 shaded color will still reflect the respective materials of the meshes.
142
143 The default value is \c false.
144
145 \image debugsettings_wireframe.jpg
146 {Scene showing wireframe rendering}
147*/
148
149
150bool QQuick3DDebugSettings::wireframeEnabled() const
151{
152 return m_wireframeEnabled;
153}
154
155void QQuick3DDebugSettings::setWireframeEnabled(bool newWireframeEnabled)
156{
157 if (m_wireframeEnabled == newWireframeEnabled)
158 return;
159 m_wireframeEnabled = newWireframeEnabled;
160 emit wireframeEnabledChanged();
161 update();
162}
163
164/*!
165 \qmlproperty bool QtQuick3D::DebugSettings::drawDirectionalLightShadowBoxes
166 \since 6.8
167
168 When this property is enabled a bounding box is drawn for every directional light's shadowmap.
169
170 The default value is \c false.
171*/
172
173bool QQuick3DDebugSettings::drawDirectionalLightShadowBoxes() const
174{
175 return m_drawDirectionalLightShadowBoxes;
176}
177
178void QQuick3DDebugSettings::setDrawDirectionalLightShadowBoxes(bool newDrawDirectionalLightShadowBoxes)
179{
180 if (m_drawDirectionalLightShadowBoxes == newDrawDirectionalLightShadowBoxes)
181 return;
182 m_drawDirectionalLightShadowBoxes = newDrawDirectionalLightShadowBoxes;
183 emit drawDirectionalLightShadowBoxesChanged();
184 update();
185}
186
187/*!
188 \qmlproperty bool QtQuick3D::DebugSettings::drawShadowCastingBounds
189 \since 6.8
190
191 When this property is enabled a bounding box is drawn for the shadow casting objects.
192
193 The default value is \c false.
194*/
195
196bool QQuick3DDebugSettings::drawShadowCastingBounds() const
197{
198 return m_drawShadowCastingBounds;
199}
200
201void QQuick3DDebugSettings::setDrawShadowCastingBounds(bool newDrawShadowCastingBounds)
202{
203 if (m_drawShadowCastingBounds == newDrawShadowCastingBounds)
204 return;
205 m_drawShadowCastingBounds = newDrawShadowCastingBounds;
206 emit drawShadowCastingBoundsChanged();
207 update();
208}
209
210/*!
211 \qmlproperty bool QtQuick3D::DebugSettings::drawPointLightShadowBoxes
212 \since 6.9
213
214 When this property is enabled a bounding box is drawn for every point light's shadowmap.
215
216 The default value is \c false.
217*/
218
219bool QQuick3DDebugSettings::drawPointLightShadowBoxes() const
220{
221 return m_drawPointLightShadowBoxes;
222}
223
224void QQuick3DDebugSettings::setDrawPointLightShadowBoxes(bool newDrawPointLightShadowBoxes)
225{
226 if (m_drawPointLightShadowBoxes == newDrawPointLightShadowBoxes)
227 return;
228 m_drawPointLightShadowBoxes = newDrawPointLightShadowBoxes;
229 emit drawPointLightShadowBoxesChanged();
230 update();
231}
232
233/*!
234 \qmlproperty bool QtQuick3D::DebugSettings::drawShadowReceivingBounds
235 \since 6.8
236
237 When this property is enabled a bounding box is drawn for the shadow receiving objects.
238
239 The default value is \c false.
240*/
241
242bool QQuick3DDebugSettings::drawShadowReceivingBounds() const
243{
244 return m_drawShadowReceivingBounds;
245}
246
247void QQuick3DDebugSettings::setDrawShadowReceivingBounds(bool newDrawShadowReceivingBounds)
248{
249 if (m_drawShadowReceivingBounds == newDrawShadowReceivingBounds)
250 return;
251 m_drawShadowReceivingBounds = newDrawShadowReceivingBounds;
252 emit drawShadowReceivingBoundsChanged();
253 update();
254}
255
256/*!
257 \qmlproperty bool QtQuick3D::DebugSettings::drawCascades
258 \since 6.8
259
260 When this property is enabled a frustum is drawn with splits indicating where the
261 shadowmap cascades begin and end.
262
263 The default value is \c false.
264*/
265
266bool QQuick3DDebugSettings::drawCascades() const
267{
268 return m_drawCascades;
269}
270
271void QQuick3DDebugSettings::setDrawCascades(bool newDrawCascades)
272{
273 if (m_drawCascades == newDrawCascades)
274 return;
275 m_drawCascades = newDrawCascades;
276 emit drawCascadesChanged();
277 update();
278}
279
280/*!
281 \qmlproperty bool QtQuick3D::DebugSettings::drawSceneCascadeIntersection
282 \since 6.8
283
284 When this property is enabled the intersection of the shadowmap cascades
285 and the casting and receiving objects of the scene is drawn.
286
287 The default value is \c false.
288*/
289
290bool QQuick3DDebugSettings::drawSceneCascadeIntersection() const
291{
292 return m_drawSceneCascadeIntersection;
293}
294
295void QQuick3DDebugSettings::setDrawSceneCascadeIntersection(bool newDrawSceneCascadeIntersection)
296{
297 if (m_drawSceneCascadeIntersection == newDrawSceneCascadeIntersection)
298 return;
299 m_drawSceneCascadeIntersection = newDrawSceneCascadeIntersection;
300 emit drawSceneCascadeIntersectionChanged();
301 update();
302}
303
304/*!
305 \qmlproperty bool QtQuick3D::DebugSettings::disableShadowCameraUpdate
306 \since 6.8
307
308 When this property is enabled the camera update is disabled for the shadowmap.
309 This means that the view frustum will be locked in space just for the shadowmap
310 calculations. This is just a debug tool to be able to view the camera frustum
311 and shadow map from different angles.
312
313 The default value is \c false.
314*/
315
316bool QQuick3DDebugSettings::disableShadowCameraUpdate() const
317{
318 return m_disableShadowCameraUpdate;
319}
320
321void QQuick3DDebugSettings::setDisableShadowCameraUpdate(bool newDisableShadowCameraUpdate)
322{
323 if (m_disableShadowCameraUpdate == newDisableShadowCameraUpdate)
324 return;
325 m_disableShadowCameraUpdate = newDisableShadowCameraUpdate;
326 emit disableShadowCameraUpdateChanged();
327 update();
328}
329/*!
330 \internal
331 \qmlproperty bool QtQuick3D::DebugSettings::drawCulledObjects
332 \since 6.11
333
334 Draws a different-colored bounding box based on whether the model is culled.
335
336 The default value is \c false.
337*/
338bool QQuick3DDebugSettings::drawCulledObjects() const
339{
340 return m_drawCulledObjects;
341}
342
343void QQuick3DDebugSettings::setDrawCulledObjects(bool newDrawCulledObjects)
344{
345 if (m_drawCulledObjects == newDrawCulledObjects)
346 return;
347 m_drawCulledObjects = newDrawCulledObjects;
348 emit drawCulledObjectsChanged();
349 update();
350}
351
352QT_END_NAMESPACE
Combined button and popup list for selecting options.