Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
Vignette.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4import QtQuick
5
13Item {
14 id: root
15 Accessible.ignored: true
16
21 property variant source
22
26 property alias radius: effect.radius
27
31 property alias brightness: effect.brightness
32
33 ShaderEffect {
34 id: effect
35 anchors.fill: parent
36
37 property variant source: ShaderEffectSource {
38 sourceItem: root.source
39 sourceRect: Qt.rect(0, 0, 0, 0)
40 hideSource: false
41 smooth: true
42 visible: false
43 }
44
45 property real radius: 16
46 property real brightness: 0.1
47
48 fragmentShader: "
49 varying highp vec2 qt_TexCoord0;
50 uniform highp float qt_Opacity;
51 uniform highp float radius;
52 uniform highp float brightness;
53 uniform lowp sampler2D source;
54
55 void main() {
56 highp vec2 uv = qt_TexCoord0.xy;
57 highp vec2 coord = qt_TexCoord0 - 0.5;
58 lowp vec4 orig = texture2D(source, uv);
59
60 highp float vignette = 1.0 - dot(coord, coord);
61
62 lowp vec3 col = orig.rgb * clamp(pow(vignette, radius) + brightness, 0.0, 1.0);
63
64 gl_FragColor = vec4(col, 1.0);
65 }"
66 }
67}