mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
add super-xbr-6p-adaptive
This commit is contained in:
parent
de7b2d8859
commit
56d8fd0c5f
|
@ -35,17 +35,24 @@ layout(push_constant) uniform Push
|
||||||
float XBR_EDGE_STR;
|
float XBR_EDGE_STR;
|
||||||
float XBR_WEIGHT;
|
float XBR_WEIGHT;
|
||||||
float XBR_ANTI_RINGING;
|
float XBR_ANTI_RINGING;
|
||||||
float DETAILS;
|
float MODE;
|
||||||
|
float XBR_EDGE_SHP;
|
||||||
|
float XBR_TEXTURE_SHP;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
#pragma parameter XBR_EDGE_STR "Xbr - Edge Strength p0" 0.6 0.0 5.0 0.2
|
#pragma parameter XBR_EDGE_STR "Xbr - Edge Strength p0" 0.6 0.0 5.0 0.2
|
||||||
#pragma parameter XBR_WEIGHT "Xbr - Filter Weight" 1.0 0.00 1.50 0.01
|
#pragma parameter XBR_WEIGHT "Xbr - Filter Weight" 1.0 0.00 1.50 0.01
|
||||||
#pragma parameter XBR_ANTI_RINGING "Xbr - Anti-Ringing Level" 1.0 0.0 1.0 1.0
|
#pragma parameter XBR_ANTI_RINGING "Xbr - Anti-Ringing Level" 1.0 0.0 1.0 1.0
|
||||||
#pragma parameter DETAILS "Xbr - Preserve Details" 0.0 0.0 1.0 1.0
|
#pragma parameter MODE "Mode - Normal, Details, Adaptive" 0.0 0.0 2.0 1.0
|
||||||
|
#pragma parameter XBR_EDGE_SHP "Adaptive Dynamic Edge Sharp" 0.4 0.0 3.0 0.1
|
||||||
|
#pragma parameter XBR_TEXTURE_SHP "Adaptive Static Edge Sharp" 1.0 0.0 2.0 0.1
|
||||||
|
|
||||||
#define XBR_EDGE_STR params.XBR_EDGE_STR
|
#define XBR_EDGE_STR params.XBR_EDGE_STR
|
||||||
#define XBR_WEIGHT params.XBR_WEIGHT
|
#define XBR_WEIGHT params.XBR_WEIGHT
|
||||||
#define XBR_ANTI_RINGING params.XBR_ANTI_RINGING
|
#define XBR_ANTI_RINGING params.XBR_ANTI_RINGING
|
||||||
|
#define MODE params.MODE
|
||||||
|
#define XBR_EDGE_SHP params.XBR_EDGE_SHP
|
||||||
|
#define XBR_TEXTURE_SHP params.XBR_TEXTURE_SHP
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
|
@ -54,16 +61,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
|
|
||||||
#define wp1 1.0
|
|
||||||
#define wp2 0.0
|
|
||||||
#define wp3 0.0
|
|
||||||
//#define wp4 2.0
|
|
||||||
#define wp5 -1.0
|
|
||||||
#define wp6 0.0
|
|
||||||
|
|
||||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
|
||||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
|
||||||
|
|
||||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||||
|
|
||||||
float RGBtoYUV(vec3 color)
|
float RGBtoYUV(vec3 color)
|
||||||
|
@ -87,15 +84,13 @@ float df(float A, float B)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
float d_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||||
{
|
{
|
||||||
float wp4 = (params.DETAILS > 0.5) ? 1.0 : 2.0;
|
|
||||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
float hv_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||||
{
|
{
|
||||||
float wp4 = (params.DETAILS > 0.5) ? 1.0 : 2.0;
|
|
||||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,11 +98,17 @@ vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||||
{
|
{
|
||||||
return min(a, min(b, min(c, d)));
|
return min(a, min(b, min(c, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||||
{
|
{
|
||||||
return max(a, max(b, max(c, d)));
|
return max(a, max(b, max(c, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float max4float(float a, float b, float c, float d)
|
||||||
|
{
|
||||||
|
return max(a, max(b, max(c, d)));
|
||||||
|
}
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
layout(location = 1) in vec2 TexCoord;
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
@ -141,6 +142,46 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// settings //
|
||||||
|
float wp1, wp2, wp3, wp4, wp5, wp6, weight1, weight2;
|
||||||
|
if (MODE == 1.0)
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 1.0;
|
||||||
|
wp5 = -1.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.29633/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.75068/10.0/2.0);
|
||||||
|
}
|
||||||
|
else if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 2.0;
|
||||||
|
wp5 = -1.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (1.29633/10.0);
|
||||||
|
weight2 = (1.75068/10.0/2.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wp1 = 2.0;
|
||||||
|
wp2 = 1.0;
|
||||||
|
wp3 = -1.0;
|
||||||
|
wp4 = 4.0;
|
||||||
|
wp5 = -1.0;
|
||||||
|
wp6 = 1.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.29633/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.75068/10.0/2.0);
|
||||||
|
}
|
||||||
|
// end settings //
|
||||||
|
|
||||||
vec3 P0 = texture(Source, t1.xy).xyz;
|
vec3 P0 = texture(Source, t1.xy).xyz;
|
||||||
vec3 P1 = texture(Source, t1.zy).xyz;
|
vec3 P1 = texture(Source, t1.zy).xyz;
|
||||||
vec3 P2 = texture(Source, t1.xw).xyz;
|
vec3 P2 = texture(Source, t1.xw).xyz;
|
||||||
|
@ -176,23 +217,41 @@ void main()
|
||||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||||
|
|
||||||
/* Calc edgeness in diagonal directions. */
|
/* Calc edgeness in diagonal directions. */
|
||||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
float d_edge = (d_wd( wp1, wp2, wp3, wp4, wp5, wp6, d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( wp1, wp2, wp3, wp4, wp5, wp6, c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||||
|
|
||||||
/* Calc edgeness in horizontal/vertical directions. */
|
/* Calc edgeness in horizontal/vertical directions. */
|
||||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
float hv_edge = (hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, f, i, e, h, c, i5, b, h5) - hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, e, f, h, i, d, f4, g, i4));
|
||||||
|
|
||||||
float limits = XBR_EDGE_STR + 0.000001;
|
float limits = XBR_EDGE_STR + 0.000001;
|
||||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||||
|
|
||||||
|
vec4 w1, w2;
|
||||||
|
vec3 c3, c4;
|
||||||
|
if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
float contrast = max(max4float(df(e,f),df(e,i),df(e,h),df(f,h)),max(df(f,i),df(h,i)))/(e+0.001);
|
||||||
|
|
||||||
/* Filter weights. Two taps only. */
|
float wgt1 = weight1*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
float wgt2 = weight2*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-wgt1, wgt1+ 0.5, wgt1+ 0.5, -wgt1);
|
||||||
|
w2 = vec4(-wgt2, wgt2+0.25, wgt2+0.25, -wgt2);
|
||||||
|
c3 = mul(w2, mat4x3(P0+2.0*(D+G)+P2, B+2.0*(E+H)+H5, C+2.0*(F+I)+I5, P1+2.0*(F4+I4)+P3))/3.0;
|
||||||
|
c4 = mul(w2, mat4x3(P0+2.0*(C+B)+P1, D+2.0*(F+E)+F4, G+2.0*(I+H)+I4, P2+2.0*(I5+H5)+P3))/3.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||||
|
w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||||
|
c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||||
|
c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||||
|
}
|
||||||
|
|
||||||
/* Filtering and normalization in four direction generating four colors. */
|
/* Filtering and normalization in four direction generating four colors. */
|
||||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
|
||||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
|
||||||
|
|
||||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const float XBR_EDGE_STR = 0.6;
|
#define XBR_EDGE_STR 0.6
|
||||||
const float XBR_WEIGHT = 1.0;
|
#define XBR_WEIGHT 1.0
|
||||||
const float XBR_ANTI_RINGING = 1.0;
|
#define XBR_ANTI_RINGING 1.0
|
||||||
|
|
||||||
layout(push_constant) uniform Push
|
layout(push_constant) uniform Push
|
||||||
{
|
{
|
||||||
|
@ -36,10 +36,18 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
float DETAILS;
|
float MODE;
|
||||||
|
float XBR_EDGE_SHP;
|
||||||
|
float XBR_TEXTURE_SHP;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
#pragma parameter DETAILS "Xbr - Preserve Details" 0.0 0.0 1.0 1.0
|
#pragma parameter MODE "Mode - Normal, Details, Adaptive" 0.0 0.0 2.0 1.0
|
||||||
|
#pragma parameter XBR_EDGE_SHP "Adaptive Dynamic Edge Sharp" 0.4 0.0 3.0 0.1
|
||||||
|
#pragma parameter XBR_TEXTURE_SHP "Adaptive Static Edge Sharp" 1.0 0.0 2.0 0.1
|
||||||
|
|
||||||
|
#define MODE params.MODE
|
||||||
|
#define XBR_EDGE_SHP params.XBR_EDGE_SHP
|
||||||
|
#define XBR_TEXTURE_SHP params.XBR_TEXTURE_SHP
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
|
@ -48,16 +56,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
|
|
||||||
#define wp1 1.0
|
|
||||||
#define wp2 0.0
|
|
||||||
#define wp3 0.0
|
|
||||||
//#define wp4 0.0
|
|
||||||
//#define wp5 0.0
|
|
||||||
#define wp6 0.0
|
|
||||||
|
|
||||||
#define weight1 (XBR_WEIGHT*1.75068/10.0)
|
|
||||||
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
|
|
||||||
|
|
||||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||||
|
|
||||||
float RGBtoYUV(vec3 color)
|
float RGBtoYUV(vec3 color)
|
||||||
|
@ -80,21 +78,13 @@ float df(float A, float B)
|
||||||
P2
|
P2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
float d_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||||
{
|
{
|
||||||
float wp4 = 0.0;
|
|
||||||
float wp5 = 0.0;
|
|
||||||
if(params.DETAILS > 0.5)
|
|
||||||
{
|
|
||||||
wp4 = 1.0;
|
|
||||||
wp5 = -1.0;
|
|
||||||
}
|
|
||||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
float hv_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||||
{
|
{
|
||||||
float wp4 = (params.DETAILS > 0.5) ? 1.0 : 0.0;
|
|
||||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +97,11 @@ vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||||
return max(a, max(b, max(c, d)));
|
return max(a, max(b, max(c, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float max4float(float a, float b, float c, float d)
|
||||||
|
{
|
||||||
|
return max(a, max(b, max(c, d)));
|
||||||
|
}
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
layout(location = 1) in vec2 TexCoord;
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
@ -126,6 +121,46 @@ layout(set = 0, binding = 3) uniform sampler2D Original;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// settings //
|
||||||
|
float wp1, wp2, wp3, wp4, wp5, wp6, weight1, weight2;
|
||||||
|
if (MODE == 1.0)
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 1.0;
|
||||||
|
wp5 = -1.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.75068/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.29633/10.0/2.0);
|
||||||
|
}
|
||||||
|
else if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
wp1 = 8.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 0.0;
|
||||||
|
wp5 = 0.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (1.75068/10.0);
|
||||||
|
weight2 = (1.29633/10.0/2.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wp1 = 8.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 0.0;
|
||||||
|
wp5 = 0.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.75068/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.29633/10.0/2.0);
|
||||||
|
}
|
||||||
|
// end settings //
|
||||||
|
|
||||||
//Skip pixels on wrong grid
|
//Skip pixels on wrong grid
|
||||||
vec2 fp = fract(vTexCoord.xy * params.SourceSize.xy);
|
vec2 fp = fract(vTexCoord.xy * params.SourceSize.xy);
|
||||||
vec2 dir = fp - vec2(0.5,0.5);
|
vec2 dir = fp - vec2(0.5,0.5);
|
||||||
|
@ -172,23 +207,41 @@ void main()
|
||||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||||
|
|
||||||
/* Calc edgeness in diagonal directions. */
|
/* Calc edgeness in diagonal directions. */
|
||||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
float d_edge = (d_wd( wp1, wp2, wp3, wp4, wp5, wp6, d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( wp1, wp2, wp3, wp4, wp5, wp6, c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||||
|
|
||||||
/* Calc edgeness in horizontal/vertical directions. */
|
/* Calc edgeness in horizontal/vertical directions. */
|
||||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
float hv_edge = (hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, f, i, e, h, c, i5, b, h5) - hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, e, f, h, i, d, f4, g, i4));
|
||||||
|
|
||||||
float limits = XBR_EDGE_STR + 0.000001;
|
float limits = XBR_EDGE_STR + 0.000001;
|
||||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||||
|
|
||||||
|
vec4 w1, w2;
|
||||||
|
vec3 c3, c4;
|
||||||
|
if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
float contrast = max(max4float(df(e,f),df(e,i),df(e,h),df(f,h)),max(df(f,i),df(h,i)))/(e+0.001);
|
||||||
|
|
||||||
/* Filter weights. Two taps only. */
|
float wgt1 = weight1*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
float wgt2 = weight2*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-wgt1, wgt1+ 0.5, wgt1+ 0.5, -wgt1);
|
||||||
|
w2 = vec4(-wgt2, wgt2+0.25, wgt2+0.25, -wgt2);
|
||||||
|
c3 = mul(w2, mat4x3(P0+2.0*(D+G)+P2, B+2.0*(E+H)+H5, C+2.0*(F+I)+I5, P1+2.0*(F4+I4)+P3))/3.0;
|
||||||
|
c4 = mul(w2, mat4x3(P0+2.0*(C+B)+P1, D+2.0*(F+E)+F4, G+2.0*(I+H)+I4, P2+2.0*(I5+H5)+P3))/3.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||||
|
w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||||
|
c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||||
|
c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||||
|
}
|
||||||
|
|
||||||
/* Filtering and normalization in four direction generating four colors. */
|
/* Filtering and normalization in four direction generating four colors. */
|
||||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
|
||||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
|
||||||
|
|
||||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||||
|
|
|
@ -36,8 +36,19 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
|
float MODE;
|
||||||
|
float XBR_EDGE_SHP;
|
||||||
|
float XBR_TEXTURE_SHP;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
|
#pragma parameter MODE "Mode - Normal, Details, Adaptive" 0.0 0.0 2.0 1.0
|
||||||
|
#pragma parameter XBR_EDGE_SHP "Adaptive Dynamic Edge Sharp" 0.4 0.0 3.0 0.1
|
||||||
|
#pragma parameter XBR_TEXTURE_SHP "Adaptive Static Edge Sharp" 1.0 0.0 2.0 0.1
|
||||||
|
|
||||||
|
#define MODE params.MODE
|
||||||
|
#define XBR_EDGE_SHP params.XBR_EDGE_SHP
|
||||||
|
#define XBR_TEXTURE_SHP params.XBR_TEXTURE_SHP
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
|
@ -47,16 +58,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
|
||||||
#define XBR_RES 2.0
|
#define XBR_RES 2.0
|
||||||
|
|
||||||
#define wp1 1.0
|
|
||||||
#define wp2 0.0
|
|
||||||
#define wp3 0.0
|
|
||||||
#define wp4 4.0
|
|
||||||
#define wp5 0.0
|
|
||||||
#define wp6 0.0
|
|
||||||
|
|
||||||
#define weight1 (XBR_WEIGHT*1.75068/10.0)
|
|
||||||
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
|
|
||||||
|
|
||||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||||
|
|
||||||
float RGBtoYUV(vec3 color)
|
float RGBtoYUV(vec3 color)
|
||||||
|
@ -79,12 +80,12 @@ float df(float A, float B)
|
||||||
P2
|
P2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
float d_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||||
{
|
{
|
||||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
float hv_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||||
{
|
{
|
||||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||||
}
|
}
|
||||||
|
@ -93,11 +94,17 @@ vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||||
{
|
{
|
||||||
return min(a, min(b, min(c, d)));
|
return min(a, min(b, min(c, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||||
{
|
{
|
||||||
return max(a, max(b, max(c, d)));
|
return max(a, max(b, max(c, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float max4float(float a, float b, float c, float d)
|
||||||
|
{
|
||||||
|
return max(a, max(b, max(c, d)));
|
||||||
|
}
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
layout(location = 1) in vec2 TexCoord;
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
@ -117,6 +124,45 @@ layout(set = 0, binding = 3) uniform sampler2D PassPrev2;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// settings //
|
||||||
|
float wp1, wp2, wp3, wp4, wp5, wp6, weight1, weight2;
|
||||||
|
if (MODE == 1.0)
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 1.0;
|
||||||
|
wp5 = -1.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.75068/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.29633/10.0/2.0);
|
||||||
|
}
|
||||||
|
else if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
wp1 = 8.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 0.0;
|
||||||
|
wp5 = 0.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (1.75068/10.0);
|
||||||
|
weight2 = (1.29633/10.0/2.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wp1 = 8.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 0.0;
|
||||||
|
wp5 = 0.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.75068/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.29633/10.0/2.0);
|
||||||
|
}
|
||||||
|
// end settings //
|
||||||
//Skip pixels on wrong grid
|
//Skip pixels on wrong grid
|
||||||
vec2 fp = fract(vTexCoord*params.SourceSize.xy);
|
vec2 fp = fract(vTexCoord*params.SourceSize.xy);
|
||||||
vec2 dir = fp - vec2(0.5,0.5);
|
vec2 dir = fp - vec2(0.5,0.5);
|
||||||
|
@ -161,23 +207,41 @@ void main()
|
||||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||||
|
|
||||||
/* Calc edgeness in diagonal directions. */
|
/* Calc edgeness in diagonal directions. */
|
||||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
float d_edge = (d_wd( wp1, wp2, wp3, wp4, wp5, wp6, d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( wp1, wp2, wp3, wp4, wp5, wp6, c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||||
|
|
||||||
/* Calc edgeness in horizontal/vertical directions. */
|
/* Calc edgeness in horizontal/vertical directions. */
|
||||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
float hv_edge = (hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, f, i, e, h, c, i5, b, h5) - hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, e, f, h, i, d, f4, g, i4));
|
||||||
|
|
||||||
float limits = XBR_EDGE_STR + 0.000001;
|
float limits = XBR_EDGE_STR + 0.000001;
|
||||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||||
|
|
||||||
/* Filter weights. Two taps only. */
|
vec4 w1, w2;
|
||||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
vec3 c3, c4;
|
||||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
float contrast = max(max4float(df(e,f),df(e,i),df(e,h),df(f,h)),max(df(f,i),df(h,i)))/(e+0.001);
|
||||||
|
|
||||||
|
float wgt1 = weight1*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
|
float wgt2 = weight2*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
|
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-wgt1, wgt1+ 0.5, wgt1+ 0.5, -wgt1);
|
||||||
|
w2 = vec4(-wgt2, wgt2+0.25, wgt2+0.25, -wgt2);
|
||||||
|
c3 = mul(w2, mat4x3(P0+2.0*(D+G)+P2, B+2.0*(E+H)+H5, C+2.0*(F+I)+I5, P1+2.0*(F4+I4)+P3))/3.0;
|
||||||
|
c4 = mul(w2, mat4x3(P0+2.0*(C+B)+P1, D+2.0*(F+E)+F4, G+2.0*(I+H)+I4, P2+2.0*(I5+H5)+P3))/3.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||||
|
w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||||
|
c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||||
|
c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||||
|
}
|
||||||
|
|
||||||
/* Filtering and normalization in four direction generating four colors. */
|
/* Filtering and normalization in four direction generating four colors. */
|
||||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
|
||||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
|
||||||
|
|
||||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||||
|
|
|
@ -36,10 +36,18 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
float DETAILS;
|
float MODE;
|
||||||
|
float XBR_EDGE_SHP;
|
||||||
|
float XBR_TEXTURE_SHP;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
#pragma parameter DETAILS "Xbr - Preserve Details" 0.0 0.0 1.0 1.0
|
#pragma parameter MODE "Mode - Normal, Details, Adaptive" 0.0 0.0 2.0 1.0
|
||||||
|
#pragma parameter XBR_EDGE_SHP "Adaptive Dynamic Edge Sharp" 0.4 0.0 3.0 0.1
|
||||||
|
#pragma parameter XBR_TEXTURE_SHP "Adaptive Static Edge Sharp" 1.0 0.0 2.0 0.1
|
||||||
|
|
||||||
|
#define MODE params.MODE
|
||||||
|
#define XBR_EDGE_SHP params.XBR_EDGE_SHP
|
||||||
|
#define XBR_TEXTURE_SHP params.XBR_TEXTURE_SHP
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
|
@ -48,16 +56,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
|
|
||||||
#define wp1 1.0
|
|
||||||
#define wp2 0.0
|
|
||||||
#define wp3 0.0
|
|
||||||
//#define wp4 0.0
|
|
||||||
//#define wp5 0.0
|
|
||||||
#define wp6 0.0
|
|
||||||
|
|
||||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
|
||||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
|
||||||
|
|
||||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||||
|
|
||||||
float RGBtoYUV(vec3 color)
|
float RGBtoYUV(vec3 color)
|
||||||
|
@ -80,21 +78,13 @@ float df(float A, float B)
|
||||||
P2
|
P2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
float d_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||||
{
|
{
|
||||||
float wp4 = 0.0;
|
|
||||||
float wp5 = 0.0;
|
|
||||||
if(params.DETAILS > 0.5)
|
|
||||||
{
|
|
||||||
wp4 = 1.0;
|
|
||||||
wp5 = -1.0;
|
|
||||||
}
|
|
||||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
float hv_wd(float wp1, float wp2, float wp3, float wp4, float wp5, float wp6, float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||||
{
|
{
|
||||||
float wp4 = (params.DETAILS > 0.5) ? 1.0 : 0.0;
|
|
||||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +97,11 @@ vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||||
return max(a, max(b, max(c, d)));
|
return max(a, max(b, max(c, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float max4float(float a, float b, float c, float d)
|
||||||
|
{
|
||||||
|
return max(a, max(b, max(c, d)));
|
||||||
|
}
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
layout(location = 1) in vec2 TexCoord;
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
@ -140,6 +135,46 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// settings //
|
||||||
|
float wp1, wp2, wp3, wp4, wp5, wp6, weight1, weight2;
|
||||||
|
if (MODE == 1.0)
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 0.0;
|
||||||
|
wp4 = 0.0;
|
||||||
|
wp5 = 0.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.29633/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.75068/10.0/2.0);
|
||||||
|
}
|
||||||
|
else if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 1.0;
|
||||||
|
wp4 = 3.0;
|
||||||
|
wp5 = -2.0;
|
||||||
|
wp6 = 0.0;
|
||||||
|
|
||||||
|
weight1 = (1.29633/10.0);
|
||||||
|
weight2 = (1.75068/10.0/2.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wp1 = 1.0;
|
||||||
|
wp2 = 0.0;
|
||||||
|
wp3 = 2.0;
|
||||||
|
wp4 = 3.0;
|
||||||
|
wp5 = -2.0;
|
||||||
|
wp6 = 1.0;
|
||||||
|
|
||||||
|
weight1 = (XBR_WEIGHT*1.29633/10.0);
|
||||||
|
weight2 = (XBR_WEIGHT*1.75068/10.0/2.0);
|
||||||
|
}
|
||||||
|
// end settings //
|
||||||
|
|
||||||
vec3 P0 = texture(Source, t1.xy).xyz;
|
vec3 P0 = texture(Source, t1.xy).xyz;
|
||||||
vec3 P1 = texture(Source, t1.zy).xyz;
|
vec3 P1 = texture(Source, t1.zy).xyz;
|
||||||
vec3 P2 = texture(Source, t1.xw).xyz;
|
vec3 P2 = texture(Source, t1.xw).xyz;
|
||||||
|
@ -185,23 +220,41 @@ void main()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Calc edgeness in diagonal directions. */
|
/* Calc edgeness in diagonal directions. */
|
||||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
float d_edge = (d_wd( wp1, wp2, wp3, wp4, wp5, wp6, d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( wp1, wp2, wp3, wp4, wp5, wp6, c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||||
|
|
||||||
/* Calc edgeness in horizontal/vertical directions. */
|
/* Calc edgeness in horizontal/vertical directions. */
|
||||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
float hv_edge = (hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, f, i, e, h, c, i5, b, h5) - hv_wd(wp1, wp2, wp3, wp4, wp5, wp6, e, f, h, i, d, f4, g, i4));
|
||||||
|
|
||||||
float limits = XBR_EDGE_STR + 0.000001;
|
float limits = XBR_EDGE_STR + 0.000001;
|
||||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||||
|
|
||||||
|
vec4 w1, w2;
|
||||||
|
vec3 c3, c4;
|
||||||
|
if (MODE == 2.0)
|
||||||
|
{
|
||||||
|
float contrast = max(max4float(df(e,f),df(e,i),df(e,h),df(f,h)),max(df(f,i),df(h,i)))/(e+0.001);
|
||||||
|
|
||||||
/* Filter weights. Two taps only. */
|
float wgt1 = weight1*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
float wgt2 = weight2*(smoothstep(0.0, 0.6, contrast)*XBR_EDGE_SHP + XBR_TEXTURE_SHP);
|
||||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-wgt1, wgt1+ 0.5, wgt1+ 0.5, -wgt1);
|
||||||
|
w2 = vec4(-wgt2, wgt2+0.25, wgt2+0.25, -wgt2);
|
||||||
|
c3 = mul(w2, mat4x3(P0+2.0*(D+G)+P2, B+2.0*(E+H)+H5, C+2.0*(F+I)+I5, P1+2.0*(F4+I4)+P3))/3.0;
|
||||||
|
c4 = mul(w2, mat4x3(P0+2.0*(C+B)+P1, D+2.0*(F+E)+F4, G+2.0*(I+H)+I4, P2+2.0*(I5+H5)+P3))/3.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Filter weights. Two taps only. */
|
||||||
|
w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||||
|
w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||||
|
c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||||
|
c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||||
|
}
|
||||||
|
|
||||||
/* Filtering and normalization in four direction generating four colors. */
|
/* Filtering and normalization in four direction generating four colors. */
|
||||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
|
||||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
|
||||||
|
|
||||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||||
|
|
44
xbr/super-xbr-6p-adaptive.slangp
Normal file
44
xbr/super-xbr-6p-adaptive.slangp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
shaders = "7"
|
||||||
|
shader0 = "shaders/super-xbr/super-xbr-pass0.slang"
|
||||||
|
filter_linear0 = false
|
||||||
|
scale_type_x0 = "source"
|
||||||
|
scale_x0 = "1.000000"
|
||||||
|
scale_type_y0 = "source"
|
||||||
|
scale_y0 = "1.000000"
|
||||||
|
shader1 = "shaders/super-xbr/super-xbr-pass1.slang"
|
||||||
|
filter_linear1 = false
|
||||||
|
scale_type_x1 = "source"
|
||||||
|
scale_x1 = "2.000000"
|
||||||
|
scale_type_y1 = "source"
|
||||||
|
scale_y1 = "2.000000"
|
||||||
|
alias2 = "PassPrev2"
|
||||||
|
shader2 = "shaders/super-xbr/super-xbr-pass2.slang"
|
||||||
|
filter_linear2 = false
|
||||||
|
scale_type_x2 = "source"
|
||||||
|
scale_x2 = "1.000000"
|
||||||
|
scale_type_y2 = "source"
|
||||||
|
scale_y2 = "1.000000"
|
||||||
|
shader3 = "shaders/super-xbr/super-xbr-pass0.slang"
|
||||||
|
filter_linear3 = false
|
||||||
|
scale_type_x3 = "source"
|
||||||
|
scale_x3 = "1.000000"
|
||||||
|
scale_type_y3 = "source"
|
||||||
|
scale_y3 = "1.000000"
|
||||||
|
shader4 = "shaders/super-xbr/super-xbr-pass1b.slang"
|
||||||
|
filter_linear4 = false
|
||||||
|
scale_type_x4 = "source"
|
||||||
|
scale_x4 = "2.000000"
|
||||||
|
scale_type_y4 = "source"
|
||||||
|
scale_y4 = "2.000000"
|
||||||
|
shader5 = "shaders/super-xbr/super-xbr-pass2.slang"
|
||||||
|
filter_linear5 = false
|
||||||
|
scale_type_x5 = "source"
|
||||||
|
scale_x5 = "1.000000"
|
||||||
|
scale_type_y5 = "source"
|
||||||
|
scale_y5 = "1.000000"
|
||||||
|
shader6 = "shaders/super-xbr/custom-jinc2-sharper.slang"
|
||||||
|
filter_linear6 = false
|
||||||
|
|
||||||
|
parameters = "MODE;XBR_EDGE_STR"
|
||||||
|
MODE = "2.0"
|
||||||
|
XBR_EDGE_STR = "2.0"
|
|
@ -39,6 +39,6 @@ scale_y5 = "1.000000"
|
||||||
shader6 = "shaders/super-xbr/custom-jinc2-sharper.slang"
|
shader6 = "shaders/super-xbr/custom-jinc2-sharper.slang"
|
||||||
filter_linear6 = false
|
filter_linear6 = false
|
||||||
|
|
||||||
parameters = "DETAILS;XBR_EDGE_STR"
|
parameters = "MODE;XBR_EDGE_STR"
|
||||||
DETAILS = "1.0"
|
MODE = "1.0"
|
||||||
XBR_EDGE_STR = "2.0"
|
XBR_EDGE_STR = "2.0"
|
||||||
|
|
Loading…
Reference in a new issue