aboutsummaryrefslogtreecommitdiffstats
path: root/tools/materialeditor/FrostedGlass.qml
blob: 6452a417a87ac5351b5c1ff525c4e4098de69bb2 (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

import QtQuick

Item {
    id: root
    required property Item backgroundItem
    property alias range: glassEffect.range
    property alias blur: glassEffect.blur
    property alias color: glassEffect.color
    property alias backgroundRect: backgroundSourceImage.sourceRect

    ShaderEffectSource {
        anchors.fill: parent
        id: backgroundSourceImage
        sourceRect: Qt.rect(0, 0, width, height)
        sourceItem: root.backgroundItem
        visible: false
    }


    ShaderEffectSource {
        anchors.fill: parent
        id: noiseImageSource
        sourceRect: Qt.rect(0, 0, width, height)
        sourceItem: noiseImage
        visible: false
    }

    Image {
        anchors.fill: parent
        id: noiseImage
        fillMode: Image.Tile
        horizontalAlignment: Image.AlignLeft
        verticalAlignment: Image.AlignTop
        visible: false
        source: "assets/images/noise.png"
    }

    ShaderEffect {
        id: glassEffect
        property variant sourceTex: backgroundSourceImage
        property variant noiseTex: noiseImageSource
        property real range: 0.25;
        property real blur: 0.05;
        property color color: "white"
        anchors.fill: parent
        fragmentShader: "assets/shaders/frostedGlass.frag.qsb"
    }
}