aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects/BrushStrokes.qml
blob: cc282620c10e8a5608a7eb5e73b0ebcaa81c6425 (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
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick
import QtQuick3D

Effect {
    property TextureInput noiseSample: TextureInput {
        texture: Texture {
            tilingModeHorizontal: Texture.Repeat
            tilingModeVertical: Texture.Repeat
            source: "qrc:/qtquick3deffects/maps/brushnoise.png"
        }
    }
    property real brushLength: 1.0  // 0 - 3
    property real brushSize: 100.0  // 10 - 200
    property real brushAngle: 45.0
    readonly property real sinAlpha: Math.sin(degrees_to_radians(brushAngle))
    readonly property real cosAlpha: Math.cos(degrees_to_radians(brushAngle))

    function degrees_to_radians(degrees) {
        var pi = Math.PI;
        return degrees * (pi/180);
    }

    Shader {
        id: brushstrokes
        stage: Shader.Fragment
        shader: "qrc:/qtquick3deffects/shaders/brushstrokes.frag"
    }

    passes: [
        Pass {
            shaders: [ brushstrokes ]
        }
    ]
}