{
    "QEN": {
        "description": "Generates a colorized and blurred shadow inside the source.",
        "extraMargin": 80,
        "fragmentCode": [
            "@requires BlurHelper",
            "float linearstep(float e0, float e1, float x) {",
            "    return clamp((x - e0) / (e1 - e0), 0.0, 1.0);",
            "}",
            "@main",
            "{",
            "    float shadow = texture(iSource, innerShadowTexCoord).a * innerShadowBlurWeight1[0];",
            "    shadow += texture(iSourceBlur1, innerShadowTexCoord).a * innerShadowBlurWeight1[1];",
            "#if (BLUR_HELPER_MAX_LEVEL > 2)",
            "    shadow += texture(iSourceBlur2, innerShadowTexCoord).a * innerShadowBlurWeight1[2];",
            "#endif",
            "#if (BLUR_HELPER_MAX_LEVEL > 8)",
            "    shadow += texture(iSourceBlur3, innerShadowTexCoord).a * innerShadowBlurWeight1[3];",
            "#endif",
            "#if (BLUR_HELPER_MAX_LEVEL > 16)",
            "    shadow += texture(iSourceBlur4, innerShadowTexCoord).a * innerShadowBlurWeight2[0];",
            "#endif",
            "#if (BLUR_HELPER_MAX_LEVEL > 32)",
            "    shadow += texture(iSourceBlur5, innerShadowTexCoord).a * innerShadowBlurWeight2[1];",
            "#endif",
            "",
            "    vec4 shadowColor = innerShadowColor  - innerShadowColor * shadow;",
            "    vec4 originalColor = fragColor;",
            "    float spread = 1.0 - (innerShadowSpread * 0.98);",
            "    shadowColor.rgb = mix(originalColor.rgb, innerShadowColor.rgb * originalColor.a, linearstep(0.0, spread, shadowColor.a));",
            "    fragColor = vec4(shadowColor.rgb, originalColor.a) * originalColor.a;",
            "}"
        ],
        "name": "Inner Shadow",
        "properties": [
            {
                "defaultValue": "1",
                "description": "Sets the amount of blur (radius) applied to the shadow.\n\nThe value ranges from 0.0 (no blur) to 1.0 (full blur).\n\nThe amount of blur is also affected by the Blur Helper Multiplier property.",
                "maxValue": "1",
                "minValue": "0",
                "name": "innerShadowBlurAmount",
                "displayName": "Blur Amount",
                "type": "float"
            },
            {
                "defaultValue": "0",
                "description": "Sets the horizontal position of the shadow.",
                "maxValue": "30",
                "minValue": "-30",
                "name": "innerShadowHorizontalOffset",
                "displayName": "Horizontal Offset",
                "type": "float"
            },
            {
                "defaultValue": "0",
                "description": "Sets the vertical position of the shadow.",
                "maxValue": "30",
                "minValue": "-30",
                "name": "innerShadowVerticalOffset",
                "displayName": "Vertical Offset",
                "type": "float"
            },
            {
                "defaultValue": "0, 0, 0, 1",
                "description": "Sets the color of the shadow.",
                "name": "innerShadowColor",
                "displayName": "Color",
                "type": "color"
            },
            {
                "defaultValue": "0",
                "description": "Sets how large part of the shadow is strengthened near the source edges.",
                "maxValue": "1",
                "minValue": "0",
                "name": "innerShadowSpread",
                "displayName": "Spread",
                "type": "float"
            }
        ],
        "version": 1,
        "vertexCode": [
            "out vec2 innerShadowTexCoord;",
            "out vec4 innerShadowBlurWeight1;",
            "out vec2 innerShadowBlurWeight2;",
            "",
            "float innerShadowBlurWeight(float v) {",
            "    return max(0.0, min(1.0, 1.0 - v * 2.0));",
            "}",
            "",
            "@main",
            "{",
            "    float shadowBlurLod = sqrt(innerShadowBlurAmount * (BLUR_HELPER_MAX_LEVEL / 64.0)) * 1.2 - 0.2;",
            "    float sbw1 = innerShadowBlurWeight(abs(shadowBlurLod - 0.1));",
            "    float sbw2 = innerShadowBlurWeight(abs(shadowBlurLod - 0.3));",
            "    float sbw3 = innerShadowBlurWeight(abs(shadowBlurLod - 0.5));",
            "    float sbw4 = innerShadowBlurWeight(abs(shadowBlurLod - 0.7));",
            "    float sbw5 = innerShadowBlurWeight(abs(shadowBlurLod - 0.9));",
            "    float sbw6 = innerShadowBlurWeight(abs(shadowBlurLod - 1.1));",
            "",
            "    float sbsum = sbw1 + sbw2 + sbw3 + sbw4 + sbw5 + sbw6;",
            "    innerShadowBlurWeight1 = vec4(sbw1 / sbsum, sbw2 / sbsum, sbw3 / sbsum, sbw4 / sbsum);",
            "    innerShadowBlurWeight2 = vec2(sbw5 / sbsum, sbw6 / sbsum);",
            "",
            "    vec2 shadowOffset = vec2(innerShadowHorizontalOffset / iResolution.x, innerShadowVerticalOffset / iResolution.y);",
            "    innerShadowTexCoord = qt_MultiTexCoord0 - shadowOffset;",
            "}"
        ]
    }
}
