aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick3d/cascadedshadowmaps/SettingsPane.qml
blob: e33106a1dc0c8bcfeca5493419488ecc27099ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
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
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: root
    width: settingsDrawer.width
    height: parent.height

    property real shadowFactor: sliderDirectionaLightShadowFactor.value
    property vector3d eulerRotation: Qt.vector3d(sliderDirectionalLightRotX.value,
                                                 sliderDirectionalLightRotY.value,
                                                 0)
    property real csmSplit1: sliderCSMSplit1.value
    property real csmSplit2: sliderCSMSplit2.value
    property real csmSplit3: sliderCSMSplit3.value
    property int csmNumSplits: sliderNumSplits.currentIndex
    property int shadowMapQuality: shadowmapquality_combobox.currentIndex
    property real csmBlendRatio: sliderBlendRatio.value
    property real shadowBias: sliderShadowBiasDirLight.value
    property real pcfFactor: sliderPCFFactor.value
    property int softShadowQuality: softshadowquality_combobox.currentIndex
    property real shadowMapFar: sliderShadowMapFar.value
    property real clipFar: sliderCameraClipFar.value
    property bool lockShadowmapTexels: checkboxLockShadowmapTexels.checked

    property real viewX: settingsDrawer.visible ? (settingsDrawer.x + settingsDrawer.width) : 0

    RoundButton {
        id: iconOpen
        icon.source: "sliders.svg"
        icon.width: 25
        icon.height: 25
        padding: 10
        x: padding + root.viewX
        y: padding
        onClicked: {
            settingsDrawer.visible = !settingsDrawer.visible;
        }
    }

    Drawer {
        id: settingsDrawer
        edge: Qt.LeftEdge
        interactive: false
        modal: false
        height: parent.height

        enter: Transition {
            NumberAnimation {
                property: "position"
                to: 1.0
                duration: 400
                easing.type: Easing.InOutQuad
            }
        }

        exit: Transition {
            NumberAnimation {
                property: "position"
                to: 0.0
                duration: 400
                easing.type: Easing.InOutQuad
            }
        }

        Page {
            anchors.fill: parent

            header: ToolBar {
                width: parent.width
                Label {
                    anchors.horizontalCenter: parent.horizontalCenter
                    text: "Settings"
                    font.pointSize: 17
                }
            }

            ScrollView {
                anchors.fill: parent
                ScrollBar.vertical.policy: ScrollBar.AlwaysOn
                padding: 10
                contentHeight: settingsArea.implicitHeight

                ColumnLayout {
                    id: settingsArea
                    width: parent.width
                    spacing: 5

                    component SliderWithValue : RowLayout {
                        id: sliderWithValue
                        property alias value: slider.value
                        property alias from: slider.from
                        property alias to: slider.to
                        property alias stepSize: slider.stepSize
                        property int numDecimals: 3
                        readonly property bool highlight: slider.hovered || slider.pressed
                        Slider {
                            id: slider
                            stepSize: 0.01
                            Layout.minimumWidth: 200
                            Layout.maximumWidth: 200
                        }
                        Label {
                            id: valueText
                            text: slider.value.toFixed(sliderWithValue.numDecimals)
                            Layout.minimumWidth: 80
                            Layout.maximumWidth: 80
                        }
                    }



                    Label {
                        text: "Camera Clip Far"
                    }

                    SliderWithValue {
                        id: sliderCameraClipFar
                        value: 15000
                        from: 0
                        to: 30000
                        stepSize: 1000
                        numDecimals: 0
                    }

                    Label {
                        text: "Shadow Map Far"
                    }

                    SliderWithValue {
                        id: sliderShadowMapFar
                        value: 15000
                        from: 0
                        to: 30000
                        stepSize: 1000
                        numDecimals: 0
                    }

                    Label {
                        text: "Light Euler Rotation XY"
                    }

                    SliderWithValue {
                        id: sliderDirectionalLightRotX
                        value: -40
                        from: -180
                        to: 0
                        numDecimals: 0
                    }

                    SliderWithValue {
                        id: sliderDirectionalLightRotY
                        value: -120
                        from: -180
                        to: 180
                        numDecimals: 0
                    }

                    Label {
                        text: "Shadow Factor"
                    }

                    SliderWithValue {
                        id: sliderDirectionaLightShadowFactor
                        value: 75
                        from: 0
                        to: 100
                        numDecimals: 0
                    }

                    Label {
                        text: "Num Cascade Splits"
                    }

                    ComboBox {
                        id: sliderNumSplits
                        model: ListModel {
                            id: model
                            ListElement { text: "0" }
                            ListElement { text: "1" }
                            ListElement { text: "2" }
                            ListElement { text: "3" }
                        }
                        currentIndex: 2
                    }

                    Label {
                        text: "Cascade Splits"
                    }

                    SliderWithValue {
                        id: sliderCSMSplit1
                        value: 0.15
                        from: 0.01
                        to: 0.99
                        numDecimals: 2
                    }

                    SliderWithValue {
                        id: sliderCSMSplit2
                        value: 0.5
                        from: 0.01
                        to: 0.99
                        numDecimals: 2
                    }

                    SliderWithValue {
                        id: sliderCSMSplit3
                        value: 0.75
                        from: 0.01
                        to: 0.99
                        numDecimals: 2
                    }

                    Label {
                        text: "Cascade Blend Ratio"
                    }

                    SliderWithValue {
                        id: sliderBlendRatio
                        value: 0.05
                        from: 0
                        to: 1
                        numDecimals: 2
                    }

                    Label {
                        text: "PCF Factor"
                    }

                    SliderWithValue {
                        id: sliderPCFFactor
                        value: 3
                        from: 0
                        to: 30
                        stepSize: 1
                        numDecimals: 0
                    }

                    Label {
                        text: "Shadow Bias"
                    }

                    SliderWithValue {
                        id: sliderShadowBiasDirLight
                        value: 10
                        from: 0
                        to: 30
                        stepSize: 1
                        numDecimals: 0
                    }

                    Label {
                        text: "Soft-shadow Quality"
                    }

                    ComboBox {
                        id: softshadowquality_combobox
                        editable: false
                        model: ListModel {
                            ListElement { text: "Hard" }
                            ListElement { text: "PCF4" }
                            ListElement { text: "PCF8" }
                            ListElement { text: "PCF16" }
                            ListElement { text: "PCF32" }
                            ListElement { text: "PCF64" }
                        }
                        currentIndex: 3
                    }

                    Label {
                        text: "Shadow Map Quality"
                    }

                    ComboBox {
                        id: shadowmapquality_combobox
                        editable: false
                        model: ListModel {
                            ListElement { text: "Low" }
                            ListElement { text: "Medium" }
                            ListElement { text: "High" }
                            ListElement { text: "VeryHigh" }
                        }
                        currentIndex: 2
                    }

                    CheckBox {
                        id: checkboxLockShadowmapTexels
                        checked: false
                        text: qsTr("Lock Shadow Map Texels")
                    }
                }
            }
        }
    }
}