fix super-*xbr-3d shaders

This commit is contained in:
hunterk 2019-07-11 10:15:45 -05:00
parent c8c3957ad0
commit 6722097415
9 changed files with 237 additions and 230 deletions

View file

@ -54,12 +54,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define XBR_RES 2.0
#define wp1 1.0
#define wp2 0.0
#define wp3 0.0
#define wp4 2.0
#define wp1 2.0
#define wp2 1.0
#define wp3 -1.0
#define wp4 4.0
#define wp5 -1.0
#define wp6 0.0
#define wp6 1.0
#define weight1 (XBR_WEIGHT*1.29633/10.0)
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
@ -88,7 +88,6 @@ bool eq(float A, float B)
return (df(A, B) < 15.0);
}
/*
P1
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
@ -138,9 +137,10 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
//Skip pixels on wrong grid
if (any(lessThan(fract(vTexCoord*params.SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
if (any(lessThan(fract(vTexCoord.xy*params.SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
{
FragColor = texture(Source, vTexCoord);
return;
}
else
{
@ -225,12 +225,13 @@ void main()
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));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
// doesn't seem to be used anywhere, so commenting for performance
// bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/*
P1
@ -243,12 +244,12 @@ void main()
*/
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : E;
color = (block_3d) ? color : E;
FragColor = vec4(color, 1.0);
}

View file

@ -45,15 +45,15 @@ const float XBR_ANTI_RINGING = 0.0;
#define mul(a,b) (b*a)
#define XBR_RES 2.0
#define wp1 1.0
#define wp1 8.0
#define wp2 0.0
#define wp3 0.0
#define wp4 2.0
#define wp5 -1.0
#define wp4 0.0
#define wp5 0.0
#define wp6 0.0
#define XBR_RES 2.0
#define weight1 (XBR_WEIGHT*1.75068/10.0)
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
@ -131,35 +131,35 @@ void main()
{
//Skip pixels on wrong grid
vec2 dir = fract(vTexCoord*params.SourceSize.xy/XBR_RES) - vec2(0.5,0.5);
if ((dir.x*dir.y)>0.0){
FragColor = texture(Source, vTexCoord);
}else{
if ((dir.x*dir.y)>0.0){ FragColor = texture(Source, vTexCoord);
return;}
else{
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/params.SourceSize.xy;
vec2 g1 = vec2((XBR_RES/2.0)/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, (XBR_RES/2.0)/params.SourceSize.y);
vec3 P0 = texture(Source, vTexCoord -3.0*g1 ).xyz;
vec3 P1 = texture(Source, vTexCoord -3.0*g2).xyz;
vec3 P2 = texture(Source, vTexCoord +3.0*g2).xyz;
vec3 P3 = texture(Source, vTexCoord +3.0*g1 ).xyz;
vec3 P0 = texture(Source, vTexCoord -3.0*g1 ).xyz;
vec3 P1 = texture(Source, vTexCoord -3.0*g2).xyz;
vec3 P2 = texture(Source, vTexCoord +3.0*g2).xyz;
vec3 P3 = texture(Source, vTexCoord +3.0*g1 ).xyz;
vec3 B = texture(Source, vTexCoord -2.0*g1 -g2).xyz;
vec3 C = texture(Source, vTexCoord -g1 -2.0*g2).xyz;
vec3 D = texture(Source, vTexCoord -2.0*g1 +g2).xyz;
vec3 E = texture(Source, vTexCoord -g1 ).xyz;
vec3 F = texture(Source, vTexCoord -g2).xyz;
vec3 G = texture(Source, vTexCoord -g1 +2.0*g2).xyz;
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1 ).xyz;
vec3 B = texture(Source, vTexCoord -2.0*g1 -g2).xyz;
vec3 C = texture(Source, vTexCoord -g1 -2.0*g2).xyz;
vec3 D = texture(Source, vTexCoord -2.0*g1 +g2).xyz;
vec3 E = texture(Source, vTexCoord -g1 ).xyz;
vec3 F = texture(Source, vTexCoord -g2).xyz;
vec3 G = texture(Source, vTexCoord -g1 +2.0*g2).xyz;
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1 ).xyz;
vec3 F4 = texture(Source,vTexCoord +g1 -2.0*g2).xyz;
vec3 I4 = texture(Source,vTexCoord +2.0*g1 -g2).xyz;
vec3 H5 = texture(Source,vTexCoord +g1 +2.0*g2).xyz;
vec3 I5 = texture(Source,vTexCoord +2.0*g1 +g2).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
vec3 F4 = texture(Source, vTexCoord +g1 -2.0*g2).xyz;
vec3 I4 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
vec3 H5 = texture(Source, vTexCoord +g1 +2.0*g2).xyz;
vec3 I5 = texture(Source, vTexCoord +2.0*g1 +g2).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
g1 *= 2.0;
g2 *= 2.0;
@ -177,7 +177,7 @@ void main()
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
@ -209,24 +209,19 @@ void main()
/* Filtering and normalization in four direction generating four colors. */
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
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));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : A;
FragColor = vec4(color, 1.0);
}
color = (block_3d) ? color : A;
FragColor = vec4(color, 1.0);
}
}

View file

@ -26,9 +26,9 @@
*/
const float XBR_EDGE_STR = 0.0;
const float XBR_WEIGHT = 0.0;
const float XBR_ANTI_RINGING = 0.0;
const float XBR_EDGE_STR = 0.6;
const float XBR_WEIGHT = 1.0;
const float XBR_ANTI_RINGING = 1.0;
layout(push_constant) uniform Push
{
@ -49,10 +49,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define wp1 1.0
#define wp2 0.0
#define wp3 0.0
#define wp4 0.0
#define wp5 -1.0
#define wp6 0.0
#define wp3 2.0
#define wp4 3.0
#define wp5 -2.0
#define wp6 1.0
#define XBR_RES 2.0
#define weight1 (XBR_WEIGHT*1.29633/10.0)
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
@ -168,8 +170,8 @@ void main()
vec3 F = texture(Source, t4.zy).xyz;
vec3 H = texture(Source, t4.xw).xyz;
vec3 I = texture(Source, t4.zw).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
vec3 F6 = texture(Original, tex +g1+0.25*g1+0.25*g2).xyz;
vec3 F7 = texture(Original, tex +g1+0.25*g1-0.25*g2).xyz;
@ -184,7 +186,7 @@ void main()
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
@ -229,18 +231,15 @@ void main()
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));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : A;
color = (block_3d) ? color : A;
FragColor = vec4(color, 1.0);
}

View file

@ -37,7 +37,7 @@ layout(push_constant) uniform Push
float XBR_ANTI_RINGING;
} params;
#pragma parameter XBR_EDGE_STR "Xbr - Edge Strength p0" 0.6 0.0 5.0 0.5
#pragma parameter XBR_EDGE_STR "Xbr - Edge Strength p0" 2.0 0.0 5.0 0.2
#pragma parameter XBR_WEIGHT "Xbr - Filter Weight" 1.0 0.00 1.50 0.05
#pragma parameter XBR_ANTI_RINGING "Xbr - Anti-Ringing Level" 1.0 0.0 1.0 1.0
@ -52,14 +52,14 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define mul(a,b) (b*a)
#define XBR_RES 4.0
#define wp1 1.0
#define wp2 0.0
#define wp3 0.0
#define wp4 2.0
#define wp1 2.0
#define wp2 1.0
#define wp3 -1.0
#define wp4 4.0
#define wp5 -1.0
#define wp6 0.0
#define wp6 1.0
#define XBR_RES 4.0
#define weight1 (XBR_WEIGHT*1.29633/10.0)
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
@ -141,6 +141,7 @@ void main()
if (any(lessThan(fract(vTexCoord*params.SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
{
FragColor = texture(Source, vTexCoord);
return;
}
else
{
@ -226,11 +227,11 @@ void main()
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));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
//bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/*
P1
@ -243,12 +244,12 @@ void main()
*/
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : E;
color = (block_3d) ? color : E;
FragColor = vec4(color, 1.0);
}

View file

@ -45,15 +45,15 @@ const float XBR_ANTI_RINGING = 0.0;
#define mul(a,b) (b*a)
#define XBR_RES 4.0
#define wp1 1.0
#define wp1 8.0
#define wp2 0.0
#define wp3 0.0
#define wp4 4.0
#define wp4 0.0
#define wp5 0.0
#define wp6 0.0
#define XBR_RES 4.0
#define weight1 (XBR_WEIGHT*1.75068/10.0)
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
@ -131,9 +131,9 @@ void main()
{
//Skip pixels on wrong grid
vec2 dir = fract(vTexCoord*params.SourceSize.xy/XBR_RES) - vec2(0.5,0.5);
if ((dir.x*dir.y)>0.0) {
FragColor = texture(Source, vTexCoord);
}else{
if ((dir.x*dir.y)>0.0){ FragColor = texture(Source, vTexCoord);
return;}
else{
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/params.SourceSize.xy;
@ -154,10 +154,10 @@ void main()
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1 ).xyz;
vec3 F4 = texture(Source,vTexCoord +g1 -2.0*g2).xyz;
vec3 I4 = texture(Source,vTexCoord +2.0*g1 -g2).xyz;
vec3 H5 = texture(Source,vTexCoord +g1 +2.0*g2).xyz;
vec3 I5 = texture(Source,vTexCoord +2.0*g1 +g2).xyz;
vec3 F4 = texture(Source, vTexCoord +g1 -2.0*g2).xyz;
vec3 I4 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
vec3 H5 = texture(Source, vTexCoord +g1 +2.0*g2).xyz;
vec3 I5 = texture(Source, vTexCoord +2.0*g1 +g2).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
@ -177,7 +177,7 @@ void main()
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
@ -192,6 +192,16 @@ void main()
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
/*
P1
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
G H5
P2
*/
/* 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 ));
@ -207,24 +217,24 @@ void main()
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
/* Filtering and normalization in four direction generating four colors. */
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
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));
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
//bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : A;
color = (block_3d) ? color : A;
FragColor = vec4(color, 1.0);
}
}
}

View file

@ -49,10 +49,10 @@ const float XBR_ANTI_RINGING = 0.0;
#define wp1 1.0
#define wp2 0.0
#define wp3 0.0
#define wp4 0.0
#define wp5 -1.0
#define wp6 0.0
#define wp3 2.0
#define wp4 3.0
#define wp5 -2.0
#define wp6 1.0
#define weight1 (XBR_WEIGHT*1.29633/10.0)
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
@ -146,8 +146,8 @@ void main()
{
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/params.SourceSize.xy;
vec2 g1 = vec2((XBR_RES/2.0)/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, (XBR_RES/2.0)/params.SourceSize.y);
vec2 g1 = vec2(XBR_RES/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, XBR_RES/params.SourceSize.y);
vec3 P0 = texture(Source, t1.xy).xyz;
vec3 P1 = texture(Source, t1.zy).xyz;
@ -184,7 +184,7 @@ void main()
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
@ -199,7 +199,7 @@ void main()
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
/*
P1
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
@ -210,6 +210,7 @@ void main()
P2
*/
/* 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 ));
@ -224,15 +225,16 @@ void main()
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
/* Filtering and normalization in four direction generating four colors. */
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
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));
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
//bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
@ -240,7 +242,7 @@ void main()
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : A;
color = (block_3d) ? color : A;
FragColor = vec4(color, 1.0);
}

View file

@ -45,14 +45,14 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define mul(a,b) (b*a)
#define XBR_RES 2.0
#define wp1 1.0
#define wp2 0.0
#define wp3 0.0
#define wp4 2.0
#define wp1 2.0
#define wp2 1.0
#define wp3 -1.0
#define wp4 4.0
#define wp5 -1.0
#define wp6 0.0
#define wp6 1.0
#define XBR_RES2 2.0
#define weight1 (XBR_WEIGHT*1.29633/10.0)
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
@ -130,64 +130,61 @@ layout(set = 0, binding = 3) uniform sampler2D Original;
void main()
{
//Skip pixels on wrong grid
if (any(lessThan(fract(vTexCoord*params.SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
{
FragColor = texture(Source, vTexCoord);
}
else
{
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/params.SourceSize.xy;
if (any(lessThan(fract(vTexCoord*params.SourceSize.xy/XBR_RES2),vec2(0.5,0.5)))){ FragColor = texture(Source, vTexCoord); return;}
vec2 g1 = vec2(XBR_RES/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, XBR_RES/params.SourceSize.y);
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES2) + vec2(0.5, 0.5))*XBR_RES2/params.SourceSize.xy;
vec3 P0 = texture(Source, vTexCoord -g1 -g2).xyz;
vec3 P1 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
vec3 P2 = texture(Source, vTexCoord -g1+2.0*g2).xyz;
vec3 P3 = texture(Source, vTexCoord +2.0*g1+2.0*g2).xyz;
vec2 g1 = vec2(XBR_RES2/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, XBR_RES2/params.SourceSize.y);
vec3 B = texture(Source, vTexCoord -g2).xyz;
vec3 C = texture(Source, vTexCoord +g1-g2).xyz;
vec3 D = texture(Source, vTexCoord -g1 ).xyz;
vec3 E = texture(Source, vTexCoord ).xyz;
vec3 F = texture(Source, vTexCoord +g1 ).xyz;
vec3 G = texture(Source, vTexCoord -g1+g2).xyz;
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1+g2).xyz;
vec3 P0 = texture(Source, vTexCoord -g1 -g2).xyz;
vec3 P1 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
vec3 P2 = texture(Source, vTexCoord -g1+2.0*g2).xyz;
vec3 P3 = texture(Source, vTexCoord +2.0*g1+2.0*g2).xyz;
vec3 F4 = texture(Source, vTexCoord +2.0*g1 ).xyz;
vec3 I4 = texture(Source, vTexCoord +g2+2.0*g1 ).xyz;
vec3 H5 = texture(Source, vTexCoord +2.0*g2 ).xyz;
vec3 I5 = texture(Source, vTexCoord +2.0*g2+g1 ).xyz;
vec3 B = texture(Source, vTexCoord -g2).xyz;
vec3 C = texture(Source, vTexCoord +g1-g2).xyz;
vec3 D = texture(Source, vTexCoord -g1 ).xyz;
vec3 E = texture(Source, vTexCoord ).xyz;
vec3 F = texture(Source, vTexCoord +g1 ).xyz;
vec3 G = texture(Source, vTexCoord -g1+g2).xyz;
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1+g2).xyz;
vec3 F6 = texture(Source, tex +g1+0.25*g1+0.25*g2).xyz;
vec3 F7 = texture(Source, tex +g1+0.25*g1-0.25*g2).xyz;
vec3 F8 = texture(Source, tex +g1-0.25*g1-0.25*g2).xyz;
vec3 F9 = texture(Source, tex +g1-0.25*g1+0.25*g2).xyz;
vec3 F4 = texture(Source,vTexCoord +2.0*g1 ).xyz;
vec3 I4 = texture(Source,vTexCoord +g2+2.0*g1 ).xyz;
vec3 H5 = texture(Source,vTexCoord +2.0*g2 ).xyz;
vec3 I5 = texture(Source,vTexCoord +2.0*g2+g1 ).xyz;
vec3 H6 = texture(Source, tex +0.25*g1+0.25*g2+g2).xyz;
vec3 H7 = texture(Source, tex +0.25*g1-0.25*g2+g2).xyz;
vec3 H8 = texture(Source, tex -0.25*g1-0.25*g2+g2).xyz;
vec3 H9 = texture(Source, tex -0.25*g1+0.25*g2+g2).xyz;
vec3 F6 = texture(Source, tex +g1+0.25*g1+0.25*g2).xyz;
vec3 F7 = texture(Source, tex +g1+0.25*g1-0.25*g2).xyz;
vec3 F8 = texture(Source, tex +g1-0.25*g1-0.25*g2).xyz;
vec3 F9 = texture(Source, tex +g1-0.25*g1+0.25*g2).xyz;
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
vec3 H6 = texture(Source, tex +0.25*g1+0.25*g2+g2).xyz;
vec3 H7 = texture(Source, tex +0.25*g1-0.25*g2+g2).xyz;
vec3 H8 = texture(Source, tex -0.25*g1-0.25*g2+g2).xyz;
vec3 H9 = texture(Source, tex -0.25*g1+0.25*g2+g2).xyz;
bool block_3d = ((f0.xyz == f0.yzw) && (h0.xyz == h0.yzw));
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
float d = RGBtoYUV( D );
float e = RGBtoYUV( E );
float f = RGBtoYUV( F );
float g = RGBtoYUV( G );
float h = RGBtoYUV( H );
float i = RGBtoYUV( I );
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
float d = RGBtoYUV( D );
float e = RGBtoYUV( E );
float f = RGBtoYUV( F );
float g = RGBtoYUV( G );
float h = RGBtoYUV( H );
float i = RGBtoYUV( I );
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
/*
P1
@ -199,29 +196,31 @@ void main()
P2
*/
/* 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 ));
/* 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));
/* 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 limits = XBR_EDGE_STR + 0.000001;
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
/* 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));
/* Filter weights. Two taps only. */
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
float limits = XBR_EDGE_STR + 0.000001;
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
/* Filtering and normalization in four direction generating four colors. */
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
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));
/* Filter weights. Two taps only. */
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* Filtering and normalization in four direction generating four colors. */
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
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). */
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
//bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
/*
P1
@ -232,15 +231,16 @@ void main()
G H5
P2
*/
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : E;
FragColor = vec4(color, 1.0);
}
/* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
color = clamp(color, min_sample, max_sample);
color = (block_3d) ? color : E;
FragColor = vec4(color, 1.0);
}

View file

@ -45,15 +45,15 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define mul(a,b) (b*a)
#define XBR_RES 2.0
#define wp1 1.0
#define wp1 8.0
#define wp2 0.0
#define wp3 0.0
#define wp4 4.0
#define wp4 0.0
#define wp5 0.0
#define wp6 0.0
#define XBR_RES2 2.0
#define weight1 (XBR_WEIGHT*1.75068/10.0)
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
@ -130,36 +130,36 @@ layout(set = 0, binding = 3) uniform sampler2D Original;
void main()
{
//Skip pixels on wrong grid
vec2 dir = fract(vTexCoord*params.SourceSize.xy/XBR_RES) - vec2(0.5,0.5);
if ((dir.x*dir.y)>0.0){
FragColor = texture(Source, vTexCoord);
}else{
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/params.SourceSize.xy;
vec2 dir = fract(vTexCoord*params.SourceSize.xy/XBR_RES2) - vec2(0.5,0.5);
if ((dir.x*dir.y)>0.0){ FragColor = texture(Source, vTexCoord);
return;}
else{
vec2 g1 = vec2((XBR_RES/2.0)/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, (XBR_RES/2.0)/params.SourceSize.y);
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES2) + vec2(0.5, 0.5))*XBR_RES2/params.SourceSize.xy;
vec2 g1 = vec2((XBR_RES2/2.0)/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, (XBR_RES2/2.0)/params.SourceSize.y);
vec3 P0 = texture(Source, vTexCoord -3.0*g1 ).xyz;
vec3 P1 = texture(Source, vTexCoord -3.0*g2).xyz;
vec3 P2 = texture(Source, vTexCoord +3.0*g2).xyz;
vec3 P3 = texture(Source, vTexCoord +3.0*g1 ).xyz;
vec3 B = texture(Source, vTexCoord -2.0*g1 -g2).xyz;
vec3 C = texture(Source, vTexCoord -g1 -2.0*g2).xyz;
vec3 D = texture(Source, vTexCoord -2.0*g1 +g2).xyz;
vec3 E = texture(Source, vTexCoord -g1 ).xyz;
vec3 F = texture(Source, vTexCoord -g2).xyz;
vec3 G = texture(Source, vTexCoord -g1 +2.0*g2).xyz;
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1 ).xyz;
vec3 B = texture(Source, vTexCoord -2.0*g1 -g2).xyz;
vec3 C = texture(Source, vTexCoord -g1 -2.0*g2).xyz;
vec3 D = texture(Source, vTexCoord -2.0*g1 +g2).xyz;
vec3 E = texture(Source, vTexCoord -g1 ).xyz;
vec3 F = texture(Source, vTexCoord -g2).xyz;
vec3 G = texture(Source, vTexCoord -g1 +2.0*g2).xyz;
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1 ).xyz;
vec3 F4 = texture(Source, vTexCoord +g1 -2.0*g2).xyz;
vec3 I4 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
vec3 H5 = texture(Source, vTexCoord +g1 +2.0*g2).xyz;
vec3 I5 = texture(Source, vTexCoord +2.0*g1 +g2).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
g1 *= 2.0;
g2 *= 2.0;
@ -222,7 +222,7 @@ void main()
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));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
//bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* 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);
@ -243,7 +243,7 @@ void main()
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : E;
color = (block_3d) ? color : A;
FragColor = vec4(color, 1.0);
}

View file

@ -49,10 +49,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define wp1 1.0
#define wp2 0.0
#define wp3 0.0
#define wp4 0.0
#define wp5 -1.0
#define wp6 0.0
#define wp3 2.0
#define wp4 3.0
#define wp5 -2.0
#define wp6 1.0
#define weight1 (XBR_WEIGHT*1.29633/10.0)
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
@ -169,7 +169,7 @@ void main()
vec3 H = texture(Source, t4.xw).xyz;
vec3 I = texture(Source, t4.zw).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
vec3 A = texture(Source, vTexCoord).xyz;
vec3 F6 = texture(Original, tex +g1+0.25*g1+0.25*g2).xyz;
vec3 F7 = texture(Original, tex +g1+0.25*g1-0.25*g2).xyz;
@ -184,7 +184,7 @@ void main()
vec4 f0 = reduce4(F6, F7, F8, F9);
vec4 h0 = reduce4(H6, H7, H8, H9);
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
float b = RGBtoYUV( B );
float c = RGBtoYUV( C );
@ -210,7 +210,6 @@ void main()
P2
*/
/* 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 ));
@ -230,7 +229,7 @@ void main()
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));
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
//bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
@ -242,7 +241,7 @@ void main()
color = clamp(color, min_sample, max_sample);
color = block_3d ? color : A;
color = (block_3d) ? color : A;
FragColor = vec4(color, 1.0);
}