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
{
@ -226,11 +226,12 @@ 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)) );
// 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,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;
@ -212,20 +212,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);
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

@ -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)
@ -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;
@ -193,6 +193,16 @@ void main()
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 ));
@ -212,18 +222,18 @@ 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);
/* 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;
@ -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 ));
@ -229,10 +230,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);
/* 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,16 +130,12 @@ 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;
vec2 g1 = vec2(XBR_RES2/params.SourceSize.x, 0.0);
vec2 g2 = vec2(0.0, XBR_RES2/params.SourceSize.y);
vec3 P0 = texture(Source, vTexCoord -g1 -g2).xyz;
vec3 P1 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
@ -155,10 +151,10 @@ void main()
vec3 H = texture(Source, vTexCoord +g2).xyz;
vec3 I = texture(Source, vTexCoord +g1+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 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 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;
@ -173,7 +169,8 @@ 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,6 +196,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 ));
@ -218,7 +216,8 @@ 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);
@ -233,14 +232,15 @@ void main()
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));
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 @@ 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,15 +130,15 @@ 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 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 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/params.SourceSize.xy;
vec2 tex = (floor(vTexCoord*params.SourceSize.xy/XBR_RES2) + vec2(0.5, 0.5))*XBR_RES2/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_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;
@ -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)
@ -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);
}