diff options
Diffstat (limited to 'src/effects/shaders_ng')
49 files changed, 828 insertions, 0 deletions
diff --git a/src/effects/shaders_ng/brightnesscontrast.frag b/src/effects/shaders_ng/brightnesscontrast.frag new file mode 100644 index 0000000..c9ae173 --- /dev/null +++ b/src/effects/shaders_ng/brightnesscontrast.frag @@ -0,0 +1,26 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float brightness; + float contrast; +}; + +layout(binding = 1) uniform sampler2D source; + +void main() +{ + vec4 pixelColor = texture(source, qt_TexCoord0); + pixelColor.rgb /= max(1.0/256.0, pixelColor.a); + float c = 1.0 + contrast; + float contrastGainFactor = 1.0 + c * c * c * c * step(0.0, contrast); + pixelColor.rgb = ((pixelColor.rgb - 0.5) * (contrastGainFactor * contrast + 1.0)) + 0.5; + pixelColor.rgb = mix(pixelColor.rgb, vec3(step(0.0, brightness)), abs(brightness)); + fragColor = vec4(pixelColor.rgb * pixelColor.a, pixelColor.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/brightnesscontrast.frag.qsb b/src/effects/shaders_ng/brightnesscontrast.frag.qsb Binary files differnew file mode 100644 index 0000000..2fc9761 --- /dev/null +++ b/src/effects/shaders_ng/brightnesscontrast.frag.qsb diff --git a/src/effects/shaders_ng/colorize.frag b/src/effects/shaders_ng/colorize.frag new file mode 100644 index 0000000..a109a45 --- /dev/null +++ b/src/effects/shaders_ng/colorize.frag @@ -0,0 +1,72 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float hue; + float saturation; + float lightness; +}; + +layout(binding = 1) uniform sampler2D source; + +float RGBtoL(vec3 color) +{ + float cmin = min(color.r, min(color.g, color.b)); + float cmax = max(color.r, max(color.g, color.b)); + float l = (cmin + cmax) / 2.0; + return l; +} + +float hueToIntensity(float v1, float v2, float h) +{ + h = fract(h); + if (h < 1.0 / 6.0) + return v1 + (v2 - v1) * 6.0 * h; + else if (h < 1.0 / 2.0) + return v2; + else if (h < 2.0 / 3.0) + return v1 + (v2 - v1) * 6.0 * (2.0 / 3.0 - h); + + return v1; +} + +vec3 HSLtoRGB(vec3 color) +{ + float h = color.x; + float l = color.z; + float s = color.y; + + if (s < 1.0 / 256.0) + return vec3(l, l, l); + + float v1; + float v2; + if (l < 0.5) + v2 = l * (1.0 + s); + else + v2 = (l + s) - (s * l); + + v1 = 2.0 * l - v2; + + float d = 1.0 / 3.0; + float r = hueToIntensity(v1, v2, h + d); + float g = hueToIntensity(v1, v2, h); + float b = hueToIntensity(v1, v2, h - d); + return vec3(r, g, b); +} + +void main() +{ + vec4 samp = texture(source, qt_TexCoord0); + samp = vec4(samp.rgb / max(1.0/256.0, samp.a), samp.a); + float light = RGBtoL(samp.rgb); + float c = step(0.0, lightness); + samp.rgb = HSLtoRGB(vec3(hue, saturation, mix(light, c, abs(lightness)))); + fragColor = vec4(samp.rgb * samp.a, samp.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/colorize.frag.qsb b/src/effects/shaders_ng/colorize.frag.qsb Binary files differnew file mode 100644 index 0000000..eb55cb3 --- /dev/null +++ b/src/effects/shaders_ng/colorize.frag.qsb diff --git a/src/effects/shaders_ng/coloroverlay.frag b/src/effects/shaders_ng/coloroverlay.frag new file mode 100644 index 0000000..5ec1666 --- /dev/null +++ b/src/effects/shaders_ng/coloroverlay.frag @@ -0,0 +1,20 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec4 color; +}; + +layout(binding = 1) uniform sampler2D source; + +void main() +{ + vec4 pixelColor = texture(source, qt_TexCoord0); + fragColor = vec4(mix(pixelColor.rgb/max(pixelColor.a, 0.00390625), color.rgb/max(color.a, 0.00390625), color.a) * pixelColor.a, pixelColor.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/coloroverlay.frag.qsb b/src/effects/shaders_ng/coloroverlay.frag.qsb Binary files differnew file mode 100644 index 0000000..e1eb955 --- /dev/null +++ b/src/effects/shaders_ng/coloroverlay.frag.qsb diff --git a/src/effects/shaders_ng/compile.bat b/src/effects/shaders_ng/compile.bat new file mode 100644 index 0000000..cb0e222 --- /dev/null +++ b/src/effects/shaders_ng/compile.bat @@ -0,0 +1,66 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Copyright (C) 2020 The Qt Company Ltd. +:: Contact: https://www.qt.io/licensing/ +:: +:: This file is part of the QtQuick module of the Qt Toolkit. +:: +:: $QT_BEGIN_LICENSE:LGPL$ +:: Commercial License Usage +:: Licensees holding valid commercial Qt licenses may use this file in +:: accordance with the commercial license agreement provided with the +:: Software or, alternatively, in accordance with the terms contained in +:: a written agreement between you and The Qt Company. For licensing terms +:: and conditions see https://www.qt.io/terms-conditions. For further +:: information use the contact form at https://www.qt.io/contact-us. +:: +:: GNU Lesser General Public License Usage +:: Alternatively, this file may be used under the terms of the GNU Lesser +:: General Public License version 3 as published by the Free Software +:: Foundation and appearing in the file LICENSE.LGPL3 included in the +:: packaging of this file. Please review the following information to +:: ensure the GNU Lesser General Public License version 3 requirements +:: will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +:: +:: GNU General Public License Usage +:: Alternatively, this file may be used under the terms of the GNU +:: General Public License version 2.0 or (at your option) the GNU General +:: Public license version 3 or any later version approved by the KDE Free +:: Qt Foundation. The licenses are as published by the Free Software +:: Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +:: included in the packaging of this file. Please review the following +:: information to ensure the GNU General Public License requirements will +:: be met: https://www.gnu.org/licenses/gpl-2.0.html and +:: https://www.gnu.org/licenses/gpl-3.0.html. +:: +:: $QT_END_LICENSE$ +:: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: For HLSL we invoke fxc.exe (-c argument) and store the resulting intermediate format +:: instead of HLSL source, so this needs to be run on Windows from a developer command prompt. + +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o opacitymask.frag.qsb opacitymask.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o opacitymask_invert.frag.qsb opacitymask_invert.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o fastblur.frag.qsb fastblur.frag +qsb -b --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o fastblur_internal.vert.qsb fastblur_internal.vert +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o fastblur_internal.frag.qsb fastblur_internal.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o fastglow.frag.qsb fastglow.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o colorize.frag.qsb colorize.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o brightnesscontrast.frag.qsb brightnesscontrast.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o coloroverlay.frag.qsb coloroverlay.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o desaturate.frag.qsb desaturate.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o displace.frag.qsb displace.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o gammaadjust.frag.qsb gammaadjust.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o huesaturation.frag.qsb huesaturation.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o rectangularglow.frag.qsb rectangularglow.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o thresholdmask.frag.qsb thresholdmask.frag +qsb -b --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o lineargradient.vert.qsb lineargradient.vert +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o lineargradient_nomask.frag.qsb lineargradient_nomask.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o lineargradient_mask.frag.qsb lineargradient_mask.frag +qsb -b --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o radialgradient.vert.qsb radialgradient.vert +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o radialgradient_nomask.frag.qsb radialgradient_nomask.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o radialgradient_mask.frag.qsb radialgradient_mask.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o conicalgradient_nomask.frag.qsb conicalgradient_nomask.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o conicalgradient_mask.frag.qsb conicalgradient_mask.frag +qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o leveladjust.frag.qsb leveladjust.frag diff --git a/src/effects/shaders_ng/conicalgradient_mask.frag b/src/effects/shaders_ng/conicalgradient_mask.frag new file mode 100644 index 0000000..5c1f2ed --- /dev/null +++ b/src/effects/shaders_ng/conicalgradient_mask.frag @@ -0,0 +1,25 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec2 center; + float startAngle; +}; + +layout(binding = 1) uniform sampler2D gradientSource; +layout(binding = 2) uniform sampler2D maskSource; + +void main() +{ + float maskAlpha = texture(maskSource, qt_TexCoord0).a; + const float PI = 3.14159265; + const float PIx2inv = 0.1591549; + float a = (atan((center.y - qt_TexCoord0.t), (center.x - qt_TexCoord0.s)) + PI - startAngle) * PIx2inv; + fragColor = texture(gradientSource, vec2(0.0, fract(a))) * maskAlpha * qt_Opacity; +} diff --git a/src/effects/shaders_ng/conicalgradient_mask.frag.qsb b/src/effects/shaders_ng/conicalgradient_mask.frag.qsb Binary files differnew file mode 100644 index 0000000..f0ce8e7 --- /dev/null +++ b/src/effects/shaders_ng/conicalgradient_mask.frag.qsb diff --git a/src/effects/shaders_ng/conicalgradient_nomask.frag b/src/effects/shaders_ng/conicalgradient_nomask.frag new file mode 100644 index 0000000..b63d7e6 --- /dev/null +++ b/src/effects/shaders_ng/conicalgradient_nomask.frag @@ -0,0 +1,23 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec2 center; + float startAngle; +}; + +layout(binding = 1) uniform sampler2D gradientSource; + +void main() +{ + const float PI = 3.14159265; + const float PIx2inv = 0.1591549; + float a = (atan((center.y - qt_TexCoord0.t), (center.x - qt_TexCoord0.s)) + PI - startAngle) * PIx2inv; + fragColor = texture(gradientSource, vec2(0.0, fract(a))) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/conicalgradient_nomask.frag.qsb b/src/effects/shaders_ng/conicalgradient_nomask.frag.qsb Binary files differnew file mode 100644 index 0000000..d074e61 --- /dev/null +++ b/src/effects/shaders_ng/conicalgradient_nomask.frag.qsb diff --git a/src/effects/shaders_ng/desaturate.frag b/src/effects/shaders_ng/desaturate.frag new file mode 100644 index 0000000..b54b3ac --- /dev/null +++ b/src/effects/shaders_ng/desaturate.frag @@ -0,0 +1,21 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float desaturation; +}; + +layout(binding = 1) uniform sampler2D source; + +void main(void) +{ + vec4 textureColor = texture(source, qt_TexCoord0.st); + float grayColor = (textureColor.r + textureColor.g + textureColor.b) / 3.0; + fragColor = mix(textureColor, vec4(vec3(grayColor), textureColor.a), desaturation) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/desaturate.frag.qsb b/src/effects/shaders_ng/desaturate.frag.qsb Binary files differnew file mode 100644 index 0000000..8a0b4da --- /dev/null +++ b/src/effects/shaders_ng/desaturate.frag.qsb diff --git a/src/effects/shaders_ng/displace.frag b/src/effects/shaders_ng/displace.frag new file mode 100644 index 0000000..df6bc78 --- /dev/null +++ b/src/effects/shaders_ng/displace.frag @@ -0,0 +1,39 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float displacement; + float xPixel; + float yPixel; +}; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D displacementSource; + +float linearstep(float e0, float e1, float x) +{ + return clamp((x - e0) / (e1 - e0), 0.0, 1.0); +} + +void main() +{ + vec4 offset = texture(displacementSource, qt_TexCoord0); + offset.xy -= vec2(0.5, 0.5); + offset.xy = offset.xy * step(vec2(1.0/256.0), abs(offset.xy)); + vec2 tx = qt_TexCoord0 + (vec2(-offset.x, offset.y) * displacement); + + float e1 = linearstep(0.0, xPixel, tx.x); + float e2 = linearstep(0.0, yPixel, tx.y); + float e3 = 1.0 - linearstep(1.0, 1.0 + xPixel, tx.x); + float e4 = 1.0 - linearstep(1.0, 1.0 + yPixel, tx.y); + + vec4 samp = texture(source, tx); + samp.rgb *= e1 * e2 * e3 * e4; + fragColor = samp * qt_Opacity * offset.a; +} diff --git a/src/effects/shaders_ng/displace.frag.qsb b/src/effects/shaders_ng/displace.frag.qsb Binary files differnew file mode 100644 index 0000000..3c3656c --- /dev/null +++ b/src/effects/shaders_ng/displace.frag.qsb diff --git a/src/effects/shaders_ng/fastblur.frag b/src/effects/shaders_ng/fastblur.frag new file mode 100644 index 0000000..6e2ca14 --- /dev/null +++ b/src/effects/shaders_ng/fastblur.frag @@ -0,0 +1,32 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float weight1; + float weight2; + float weight3; + float weight4; + float weight5; +}; + +layout(binding = 1) uniform sampler2D source1; +layout(binding = 2) uniform sampler2D source2; +layout(binding = 3) uniform sampler2D source3; +layout(binding = 4) uniform sampler2D source4; +layout(binding = 5) uniform sampler2D source5; + +void main() +{ + vec4 sourceColor = texture(source1, qt_TexCoord0) * weight1; + sourceColor += texture(source2, qt_TexCoord0) * weight2; + sourceColor += texture(source3, qt_TexCoord0) * weight3; + sourceColor += texture(source4, qt_TexCoord0) * weight4; + sourceColor += texture(source5, qt_TexCoord0) * weight5; + fragColor = sourceColor * qt_Opacity; +} diff --git a/src/effects/shaders_ng/fastblur.frag.qsb b/src/effects/shaders_ng/fastblur.frag.qsb Binary files differnew file mode 100644 index 0000000..24c623a --- /dev/null +++ b/src/effects/shaders_ng/fastblur.frag.qsb diff --git a/src/effects/shaders_ng/fastblur_internal.frag b/src/effects/shaders_ng/fastblur_internal.frag new file mode 100644 index 0000000..7a608de --- /dev/null +++ b/src/effects/shaders_ng/fastblur_internal.frag @@ -0,0 +1,25 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 1) in vec2 qt_TexCoord1; +layout(location = 2) in vec2 qt_TexCoord2; +layout(location = 3) in vec2 qt_TexCoord3; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + float xStep; + float yStep; +}; + +layout(binding = 1) uniform sampler2D source; + +void main() +{ + vec4 sourceColor = (texture(source, qt_TexCoord0) + + texture(source, qt_TexCoord1) + + texture(source, qt_TexCoord2) + + texture(source, qt_TexCoord3)) * 0.25; + fragColor = sourceColor * qt_Opacity; +} diff --git a/src/effects/shaders_ng/fastblur_internal.frag.qsb b/src/effects/shaders_ng/fastblur_internal.frag.qsb Binary files differnew file mode 100644 index 0000000..fd439c8 --- /dev/null +++ b/src/effects/shaders_ng/fastblur_internal.frag.qsb diff --git a/src/effects/shaders_ng/fastblur_internal.vert b/src/effects/shaders_ng/fastblur_internal.vert new file mode 100644 index 0000000..e9a14b0 --- /dev/null +++ b/src/effects/shaders_ng/fastblur_internal.vert @@ -0,0 +1,27 @@ +#version 440 + +layout(location = 0) in vec4 qt_Vertex; +layout(location = 1) in vec2 qt_MultiTexCoord0; + +layout(location = 0) out vec2 qt_TexCoord0; +layout(location = 1) out vec2 qt_TexCoord1; +layout(location = 2) out vec2 qt_TexCoord2; +layout(location = 3) out vec2 qt_TexCoord3; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + float xStep; + float yStep; +}; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + qt_TexCoord0 = vec2(qt_MultiTexCoord0.x + xStep, qt_MultiTexCoord0.y + yStep * 0.36); + qt_TexCoord1 = vec2(qt_MultiTexCoord0.x + xStep * 0.36, qt_MultiTexCoord0.y - yStep); + qt_TexCoord2 = vec2(qt_MultiTexCoord0.x - xStep * 0.36, qt_MultiTexCoord0.y + yStep); + qt_TexCoord3 = vec2(qt_MultiTexCoord0.x - xStep, qt_MultiTexCoord0.y - yStep * 0.36); + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/src/effects/shaders_ng/fastblur_internal.vert.qsb b/src/effects/shaders_ng/fastblur_internal.vert.qsb Binary files differnew file mode 100644 index 0000000..96781b8 --- /dev/null +++ b/src/effects/shaders_ng/fastblur_internal.vert.qsb diff --git a/src/effects/shaders_ng/fastglow.frag b/src/effects/shaders_ng/fastglow.frag new file mode 100644 index 0000000..fa19239 --- /dev/null +++ b/src/effects/shaders_ng/fastglow.frag @@ -0,0 +1,40 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec4 color; + float spread; + float weight1; + float weight2; + float weight3; + float weight4; + float weight5; +}; + +layout(binding = 1) uniform sampler2D source1; +layout(binding = 2) uniform sampler2D source2; +layout(binding = 3) uniform sampler2D source3; +layout(binding = 4) uniform sampler2D source4; +layout(binding = 5) uniform sampler2D source5; + +float linearstep(float e0, float e1, float x) +{ + return clamp((x - e0) / (e1 - e0), 0.0, 1.0); +} + +void main() +{ + vec4 sourceColor = texture(source1, qt_TexCoord0) * weight1; + sourceColor += texture(source2, qt_TexCoord0) * weight2; + sourceColor += texture(source3, qt_TexCoord0) * weight3; + sourceColor += texture(source4, qt_TexCoord0) * weight4; + sourceColor += texture(source5, qt_TexCoord0) * weight5; + sourceColor = mix(vec4(0), color, linearstep(0.0, spread, sourceColor.a)); + fragColor = sourceColor * qt_Opacity; +} diff --git a/src/effects/shaders_ng/fastglow.frag.qsb b/src/effects/shaders_ng/fastglow.frag.qsb Binary files differnew file mode 100644 index 0000000..d78cd6d --- /dev/null +++ b/src/effects/shaders_ng/fastglow.frag.qsb diff --git a/src/effects/shaders_ng/gammaadjust.frag b/src/effects/shaders_ng/gammaadjust.frag new file mode 100644 index 0000000..0a1175a --- /dev/null +++ b/src/effects/shaders_ng/gammaadjust.frag @@ -0,0 +1,22 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float gamma; +}; + +layout(binding = 1) uniform sampler2D source; + +void main() +{ + vec4 originalColor = texture(source, qt_TexCoord0.st); + originalColor.rgb = originalColor.rgb / max(1.0/256.0, originalColor.a); + vec3 adjustedColor = pow(originalColor.rgb, vec3(gamma)); + fragColor = vec4(adjustedColor * originalColor.a, originalColor.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/gammaadjust.frag.qsb b/src/effects/shaders_ng/gammaadjust.frag.qsb Binary files differnew file mode 100644 index 0000000..40ab6c1 --- /dev/null +++ b/src/effects/shaders_ng/gammaadjust.frag.qsb diff --git a/src/effects/shaders_ng/huesaturation.frag b/src/effects/shaders_ng/huesaturation.frag new file mode 100644 index 0000000..0b1e10e --- /dev/null +++ b/src/effects/shaders_ng/huesaturation.frag @@ -0,0 +1,91 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec3 hsl; +}; + +layout(binding = 1) uniform sampler2D source; + +vec3 RGBtoHSL(vec3 color) +{ + float cmin = min(color.r, min(color.g, color.b)); + float cmax = max(color.r, max(color.g, color.b)); + float h = 0.0; + float s = 0.0; + float l = (cmin + cmax) / 2.0; + float diff = cmax - cmin; + + if (diff > 1.0 / 256.0) { + if (l < 0.5) + s = diff / (cmin + cmax); + else + s = diff / (2.0 - (cmin + cmax)); + + if (color.r == cmax) + h = (color.g - color.b) / diff; + else if (color.g == cmax) + h = 2.0 + (color.b - color.r) / diff; + else + h = 4.0 + (color.r - color.g) / diff; + + h /= 6.0; + } + return vec3(h, s, l); +} + +float hueToIntensity(float v1, float v2, float h) +{ + h = fract(h); + if (h < 1.0 / 6.0) + return v1 + (v2 - v1) * 6.0 * h; + else if (h < 1.0 / 2.0) + return v2; + else if (h < 2.0 / 3.0) + return v1 + (v2 - v1) * 6.0 * (2.0 / 3.0 - h); + + return v1; +} + +vec3 HSLtoRGB(vec3 color) +{ + float h = color.x; + float l = color.z; + float s = color.y; + + if (s < 1.0 / 256.0) + return vec3(l); + + float v1; + float v2; + if (l < 0.5) + v2 = l * (1.0 + s); + else + v2 = (l + s) - (s * l); + + v1 = 2.0 * l - v2; + + float d = 1.0 / 3.0; + float r = hueToIntensity(v1, v2, h + d); + float g = hueToIntensity(v1, v2, h); + float b = hueToIntensity(v1, v2, h - d); + return vec3(r, g, b); +} + +void main() +{ + vec4 samp = texture(source, qt_TexCoord0); + samp = vec4(samp.rgb / max(1.0/256.0, samp.a), samp.a); + samp.rgb = mix(vec3(dot(samp.rgb, vec3(0.2125, 0.7154, 0.0721))), samp.rgb, 1.0 + hsl.y); + samp.xyz = RGBtoHSL(samp.rgb); + samp.rgb = HSLtoRGB(vec3(samp.x + hsl.x, samp.y, samp.z)); + float c = step(0.0, hsl.z); + samp.rgb = mix(samp.rgb, vec3(c), abs(hsl.z)); + fragColor = vec4(samp.rgb * samp.a, samp.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/huesaturation.frag.qsb b/src/effects/shaders_ng/huesaturation.frag.qsb Binary files differnew file mode 100644 index 0000000..028a8b8 --- /dev/null +++ b/src/effects/shaders_ng/huesaturation.frag.qsb diff --git a/src/effects/shaders_ng/leveladjust.frag b/src/effects/shaders_ng/leveladjust.frag new file mode 100644 index 0000000..d8cde59 --- /dev/null +++ b/src/effects/shaders_ng/leveladjust.frag @@ -0,0 +1,47 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec3 minimumInputRGB; + vec3 maximumInputRGB; + float minimumInputAlpha; + float maximumInputAlpha; + vec3 minimumOutputRGB; + vec3 maximumOutputRGB; + float minimumOutputAlpha; + float maximumOutputAlpha; + vec3 gamma; +}; + +layout(binding = 1) uniform sampler2D source; + +float linearstep(float e0, float e1, float x) +{ + return clamp((x - e0) / (e1 - e0), 0.0, 1.0); +} + +void main() +{ + vec4 textureColor = texture(source, qt_TexCoord0.st); + vec4 color = vec4(textureColor.rgb / max(1.0/256.0, textureColor.a), textureColor.a); + + color.r = linearstep(minimumInputRGB.r, maximumInputRGB.r, color.r); + color.g = linearstep(minimumInputRGB.g, maximumInputRGB.g, color.g); + color.b = linearstep(minimumInputRGB.b, maximumInputRGB.b, color.b); + color.a = linearstep(minimumInputAlpha, maximumInputAlpha, color.a); + + color.rgb = pow(color.rgb, gamma); + + color.r = minimumOutputRGB.r + color.r * (maximumOutputRGB.r - minimumOutputRGB.r); + color.g = minimumOutputRGB.g + color.g * (maximumOutputRGB.g - minimumOutputRGB.g); + color.b = minimumOutputRGB.b + color.b * (maximumOutputRGB.b - minimumOutputRGB.b); + color.a = minimumOutputAlpha + color.a * (maximumOutputAlpha - minimumOutputAlpha); + + fragColor = vec4(color.rgb * color.a, color.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/leveladjust.frag.qsb b/src/effects/shaders_ng/leveladjust.frag.qsb Binary files differnew file mode 100644 index 0000000..fad450d --- /dev/null +++ b/src/effects/shaders_ng/leveladjust.frag.qsb diff --git a/src/effects/shaders_ng/lineargradient.vert b/src/effects/shaders_ng/lineargradient.vert new file mode 100644 index 0000000..cd8f8a8 --- /dev/null +++ b/src/effects/shaders_ng/lineargradient.vert @@ -0,0 +1,31 @@ +#version 440 + +layout(location = 0) in vec4 qt_Vertex; +layout(location = 1) in vec2 qt_MultiTexCoord0; + +layout(location = 0) out vec2 qt_TexCoord0; +layout(location = 1) out vec2 qt_TexCoord1; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + vec2 startPoint; + vec2 matrixData; + float l; +}; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + mat2 rot = mat2(matrixData.y, -matrixData.x, + matrixData.x, matrixData.y); + + qt_TexCoord0 = qt_MultiTexCoord0; + + qt_TexCoord1 = qt_MultiTexCoord0 * l; + qt_TexCoord1 -= startPoint * l; + qt_TexCoord1 *= rot; + + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/src/effects/shaders_ng/lineargradient.vert.qsb b/src/effects/shaders_ng/lineargradient.vert.qsb Binary files differnew file mode 100644 index 0000000..475ace8 --- /dev/null +++ b/src/effects/shaders_ng/lineargradient.vert.qsb diff --git a/src/effects/shaders_ng/lineargradient_mask.frag b/src/effects/shaders_ng/lineargradient_mask.frag new file mode 100644 index 0000000..dda85d7 --- /dev/null +++ b/src/effects/shaders_ng/lineargradient_mask.frag @@ -0,0 +1,23 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 1) in vec2 qt_TexCoord1; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + vec2 startPoint; + vec2 matrixData; + float l; +}; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D maskSource; + +void main() +{ + vec4 gradientColor = texture(source, qt_TexCoord1); + float maskAlpha = texture(maskSource, qt_TexCoord0).a; + fragColor = gradientColor * maskAlpha * qt_Opacity; +} diff --git a/src/effects/shaders_ng/lineargradient_mask.frag.qsb b/src/effects/shaders_ng/lineargradient_mask.frag.qsb Binary files differnew file mode 100644 index 0000000..1e99b35 --- /dev/null +++ b/src/effects/shaders_ng/lineargradient_mask.frag.qsb diff --git a/src/effects/shaders_ng/lineargradient_nomask.frag b/src/effects/shaders_ng/lineargradient_nomask.frag new file mode 100644 index 0000000..be1d992 --- /dev/null +++ b/src/effects/shaders_ng/lineargradient_nomask.frag @@ -0,0 +1,20 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 1) in vec2 qt_TexCoord1; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + vec2 startPoint; + vec2 matrixData; + float l; +}; + +layout(binding = 1) uniform sampler2D source; + +void main() +{ + fragColor = texture(source, qt_TexCoord1) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/lineargradient_nomask.frag.qsb b/src/effects/shaders_ng/lineargradient_nomask.frag.qsb Binary files differnew file mode 100644 index 0000000..99c479c --- /dev/null +++ b/src/effects/shaders_ng/lineargradient_nomask.frag.qsb diff --git a/src/effects/shaders_ng/opacitymask.frag b/src/effects/shaders_ng/opacitymask.frag new file mode 100644 index 0000000..94a80b8 --- /dev/null +++ b/src/effects/shaders_ng/opacitymask.frag @@ -0,0 +1,19 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D maskSource; + +void main() +{ + fragColor = texture(source, qt_TexCoord0.st) * (texture(maskSource, qt_TexCoord0.st).a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/opacitymask.frag.qsb b/src/effects/shaders_ng/opacitymask.frag.qsb Binary files differnew file mode 100644 index 0000000..cef12b4 --- /dev/null +++ b/src/effects/shaders_ng/opacitymask.frag.qsb diff --git a/src/effects/shaders_ng/opacitymask_invert.frag b/src/effects/shaders_ng/opacitymask_invert.frag new file mode 100644 index 0000000..2506bdb --- /dev/null +++ b/src/effects/shaders_ng/opacitymask_invert.frag @@ -0,0 +1,19 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; +}; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D maskSource; + +void main() +{ + fragColor = texture(source, qt_TexCoord0.st) * (1.0 - texture(maskSource, qt_TexCoord0.st).a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/opacitymask_invert.frag.qsb b/src/effects/shaders_ng/opacitymask_invert.frag.qsb Binary files differnew file mode 100644 index 0000000..b622ff9 --- /dev/null +++ b/src/effects/shaders_ng/opacitymask_invert.frag.qsb diff --git a/src/effects/shaders_ng/radialgradient.vert b/src/effects/shaders_ng/radialgradient.vert new file mode 100644 index 0000000..27dd88a --- /dev/null +++ b/src/effects/shaders_ng/radialgradient.vert @@ -0,0 +1,39 @@ +#version 440 + +layout(location = 0) in vec4 qt_Vertex; +layout(location = 1) in vec2 qt_MultiTexCoord0; + +layout(location = 0) out vec2 qt_TexCoord0; +layout(location = 1) out vec2 qt_TexCoord1; +layout(location = 2) out vec2 centerPoint; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + vec2 center; + vec2 matrixData; + float horizontalRatio; + float verticalRatio; +}; + +out gl_PerVertex { vec4 gl_Position; }; + +void main() +{ + vec2 ratio = vec2(horizontalRatio, verticalRatio); + + mat2 rot = mat2(matrixData.y, -matrixData.x, + matrixData.x, matrixData.y); + + qt_TexCoord0 = qt_MultiTexCoord0; + + qt_TexCoord1 = qt_MultiTexCoord0; + qt_TexCoord1 -= center; + qt_TexCoord1 *= rot; + qt_TexCoord1 += center; + qt_TexCoord1 *= ratio; + + centerPoint = center * ratio; + + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/src/effects/shaders_ng/radialgradient.vert.qsb b/src/effects/shaders_ng/radialgradient.vert.qsb Binary files differnew file mode 100644 index 0000000..38961b8 --- /dev/null +++ b/src/effects/shaders_ng/radialgradient.vert.qsb diff --git a/src/effects/shaders_ng/radialgradient_mask.frag b/src/effects/shaders_ng/radialgradient_mask.frag new file mode 100644 index 0000000..b67d67f --- /dev/null +++ b/src/effects/shaders_ng/radialgradient_mask.frag @@ -0,0 +1,25 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 1) in vec2 qt_TexCoord1; +layout(location = 2) in vec2 centerPoint; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + vec2 center; + vec2 matrixData; + float horizontalRatio; + float verticalRatio; +}; + +layout(binding = 1) uniform sampler2D gradientImage; +layout(binding = 2) uniform sampler2D maskSource; + +void main() +{ + vec4 gradientColor = texture(gradientImage, vec2(0.0, 2.0 * distance(qt_TexCoord1, centerPoint))); + float maskAlpha = texture(maskSource, qt_TexCoord0).a; + fragColor = gradientColor * maskAlpha * qt_Opacity; +} diff --git a/src/effects/shaders_ng/radialgradient_mask.frag.qsb b/src/effects/shaders_ng/radialgradient_mask.frag.qsb Binary files differnew file mode 100644 index 0000000..8606a67 --- /dev/null +++ b/src/effects/shaders_ng/radialgradient_mask.frag.qsb diff --git a/src/effects/shaders_ng/radialgradient_nomask.frag b/src/effects/shaders_ng/radialgradient_nomask.frag new file mode 100644 index 0000000..777d53d --- /dev/null +++ b/src/effects/shaders_ng/radialgradient_nomask.frag @@ -0,0 +1,23 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 1) in vec2 qt_TexCoord1; +layout(location = 2) in vec2 centerPoint; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + vec2 center; + vec2 matrixData; + float horizontalRatio; + float verticalRatio; +}; + +layout(binding = 1) uniform sampler2D gradientImage; + +void main() +{ + vec4 gradientColor = texture(gradientImage, vec2(0.0, 2.0 * distance(qt_TexCoord1, centerPoint))); + fragColor = gradientColor * qt_Opacity; +} diff --git a/src/effects/shaders_ng/radialgradient_nomask.frag.qsb b/src/effects/shaders_ng/radialgradient_nomask.frag.qsb Binary files differnew file mode 100644 index 0000000..1df3ebc --- /dev/null +++ b/src/effects/shaders_ng/radialgradient_nomask.frag.qsb diff --git a/src/effects/shaders_ng/rectangularglow.frag b/src/effects/shaders_ng/rectangularglow.frag new file mode 100644 index 0000000..cf20b93 --- /dev/null +++ b/src/effects/shaders_ng/rectangularglow.frag @@ -0,0 +1,30 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + vec4 color; + float relativeSizeX; + float relativeSizeY; + float spread; +}; + +float linearstep(float e0, float e1, float x) +{ + return clamp((x - e0) / (e1 - e0), 0.0, 1.0); +} + +void main() +{ + float alpha = + smoothstep(0.0, relativeSizeX, 0.5 - abs(0.5 - qt_TexCoord0.x)) * + smoothstep(0.0, relativeSizeY, 0.5 - abs(0.5 - qt_TexCoord0.y)); + + float spreadMultiplier = linearstep(spread, 1.0 - spread, alpha); + fragColor = color * qt_Opacity * spreadMultiplier * spreadMultiplier; +} diff --git a/src/effects/shaders_ng/rectangularglow.frag.qsb b/src/effects/shaders_ng/rectangularglow.frag.qsb Binary files differnew file mode 100644 index 0000000..7eaf930 --- /dev/null +++ b/src/effects/shaders_ng/rectangularglow.frag.qsb diff --git a/src/effects/shaders_ng/thresholdmask.frag b/src/effects/shaders_ng/thresholdmask.frag new file mode 100644 index 0000000..7740e7e --- /dev/null +++ b/src/effects/shaders_ng/thresholdmask.frag @@ -0,0 +1,23 @@ +#version 440 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { + // qt_Matrix and qt_Opacity must always be both present + // if the built-in vertex shader is used. + mat4 qt_Matrix; + float qt_Opacity; + float threshold; + float spread; +}; + +layout(binding = 1) uniform sampler2D source; +layout(binding = 2) uniform sampler2D maskSource; + +void main() +{ + vec4 colorFragment = texture(source, qt_TexCoord0.st); + vec4 maskFragment = texture(maskSource, qt_TexCoord0.st); + fragColor = colorFragment * smoothstep(threshold * (1.0 + spread) - spread, threshold * (1.0 + spread), maskFragment.a) * qt_Opacity; +} diff --git a/src/effects/shaders_ng/thresholdmask.frag.qsb b/src/effects/shaders_ng/thresholdmask.frag.qsb Binary files differnew file mode 100644 index 0000000..38e7391 --- /dev/null +++ b/src/effects/shaders_ng/thresholdmask.frag.qsb |