RetroArch-Wii-U-Slang-Shaders/blurs/sharpsmoother.ppslang
2020-04-26 18:03:54 -05:00

113 lines
2.7 KiB
Text

#version 450
layout(push_constant)uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
float max_w;
float min_w;
float smoot;
float lumad;
float mtric;
} params;
#pragma parametermax_w¡0.100.000.200.01
#pragma parametermin_w¡-0.07-0.150.050.01
#pragma parametersmoot¡0.550.001.500.01
#pragma parameterlumad¡0.300.105.000.10
#pragma parametermtric¡0.700.102.000.10
layout(std140, set = 0, binding = 0)uniform UBO
{
mat4 MVP;
} global;
vec3 dt = vec3(1.0, 1.0, 1.0);
float wt(vec3 A, vec3 B)
{
return clamp(params . smoot -((6.0 + params . lumad)/ pow(3.0, params . mtric))* pow(dot(pow(abs(A - B), vec3(1.0 / params . mtric)), dt), params . mtric)/(dot(A + B, dt)+ params . lumad), params . min_w, params . max_w);
}
#pragma stagevertex
layout(location = 0)in vec4 Position;
layout(location = 1)in vec2 TexCoord;
layout(location = 0)out vec2 vTexCoord;
layout(location = 1)out vec4 t1;
layout(location = 2)out vec4 t2;
layout(location = 3)out vec4 t3;
layout(location = 4)out vec4 t4;
void main()
{
gl_Position = global . MVP * Position;
vTexCoord = TexCoord;
float x = 1.0 *(1.0 / params . SourceSize . x);
float y = 1.0 *(1.0 / params . SourceSize . y);
vec2 dg1 = vec2(x, y);
vec2 dg2 = vec2(- x, y);
vec2 dx = vec2(x, 0.0);
vec2 dy = vec2(0.0, y);
t1 = vec4(vTexCoord . xy - dg1, vTexCoord . xy - dy);
t2 = vec4(vTexCoord . xy - dg2, vTexCoord . xy + dx);
t3 = vec4(vTexCoord . xy + dg1, vTexCoord . xy + dy);
t4 = vec4(vTexCoord . xy + dg2, vTexCoord . xy - dx);
}
#pragma stagefragment
layout(location = 0)in vec2 vTexCoord;
layout(location = 1)in vec4 t1;
layout(location = 2)in vec4 t2;
layout(location = 3)in vec4 t3;
layout(location = 4)in vec4 t4;
layout(location = 0)out vec4 FragColor;
layout(set = 0, binding = 2)uniform sampler2D Source;
void main()
{
vec3 c00 = texture(Source, t1 . xy). xyz;
vec3 c10 = texture(Source, t1 . zw). xyz;
vec3 c20 = texture(Source, t2 . xy). xyz;
vec3 c01 = texture(Source, t4 . zw). xyz;
vec3 c11 = texture(Source, vTexCoord . xy). xyz;
vec3 c21 = texture(Source, t2 . zw). xyz;
vec3 c02 = texture(Source, t4 . xy). xyz;
vec3 c12 = texture(Source, t3 . zw). xyz;
vec3 c22 = texture(Source, t3 . xy). xyz;
float w10 = wt(c11, c10);
float w21 = wt(c11, c21);
float w12 = wt(c11, c12);
float w01 = wt(c11, c01);
float w00 = wt(c11, c00)* 0.75;
float w22 = wt(c11, c22)* 0.75;
float w20 = wt(c11, c20)* 0.75;
float w02 = wt(c11, c02)* 0.75;
FragColor = vec4(w10 * c10 + w21 * c21 + w12 * c12 + w01 * c01 + w00 * c00 + w22 * c22 + w20 * c20 + w02 * c02 +(1.0 - w10 - w21 - w12 - w01 - w00 - w22 - w20 - w02)* c11, 1.0);
}