summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc')
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc122
1 files changed, 48 insertions, 74 deletions
diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc
index 421cf1efb9d..0294c56b84f 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv2.sc
@@ -41,24 +41,11 @@ uniform vec4 u_tex_size0;
SAMPLER2D(decal, 0);
// Uncomment just one of the three params below to choose the corner detection
-#define CORNER_A
+//#define CORNER_A
//#define CORNER_B
-//#define CORNER_C
+#define CORNER_C
//#define CORNER_D
-const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
-const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
-const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
-const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
-const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
-const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
-const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
-const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
-const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
-const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
-
-const vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
-
vec4 df(vec4 A, vec4 B)
{
return abs(A - B);
@@ -66,43 +53,17 @@ vec4 df(vec4 A, vec4 B)
float c_df(vec3 c1, vec3 c2)
{
- vec3 df = abs(c1 - c2);
- return df.r + df.g + df.b;
-}
-
-vec4 ge(vec4 A, vec4 B)
-{
- return vec4(greaterThanEqual(A, B));
-}
-
-vec4 le(vec4 A, vec4 B)
-{
- return vec4(lessThanEqual(A, B));
-}
-
-vec4 lt(vec4 A, vec4 B)
-{
- return vec4(lessThan(A, B));
+ return dot(abs(c1 - c2), vec3(1.0, 1.0, 1.0));
}
vec4 eq(vec4 A, vec4 B)
{
- return vec4(equal(A, B));
-}
-
-vec4 ne(vec4 A, vec4 B)
-{
- return vec4(notEqual(A, B));
-}
-
-vec4 abslt(vec4 A, vec4 B)
-{
- return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+ return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
}
-vec4 absge(vec4 A, vec4 B)
+vec4 neq(vec4 A, vec4 B)
{
- return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
+ return vec4(greaterThanEqual(df(A, B), XBR_EQ_THRESHOLD.xxxx));
}
vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
@@ -112,6 +73,8 @@ vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, v
void main()
{
+ vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
+
vec4 delta = 1.0 / XBR_SCALE.xxxx;
vec4 deltaL = vec4(0.5, 1.0, 0.5, 1.0) / XBR_SCALE.xxxx;
vec4 deltaU = deltaL.yxwz;
@@ -146,42 +109,54 @@ void main()
vec4 F4 = texture2D(decal, v_texcoord7.xz);
vec4 I4 = texture2D(decal, v_texcoord7.xw);
- vec4 b = mul(mat4(B, D, H, F), XBR_Y_WEIGHT.xxxx * Y);
- vec4 c = mul(mat4(C, A, G, I), XBR_Y_WEIGHT.xxxx * Y);
- vec4 e = mul(mat4(E, E, E, E), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 weightVec = XBR_Y_WEIGHT.xxxx * Y;
+ vec4 b = instMul(weightVec, mat4(B, D, H, F));
+ vec4 c = instMul(weightVec, mat4(C, A, G, I));
+ vec4 e = instMul(weightVec, mat4(E, E, E, E));
vec4 d = b.yzwx;
vec4 f = b.wxyz;
vec4 g = c.zwxy;
vec4 h = b.zwxy;
vec4 i = c.wxyz;
- vec4 i4 = mul(mat4(I4, C1, A0, G5), XBR_Y_WEIGHT.xxxx * Y);
- vec4 i5 = mul(mat4(I5, C4, A1, G0), XBR_Y_WEIGHT.xxxx * Y);
- vec4 h5 = mul(mat4(H5, F4, B1, D0), XBR_Y_WEIGHT.xxxx * Y);
+ vec4 i4 = instMul(weightVec, mat4(I4, C1, A0, G5));
+ vec4 i5 = instMul(weightVec, mat4(I5, C4, A1, G0));
+ vec4 h5 = instMul(weightVec, mat4(H5, F4, B1, D0));
vec4 f4 = h5.yzwx;
+ vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
+ vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
+ vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
+ vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
+ vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
+ vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
+ vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
+ vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
+
// These inequations define the line below which interpolation occurs.
vec4 fx = (Ao*fp.y+Bo*fp.x);
vec4 fx_left = (Ax*fp.y+Bx*fp.x);
vec4 fx_up = (Ay*fp.y+By*fp.x);
- vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
+ vec4 interp_restriction_lv0 = vec4(notEqual(e,f)) * vec4(notEqual(e,h));
vec4 interp_restriction_lv1 = interp_restriction_lv0;
#ifdef CORNER_B
- interp_restriction_lv1 = (interp_restriction_lv0 * ( ge(f,b) * ge(h,d) + lt(e,i) * ge(f,i4) * ge(h,i5) + lt(e,g) + lt(e,c) ) );
+ interp_restriction_lv1 = (interp_restriction_lv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) );
#endif
#ifdef CORNER_D
vec4 c1 = i4.yzwx;
vec4 g0 = i5.wxyz;
- interp_restriction_lv1 = (interp_restriction_lv0 * ( ge(f,b) * ge(h,d) + lt(e,i) * ge(f,i4) * ge(h,i5) + lt(e,g) + lt(e,c) ) * (ne(f,f4) * ne(f,i) + ne(h,h5) * ne(h,i) + ne(h,g) + ne(f,c) + lt(b,c1) * lt(d,g0)));
+ interp_restriction_lv1 = (interp_restriction_lv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (vec4(notEqual(f,f4)) * vec4(notEqual(f,i)) + vec4(notEqual(h,h5)) * vec4(notEqual(h,i)) + vec4(notEqual(h,g)) + vec4(notEqual(f,c)) + eq(b,c1) * eq(d,g0)));
#endif
#ifdef CORNER_C
- interp_restriction_lv1 = (interp_restriction_lv0 * ( ge(f,b) * ge(f,c) + ge(h,d) * ge(h,g) + lt(e,i) * (ge(f,f4) * ge(f,i4) + ge(h,h5) * ge(h,i5)) + lt(e,g) + lt(e,c)) );
+ interp_restriction_lv1 = (interp_restriction_lv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) );
#endif
- vec4 interp_restriction_lv2_left = (ne(e,g) * ne(d,g));
- vec4 interp_restriction_lv2_up = (ne(e,c) * ne(b,c));
+ vec4 interp_restriction_lv2_left = vec4(notEqual(e,g)) * vec4(notEqual(d,g));
+ vec4 interp_restriction_lv2_up = vec4(notEqual(e,c)) * vec4(notEqual(b,c));
vec4 fx45i = saturate((fx + delta -Co - Ci) / (2.0 * delta ));
vec4 fx45 = saturate((fx + delta -Co ) / (2.0 * delta ));
@@ -191,26 +166,25 @@ void main()
vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f);
vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i);
- vec4 one = vec4(1.0, 1.0, 1.0, 1.0);
- vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
- vec4 edri = le(wd1,wd2) * interp_restriction_lv0;
- vec4 edr = lt(wd1,wd2) * interp_restriction_lv1;
+ vec4 edri = vec4(lessThanEqual(wd1,wd2)) * interp_restriction_lv0;
+ vec4 edr = vec4(lessThan(wd1,wd2)) * interp_restriction_lv1;
+ vec4 hcDiff = df(h,c);
+ vec4 fgDiff = df(f,g);
#ifdef CORNER_A
- edr = clamp(edr * ((one - edri.yzwx) + (one - edri.wxyz)), 0.0, 1.0);
- vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr * (one - edri.yzwx) * eq(e,c);
- vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr * (one - edri.wxyz) * eq(e,g);
-#endif
-#ifndef CORNER_A
- vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr;
- vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr;
+ edr = edr * clamp(((1.0 - edri.yzwx) + (1.0 - edri.wxyz)), 0.0, 1.0);
+ vec4 edr_left = vec4(lessThanEqual(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c))) * interp_restriction_lv2_left * edr * (1.0 - edri.yzwx) * eq(e,c);
+ vec4 edr_up = vec4(greaterThanEqual(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c))) * interp_restriction_lv2_up * edr * (1.0 - edri.wxyz) * eq(e,g);
+#else
+ vec4 edr_left = vec4(lessThanEqual(XBR_LV2_COEFFICIENT.xxxx * fgDiff, hcDiff)) * interp_restriction_lv2_left * edr;
+ vec4 edr_up = vec4(greaterThanEqual(fgDiff, XBR_LV2_COEFFICIENT.xxxx * hcDiff)) * interp_restriction_lv2_up * edr;
#endif
- fx45 = edr * fx45;
- fx30 = edr_left * fx30;
- fx60 = edr_up * fx60;
- fx45i = edri * fx45i;
+ fx45 = clamp(edr, 0.0, 1.0) * fx45;
+ fx30 = clamp(edr_left, 0.0, 1.0) * fx30;
+ fx60 = clamp(edr_up, 0.0, 1.0) * fx60;
+ fx45i = clamp(edri, 0.0, 1.0) * fx45i;
- vec4 px = le(df(e,f), df(e,h));
+ vec4 px = vec4(lessThanEqual(df(e,f), df(e,h)));
vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
@@ -222,7 +196,7 @@ void main()
res2 = mix(res2, mix(F.xyz, B.xyz, px.y), maximos.y);
res2 = mix(res2, mix(D.xyz, H.xyz, px.w), maximos.w);
- vec3 E_mix = (c_df(E.xyz, res2) >= c_df(E.xyz, res1)) ? one.xyz : zero.xyz;
+ vec3 E_mix = (c_df(E.xyz, res2) >= c_df(E.xyz, res1)) ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
vec3 res = mix(res1, res2, E_mix);
gl_FragColor = vec4(res, 1.0);