diff --git a/data/shaders/dolphinfx/bloom.glsl b/data/shaders/dolphinfx/bloom.glsl new file mode 100644 index 000000000..1e0b7f28a --- /dev/null +++ b/data/shaders/dolphinfx/bloom.glsl @@ -0,0 +1,238 @@ +/*===============================================================================*\ +|######################## [Dolphin FX Suite 2.20] #######################| +|########################## By Asmodean ##########################| +|| || +|| This program is free software; you can redistribute it and/or || +|| modify it under the terms of the GNU General Public License || +|| as published by the Free Software Foundation; either version 2 || +|| of the License, or (at your option) any later version. || +|| || +|| This program is distributed in the hope that it will be useful, || +|| but WITHOUT ANY WARRANTY; without even the implied warranty of || +|| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the || +|| GNU General Public License for more details. (C)2015 || +|| || +|#################################################################################| +\*===============================================================================*/ + +// Sourced from https://raw.githubusercontent.com/Asmodean-/dolphin/89d640cd557189bb5f921fc219150c74c39bdc55/Data/Sys/Shaders/DolphinFX.glsl with modifications. + +/* +[configuration] + +[OptionRangeInteger] +GUIName = BloomType +OptionName = A_BLOOM_TYPE +MinValue = 0 +MaxValue = 5 +StepAmount = 1 +DefaultValue = 0 + +[OptionRangeFloat] +GUIName = BloomStrength +OptionName = B_BLOOM_STRENGTH +MinValue = 0.000 +MaxValue = 1.000 +StepAmount = 0.001 +DefaultValue = 0.220 + +[OptionRangeFloat] +GUIName = BlendStrength +OptionName = C_BLEND_STRENGTH +MinValue = 0.000 +MaxValue = 1.200 +StepAmount = 0.010 +DefaultValue = 1.000 + +[OptionRangeFloat] +GUIName = BloomDefocus +OptionName = D_B_DEFOCUS +MinValue = 1.000 +MaxValue = 4.000 +StepAmount = 0.100 +DefaultValue = 2.000 + +[OptionRangeFloat] +GUIName = BloomWidth +OptionName = D_BLOOM_WIDTH +MinValue = 1.000 +MaxValue = 8.000 +StepAmount = 0.100 +DefaultValue = 3.200 + +[OptionRangeFloat] +GUIName = BloomReds +OptionName = E_BLOOM_REDS +MinValue = 0.000 +MaxValue = 0.500 +StepAmount = 0.001 +DefaultValue = 0.020 + +[OptionRangeFloat] +GUIName = BloomGreens +OptionName = F_BLOOM_GREENS +MinValue = 0.000 +MaxValue = 0.500 +StepAmount = 0.001 +DefaultValue = 0.010 + +[OptionRangeFloat] +GUIName = BloomBlues +OptionName = G_BLOOM_BLUES +MinValue = 0.000 +MaxValue = 0.500 +StepAmount = 0.001 +DefaultValue = 0.010 + +[/configuration] +*/ + +//Average relative luminance +CONSTANT float3 lumCoeff = float3(0.2126729, 0.7151522, 0.0721750); +float AvgLuminance(float3 color) +{ + return sqrt( + (color.x * color.x * lumCoeff.x) + + (color.y * color.y * lumCoeff.y) + + (color.z * color.z * lumCoeff.z)); +} + +float smootherstep(float a, float b, float x) +{ + x = saturate((x - a) / (b - a)); + return x*x*x*(x*(x * 6.0 - 15.0) + 10.0); +} + +float3 BlendAddLight(float3 bloom, float3 blend) +{ + return saturate(bloom + blend); +} + +float3 BlendScreen(float3 bloom, float3 blend) +{ + return (bloom + blend) - (bloom * blend); +} + +float3 BlendAddGlow(float3 bloom, float3 blend) +{ + float glow = smootherstep(0.0, 1.0, AvgLuminance(bloom)); + return lerp(saturate(bloom + blend), + (blend + blend) - (blend * blend), glow); +} + +float3 BlendGlow(float3 bloom, float3 blend) +{ + float glow = smootherstep(0.0, 1.0, AvgLuminance(bloom)); + return lerp((bloom + blend) - (bloom * blend), + (blend + blend) - (blend * blend), glow); +} + +float3 BlendLuma(float3 bloom, float3 blend) +{ + float lumavg = smootherstep(0.0, 1.0, AvgLuminance(bloom + blend)); + return lerp((bloom * blend), (1.0 - + ((1.0 - bloom) * (1.0 - blend))), lumavg); +} + +float3 BlendOverlay(float3 bloom, float3 blend) +{ + float3 overlay = step(0.5, bloom); + return lerp((bloom * blend * 2.0), (1.0 - (2.0 * + (1.0 - bloom) * (1.0 - blend))), overlay); +} + +float3 BloomCorrection(float3 color) +{ + float3 bloom = color; + + bloom.r = 2.0 / 3.0 * (1.0 - (bloom.r * bloom.r)); + bloom.g = 2.0 / 3.0 * (1.0 - (bloom.g * bloom.g)); + bloom.b = 2.0 / 3.0 * (1.0 - (bloom.b * bloom.b)); + + bloom.r = saturate(color.r + GetOption(E_BLOOM_REDS) * bloom.r); + bloom.g = saturate(color.g + GetOption(F_BLOOM_GREENS) * bloom.g); + bloom.b = saturate(color.b + GetOption(G_BLOOM_BLUES) * bloom.b); + + color = saturate(bloom); + + return color; +} + +float4 PyramidFilter(float2 texcoord, float2 width) +{ + float4 X = SampleLocation(texcoord + float2(0.5, 0.5) * width); + float4 Y = SampleLocation(texcoord + float2(-0.5, 0.5) * width); + float4 Z = SampleLocation(texcoord + float2(0.5, -0.5) * width); + float4 W = SampleLocation(texcoord + float2(-0.5, -0.5) * width); + + return (X + Y + Z + W) / 4.0; +} + +float3 Blend(float3 bloom, float3 blend) +{ + if (GetOption(A_BLOOM_TYPE) == 0) { return BlendGlow(bloom, blend); } + else if (GetOption(A_BLOOM_TYPE) == 1) { return BlendAddGlow(bloom, blend); } + else if (GetOption(A_BLOOM_TYPE) == 2) { return BlendAddLight(bloom, blend); } + else if (GetOption(A_BLOOM_TYPE) == 3) { return BlendScreen(bloom, blend); } + else if (GetOption(A_BLOOM_TYPE) == 4) { return BlendLuma(bloom, blend); } + else /*if (GetOption(A_BLOOM_TYPE) == 5) */ { return BlendOverlay(bloom, blend); } +} + +void main() +{ + float4 color = Sample(); + float2 texcoord = GetCoordinates(); + float2 pixelSize = GetInvResolution(); + + float anflare = 4.0; + + float2 defocus = float2(GetOption(D_B_DEFOCUS), GetOption(D_B_DEFOCUS)); + float4 bloom = PyramidFilter(texcoord, pixelSize * defocus); + + float2 dx = float2(pixelSize.x * GetOption(D_BLOOM_WIDTH), 0.0); + float2 dy = float2(0.0, pixelSize.y * GetOption(D_BLOOM_WIDTH)); + + float2 mdx = mul(dx, 2.0); + float2 mdy = mul(dy, 2.0); + + float4 blend = bloom * 0.22520613262190495; + + blend += 0.002589001911021066 * SampleLocation(texcoord - mdx + mdy); + blend += 0.010778807494659370 * SampleLocation(texcoord - dx + mdy); + blend += 0.024146616900339800 * SampleLocation(texcoord + mdy); + blend += 0.010778807494659370 * SampleLocation(texcoord + dx + mdy); + blend += 0.002589001911021066 * SampleLocation(texcoord + mdx + mdy); + + blend += 0.010778807494659370 * SampleLocation(texcoord - mdx + dy); + blend += 0.044875475183061630 * SampleLocation(texcoord - dx + dy); + blend += 0.100529757860782610 * SampleLocation(texcoord + dy); + blend += 0.044875475183061630 * SampleLocation(texcoord + dx + dy); + blend += 0.010778807494659370 * SampleLocation(texcoord + mdx + dy); + + blend += 0.024146616900339800 * SampleLocation(texcoord - mdx); + blend += 0.100529757860782610 * SampleLocation(texcoord - dx); + blend += 0.100529757860782610 * SampleLocation(texcoord + dx); + blend += 0.024146616900339800 * SampleLocation(texcoord + mdx); + + blend += 0.010778807494659370 * SampleLocation(texcoord - mdx - dy); + blend += 0.044875475183061630 * SampleLocation(texcoord - dx - dy); + blend += 0.100529757860782610 * SampleLocation(texcoord - dy); + blend += 0.044875475183061630 * SampleLocation(texcoord + dx - dy); + blend += 0.010778807494659370 * SampleLocation(texcoord + mdx - dy); + + blend += 0.002589001911021066 * SampleLocation(texcoord - mdx - mdy); + blend += 0.010778807494659370 * SampleLocation(texcoord - dx - mdy); + blend += 0.024146616900339800 * SampleLocation(texcoord - mdy); + blend += 0.010778807494659370 * SampleLocation(texcoord + dx - mdy); + blend += 0.002589001911021066 * SampleLocation(texcoord + mdx - mdy); + blend = lerp(color, blend, GetOption(C_BLEND_STRENGTH)); + + bloom.xyz = Blend(bloom.xyz, blend.xyz); + bloom.xyz = BloomCorrection(bloom.xyz); + + color.a = AvgLuminance(color.xyz); + bloom.a = AvgLuminance(bloom.xyz); + bloom.a *= anflare; + + SetOutput(lerp(color, bloom, GetOption(B_BLOOM_STRENGTH))); +} diff --git a/data/shaders/dolphinfx/celshading.glsl b/data/shaders/dolphinfx/celshading.glsl new file mode 100644 index 000000000..b1d80b7af --- /dev/null +++ b/data/shaders/dolphinfx/celshading.glsl @@ -0,0 +1,174 @@ +/*===============================================================================*\ +|######################## [Dolphin FX Suite 2.20] #######################| +|########################## By Asmodean ##########################| +|| || +|| This program is free software; you can redistribute it and/or || +|| modify it under the terms of the GNU General Public License || +|| as published by the Free Software Foundation; either version 2 || +|| of the License, or (at your option) any later version. || +|| || +|| This program is distributed in the hope that it will be useful, || +|| but WITHOUT ANY WARRANTY; without even the implied warranty of || +|| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the || +|| GNU General Public License for more details. (C)2015 || +|| || +|#################################################################################| +\*===============================================================================*/ + +// Sourced from https://raw.githubusercontent.com/Asmodean-/dolphin/89d640cd557189bb5f921fc219150c74c39bdc55/Data/Sys/Shaders/DolphinFX.glsl with modifications. + +/* +[configuration] + +[OptionRangeFloat] +GUIName = EdgeStrength +OptionName = A_EDGE_STRENGTH +MinValue = 0.00 +MaxValue = 4.00 +StepAmount = 0.01 +DefaultValue = 1.00 + +[OptionRangeFloat] +GUIName = EdgeFilter +OptionName = B_EDGE_FILTER +MinValue = 0.25 +MaxValue = 1.00 +StepAmount = 0.01 +DefaultValue = 0.60 + +[OptionRangeFloat] +GUIName = EdgeThickness +OptionName = C_EDGE_THICKNESS +MinValue = 0.25 +MaxValue = 2.00 +StepAmount = 0.01 +DefaultValue = 1.00 + +[OptionRangeInteger] +GUIName = PaletteType +OptionName = D_PALETTE_TYPE +MinValue = 0 +MaxValue = 2 +StepAmount = 1 +DefaultValue = 1 + +[OptionRangeInteger] +GUIName = UseYuvLuma +OptionName = E_YUV_LUMA +MinValue = 0 +MaxValue = 1 +StepAmount = 1 +DefaultValue = 0 + +[OptionRangeInteger] +GUIName = ColourRounding +OptionName = G_COLOR_ROUNDING +MinValue = 0 +MaxValue = 1 +StepAmount = 1 +DefaultValue = 1 + +[/configuration] +*/ + +//Average relative luminance +CONSTANT float3 lumCoeff = float3(0.2126729, 0.7151522, 0.0721750); +float AvgLuminance(float3 color) +{ + return sqrt( + (color.x * color.x * lumCoeff.x) + + (color.y * color.y * lumCoeff.y) + + (color.z * color.z * lumCoeff.z)); +} + +float3 YUVtoRGB(float3 YUV) +{ + const float3x3 m = float3x3( + 1.000, 0.000, 1.28033, + 1.000,-0.21482,-0.38059, + 1.000, 2.12798, 0.000 ); + + return mul(m, YUV); +} + +float3 RGBtoYUV(float3 RGB) +{ + const float3x3 m = float3x3( + 0.2126, 0.7152, 0.0722, + -0.09991,-0.33609, 0.436, + 0.615, -0.55861, -0.05639 ); + + return mul(m, RGB); +} + +void main() +{ + float4 color = Sample(); + float2 texcoord = GetCoordinates(); + float2 pixelSize = GetInvResolution(); + float2 texSize = GetResolution(); + + float3 yuv; + float3 sum = color.rgb; + + const int NUM = 9; + const float2 RoundingOffset = float2(0.25, 0.25); + const float3 thresholds = float3(9.0, 8.0, 6.0); + + float lum[NUM]; + float3 col[NUM]; + float2 set[NUM] = BEGIN_ARRAY(float2, NUM) + float2(-0.0078125, -0.0078125), + float2(0.00, -0.0078125), + float2(0.0078125, -0.0078125), + float2(-0.0078125, 0.00), + float2(0.00, 0.00), + float2(0.0078125, 0.00), + float2(-0.0078125, 0.0078125), + float2(0.00, 0.0078125), + float2(0.0078125, 0.0078125) END_ARRAY; + + for (int i = 0; i < NUM; i++) + { + col[i] = SampleLocation(texcoord + set[i] * RoundingOffset).rgb; + + if (GetOption(G_COLOR_ROUNDING) == 1) { + col[i].r = round(col[i].r * thresholds.r) / thresholds.r; + col[i].g = round(col[i].g * thresholds.g) / thresholds.g; + col[i].b = round(col[i].b * thresholds.b) / thresholds.b; } + + lum[i] = AvgLuminance(col[i].xyz); + yuv = RGBtoYUV(col[i]); + + if (GetOption(E_YUV_LUMA) == 0) + { yuv.r = round(yuv.r * thresholds.r) / thresholds.r; } + else + { yuv.r = saturate(round(yuv.r * lum[i]) / thresholds.r + lum[i]); } + + yuv = YUVtoRGB(yuv); + sum += yuv; + } + + float3 shadedColor = (sum / NUM); + float2 pixel = float2((1.0/texSize.x) * GetOption(C_EDGE_THICKNESS), + (1.0/texSize.y) * GetOption(C_EDGE_THICKNESS)); + + float edgeX = dot(SampleLocation(texcoord + pixel).rgb, lumCoeff); + edgeX = dot(float4(SampleLocation(texcoord - pixel).rgb, edgeX), float4(lumCoeff, -1.0)); + + float edgeY = dot(SampleLocation(texcoord + float2(pixel.x, -pixel.y)).rgb, lumCoeff); + edgeY = dot(float4(SampleLocation(texcoord + float2(-pixel.x, pixel.y)).rgb, edgeY), float4(lumCoeff, -1.0)); + + float edge = dot(float2(edgeX, edgeY), float2(edgeX, edgeY)); + + if (GetOption(D_PALETTE_TYPE) == 0) + { color.rgb = lerp(color.rgb, color.rgb + pow(edge, GetOption(B_EDGE_FILTER)) * -GetOption(A_EDGE_STRENGTH), GetOption(A_EDGE_STRENGTH)); } + else if (GetOption(D_PALETTE_TYPE) == 1) + { color.rgb = lerp(color.rgb + pow(edge, GetOption(B_EDGE_FILTER)) * -GetOption(A_EDGE_STRENGTH), shadedColor, 0.25); } + else if (GetOption(D_PALETTE_TYPE) == 2) + { color.rgb = lerp(shadedColor + edge * -GetOption(A_EDGE_STRENGTH), pow(edge, GetOption(B_EDGE_FILTER)) * -GetOption(A_EDGE_STRENGTH) + color.rgb, 0.50); } + + color.a = AvgLuminance(color.rgb); + + SetOutput(saturate(color)); +} diff --git a/data/shaders/dolphinfx/scanlines.glsl b/data/shaders/dolphinfx/scanlines.glsl new file mode 100644 index 000000000..58ced020c --- /dev/null +++ b/data/shaders/dolphinfx/scanlines.glsl @@ -0,0 +1,120 @@ +/*===============================================================================*\ +|######################## [Dolphin FX Suite 2.20] #######################| +|########################## By Asmodean ##########################| +|| || +|| This program is free software; you can redistribute it and/or || +|| modify it under the terms of the GNU General Public License || +|| as published by the Free Software Foundation; either version 2 || +|| of the License, or (at your option) any later version. || +|| || +|| This program is distributed in the hope that it will be useful, || +|| but WITHOUT ANY WARRANTY; without even the implied warranty of || +|| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the || +|| GNU General Public License for more details. (C)2015 || +|| || +|#################################################################################| +\*===============================================================================*/ + +// Sourced from https://raw.githubusercontent.com/Asmodean-/dolphin/89d640cd557189bb5f921fc219150c74c39bdc55/Data/Sys/Shaders/DolphinFX.glsl with modifications. + +/* +[configuration] + +[OptionRangeInteger] +GUIName = ScanlineType +OptionName = A_SCANLINE_TYPE +MinValue = 0 +MaxValue = 2 +StepAmount = 1 +DefaultValue = 0 + +[OptionRangeFloat] +GUIName = ScanlineIntensity +OptionName = B_SCANLINE_INTENSITY +MinValue = 0.15 +MaxValue = 0.30 +StepAmount = 0.01 +DefaultValue = 0.18 + +[OptionRangeFloat] +GUIName = ScanlineThickness +OptionName = B_SCANLINE_THICKNESS +MinValue = 0.20 +MaxValue = 0.80 +StepAmount = 0.01 +DefaultValue = 0.50 + +[OptionRangeFloat] +GUIName = ScanlineBrightness +OptionName = B_SCANLINE_BRIGHTNESS +MinValue = 0.50 +MaxValue = 2.00 +StepAmount = 0.01 +DefaultValue = 1.10 + +[OptionRangeFloat] +GUIName = ScanlineSpacing +OptionName = B_SCANLINE_SPACING +MinValue = 0.10 +MaxValue = 0.99 +StepAmount = 0.01 +DefaultValue = 0.25 + +[/configuration] +*/ + +//Average relative luminance +CONSTANT float3 lumCoeff = float3(0.2126729, 0.7151522, 0.0721750); +float AvgLuminance(float3 color) +{ + return sqrt( + (color.x * color.x * lumCoeff.x) + + (color.y * color.y * lumCoeff.y) + + (color.z * color.z * lumCoeff.z)); +} + +void main() +{ + float4 color = Sample(); + float4 intensity = float4(0.0, 0.0, 0.0, 0.0); + + if (GetOption(A_SCANLINE_TYPE) == 0) { //X coord scanlines + if (fract(gl_FragCoord.y * GetOption(B_SCANLINE_SPACING)) > GetOption(B_SCANLINE_THICKNESS)) + { + intensity = float4(0.0, 0.0, 0.0, 0.0); + } + else + { + intensity = smoothstep(0.2, GetOption(B_SCANLINE_BRIGHTNESS), color) + + normalize(float4(color.xyz, AvgLuminance(color.xyz))); + } } + + else if (GetOption(A_SCANLINE_TYPE) == 1) { //Y coord scanlines + if (fract(gl_FragCoord.x * GetOption(B_SCANLINE_SPACING)) > GetOption(B_SCANLINE_THICKNESS)) + { + intensity = float4(0.0, 0.0, 0.0, 0.0); + } + else + { + intensity = smoothstep(0.2, GetOption(B_SCANLINE_BRIGHTNESS), color) + + normalize(float4(color.xyz, AvgLuminance(color.xyz))); + } } + + else if (GetOption(A_SCANLINE_TYPE) == 2) { //XY coord scanlines + if (fract(gl_FragCoord.x * GetOption(B_SCANLINE_SPACING)) > GetOption(B_SCANLINE_THICKNESS) && + fract(gl_FragCoord.y * GetOption(B_SCANLINE_SPACING)) > GetOption(B_SCANLINE_THICKNESS)) + { + intensity = float4(0.0, 0.0, 0.0, 0.0); + } + else + { + intensity = smoothstep(0.2, GetOption(B_SCANLINE_BRIGHTNESS), color) + + normalize(float4(color.xyz, AvgLuminance(color.xyz))); + } } + + float level = (4.0-GetCoordinates().x) * GetOption(B_SCANLINE_INTENSITY); + + color = intensity * (0.5 - level) + color * 1.1; + + SetOutput(saturate(color)); +} \ No newline at end of file diff --git a/data/shaders/simple-sharpen.glsl b/data/shaders/simple-sharpen.glsl new file mode 100644 index 000000000..52bd36663 --- /dev/null +++ b/data/shaders/simple-sharpen.glsl @@ -0,0 +1,14 @@ +void main() +{ + vec2 uv = GetCoordinates(); + vec2 ts = GetInvResolution(); + + vec4 sum = vec4(0.0, 0.0, 0.0, 0.0); + sum += SampleLocation(uv + vec2(-1.0, 0.0) * ts) * -1.0; + sum += SampleLocation(uv + vec2(0.0, -1.0) * ts) * -1.0; + sum += SampleLocation(uv) * 5.0; + sum += SampleLocation(uv + vec2(0.0, 1.0) * ts) * -1.0; + sum += SampleLocation(uv + vec2(1.0, 0.0) * ts) * -1.0; + + SetOutput(saturate(sum)); +}