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