summaryrefslogtreecommitdiffstats
path: root/nodes/extra/rectangularshadow.qen
blob: 62aecbb3165ab42e7775f1935777df0750266dd0 (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
{
    "QEN": {
        "description": "Creates a rounded rectangle with blur radius. The properties match with the RectangularShadow QtQuick.Effects element, so this node provides a starting point for the custom RectangularShadow materials.",
        "fragmentCode": [
            "float roundedBox(vec2 centerPos, vec2 size, float radii) {",
            "    return length(max(abs(centerPos) - size + radii, 0.0)) - radii;",
            "}",
            "",
            "@main",
            "{",
            "    float box = roundedBox(fragCoord - iResolution.xy * 0.5, rectSize, radius);",
            "    float a = 1.0 - smoothstep(0.0, blur, box);",
            "    fragColor = color * a * a;",
            "}",
            ""
        ],
        "name": "RectangularShadow",
        "properties": [
            {
                "defaultValue": "0, 0, 0, 1",
                "description": "Color of the shadow/glow.",
                "name": "color",
                "type": "color"
            },
            {
                "defaultValue": "100, 100",
                "description": "Size of the shadow rectangle in pixels.",
                "maxValue": "200, 200",
                "minValue": "0, 0",
                "name": "rectSize",
                "type": "vec2"
            },
            {
                "defaultValue": "0",
                "description": "Corner radius amount of the shadow rectangle.",
                "maxValue": "50",
                "minValue": "0",
                "name": "radius",
                "type": "float"
            },
            {
                "defaultValue": "10",
                "description": "Blur radius amount of the shadow rectangle.",
                "maxValue": "50",
                "minValue": "0",
                "name": "blur",
                "type": "float"
            }
        ],
        "version": 1
    }
}