13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
124QQuick3DSceneEnvironment::QQuick3DSceneEnvironment(QQuick3DObject *parent)
125 : QQuick3DObject(*(
new QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::SceneEnvironment)), parent)
127 m_debugSettings =
new QQuick3DDebugSettings(
this);
128 m_debugSettingsSignalConnection = QObject::connect(m_debugSettings, &QQuick3DDebugSettings::changed,
this,
129 [
this] { update(); });
130 QObject::connect(m_debugSettings, &QObject::destroyed,
this,
131 [
this](QObject *obj) {
132 if (m_debugSettings == obj) {
133 m_debugSettings =
nullptr;
139QQuick3DSceneEnvironment::~QQuick3DSceneEnvironment()
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220QQuick3DSceneEnvironment::QQuick3DEnvironmentAAModeValues QQuick3DSceneEnvironment::antialiasingMode()
const
222 return m_antialiasingMode;
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
250QQuick3DSceneEnvironment::QQuick3DEnvironmentAAQualityValues QQuick3DSceneEnvironment::antialiasingQuality()
const
252 return m_antialiasingQuality;
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
365QQuick3DSceneEnvironment::QQuick3DEnvironmentBackgroundTypes QQuick3DSceneEnvironment::backgroundMode()
const
367 return m_backgroundMode;
371
372
373
374
375
376
377
378
379
381QColor QQuick3DSceneEnvironment::clearColor()
const
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423float QQuick3DSceneEnvironment::aoStrength()
const
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454float QQuick3DSceneEnvironment::aoDistance()
const
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485float QQuick3DSceneEnvironment::aoSoftness()
const
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507bool QQuick3DSceneEnvironment::aoDither()
const
513
514
515
516
517
518
519
520int QQuick3DSceneEnvironment::aoSampleRate()
const
522 return m_aoSampleRate;
526
527
528
529
530
531
532
533
534
535
536
537float QQuick3DSceneEnvironment::aoBias()
const
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710QQuick3DTexture *QQuick3DSceneEnvironment::lightProbe()
const
716
717
718
719
720
721
722
723
724
725
726
727
728
729float QQuick3DSceneEnvironment::probeExposure()
const
731 return m_probeExposure;
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758float QQuick3DSceneEnvironment::probeHorizon()
const
760 return m_probeHorizon;
764
765
766
767
768
769
770
771
772
773
774QVector3D QQuick3DSceneEnvironment::probeOrientation()
const
776 return m_probeOrientation;
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801bool QQuick3DSceneEnvironment::temporalAAEnabled()
const
803 return m_temporalAAEnabled;
807
808
809
810
811
812
813
814
815
816
817float QQuick3DSceneEnvironment::temporalAAStrength()
const
819 return m_temporalAAStrength;
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841bool QQuick3DSceneEnvironment::specularAAEnabled()
const
843 return m_specularAAEnabled;
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881bool QQuick3DSceneEnvironment::depthTestEnabled()
const
883 return m_depthTestEnabled;
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907bool QQuick3DSceneEnvironment::depthPrePassEnabled()
const
909 return m_depthPrePassEnabled;
913
914
915
916
917
918
919
920
921
922
923QQmlListProperty<QQuick3DEffect> QQuick3DSceneEnvironment::effects()
925 return QQmlListProperty<QQuick3DEffect>(
this,
927 QQuick3DSceneEnvironment::qmlAppendEffect,
928 QQuick3DSceneEnvironment::qmlEffectsCount,
929 QQuick3DSceneEnvironment::qmlEffectAt,
930 QQuick3DSceneEnvironment::qmlClearEffects);
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974QQuick3DSceneEnvironment::QQuick3DEnvironmentTonemapModes QQuick3DSceneEnvironment::tonemapMode()
const
976 return m_tonemapMode;
980
981
982
983
984
985
986
987
988
989
990
992float QQuick3DSceneEnvironment::skyboxBlurAmount()
const
994 return m_skyboxBlurAmount;
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1019QQuick3DDebugSettings *QQuick3DSceneEnvironment::debugSettings()
const
1021 return m_debugSettings;
1025
1026
1027
1028
1029
1030
1032QRect QQuick3DSceneEnvironment::scissorRect()
const
1034 return m_scissorRect;
1037void QQuick3DSceneEnvironment::setAntialiasingMode(QQuick3DSceneEnvironment::QQuick3DEnvironmentAAModeValues antialiasingMode)
1039 if (m_antialiasingMode == antialiasingMode)
1042 m_antialiasingMode = antialiasingMode;
1043 emit antialiasingModeChanged();
1047void QQuick3DSceneEnvironment::setAntialiasingQuality(QQuick3DSceneEnvironment::QQuick3DEnvironmentAAQualityValues antialiasingQuality)
1049 if (m_antialiasingQuality == antialiasingQuality)
1052 m_antialiasingQuality = antialiasingQuality;
1053 emit antialiasingQualityChanged();
1057void QQuick3DSceneEnvironment::setBackgroundMode(QQuick3DSceneEnvironment::QQuick3DEnvironmentBackgroundTypes backgroundMode)
1059 if (m_backgroundMode == backgroundMode)
1062 m_backgroundMode = backgroundMode;
1063 emit backgroundModeChanged();
1067void QQuick3DSceneEnvironment::setClearColor(
const QColor &clearColor)
1069 if (m_clearColor == clearColor)
1072 m_clearColor = clearColor;
1073 emit clearColorChanged();
1077void QQuick3DSceneEnvironment::setAoStrength(
float aoStrength)
1079 if (qFuzzyCompare(m_aoStrength, aoStrength))
1082 m_aoStrength = aoStrength;
1084 const bool aoEnabled = !(qFuzzyIsNull(m_aoStrength) || qFuzzyIsNull(m_aoDistance));
1085 setAoEnabled(aoEnabled);
1087 emit aoStrengthChanged();
1091void QQuick3DSceneEnvironment::setAoDistance(
float aoDistance)
1093 if (qFuzzyCompare(m_aoDistance, aoDistance))
1096 m_aoDistance = aoDistance;
1098 const bool aoEnabled = !(qFuzzyIsNull(m_aoStrength) || qFuzzyIsNull(m_aoDistance));
1099 setAoEnabled(aoEnabled);
1101 emit aoDistanceChanged();
1105void QQuick3DSceneEnvironment::setAoSoftness(
float aoSoftness)
1107 if (qFuzzyCompare(m_aoSoftness, aoSoftness))
1110 m_aoSoftness = aoSoftness;
1111 emit aoSoftnessChanged();
1115void QQuick3DSceneEnvironment::setAoDither(
bool aoDither)
1117 if (m_aoDither == aoDither)
1120 m_aoDither = aoDither;
1121 emit aoDitherChanged();
1125void QQuick3DSceneEnvironment::setAoSampleRate(
int aoSampleRate)
1127 if (m_aoSampleRate == aoSampleRate)
1130 m_aoSampleRate = aoSampleRate;
1131 emit aoSampleRateChanged();
1135void QQuick3DSceneEnvironment::setAoBias(
float aoBias)
1137 if (qFuzzyCompare(m_aoBias, aoBias))
1141 emit aoBiasChanged();
1145void QQuick3DSceneEnvironment::setLightProbe(QQuick3DTexture *lightProbe)
1147 if (m_lightProbe == lightProbe)
1150 QQuick3DObjectPrivate::attachWatcher(
this, &QQuick3DSceneEnvironment::setLightProbe, lightProbe, m_lightProbe);
1152 m_lightProbe = lightProbe;
1153 emit lightProbeChanged();
1157void QQuick3DSceneEnvironment::setProbeExposure(
float probeExposure)
1159 if (qFuzzyCompare(m_probeExposure, probeExposure))
1162 m_probeExposure = probeExposure;
1163 emit probeExposureChanged();
1167void QQuick3DSceneEnvironment::setProbeHorizon(
float probeHorizon)
1170 probeHorizon = qBound(0.0f, probeHorizon, 1.0f);
1172 if (qFuzzyCompare(m_probeHorizon, probeHorizon))
1175 m_probeHorizon = probeHorizon;
1176 emit probeHorizonChanged();
1180void QQuick3DSceneEnvironment::setProbeOrientation(
const QVector3D &orientation)
1182 if (qFuzzyCompare(m_probeOrientation, orientation))
1185 m_probeOrientation = orientation;
1186 emit probeOrientationChanged();
1190void QQuick3DSceneEnvironment::setDepthTestEnabled(
bool depthTestEnabled)
1192 if (m_depthTestEnabled == depthTestEnabled)
1195 m_depthTestEnabled = depthTestEnabled;
1196 emit depthTestEnabledChanged();
1200void QQuick3DSceneEnvironment::setDepthPrePassEnabled(
bool depthPrePassEnabled)
1202 if (m_depthPrePassEnabled == depthPrePassEnabled)
1205 m_depthPrePassEnabled = depthPrePassEnabled;
1206 emit depthPrePassEnabledChanged();
1210void QQuick3DSceneEnvironment::setTonemapMode(QQuick3DSceneEnvironment::QQuick3DEnvironmentTonemapModes tonemapMode)
1212 if (m_tonemapMode == tonemapMode)
1215 m_tonemapMode = tonemapMode;
1216 emit tonemapModeChanged();
1220bool QQuick3DSceneEnvironment::useBuiltinTonemapper()
const
1225QSSGRenderGraphObject *QQuick3DSceneEnvironment::updateSpatialNode(QSSGRenderGraphObject *node)
1231void QQuick3DSceneEnvironment::itemChange(QQuick3DObject::ItemChange change,
const QQuick3DObject::ItemChangeData &value)
1233 if (change == QQuick3DObject::ItemSceneChange)
1234 updateSceneManager(value.sceneManager);
1237const QVector<QQuick3DEffect *> &QQuick3DSceneEnvironment::effectList()
const
1242void QQuick3DSceneEnvironment::updateSceneManager(QQuick3DSceneManager *manager)
1245 QQuick3DObjectPrivate::refSceneManager(m_lightProbe, *manager);
1246 QQuick3DObjectPrivate::refSceneManager(m_skyBoxCubeMap, *manager);
1248 QQuick3DObjectPrivate::derefSceneManager(m_lightProbe);
1249 QQuick3DObjectPrivate::derefSceneManager(m_skyBoxCubeMap);
1253void QQuick3DSceneEnvironment::setTemporalAAEnabled(
bool temporalAAEnabled)
1255 if (m_temporalAAEnabled == temporalAAEnabled)
1258 m_temporalAAEnabled = temporalAAEnabled;
1259 emit temporalAAEnabledChanged();
1263void QQuick3DSceneEnvironment::setTemporalAAStrength(
float strength)
1265 if (qFuzzyCompare(m_temporalAAStrength, strength))
1268 m_temporalAAStrength = strength;
1269 emit temporalAAStrengthChanged();
1273void QQuick3DSceneEnvironment::setSpecularAAEnabled(
bool enabled)
1275 if (m_specularAAEnabled == enabled)
1278 m_specularAAEnabled = enabled;
1279 emit specularAAEnabledChanged();
1283void QQuick3DSceneEnvironment::qmlAppendEffect(QQmlListProperty<QQuick3DEffect> *list, QQuick3DEffect *effect)
1285 if (effect ==
nullptr)
1287 QQuick3DSceneEnvironment *self =
static_cast<QQuick3DSceneEnvironment *>(list->object);
1288 self->m_effects.push_back(effect);
1290 if (effect->parentItem() ==
nullptr)
1291 effect->setParentItem(self);
1293 for (QQuick3DEffect *e : self->m_effects)
1294 e->effectChainDirty();
1299QQuick3DEffect *QQuick3DSceneEnvironment::qmlEffectAt(QQmlListProperty<QQuick3DEffect> *list, qsizetype index)
1301 QQuick3DSceneEnvironment *self =
static_cast<QQuick3DSceneEnvironment *>(list->object);
1302 return self->m_effects.at(index);
1305qsizetype QQuick3DSceneEnvironment::qmlEffectsCount(QQmlListProperty<QQuick3DEffect> *list)
1307 QQuick3DSceneEnvironment *self =
static_cast<QQuick3DSceneEnvironment *>(list->object);
1308 return self->m_effects.size();
1311void QQuick3DSceneEnvironment::qmlClearEffects(QQmlListProperty<QQuick3DEffect> *list)
1313 QQuick3DSceneEnvironment *self =
static_cast<QQuick3DSceneEnvironment *>(list->object);
1314 self->m_effects.clear();
1318void QQuick3DSceneEnvironment::setSkyboxBlurAmount(
float newSkyboxBlurAmount)
1320 newSkyboxBlurAmount = qBound(0.0f, newSkyboxBlurAmount, 1.0f);
1322 if (qFuzzyCompare(m_skyboxBlurAmount, newSkyboxBlurAmount))
1325 m_skyboxBlurAmount = newSkyboxBlurAmount;
1326 emit skyboxBlurAmountChanged();
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1349QQuick3DLightmapper *QQuick3DSceneEnvironment::lightmapper()
const
1351 return m_lightmapper;
1354void QQuick3DSceneEnvironment::setLightmapper(QQuick3DLightmapper *lightmapper)
1356 if (m_lightmapper == lightmapper)
1360 m_lightmapper->disconnect(m_lightmapperSignalConnection);
1362 m_lightmapper = lightmapper;
1364 m_lightmapperSignalConnection = QObject::connect(m_lightmapper, &QQuick3DLightmapper::changed,
this,
1365 [
this] { update(); });
1367 QObject::connect(m_lightmapper, &QObject::destroyed,
this,
1368 [
this](QObject *obj)
1370 if (m_lightmapper == obj) {
1371 m_lightmapper =
nullptr;
1376 emit lightmapperChanged();
1381
1382
1383
1384
1385
1386
1387QQuick3DCubeMapTexture *QQuick3DSceneEnvironment::skyBoxCubeMap()
const
1389 return m_skyBoxCubeMap;
1392void QQuick3DSceneEnvironment::setSkyBoxCubeMap(QQuick3DCubeMapTexture *newSkyBoxCubeMap)
1394 if (m_skyBoxCubeMap == newSkyBoxCubeMap)
1397 QQuick3DObjectPrivate::attachWatcher(
this, &QQuick3DSceneEnvironment::setSkyBoxCubeMap, newSkyBoxCubeMap, m_skyBoxCubeMap);
1399 m_skyBoxCubeMap = newSkyBoxCubeMap;
1400 emit skyBoxCubeMapChanged();
1403void QQuick3DSceneEnvironment::setDebugSettings(QQuick3DDebugSettings *newDebugSettings)
1405 if (m_debugSettings == newDebugSettings)
1408 if (m_debugSettings)
1409 m_debugSettings->disconnect(m_debugSettingsSignalConnection);
1411 m_debugSettings = newDebugSettings;
1413 m_debugSettingsSignalConnection = QObject::connect(m_debugSettings, &QQuick3DDebugSettings::changed,
this,
1414 [
this] { update(); });
1415 QObject::connect(m_debugSettings, &QObject::destroyed,
this,
1416 [
this](QObject *obj) {
1417 if (m_debugSettings == obj) {
1418 m_debugSettings =
nullptr;
1423 emit debugSettingsChanged();
1427void QQuick3DSceneEnvironment::setScissorRect(QRect rect)
1429 if (m_scissorRect == rect)
1432 m_scissorRect = rect;
1433 emit scissorRectChanged();
1437bool QQuick3DSceneEnvironment::gridEnabled()
const
1439 return m_gridEnabled;
1442void QQuick3DSceneEnvironment::setGridEnabled(
bool newGridEnabled)
1444 if (m_gridEnabled == newGridEnabled)
1446 m_gridEnabled = newGridEnabled;
1450float QQuick3DSceneEnvironment::gridScale()
const
1455void QQuick3DSceneEnvironment::setGridScale(
float newGridScale)
1457 if (qFuzzyCompare(m_gridScale, newGridScale))
1459 m_gridScale = newGridScale;
1463uint QQuick3DSceneEnvironment::gridFlags()
const
1468void QQuick3DSceneEnvironment::setGridFlags(uint newGridFlags)
1470 if (m_gridFlags == newGridFlags)
1472 m_gridFlags = newGridFlags;
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1496bool QQuick3DSceneEnvironment::aoEnabled()
const
1501void QQuick3DSceneEnvironment::setAoEnabled(
bool newAoEnabled)
1503 if (m_aoEnabled == newAoEnabled)
1506 m_aoEnabled = newAoEnabled;
1509 if (qFuzzyIsNull(m_aoStrength))
1510 setAoStrength(100.0f);
1511 if (qFuzzyIsNull(m_aoDistance))
1512 setAoDistance(defaultAoDistance());
1515 emit aoEnabledChanged();
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1534QQuick3DFog *QQuick3DSceneEnvironment::fog()
const
1539void QQuick3DSceneEnvironment::setFog(QQuick3DFog *fog)
1545 m_fog->disconnect(m_fogSignalConnection);
1549 m_fogSignalConnection = QObject::connect(m_fog, &QQuick3DFog::changed,
this, [
this] { update(); });
1551 QObject::connect(m_fog, &QObject::destroyed,
this,
1552 [
this](QObject *obj)
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1594QQuick3DSceneEnvironment::QQuick3DEnvironmentOITMethod QQuick3DSceneEnvironment::oitMethod()
const
1599void QQuick3DSceneEnvironment::setOitMethod(QQuick3DSceneEnvironment::QQuick3DEnvironmentOITMethod method)
1601 if (m_oitMethod == method)
1603 m_oitMethod = method;
1604 emit oitMethodChanged();