aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick3d/principledmaterial/SpecialPane.qml
blob: 5671ca4f63a21553f64058f94259af74cd33575b (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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick3D

// qmllint disable missing-property
// Disabling missing-property because the targetMaterial property
// will either be a PrincipaledMaterial or SpecularGlossyMaterial
// but the shared properties are not part of the common base class
ScrollView {
    id: rootView
    required property Material targetMaterial
    required property Model linesModel
    required property Model pointsModel
    property bool specularGlossyMode: false

    ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
    width: availableWidth

    ColumnLayout {
        width: rootView.availableWidth
        MarkdownLabel {
            text: `# Special Stuff
The content in this section is as titled \"Special\" because you should really
only use this stuff for fairly specific reasons.
## Lighting Mode
The lighting mode property defines how the material handles the shading of
lights. The default mode is *Fragment Lighting* which perform all light shading
in the fragment shader porsion of the graphics pipeline. In this case all both
image based lighting as well as any punctual lights are used to shade the material.
The other case *No Lighting* which ignores all light sources in the scene and
the material is rendered without shading.  This mode can be useful with models
that should not be shaded, for example tools (gizmos) inside of a 3D editor.
`
        }

        ComboBox {
            id: lightingComboBox
            textRole: "text"
            valueRole: "value"
            implicitContentWidthPolicy: ComboBox.WidestText
            onActivated: rootView.targetMaterial.lighting = currentValue
            Component.onCompleted: currentIndex = indexOfValue(rootView.targetMaterial.lighting)
            model: [
                { value: PrincipledMaterial.NoLighting, text: "No Lighting"},
                { value: PrincipledMaterial.FragmentLighting, text: "Fragment Lighting"}
            ]
        }

        VerticalSectionSeparator {}

        MarkdownLabel {
            text: `## Non Triangle Primitive Sizes
Generally if you use the Mesh file format baked by balsam, or the runtime
loader for loading glTF2 scenes, the geometry primitive will be individual
triangles, so these properties are not useful. However it is possible to
create your own mesh geometry where the primitive is instead either Points
or Lines, and in these cases it is possible to change the size of these
primitives when rendered. These properties will only have an affect on a
material when the geometry primitive is set to Line or Point respectively.
The behavior of these properties will depend on which graphics API the is
being used, and is possible that they will do nothing at all.`
        }

        Button {
            text: checked ? "Hide Wireframe Model" : "Show Wireframe Model"
            checkable: true
            checked: rootView.linesModel.visible
            onClicked: {
                rootView.linesModel.visible = !rootView.linesModel.visible
            }
        }

        RowLayout {
            Label {
                text: "Line Width (" + rootView.targetMaterial.lineWidth.toFixed(2) + ")"
                Layout.fillWidth: true
            }
            Slider {
                from: 0
                to: 25
                value: rootView.targetMaterial.lineWidth
                onValueChanged: rootView.targetMaterial.lineWidth = value
            }
        }

        Button {
            text: checked ? "Hide Point Cloud" : "Show Point Cloud"
            checkable: true
            checked: rootView.pointsModel.visible
            onClicked: {
                rootView.pointsModel.visible = !rootView.pointsModel.visible
            }
        }

        RowLayout {
            Label {
                text: "Point Size (" + rootView.targetMaterial.pointSize.toFixed(2) + ")"
                Layout.fillWidth: true
            }
            Slider {
                from: 0
                to: 25
                value: rootView.targetMaterial.pointSize
                onValueChanged: rootView.targetMaterial.pointSize = value
            }
        }

        ColumnLayout {
            VerticalSectionSeparator {}

            MarkdownLabel {
                text: `## Specular Overrides
If you are using this material for Physically Based Rendering (PBR) then
these properties should not be touched as they are not energy conserving and
will make materials look less realistic. These exist for adjusting the material
for artistic or stylistic reasons.`
            }

            MarkdownLabel {
                visible: !rootView.specularGlossyMode
                text: `### Specular Amount
This Specular Amount property controls the strength of specularity (highlights
and reflections) of a dielectric material (non-metallic). Normally this should
be left at 1.0, but can be adjusted to reduce the specularity. Adjusting this
property will not affect reflections caused by Image Based Lighting.`
            }
            RowLayout {
                visible: !rootView.specularGlossyMode
                Label {
                    text: "Specular Amount  (" + rootView.targetMaterial.specularAmount.toFixed(2) + ")"
                    Layout.fillWidth: true
                }
                Slider {
                    from: 0
                    to: 1
                    value: rootView.targetMaterial.specularAmount
                    onValueChanged: rootView.targetMaterial.specularAmount = value
                }
            }

            MarkdownLabel {
                text: `### Fresnel Power
This property decreases head-on reflections (looking directly at the
surface) while maintaining reflections seen at grazing angles.`
            }
            RowLayout {
                Label {
                    text: "Fresnel Power  (" + (rootView.targetMaterial.fresnelPower !== undefined ? rootView.targetMaterial.fresnelPower.toFixed(2) : 5.0) + ")"
                    Layout.fillWidth: true
                }
                Slider {
                    from: 0.0
                    to: 10.0
                    value: (rootView.targetMaterial.fresnelPower !== undefined ? rootView.targetMaterial.fresnelPower : 5.0)
                    onValueChanged: rootView.targetMaterial.fresnelPower = value
                }
            }

            MarkdownLabel {
                text: `## Enable Fresnel ScaleBias
The material will take Fresnel Scale and Fresnel Bias into account.`
            }
            RowLayout {
                Label {
                    text: "Enable fresnel ScaleBias"
                }
                Switch {
                    checked: rootView.targetMaterial.fresnelScaleBiasEnabled
                    onCheckedChanged: {
                        fresnelScaleLabel.enabled = checked
                        fresnelScale.enabled = checked
                        fresnelBiasLabel.enabled = checked
                        fresnelBias.enabled = checked
                        rootView.targetMaterial.fresnelScaleBiasEnabled = checked
                    }
                }
            }

            MarkdownLabel {
                id: fresnelScaleLabel
                enabled: false
                text: `### Fresnel Scale
This property scale head-on reflections (looking directly at the
surface) while maintaining reflections seen at grazing angles.`
            }
            RowLayout {
                id: fresnelScale
                enabled: false
                Label {
                    text: "Fresnel scale  (" + (rootView.targetMaterial.fresnelScale !== undefined ? rootView.targetMaterial.fresnelScale.toFixed(2) : 1.0) + ")"
                    Layout.fillWidth: true
                }
                Slider {
                    from: 0.0
                    to: 10.0
                    value: (rootView.targetMaterial.fresnelScale !== undefined ? rootView.targetMaterial.fresnelScale : 1.0)
                    onValueChanged: rootView.targetMaterial.fresnelScale = value
                }
            }

            MarkdownLabel {
                id: fresnelBiasLabel
                enabled: false
                text: `### Fresnel Bias
This property push forward head-on reflections (looking directly at the
surface) while maintaining reflections seen at grazing angles.`
            }
            RowLayout {
                id: fresnelBias
                enabled: false
                Label {
                    text: "Fresnel Bias  (" + (rootView.targetMaterial.fresnelBias !== undefined ? rootView.targetMaterial.fresnelBias.toFixed(2) : 0.0) + ")"
                    Layout.fillWidth: true
                }
                Slider {
                    from: -1.0
                    to: 1.0
                    value: (rootView.targetMaterial.fresnelBias !== undefined ? rootView.targetMaterial.fresnelBias : 0.0)
                    onValueChanged: rootView.targetMaterial.fresnelBias = value
                }
            }
            MarkdownLabel {
                visible: !rootView.specularGlossyMode
                text: `### Specular Tint
The Specular Tint property defines how much of the Base Color of the material
contributes to specular reflections.  This property only has an affect with
dielectric materials (non-metallic) as metallic material's specular reflections
are already primarily tinted by the materials base color. This property allows
the Base Color to also tint the specular reflections for dielectrics as well for
artistic reasons.`
            }
            RowLayout {
                visible: !rootView.specularGlossyMode
                Label {
                    text: "Specular Tint (" + rootView.targetMaterial.specularTint.toFixed(2) + ")"
                    Layout.fillWidth: true
                }
                Slider {
                    from: 0
                    to: 1
                    value: rootView.targetMaterial.specularTint
                    onValueChanged: rootView.targetMaterial.specularTint = value
                }
            }

            MarkdownLabel {
                visible: !rootView.specularGlossyMode
                text: `### Specular Map
The Specular Map property defines color (RGB) texture to modulate the amount
and the color of specularity across the surface of the material. These values
are multiplied by the Specular Amount property. This property will only have
an affect if the material is a dielectric (non-metallic).`
            }
            RowLayout {
                visible: !rootView.specularGlossyMode
                Label {
                    text: "Enable specular single channel Map
The material will use the single value of the specularChannel from
the specularMap as RGB value."
                }
                Switch {
                    checked: rootView.targetMaterial.specularSingleChannelEnabled
                    onCheckedChanged: {
                        rootView.targetMaterial.specularSingleChannelEnabled = checked
                    }
                }
            }
            ComboBox {
                visible: !rootView.specularGlossyMode
                enabled: rootView.targetMaterial.specularSingleChannelEnabled
                textRole: "text"
                valueRole: "value"
                implicitContentWidthPolicy: ComboBox.WidestText
                onActivated: rootView.targetMaterial.specularChannel = currentValue
                Component.onCompleted: currentIndex = indexOfValue(rootView.targetMaterial.specularChannel)
                model: [
                    { value: PrincipledMaterial.R, text: "Red Channel"},
                    { value: PrincipledMaterial.G, text: "Green Channel"},
                    { value: PrincipledMaterial.B, text: "Blue Channel"},
                    { value: PrincipledMaterial.A, text: "Alpha Channel"}
                ]
            }
            TextureSourceControl {
                visible: !rootView.specularGlossyMode
                defaultClearColor: "black"
                defaultTexture: "maps/metallic/metallic.jpg"
                onTargetTextureChanged: {
                    rootView.targetMaterial.specularMap = targetTexture
                }
            }

            MarkdownLabel {
                visible: !rootView.specularGlossyMode
                text: `### Specular Reflection Map
The Specular Reflection Map property is for providing a static environment map
for cheap reflection calculations.  Unlike most properties which take textures
in PrincipledMaterial, this property requires the source Texture to use the
EnvironmentMap mapping mode to look correct. In addition this means that the
source image file should be an equirectangular projection. This is an alternative
to using Imaged Based Lighting via lightProbes to get static reflections.`
            }

            TextureSourceControl {
                visible: !rootView.specularGlossyMode
                defaultClearColor: "black"
                defaultTexture: "maps/small_envmap.jpg"
                envMapMode: true
                onTargetTextureChanged: {
                    rootView.targetMaterial.specularReflectionMap = targetTexture
                }
            }
        }
    }
}
// qmllint enable missing-property