mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 07:41:31 +11:00
add guest's scalefx-aa presets and supporting shaders
This commit is contained in:
parent
6e6db3e9d1
commit
599d385f3a
143
deblur/shaders/deblur.slang
Normal file
143
deblur/shaders/deblur.slang
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
/*
|
||||||
|
Deblur Shader
|
||||||
|
|
||||||
|
Copyright (C) 2005 - 2019 guest(r) - guest.r@gmail.com
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
float OFFSET, DEBLUR, SMART;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
#pragma parameter OFFSET "Deblur offset" 2.0 0.5 4.0 0.25
|
||||||
|
#pragma parameter DEBLUR "Deblur str. " 4.5 1.0 7.0 0.25
|
||||||
|
#pragma parameter SMART "Smart deblur " 0.5 0.0 1.0 0.05
|
||||||
|
|
||||||
|
#define OFFSET params.OFFSET
|
||||||
|
#define DEBLUR params.DEBLUR
|
||||||
|
#define SMART params.SMART
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
#pragma stage vertex
|
||||||
|
layout(location = 0) in vec4 Position;
|
||||||
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = global.MVP * Position;
|
||||||
|
vTexCoord = TexCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma stage fragment
|
||||||
|
layout(location = 0) in vec2 vTexCoord;
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
|
vec3 dt = vec3(1.,1.,1.);
|
||||||
|
vec3 dtt = vec3(0.0001, 0.0001, 0.0001);
|
||||||
|
|
||||||
|
float wt(vec3 A, vec3 B)
|
||||||
|
{
|
||||||
|
return 4.0*length(A-B)/(dot(A+B,dt)+0.33);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec2 tex = vTexCoord;
|
||||||
|
vec2 texsize = params.SourceSize.xy;
|
||||||
|
float dx = OFFSET/texsize.x;
|
||||||
|
float dy = OFFSET/texsize.y;
|
||||||
|
|
||||||
|
vec4 yx = vec4( dx, dy,-dx,-dy);
|
||||||
|
vec2 xx = vec2( dx, 0.0);
|
||||||
|
vec2 yy = vec2( 0.0, dy);
|
||||||
|
|
||||||
|
vec3 c11 = texture(Source, tex ).xyz;
|
||||||
|
vec3 c00 = texture(Source, tex + yx.zw).xyz;
|
||||||
|
vec3 c20 = texture(Source, tex + yx.xw).xyz;
|
||||||
|
vec3 c22 = texture(Source, tex + yx.xy).xyz;
|
||||||
|
vec3 c02 = texture(Source, tex + yx.zy).xyz;
|
||||||
|
vec3 c10 = texture(Source, tex - yy ).xyz;
|
||||||
|
vec3 c21 = texture(Source, tex + xx ).xyz;
|
||||||
|
vec3 c12 = texture(Source, tex + yy ).xyz;
|
||||||
|
vec3 c01 = texture(Source, tex - xx ).xyz;
|
||||||
|
|
||||||
|
vec3 mn1 = min (min (c00,c01),c02);
|
||||||
|
vec3 mn2 = min (min (c10,c11),c12);
|
||||||
|
vec3 mn3 = min (min (c20,c21),c22);
|
||||||
|
vec3 mx1 = max (max (c00,c01),c02);
|
||||||
|
vec3 mx2 = max (max (c10,c11),c12);
|
||||||
|
vec3 mx3 = max (max (c20,c21),c22);
|
||||||
|
|
||||||
|
vec3 d11;
|
||||||
|
|
||||||
|
mn1 = min(min(mn1,mn2),mn3);
|
||||||
|
mx1 = max(max(mx1,mx2),mx3);
|
||||||
|
vec3 contrast = mx1 - mn1;
|
||||||
|
|
||||||
|
vec3 dif1 = abs(c11-mn1) + dtt;
|
||||||
|
vec3 dif2 = abs(c11-mx1) + dtt;
|
||||||
|
|
||||||
|
float DB1 = DEBLUR; float dif;
|
||||||
|
|
||||||
|
dif1=vec3(pow(dif1.x,DB1),pow(dif1.y,DB1),pow(dif1.z,DB1));
|
||||||
|
dif2=vec3(pow(dif2.x,DB1),pow(dif2.y,DB1),pow(dif2.z,DB1));
|
||||||
|
|
||||||
|
d11 = vec3((dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x),
|
||||||
|
(dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y),
|
||||||
|
(dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z));
|
||||||
|
|
||||||
|
float k10 = 1.0/(dot(abs(c10-d11),dt)+0.0001);
|
||||||
|
float k01 = 1.0/(dot(abs(c01-d11),dt)+0.0001);
|
||||||
|
float k11 = 1.0/(dot(abs(c11-d11),dt)+0.0001);
|
||||||
|
float k21 = 1.0/(dot(abs(c21-d11),dt)+0.0001);
|
||||||
|
float k12 = 1.0/(dot(abs(c12-d11),dt)+0.0001);
|
||||||
|
float k00 = 1.0/(dot(abs(c00-d11),dt)+0.0001);
|
||||||
|
float k02 = 1.0/(dot(abs(c02-d11),dt)+0.0001);
|
||||||
|
float k20 = 1.0/(dot(abs(c20-d11),dt)+0.0001);
|
||||||
|
float k22 = 1.0/(dot(abs(c22-d11),dt)+0.0001);
|
||||||
|
|
||||||
|
float avg = (k10+k01+k11+k21+k12+k00+k02+k20+k22)/30.0;
|
||||||
|
|
||||||
|
k10 = max(k10-avg, 0.0);
|
||||||
|
k01 = max(k01-avg, 0.0);
|
||||||
|
k11 = max(k11-avg, 0.0);
|
||||||
|
k21 = max(k21-avg, 0.0);
|
||||||
|
k12 = max(k12-avg, 0.0);
|
||||||
|
k00 = max(k00-avg, 0.0);
|
||||||
|
k02 = max(k02-avg, 0.0);
|
||||||
|
k20 = max(k20-avg, 0.0);
|
||||||
|
k22 = max(k22-avg, 0.0);
|
||||||
|
|
||||||
|
d11 = (k10*c10 + k01*c01 + k11*c11 + k21*c21 + k12*c12 + k00*c00 + k02*c02 + k20*c20 + k22*c22 + 0.0001*c11)/(k10+k01+k11+k21+k12+k00+k02+k20+k22+0.0001);
|
||||||
|
|
||||||
|
c11 = mix(c11, d11, clamp(1.75*contrast-0.125, 0.0, 1.0));
|
||||||
|
c11 = mix(d11, c11, SMART);
|
||||||
|
|
||||||
|
FragColor = vec4(c11,1.0);
|
||||||
|
}
|
67
presets/scalefx+rAA+aa-fast.slangp
Normal file
67
presets/scalefx+rAA+aa-fast.slangp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
shaders = 11
|
||||||
|
|
||||||
|
shader0 = ../stock.slang
|
||||||
|
alias0 = refpass
|
||||||
|
filter_linear0 = "false"
|
||||||
|
|
||||||
|
shader1 = ../scalefx/shaders/scalefx-pass0.slang
|
||||||
|
filter_linear1 = false
|
||||||
|
scale_type1 = source
|
||||||
|
scale1 = 1.0
|
||||||
|
float_framebuffer1 = true
|
||||||
|
alias1 = scalefx_pass0
|
||||||
|
|
||||||
|
shader2 = ../scalefx/shaders/scalefx-pass1.slang
|
||||||
|
filter_linear2 = false
|
||||||
|
scale_type2 = source
|
||||||
|
scale2 = 1.0
|
||||||
|
float_framebuffer2 = true
|
||||||
|
|
||||||
|
shader3 = ../scalefx/shaders/scalefx-pass2.slang
|
||||||
|
filter_linear3 = false
|
||||||
|
scale_type3 = source
|
||||||
|
scale3 = 1.0
|
||||||
|
|
||||||
|
shader4 = ../scalefx/shaders/scalefx-pass3.slang
|
||||||
|
filter_linear4 = false
|
||||||
|
scale_type4 = source
|
||||||
|
scale4 = 1.0
|
||||||
|
|
||||||
|
shader5 = ../scalefx/shaders/scalefx-pass4.slang
|
||||||
|
filter_linear5 = false
|
||||||
|
scale_type5 = source
|
||||||
|
scale5 = 3.0
|
||||||
|
|
||||||
|
shader6 = ../anti-aliasing/shaders/reverse-aa-post3x/reverse-aa-post3x-pass0.slang
|
||||||
|
filter_linear6 = false
|
||||||
|
scale_type6 = source
|
||||||
|
scale6 = 1.0
|
||||||
|
|
||||||
|
shader7 = ../anti-aliasing/shaders/reverse-aa-post3x/reverse-aa-post3x-pass1.slang
|
||||||
|
filter_linear7 = false
|
||||||
|
scale_type7 = source
|
||||||
|
scale7 = 1.0
|
||||||
|
|
||||||
|
shader8 = ../anti-aliasing/shaders/fxaa.slang
|
||||||
|
filter_linear8 = true
|
||||||
|
scale_type8 = source
|
||||||
|
scale8 = 1.0
|
||||||
|
|
||||||
|
shader9 = ../anti-aliasing/shaders/aa-shader-4.0-level2/aa-shader-4.0-level2-pass2.slang
|
||||||
|
filter_linear9 = true
|
||||||
|
scale_type9 = source
|
||||||
|
scale9 = 2.0
|
||||||
|
|
||||||
|
shader10 = ../deblur/shaders/deblur.slang
|
||||||
|
filter_linear10 = true
|
||||||
|
scale_type10 = viewport
|
||||||
|
scale10 = 1.0
|
||||||
|
|
||||||
|
parameters = "SFX_CLR;SFX_SAA;SFX_SCN;AAOFFSET2;OFFSET;DEBLUR;SMART"
|
||||||
|
SFX_CLR = "0.500000"
|
||||||
|
SFX_SAA = "0.000000"
|
||||||
|
SFX_SCN = "0.000000"
|
||||||
|
AAOFFSET2 = "0.400000"
|
||||||
|
OFFSET = "2.000000"
|
||||||
|
DEBLUR = "3.500000"
|
||||||
|
SMART = "0.400000"
|
77
presets/scalefx+rAA+aa.slangp
Normal file
77
presets/scalefx+rAA+aa.slangp
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
shaders = 12
|
||||||
|
|
||||||
|
shader0 = ../stock.slang
|
||||||
|
alias0 = refpass
|
||||||
|
filter_linear0 = "false"
|
||||||
|
|
||||||
|
shader1 = ../scalefx/shaders/scalefx-pass0.slang
|
||||||
|
filter_linear1 = false
|
||||||
|
scale_type1 = source
|
||||||
|
scale1 = 1.0
|
||||||
|
float_framebuffer1 = true
|
||||||
|
alias1 = scalefx_pass0
|
||||||
|
|
||||||
|
shader2 = ../scalefx/shaders/scalefx-pass1.slang
|
||||||
|
filter_linear2 = false
|
||||||
|
scale_type2 = source
|
||||||
|
scale2 = 1.0
|
||||||
|
float_framebuffer2 = true
|
||||||
|
|
||||||
|
shader3 = ../scalefx/shaders/scalefx-pass2.slang
|
||||||
|
filter_linear3 = false
|
||||||
|
scale_type3 = source
|
||||||
|
scale3 = 1.0
|
||||||
|
|
||||||
|
shader4 = ../scalefx/shaders/scalefx-pass3.slang
|
||||||
|
filter_linear4 = false
|
||||||
|
scale_type4 = source
|
||||||
|
scale4 = 1.0
|
||||||
|
|
||||||
|
shader5 = ../scalefx/shaders/scalefx-pass4.slang
|
||||||
|
filter_linear5 = false
|
||||||
|
scale_type5 = source
|
||||||
|
scale5 = 3.0
|
||||||
|
|
||||||
|
shader6 = ../anti-aliasing/shaders/reverse-aa-post3x/reverse-aa-post3x-pass0.slang
|
||||||
|
filter_linear6 = false
|
||||||
|
scale_type6 = source
|
||||||
|
scale6 = 1.0
|
||||||
|
|
||||||
|
shader7 = ../anti-aliasing/shaders/reverse-aa-post3x/reverse-aa-post3x-pass1.slang
|
||||||
|
filter_linear7 = false
|
||||||
|
scale_type7 = source
|
||||||
|
scale7 = 1.0
|
||||||
|
|
||||||
|
shader8 = ../anti-aliasing/shaders/fxaa.slang
|
||||||
|
filter_linear8 = true
|
||||||
|
scale_type8 = source
|
||||||
|
scale8 = 1.0
|
||||||
|
|
||||||
|
shader9 = ../xsoft/shaders/4xsoft.slang
|
||||||
|
filter_linear9 = true
|
||||||
|
scale_type9 = source
|
||||||
|
scale9 = 2.0
|
||||||
|
|
||||||
|
shader10 = ../sharpen/shaders/fast-sharpen.slang
|
||||||
|
filter_linear10 = true
|
||||||
|
scale_type10 = source
|
||||||
|
scale10 = 1.0
|
||||||
|
|
||||||
|
shader11 = ../deblur/shaders/deblur.slang
|
||||||
|
filter_linear11 = true
|
||||||
|
scale_type11 = viewport
|
||||||
|
scale11 = 1.0
|
||||||
|
|
||||||
|
parameters = "SFX_CLR;SFX_SAA;SFX_SCN;RESOLUTION_X;RESOLUTION_Y;CONTRAST;SHARPEN;CONTR;DETAILS;OFFSET;DEBLUR;SMART"
|
||||||
|
SFX_CLR = "0.600000"
|
||||||
|
SFX_SAA = "1.000000"
|
||||||
|
SFX_SCN = "0.000000"
|
||||||
|
RESOLUTION_X = "0.000000"
|
||||||
|
RESOLUTION_Y = "0.000000"
|
||||||
|
CONTRAST = "3.000000"
|
||||||
|
SHARPEN = "0.90000"
|
||||||
|
CONTR = "0.100000"
|
||||||
|
DETAILS = "0.500000"
|
||||||
|
OFFSET = "1.750000"
|
||||||
|
DEBLUR = "5.000000"
|
||||||
|
SMART = "0.500000"
|
57
presets/scalefx-aa-fast.slangp
Normal file
57
presets/scalefx-aa-fast.slangp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
shaders = 9
|
||||||
|
|
||||||
|
shader0 = ../stock.slang
|
||||||
|
alias0 = refpass
|
||||||
|
filter_linear0 = "false"
|
||||||
|
|
||||||
|
shader1 = ../scalefx/shaders/scalefx-pass0.slang
|
||||||
|
filter_linear1 = false
|
||||||
|
scale_type1 = source
|
||||||
|
scale1 = 1.0
|
||||||
|
float_framebuffer1 = true
|
||||||
|
alias1 = scalefx_pass0
|
||||||
|
|
||||||
|
shader2 = ../scalefx/shaders/scalefx-pass1.slang
|
||||||
|
filter_linear2 = false
|
||||||
|
scale_type2 = source
|
||||||
|
scale2 = 1.0
|
||||||
|
float_framebuffer2 = true
|
||||||
|
|
||||||
|
shader3 = ../scalefx/shaders/scalefx-pass2.slang
|
||||||
|
filter_linear3 = false
|
||||||
|
scale_type3 = source
|
||||||
|
scale3 = 1.0
|
||||||
|
|
||||||
|
shader4 = ../scalefx/shaders/scalefx-pass3.slang
|
||||||
|
filter_linear4 = false
|
||||||
|
scale_type4 = source
|
||||||
|
scale4 = 1.0
|
||||||
|
|
||||||
|
shader5 = ../scalefx/shaders/scalefx-pass4.slang
|
||||||
|
filter_linear5 = false
|
||||||
|
scale_type5 = source
|
||||||
|
scale5 = 3.0
|
||||||
|
|
||||||
|
shader6 = ../anti-aliasing/shaders/fxaa.slang
|
||||||
|
filter_linear6 = true
|
||||||
|
scale_type6 = source
|
||||||
|
scale6 = 1.0
|
||||||
|
|
||||||
|
shader7 = ../anti-aliasing/shaders/aa-shader-4.0-level2/aa-shader-4.0-level2-pass2.slang
|
||||||
|
filter_linear7 = true
|
||||||
|
scale_type7 = source
|
||||||
|
scale7 = 2.0
|
||||||
|
|
||||||
|
shader8 = ../deblur/shaders/deblur.slang
|
||||||
|
filter_linear8 = true
|
||||||
|
scale_type8 = viewport
|
||||||
|
scale8 = 1.0
|
||||||
|
|
||||||
|
parameters = "SFX_CLR;SFX_SAA;SFX_SCN;AAOFFSET2;OFFSET;DEBLUR;SMART"
|
||||||
|
SFX_CLR = "0.500000"
|
||||||
|
SFX_SAA = "1.000000"
|
||||||
|
SFX_SCN = "0.000000"
|
||||||
|
AAOFFSET2 = "0.400000"
|
||||||
|
OFFSET = "2.000000"
|
||||||
|
DEBLUR = "3.500000"
|
||||||
|
SMART = "0.300000"
|
67
presets/scalefx-aa.slangp
Normal file
67
presets/scalefx-aa.slangp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
shaders = 10
|
||||||
|
|
||||||
|
shader0 = ../stock.slang
|
||||||
|
alias0 = refpass
|
||||||
|
filter_linear0 = "false"
|
||||||
|
|
||||||
|
shader1 = ../scalefx/shaders/scalefx-pass0.slang
|
||||||
|
filter_linear1 = false
|
||||||
|
scale_type1 = source
|
||||||
|
scale1 = 1.0
|
||||||
|
float_framebuffer1 = true
|
||||||
|
alias1 = scalefx_pass0
|
||||||
|
|
||||||
|
shader2 = ../scalefx/shaders/scalefx-pass1.slang
|
||||||
|
filter_linear2 = false
|
||||||
|
scale_type2 = source
|
||||||
|
scale2 = 1.0
|
||||||
|
float_framebuffer2 = true
|
||||||
|
|
||||||
|
shader3 = ../scalefx/shaders/scalefx-pass2.slang
|
||||||
|
filter_linear3 = false
|
||||||
|
scale_type3 = source
|
||||||
|
scale3 = 1.0
|
||||||
|
|
||||||
|
shader4 = ../scalefx/shaders/scalefx-pass3.slang
|
||||||
|
filter_linear4 = false
|
||||||
|
scale_type4 = source
|
||||||
|
scale4 = 1.0
|
||||||
|
|
||||||
|
shader5 = ../scalefx/shaders/scalefx-pass4.slang
|
||||||
|
filter_linear5 = false
|
||||||
|
scale_type5 = source
|
||||||
|
scale5 = 3.0
|
||||||
|
|
||||||
|
shader6 = ../anti-aliasing/shaders/fxaa.slang
|
||||||
|
filter_linear6 = true
|
||||||
|
scale_type6 = source
|
||||||
|
scale6 = 1.0
|
||||||
|
|
||||||
|
shader7 = ../xsoft/shaders/4xsoft.slang
|
||||||
|
filter_linear7 = true
|
||||||
|
scale_type7 = source
|
||||||
|
scale7 = 2.0
|
||||||
|
|
||||||
|
shader8 = ../sharpen/shaders/fast-sharpen.slang
|
||||||
|
filter_linear8 = true
|
||||||
|
scale_type8 = source
|
||||||
|
scale8 = 1.0
|
||||||
|
|
||||||
|
shader9 = ../deblur/shaders/deblur.slang
|
||||||
|
filter_linear9 = true
|
||||||
|
scale_type9 = viewport
|
||||||
|
scale9 = 1.0
|
||||||
|
|
||||||
|
parameters = "SFX_CLR;SFX_SAA;SFX_SCN;RESOLUTION_X;RESOLUTION_Y;CONTRAST;SHARPEN;CONTR;DETAILS;OFFSET;DEBLUR;SMART"
|
||||||
|
SFX_CLR = "0.600000"
|
||||||
|
SFX_SAA = "1.000000"
|
||||||
|
SFX_SCN = "0.000000"
|
||||||
|
RESOLUTION_X = "0.000000"
|
||||||
|
RESOLUTION_Y = "0.000000"
|
||||||
|
CONTRAST = "3.000000"
|
||||||
|
SHARPEN = "1.200000"
|
||||||
|
CONTR = "0.100000"
|
||||||
|
DETAILS = "1.000000"
|
||||||
|
OFFSET = "1.750000"
|
||||||
|
DEBLUR = "5.000000"
|
||||||
|
SMART = "0.300000"
|
87
sharpen/shaders/fast-sharpen.slang
Normal file
87
sharpen/shaders/fast-sharpen.slang
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
/*
|
||||||
|
Fast Sharpen Shader
|
||||||
|
|
||||||
|
Copyright (C) 2005 - 2019 guest(r) - guest.r@gmail.com
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
layout(push_constant) uniform Push
|
||||||
|
{
|
||||||
|
vec4 SourceSize;
|
||||||
|
vec4 OriginalSize;
|
||||||
|
vec4 OutputSize;
|
||||||
|
uint FrameCount;
|
||||||
|
float SHARPEN, CONTR, DETAILS;
|
||||||
|
} params;
|
||||||
|
|
||||||
|
#pragma parameter SHARPEN "Sharpen strength" 1.00 0.0 2.00 0.05
|
||||||
|
#pragma parameter CONTR "Ammount of sharpening" 0.07 0.0 0.25 0.01
|
||||||
|
#pragma parameter DETAILS "Details sharpened " 1.00 0.0 1.00 0.05
|
||||||
|
|
||||||
|
#define SHARPEN params.SHARPEN
|
||||||
|
#define CONTR params.CONTR
|
||||||
|
#define DETAILS params.DETAILS
|
||||||
|
|
||||||
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
{
|
||||||
|
mat4 MVP;
|
||||||
|
} global;
|
||||||
|
|
||||||
|
#pragma stage vertex
|
||||||
|
layout(location = 0) in vec4 Position;
|
||||||
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
layout(location = 0) out vec2 vTexCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = global.MVP * Position;
|
||||||
|
vTexCoord = TexCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma stage fragment
|
||||||
|
layout(location = 0) in vec2 vTexCoord;
|
||||||
|
layout(location = 0) out vec4 FragColor;
|
||||||
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
|
vec2 g10 = vec2( 0.3333,-1.0)*params.SourceSize.zw;
|
||||||
|
vec2 g01 = vec2(-1.0,-0.3333)*params.SourceSize.zw;
|
||||||
|
vec2 g12 = vec2(-0.3333, 1.0)*params.SourceSize.zw;
|
||||||
|
vec2 g21 = vec2( 1.0, 0.3333)*params.SourceSize.zw;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 c10 = texture(Source, vTexCoord + g10).rgb;
|
||||||
|
vec3 c01 = texture(Source, vTexCoord + g01).rgb;
|
||||||
|
vec3 c21 = texture(Source, vTexCoord + g21).rgb;
|
||||||
|
vec3 c12 = texture(Source, vTexCoord + g12).rgb;
|
||||||
|
vec3 c11 = texture(Source, vTexCoord ).rgb;
|
||||||
|
vec3 b11 = (c10+c01+c12+c21)*0.25;
|
||||||
|
|
||||||
|
float contrast = max(max(c11.r,c11.g),c11.b);
|
||||||
|
contrast = mix(2.0*CONTR, CONTR, contrast);
|
||||||
|
|
||||||
|
vec3 mn1 = min(min(c10,c01),min(c12,c21)); mn1 = min(mn1,c11*(1.0-contrast));
|
||||||
|
vec3 mx1 = max(max(c10,c01),max(c12,c21)); mx1 = max(mx1,c11*(1.0+contrast));
|
||||||
|
|
||||||
|
vec3 dif = pow(mx1-mn1+0.0001, vec3(0.75,0.75,0.75));
|
||||||
|
vec3 sharpen = mix(vec3(SHARPEN*DETAILS), vec3(SHARPEN), dif);
|
||||||
|
|
||||||
|
c11 = clamp(mix(c11,b11,-sharpen), mn1,mx1);
|
||||||
|
|
||||||
|
FragColor = vec4(c11,1.0);
|
||||||
|
}
|
Loading…
Reference in a new issue