mirror of
https://github.com/holub/mame
synced 2025-04-19 07:00:31 +03:00
-bgfx: Fixed the following xBR shaders: xBR-lv2-fast, xBR-lv2-noblend, xBR-lv2, xBR-lv3-noblend, and xBR-lv3. [Ryan Holtz]
This commit is contained in:
parent
1c5d2e9466
commit
8496545170
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
{
|
||||
"name": "xBR-lv2-3d",
|
||||
"name": "xBR-lv2 3D",
|
||||
"author": "Hyllian",
|
||||
"passes": [
|
||||
{
|
||||
|
@ -29,13 +29,6 @@
|
||||
{
|
||||
"name": "xBR-lv2 Fast",
|
||||
"author": "Hyllian",
|
||||
"targets": [
|
||||
{
|
||||
"name": "internal",
|
||||
"mode": "guest",
|
||||
"doublebuffer": true
|
||||
}
|
||||
],
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-fast",
|
||||
@ -43,14 +36,6 @@
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
],
|
||||
"output": "internal"
|
||||
},
|
||||
{
|
||||
"effect": "misc/blit",
|
||||
"name": "Upscale",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "target": "internal" }
|
||||
],
|
||||
"output": "output"
|
||||
}
|
||||
]
|
||||
|
@ -29,13 +29,6 @@
|
||||
{
|
||||
"name": "xBR-lv2 No Blend",
|
||||
"author": "Hyllian",
|
||||
"targets": [
|
||||
{
|
||||
"name": "internal",
|
||||
"mode": "guest",
|
||||
"doublebuffer": true
|
||||
}
|
||||
],
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-noblend",
|
||||
@ -43,14 +36,6 @@
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
],
|
||||
"output": "internal"
|
||||
},
|
||||
{
|
||||
"effect": "misc/blit",
|
||||
"name": "Upscale",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "target": "internal" }
|
||||
],
|
||||
"output": "output"
|
||||
}
|
||||
]
|
||||
|
@ -29,13 +29,6 @@
|
||||
{
|
||||
"name": "xBR-lv2",
|
||||
"author": "Hyllian",
|
||||
"targets": [
|
||||
{
|
||||
"name": "internal",
|
||||
"mode": "guest",
|
||||
"doublebuffer": true
|
||||
}
|
||||
],
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2",
|
||||
@ -43,14 +36,6 @@
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
],
|
||||
"output": "internal"
|
||||
},
|
||||
{
|
||||
"effect": "misc/blit",
|
||||
"name": "Upscale",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "target": "internal" }
|
||||
],
|
||||
"output": "output"
|
||||
}
|
||||
]
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
$input v_texcoord0, v_texcoord1, v_color0
|
||||
$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
|
||||
|
||||
// license:MIT
|
||||
// copyright-holders:Hyllian
|
||||
@ -51,19 +51,6 @@ SAMPLER2D(decal, 0);
|
||||
#define SMOOTH_TIPS
|
||||
#endif
|
||||
|
||||
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);
|
||||
@ -71,43 +58,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));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 ne(vec4 A, vec4 B)
|
||||
vec4 neq(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(notEqual(A, B));
|
||||
}
|
||||
|
||||
vec4 abslt(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge(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)
|
||||
@ -117,40 +78,47 @@ 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;
|
||||
|
||||
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy / XBR_RES.xx);
|
||||
|
||||
vec4 A1 = texture2D(decal, v_texcoord1.xw);
|
||||
vec4 B1 = texture2D(decal, v_texcoord1.yw);
|
||||
vec4 C1 = texture2D(decal, v_texcoord1.zw);
|
||||
|
||||
vec4 A = texture2D(decal, v_texcoord2.xw);
|
||||
vec4 B = texture2D(decal, v_texcoord2.yw);
|
||||
vec4 C = texture2D(decal, v_texcoord2.zw);
|
||||
|
||||
vec4 D = texture2D(decal, v_texcoord3.xw);
|
||||
vec4 E = texture2D(decal, v_texcoord3.yw);
|
||||
vec4 F = texture2D(decal, v_texcoord3.zw);
|
||||
|
||||
vec4 G = texture2D(decal, v_texcoord4.xw);
|
||||
vec4 H = texture2D(decal, v_texcoord4.yw);
|
||||
vec4 I = texture2D(decal, v_texcoord4.zw);
|
||||
|
||||
vec4 G5 = texture2D(decal, v_texcoord5.xw);
|
||||
vec4 H5 = texture2D(decal, v_texcoord5.yw);
|
||||
vec4 I5 = texture2D(decal, v_texcoord5.zw);
|
||||
|
||||
vec4 A0 = texture2D(decal, v_texcoord6.xy);
|
||||
vec4 D0 = texture2D(decal, v_texcoord6.xz);
|
||||
vec4 G0 = texture2D(decal, v_texcoord6.xw);
|
||||
|
||||
vec4 C4 = texture2D(decal, v_texcoord7.xy);
|
||||
vec4 F4 = texture2D(decal, v_texcoord7.xz);
|
||||
vec4 I4 = texture2D(decal, v_texcoord7.xw);
|
||||
|
||||
vec2 dx = vec2(XBR_RES.x / u_tex_size0.x, 0.0);
|
||||
vec2 dy = vec2(0.0, XBR_RES.x / u_tex_size0.y);
|
||||
|
||||
vec2 tex = (floor(v_texcoord0 * u_tex_size0.xy / XBR_RES.xx) + vec2(0.5, 0.5)) * XBR_RES.xx / u_tex_size0.xy;
|
||||
|
||||
vec2 dx = v_texcoord1.xy;
|
||||
vec2 dy = v_texcoord1.zw;
|
||||
|
||||
vec4 A = texture2D(decal, v_texcoord0 -dx -dy);
|
||||
vec4 B = texture2D(decal, v_texcoord0 -dy);
|
||||
vec4 C = texture2D(decal, v_texcoord0 +dx -dy);
|
||||
vec4 D = texture2D(decal, v_texcoord0 -dx );
|
||||
vec4 E = texture2D(decal, v_texcoord0 );
|
||||
vec4 F = texture2D(decal, v_texcoord0 +dx );
|
||||
vec4 G = texture2D(decal, v_texcoord0 -dx +dy);
|
||||
vec4 H = texture2D(decal, v_texcoord0 +dy);
|
||||
vec4 I = texture2D(decal, v_texcoord0 +dx +dy);
|
||||
|
||||
vec4 A1 = texture2D(decal, v_texcoord0 -dx -2.0*dy);
|
||||
vec4 B1 = texture2D(decal, v_texcoord0 -2.0*dy);
|
||||
vec4 C1 = texture2D(decal, v_texcoord0 +dx -2.0*dy);
|
||||
vec4 G5 = texture2D(decal, v_texcoord0 -dx +2.0*dy);
|
||||
vec4 H5 = texture2D(decal, v_texcoord0 +2.0*dy);
|
||||
vec4 I5 = texture2D(decal, v_texcoord0 +dx +2.0*dy);
|
||||
vec4 A0 = texture2D(decal, v_texcoord0 -2.0*dx -dy);
|
||||
vec4 D0 = texture2D(decal, v_texcoord0 -2.0*dx );
|
||||
vec4 G0 = texture2D(decal, v_texcoord0 -2.0*dx +dy);
|
||||
vec4 C4 = texture2D(decal, v_texcoord0 +2.0*dx -dy);
|
||||
vec4 F4 = texture2D(decal, v_texcoord0 +2.0*dx );
|
||||
vec4 I4 = texture2D(decal, v_texcoord0 +2.0*dx +dy);
|
||||
|
||||
vec4 F6 = texture2D(decal, tex +dx+0.25*dx+0.25*dy);
|
||||
vec4 F7 = texture2D(decal, tex +dx+0.25*dx-0.25*dy);
|
||||
vec4 F8 = texture2D(decal, tex +dx-0.25*dx-0.25*dy);
|
||||
@ -171,53 +139,66 @@ void main()
|
||||
vec4 H8 = texture2D(decal, tex -0.25*dx-0.25*dy+dy);
|
||||
vec4 H9 = texture2D(decal, tex -0.25*dx+0.25*dy+dy);
|
||||
|
||||
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 f0 = mul(mat4(F6, B6, D6, H6), XBR_Y_WEIGHT.xxxx * Y);
|
||||
vec4 f1 = mul(mat4(F7, B7, D7, H7), XBR_Y_WEIGHT.xxxx * Y);
|
||||
vec4 f2 = mul(mat4(F8, B8, D8, H8), XBR_Y_WEIGHT.xxxx * Y);
|
||||
vec4 f3 = mul(mat4(F9, B9, D9, H9), XBR_Y_WEIGHT.xxxx * Y);
|
||||
vec4 f0 = instMul(weightVec, mat4(F6, B6, D6, H6));
|
||||
vec4 f1 = instMul(weightVec, mat4(F7, B7, D7, H7));
|
||||
vec4 f2 = instMul(weightVec, mat4(F8, B8, D8, H8));
|
||||
vec4 f3 = instMul(weightVec, mat4(F9, B9, D9, H9));
|
||||
|
||||
vec4 h0 = f0.wxyz;
|
||||
vec4 h1 = f1.wxyz;
|
||||
vec4 h2 = f2.wxyz;
|
||||
vec4 h3 = f3.wxyz;
|
||||
|
||||
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 block_3d = (eq(f0,f1) * eq(f1,f2) * eq(f2,f3) * eq(h0,h1) * eq(h1,h2) * eq(h2,h3));
|
||||
vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h) * block_3d);
|
||||
vec4 block_3d = vec4(equal(f0,f1)) * vec4(equal(f1,f2)) * vec4(equal(f2,f3)) * vec4(equal(h0,h1)) * vec4(equal(h1,h2)) * vec4(equal(h2,h3));
|
||||
vec4 interp_restriction_lv0 = vec4(notEqual(e,f)) * vec4(notEqual(e,h)) * block_3d;
|
||||
vec4 interp_restriction_lv1 = interp_restriction_lv0;
|
||||
|
||||
#ifdef CORNER_B
|
||||
interp_restriction_lv1 = (interp_restriction_lv0 * (ge(f,b) * ge(h,d) + eq(e,i) * ge(f,i4) * ge(h,i5) + eq(e,g) + eq(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) + eq(e,i) * ge(f,i4) * ge(h,i5) + eq(e,g) + eq(e,c) ) * (ne(f,f4) * ne(f,i) + ne(h,h5) * ne(h,i) + ne(h,g) + ne(f,c) + eq(b,c1) * eq(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) + eq(e,i) * (ge(f,f4) * ge(f,i4) + ge(h,h5) * ge(h,i5)) + eq(e,g) + eq(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
|
||||
//interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
|
||||
|
||||
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 ));
|
||||
@ -227,17 +208,19 @@ 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 edri = le(wd1,wd2) * interp_restriction_lv0;
|
||||
vec4 edr = lt(wd1,wd2) * interp_restriction_lv1;
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
|
||||
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,f3), df(e,h1));
|
||||
vec4 px = vec4(lessThanEqual(df(e,f3), df(e,h1)));
|
||||
|
||||
#ifdef SMOOTH_TIPS
|
||||
vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
|
||||
|
@ -50,19 +50,6 @@ SAMPLER2D(decal, 0);
|
||||
#define SMOOTH_TIPS
|
||||
#endif
|
||||
|
||||
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);
|
||||
@ -70,43 +57,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));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 ne(vec4 A, vec4 B)
|
||||
vec4 neq(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(notEqual(A, B));
|
||||
}
|
||||
|
||||
vec4 abslt(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge(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)
|
||||
@ -117,6 +78,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;
|
||||
@ -135,9 +98,10 @@ void main()
|
||||
vec4 H = texture2D(decal, v_texcoord3.yw);
|
||||
vec4 I = texture2D(decal, v_texcoord3.zw);
|
||||
|
||||
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 a = c.yzwx;
|
||||
vec4 d = b.yzwx;
|
||||
vec4 f = b.wxyz;
|
||||
@ -145,20 +109,31 @@ void main()
|
||||
vec4 h = b.zwxy;
|
||||
vec4 i = c.wxyz;
|
||||
|
||||
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_lv1 = interp_restriction_lv0;
|
||||
vec4 interp_restriction_lv0 = vec4(notEqual(e,f)) * vec4(notEqual(e,h));
|
||||
vec4 interp_restriction_lv1 = interp_restriction_lv0;
|
||||
|
||||
#ifndef CORNER_A
|
||||
interp_restriction_lv1 = clamp(interp_restriction_lv0 * (ge(f,b) * ge(f,c) + ge(h,d) * ge(h,g) + lt(e,g) + lt(e,c)), 0.0, 1.0);
|
||||
interp_restriction_lv1 = clamp(interp_restriction_lv0 * (neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,g) + eq(e,c)), 0.0, 1.0);
|
||||
#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 ));
|
||||
@ -168,17 +143,19 @@ void main()
|
||||
vec4 wd1 = weighted_distance( d, b, g, e, e, c, h, f);
|
||||
vec4 wd2 = weighted_distance( a, e, b, f, d, h, e, i);
|
||||
|
||||
vec4 edri = le(wd1, wd2) * interp_restriction_lv0;
|
||||
vec4 edr = lt(wd1, wd2) * interp_restriction_lv1;
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
|
||||
fx45 = edr * fx45;
|
||||
fx30 = edr_left * fx30;
|
||||
fx60 = edr_up * fx60;
|
||||
fx45i = edri * fx45i;
|
||||
|
||||
vec4 px = le(df(e,f), df(e,h));
|
||||
vec4 px = vec4(lessThanEqual(df(e,f), df(e,h)));
|
||||
|
||||
#ifdef SMOOTH_TIPS
|
||||
vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
|
||||
|
@ -44,8 +44,6 @@ SAMPLER2D(decal, 0);
|
||||
//#define CORNER_C
|
||||
//#define CORNER_D
|
||||
|
||||
const vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
|
||||
|
||||
vec4 df(vec4 A, vec4 B)
|
||||
{
|
||||
return abs(A - B);
|
||||
@ -53,48 +51,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));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 ne(vec4 A, vec4 B)
|
||||
vec4 neq(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(notEqual(A, B));
|
||||
}
|
||||
|
||||
vec4 gt(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(greaterThan(A, B));
|
||||
}
|
||||
|
||||
vec4 abslt(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge(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)
|
||||
@ -104,6 +71,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);
|
||||
|
||||
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
|
||||
|
||||
vec4 A1 = texture2D(decal, v_texcoord1.xw);
|
||||
@ -134,18 +103,18 @@ void main()
|
||||
vec4 F4 = texture2D(decal, v_texcoord7.xz);
|
||||
vec4 I4 = texture2D(decal, v_texcoord7.xw);
|
||||
|
||||
vec4 b = mul(mat4(B, D, H, F), Y);
|
||||
vec4 c = mul(mat4(C, A, G, I), Y);
|
||||
vec4 e = mul(mat4(E, E, E, E), Y);
|
||||
vec4 b = instMul(Y, mat4(B, D, H, F));
|
||||
vec4 c = instMul(Y, mat4(C, A, G, I));
|
||||
vec4 e = instMul(Y, 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), Y);
|
||||
vec4 i5 = mul(mat4(I5, C4, A1, G0), Y);
|
||||
vec4 h5 = mul(mat4(H5, F4, B1, D0), Y);
|
||||
vec4 i4 = instMul(Y, mat4(I4, C1, A0, G5));
|
||||
vec4 i5 = instMul(Y, mat4(I5, C4, A1, G0));
|
||||
vec4 h5 = instMul(Y, mat4(H5, F4, B1, D0));
|
||||
vec4 f4 = h5.yzwx;
|
||||
|
||||
vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
@ -159,49 +128,47 @@ void main()
|
||||
vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
|
||||
|
||||
// These inequations define the line below which interpolation occurs.
|
||||
vec4 fx = gt(Ao * fp.y + Bo * fp.x, Co);
|
||||
vec4 fx_left = gt(Ax * fp.y + Bx * fp.x, Cx);
|
||||
vec4 fx_up = gt(Ay * fp.y + By * fp.x, Cy);
|
||||
vec4 fx = vec4(greaterThan(Ao * fp.y + Bo * fp.x, Co));
|
||||
vec4 fx_left = vec4(greaterThan(Ax * fp.y + Bx * fp.x, Cx));
|
||||
vec4 fx_up = vec4(greaterThan(Ay * fp.y + By * fp.x, Cy));
|
||||
|
||||
#ifdef CORNER_A
|
||||
vec4 interp_restriction_lv1 = ne(e,f) * ne(e,h);
|
||||
vec4 interp_restriction_lv1 = vec4(notEqual(e,f)) * vec4(notEqual(e,h));
|
||||
#endif
|
||||
#ifdef CORNER_B
|
||||
vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (ge(f,b) * ge(h,d) + lt(e,i) * ge(f,i4) * ge(h,i5) + lt(e,g) + lt(e,c)));
|
||||
vec4 interp_restriction_lv1 = (vec4(notEqual(e,f)) * vec4(notEqual(e,h)) * (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;
|
||||
vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (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)));
|
||||
vec4 interp_restriction_lv1 = (vec4(notEqual(e,f)) * vec4(notEqual(e,h)) * (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
|
||||
vec4 interp_restriction_lv1 = (ne(e,f) * ne(e,h) * (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)));
|
||||
vec4 interp_restriction_lv1 = (vec4(notEqual(e,f)) * vec4(notEqual(e,h)) * (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
|
||||
|
||||
interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
|
||||
|
||||
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 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_lv1;
|
||||
vec4 edr = lt(wd1,wd2) * interp_restriction_lv1 * ((one - edri.yzwx) + (one - edri.wxyz));
|
||||
vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left * edr * ((one - edri.yzwx) * lt(e,c));
|
||||
vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr * ((one - edri.wxyz) * lt(e,g));
|
||||
vec4 edri = vec4(lessThanEqual(wd1,wd2)) * interp_restriction_lv1;
|
||||
vec4 edr = vec4(lessThan(wd1,wd2)) * interp_restriction_lv1 * 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);
|
||||
|
||||
|
||||
vec4 nc = clamp(edr * (fx + edr_left * fx_left + edr_up * fx_up), 0.0, 1.0);
|
||||
|
||||
vec4 px = le(df(e,f), df(e,h));
|
||||
bvec4 px = lessThanEqual(df(e,f), df(e,h));
|
||||
|
||||
vec3 res1 = nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : E.xyz;
|
||||
vec3 res2 = nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : E.xyz;
|
||||
vec3 res1 = nc.x > 0.0 ? px.x ? F.xyz : H.xyz : nc.y > 0.0 ? px.y ? B.xyz : F.xyz : nc.z > 0.0 ? px.z ? D.xyz : B.xyz : E.xyz;
|
||||
vec3 res2 = nc.w > 0.0 ? px.w ? H.xyz : D.xyz : nc.z > 0.0 ? px.z ? D.xyz : B.xyz : nc.y > 0.0 ? px.y ? B.xyz : F.xyz : E.xyz;
|
||||
|
||||
vec2 df12 = abs(mul(mat3(res1, res2, vec3(0.0, 0.0, 0.0)), Y.xyz).xy - e.xy);
|
||||
vec2 df12 = abs(instMul(Y.xyz, mat3(res1, res2, vec3(0.0, 0.0, 0.0))).xy - e.xy);
|
||||
|
||||
vec3 res_mix = (df12.y >= df12.x) ? vec3(1.0, 1.0, 1.0) : vec3(0.0, 0.0, 0.0);
|
||||
vec3 res = mix(res1, res2, res_mix);
|
||||
|
@ -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));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 ne(vec4 A, vec4 B)
|
||||
vec4 neq(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(notEqual(A, B));
|
||||
}
|
||||
|
||||
vec4 abslt(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge(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);
|
||||
|
@ -39,13 +39,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
|
||||
// Uncomment just one of the four params below to choose the corner detection
|
||||
//#define CORNER_A
|
||||
//#define CORNER_B
|
||||
//#define CORNER_C
|
||||
//#define CORNER_D
|
||||
|
||||
const vec4 Y = vec4(0.2126, 0.7152, 0.0722, 0.0);
|
||||
#define CORNER_D
|
||||
|
||||
vec4 df(vec4 A, vec4 B)
|
||||
{
|
||||
@ -54,53 +52,27 @@ 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));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 ne(vec4 A, vec4 B)
|
||||
vec4 eq2(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(notEqual(A, B));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD2.xxxx));
|
||||
}
|
||||
|
||||
vec4 gt(vec4 A, vec4 B)
|
||||
vec4 neq(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(greaterThan(A, B));
|
||||
return vec4(greaterThanEqual(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 abslt2(vec4 A, vec4 B)
|
||||
vec4 neq2(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD2.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge(vec4 A, vec4 B)
|
||||
{
|
||||
return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge2(vec4 A, vec4 B)
|
||||
{
|
||||
return ge(df(A, B), XBR_EQ_THRESHOLD2.xxxx);
|
||||
return vec4(greaterThanEqual(df(A, B), XBR_EQ_THRESHOLD2.xxxx));
|
||||
}
|
||||
|
||||
vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
|
||||
@ -110,6 +82,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);
|
||||
|
||||
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
|
||||
|
||||
vec4 A1 = texture2D(decal, v_texcoord1.xw);
|
||||
@ -140,18 +114,18 @@ void main()
|
||||
vec4 F4 = texture2D(decal, v_texcoord7.xz);
|
||||
vec4 I4 = texture2D(decal, v_texcoord7.xw);
|
||||
|
||||
vec4 b = mul(mat4(B, D, H, F), Y);
|
||||
vec4 c = mul(mat4(C, A, G, I), Y);
|
||||
vec4 e = mul(mat4(E, E, E, E), Y);
|
||||
vec4 b = instMul(Y, mat4(B, D, H, F));
|
||||
vec4 c = instMul(Y, mat4(C, A, G, I));
|
||||
vec4 e = instMul(Y, 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), Y);
|
||||
vec4 i5 = mul(mat4(I5, C4, A1, G0), Y);
|
||||
vec4 h5 = mul(mat4(H5, F4, B1, D0), Y);
|
||||
vec4 i4 = instMul(Y, mat4(I4, C1, A0, G5));
|
||||
vec4 i5 = instMul(Y, mat4(I5, C4, A1, G0));
|
||||
vec4 h5 = instMul(Y, mat4(H5, F4, B1, D0));
|
||||
vec4 f4 = h5.yzwx;
|
||||
|
||||
vec4 c4 = i5.yzwx;
|
||||
@ -181,50 +155,55 @@ void main()
|
||||
vec4 Cw = vec4( 5.0, -1.0, -3.0, 3.0 );
|
||||
|
||||
// These inequations define the line below which interpolation occurs.
|
||||
vec4 fx = gt(Ao * fp.y + Bo * fp.x, Co);
|
||||
vec4 fx_left = gt(Ax * fp.y + Bx * fp.x, Cx);
|
||||
vec4 fx_up = gt(Ay * fp.y + By * fp.x, Cy);
|
||||
vec4 fx3_left= gt(Az * fp.y + Bz * fp.x, Cz);
|
||||
vec4 fx3_up = gt(Aw * fp.y + Bw * fp.x, Cw);
|
||||
vec4 fx = vec4(greaterThan(Ao * fp.y + Bo * fp.x, Co));
|
||||
vec4 fx_left = vec4(greaterThan(Ax * fp.y + Bx * fp.x, Cx));
|
||||
vec4 fx_up = vec4(greaterThan(Ay * fp.y + By * fp.x, Cy));
|
||||
vec4 fx3_left= vec4(greaterThan(Az * fp.y + Bz * fp.x, Cz));
|
||||
vec4 fx3_up = vec4(greaterThan(Aw * fp.y + Bw * fp.x, Cw));
|
||||
|
||||
vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
|
||||
vec4 interp_restriction_lv0 = (vec4(notEqual(e,f)) * vec4(notEqual(e,h)));
|
||||
|
||||
// It uses CORNER_C if none of the others are defined.
|
||||
#ifdef CORNER_A
|
||||
vec4 interp_restriction_lv1 = interp_restriction_lv0;
|
||||
#elif CORNER_B
|
||||
vec4 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)));
|
||||
vec4 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)));
|
||||
#elif CORNER_D
|
||||
vec4 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)));
|
||||
vec4 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)));
|
||||
#elif CORNER_C
|
||||
vec4 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)));
|
||||
vec4 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
|
||||
|
||||
interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
|
||||
|
||||
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_lv3_left = abslt2(g,g0) * absge2(d0,g0);
|
||||
vec4 interp_restriction_lv3_up = abslt2(c,c1) * absge2(b1,c1);
|
||||
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 interp_restriction_lv3_left = eq2(g,g0) * vec4(notEqual(d0,g0));
|
||||
vec4 interp_restriction_lv3_up = eq2(c,c1) * vec4(notEqual(b1,c1));
|
||||
|
||||
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_lv1;
|
||||
vec4 edr = clamp(lt(wd1,wd2) * interp_restriction_lv1 * ((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) * lt(e,c);
|
||||
vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up * edr * (one - edri.wxyz) * lt(e,g);
|
||||
|
||||
vec4 edri = vec4(lessThanEqual(wd1,wd2)) * interp_restriction_lv1;
|
||||
vec4 edr = vec4(lessThan(wd1,wd2)) * interp_restriction_lv1 * ((1.0 - edri.yzwx) + (1.0 - edri.wxyz));
|
||||
edr = clamp(edr, 0.0, 1.0);
|
||||
|
||||
vec4 hcDiff = df(h,c);
|
||||
vec4 fgDiff = df(f,g);
|
||||
vec4 edr_left = vec4(lessThanEqual(XBR_LV2_COEFFICIENT.xxxx * fgDiff, hcDiff)) * interp_restriction_lv2_left * edr * (1.0 - edri.yzwx) * eq(e,c);
|
||||
vec4 edr_up = vec4(greaterThanEqual(fgDiff, XBR_LV2_COEFFICIENT.xxxx * hcDiff)) * interp_restriction_lv2_up * edr * (1.0 - edri.wxyz) * eq(e,g);
|
||||
vec4 edr3_left = interp_restriction_lv3_left;
|
||||
vec4 edr3_up = interp_restriction_lv3_up;
|
||||
|
||||
vec4 nc = clamp((edr * fx + edr_left * (fx_left + edr3_left * fx3_left * lt(e,c4)) + edr_up * (fx_up + edr3_up * fx3_up * lt(e,g5))), 0.0, 1.0);
|
||||
vec4 nc = edr * (fx + edr_left * (fx_left + edr3_left * fx3_left * eq(e,c4)) + edr_up * (fx_up + edr3_up * fx3_up * eq(e,g5)));
|
||||
|
||||
vec4 px = le(df(e,f), df(e,h));
|
||||
bvec4 px = lessThanEqual(df(e,f), df(e,h));
|
||||
|
||||
vec3 res1 = nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : E.xyz;
|
||||
vec3 res2 = nc.w > 0.0 ? px.w > 0.0 ? H.xyz : D.xyz : nc.z > 0.0 ? px.z > 0.0 ? D.xyz : B.xyz : nc.y > 0.0 ? px.y > 0.0 ? B.xyz : F.xyz : nc.x > 0.0 ? px.x > 0.0 ? F.xyz : H.xyz : E.xyz;
|
||||
vec3 res1 = nc.x > 0.0 ? px.x ? F.xyz : H.xyz : nc.y > 0.0 ? px.y ? B.xyz : F.xyz : nc.z > 0.0 ? px.z ? D.xyz : B.xyz : nc.w > 0.0 ? px.w ? H.xyz : D.xyz : E.xyz;
|
||||
vec3 res2 = nc.w > 0.0 ? px.w ? H.xyz : D.xyz : nc.z > 0.0 ? px.z ? D.xyz : B.xyz : nc.y > 0.0 ? px.y ? B.xyz : F.xyz : nc.x > 0.0 ? px.x ? F.xyz : H.xyz : E.xyz;
|
||||
|
||||
vec2 df12 = abs(mul(mat3(res1, res2, zero.xyz), Y.xyz).xy - e.xy);
|
||||
|
||||
|
@ -38,10 +38,13 @@ uniform vec4 XBR_LV2_COEFFICIENT;
|
||||
|
||||
uniform vec4 u_tex_size0;
|
||||
|
||||
SAMPLER2D(decal, 0);
|
||||
// Uncomment just one of the four params below to choose the corner detection
|
||||
//#define CORNER_A
|
||||
//#define CORNER_B
|
||||
#define CORNER_C
|
||||
//#define CORNER_D
|
||||
|
||||
const vec4 yuv = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
|
||||
SAMPLER2D(decal, 0);
|
||||
|
||||
vec4 df(vec4 A, vec4 B)
|
||||
{
|
||||
@ -50,53 +53,27 @@ 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));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 ne(vec4 A, vec4 B)
|
||||
vec4 eq2(vec4 A, vec4 B)
|
||||
{
|
||||
return vec4(notEqual(A, B));
|
||||
return vec4(lessThan(df(A, B), XBR_EQ_THRESHOLD2.xxxx));
|
||||
}
|
||||
|
||||
vec4 abslt(vec4 A, vec4 B)
|
||||
vec4 neq(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
return vec4(greaterThanEqual(df(A, B), XBR_EQ_THRESHOLD.xxxx));
|
||||
}
|
||||
|
||||
vec4 abslt2(vec4 A, vec4 B)
|
||||
vec4 neq2(vec4 A, vec4 B)
|
||||
{
|
||||
return lt(df(A, B), XBR_EQ_THRESHOLD2.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge(vec4 A, vec4 B)
|
||||
{
|
||||
return ge(df(A, B), XBR_EQ_THRESHOLD.xxxx);
|
||||
}
|
||||
|
||||
vec4 absge2(vec4 A, vec4 B)
|
||||
{
|
||||
return ge(df(A, B), XBR_EQ_THRESHOLD2.xxxx);
|
||||
return vec4(greaterThanEqual(df(A, B), XBR_EQ_THRESHOLD2.xxxx));
|
||||
}
|
||||
|
||||
vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
|
||||
@ -106,6 +83,9 @@ vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, v
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 yuv = vec4(0.299, 0.587, 0.114, 0.0);
|
||||
vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
|
||||
|
||||
vec2 fp = fract(v_texcoord0 * u_tex_size0.xy);
|
||||
|
||||
vec4 A1 = texture2D(decal, v_texcoord1.xw);
|
||||
@ -136,18 +116,19 @@ 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 * yuv);
|
||||
vec4 c = mul(mat4(C, A, G, I), XBR_Y_WEIGHT.xxxx * yuv);
|
||||
vec4 e = mul(mat4(E, E, E, E), XBR_Y_WEIGHT.xxxx * yuv);
|
||||
vec4 weightVec = XBR_Y_WEIGHT.xxxx * yuv;
|
||||
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 * yuv);
|
||||
vec4 i5 = mul(mat4(I5, C4, A1, G0), XBR_Y_WEIGHT.xxxx * yuv);
|
||||
vec4 h5 = mul(mat4(H5, F4, B1, D0), XBR_Y_WEIGHT.xxxx * yuv);
|
||||
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 c1 = i4.yzwx;
|
||||
@ -179,25 +160,25 @@ void main()
|
||||
vec4 fx3_left= (Az * fp.y + Bz * fp.x);
|
||||
vec4 fx3_up = (Aw * fp.y + Bw * fp.x);
|
||||
|
||||
vec4 interp_restriction_lv0 = (ne(e,f) * ne(e,h));
|
||||
vec4 interp_restriction_lv0 = (vec4(notEqual(e,f)) * vec4(notEqual(e,h)));
|
||||
|
||||
// It uses CORNER_C if none of the others are defined.
|
||||
#ifdef CORNER_A
|
||||
vec4 interp_restriction_lv1 = interp_restriction_lv0;
|
||||
#elif CORNER_B
|
||||
vec4 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) ) );
|
||||
vec4 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) ) );
|
||||
#elif CORNER_D
|
||||
vec4 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) ) * (f!=f4 * f!=i + h!=h5 * h!=i + h!=g + f!=c + lt(b,c1) * lt(d,g0)));
|
||||
vec4 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)));
|
||||
#else
|
||||
vec4 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)) );
|
||||
vec4 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
|
||||
|
||||
interp_restriction_lv1 = clamp(interp_restriction_lv1, 0.0, 1.0);
|
||||
|
||||
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_lv3_left = abslt2(g,g0) * absge2(d0,g0);
|
||||
vec4 interp_restriction_lv3_up = abslt2(c,c1) * absge2(b1,c1);
|
||||
|
||||
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 interp_restriction_lv3_left = eq2(g,g0) * neq2(d0,g0);
|
||||
vec4 interp_restriction_lv3_up = eq2(c,c1) * neq2(b1,c1);
|
||||
|
||||
vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
|
||||
vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
|
||||
@ -205,22 +186,22 @@ void main()
|
||||
vec4 fx15 = smoothstep(Cz - delta, Cz + delta, fx3_left);
|
||||
vec4 fx75 = smoothstep(Cw - delta, Cw + delta, fx3_up);
|
||||
|
||||
vec4 edr = lt(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)) * interp_restriction_lv1;
|
||||
vec4 edr_left = le(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c)) * interp_restriction_lv2_left;
|
||||
vec4 edr_up = ge(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c)) * interp_restriction_lv2_up;
|
||||
vec4 edr = vec4(lessThan(weighted_distance(e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i))) * interp_restriction_lv1;
|
||||
vec4 edr_left = vec4(lessThanEqual(XBR_LV2_COEFFICIENT.xxxx * df(f,g), df(h,c))) * interp_restriction_lv2_left;
|
||||
vec4 edr_up = vec4(greaterThanEqual(df(f,g), XBR_LV2_COEFFICIENT.xxxx * df(h,c))) * interp_restriction_lv2_up;
|
||||
|
||||
vec4 edr3_left = interp_restriction_lv3_left;
|
||||
vec4 edr3_up = interp_restriction_lv3_up;
|
||||
|
||||
vec4 nc45 = edr * fx45;
|
||||
vec4 nc30 = edr * edr_left * fx30;
|
||||
vec4 nc60 = edr * edr_up * fx60;
|
||||
vec4 nc15 = edr * edr_left * edr3_left * fx15;
|
||||
vec4 nc75 = edr * edr_up * edr3_up * fx75;
|
||||
vec4 nc45 = (edr * fx45);
|
||||
vec4 nc30 = (edr * edr_left * fx30);
|
||||
vec4 nc60 = (edr * edr_up * fx60);
|
||||
vec4 nc15 = (edr * edr_left * edr3_left * fx15);
|
||||
vec4 nc75 = (edr * edr_up * edr3_up * fx75);
|
||||
|
||||
vec4 px = le(df(e,f), df(e,h));
|
||||
bvec4 px = lessThanEqual(df(e,f), df(e,h));
|
||||
|
||||
vec4 nc = nc75 + nc15 + nc30 + nc60 + nc45;
|
||||
vec4 nc = clamp(nc75 + nc15 + nc30 + nc60 + nc45, 0.0, 1.0);
|
||||
|
||||
vec4 final45 = nc45 * fx45;
|
||||
vec4 final30 = nc30 * fx30;
|
||||
@ -232,17 +213,17 @@ void main()
|
||||
|
||||
float blend1;
|
||||
vec3 pix1;
|
||||
if (nc.x > 0.0) {pix1 = px.x > 0.0 ? F.xyz : H.xyz; blend1 = maximo.x;}
|
||||
else if (nc.y > 0.0) {pix1 = px.y > 0.0 ? B.xyz : F.xyz; blend1 = maximo.y;}
|
||||
else if (nc.z > 0.0) {pix1 = px.z > 0.0 ? D.xyz : B.xyz; blend1 = maximo.z;}
|
||||
else if (nc.w > 0.0) {pix1 = px.w > 0.0 ? H.xyz : D.xyz; blend1 = maximo.w;}
|
||||
if (nc.x > 0.0) {pix1 = px.x ? F.xyz : H.xyz; blend1 = maximo.x;}
|
||||
else if (nc.y > 0.0) {pix1 = px.y ? B.xyz : F.xyz; blend1 = maximo.y;}
|
||||
else if (nc.z > 0.0) {pix1 = px.z ? D.xyz : B.xyz; blend1 = maximo.z;}
|
||||
else if (nc.w > 0.0) {pix1 = px.w ? H.xyz : D.xyz; blend1 = maximo.w;}
|
||||
|
||||
float blend2;
|
||||
vec3 pix2;
|
||||
if (nc.w > 0.0) {pix2 = px.w > 0.0 ? H.xyz : D.xyz; blend2 = maximo.w;}
|
||||
else if (nc.z > 0.0) {pix2 = px.z > 0.0 ? D.xyz : B.xyz; blend2 = maximo.z;}
|
||||
else if (nc.y > 0.0) {pix2 = px.y > 0.0 ? B.xyz : F.xyz; blend2 = maximo.y;}
|
||||
else if (nc.x > 0.0) {pix2 = px.x > 0.0 ? F.xyz : H.xyz; blend2 = maximo.x;}
|
||||
if (nc.w > 0.0) {pix2 = px.w ? H.xyz : D.xyz; blend2 = maximo.w;}
|
||||
else if (nc.z > 0.0) {pix2 = px.z ? D.xyz : B.xyz; blend2 = maximo.z;}
|
||||
else if (nc.y > 0.0) {pix2 = px.y ? B.xyz : F.xyz; blend2 = maximo.y;}
|
||||
else if (nc.x > 0.0) {pix2 = px.x ? F.xyz : H.xyz; blend2 = maximo.x;}
|
||||
|
||||
vec3 res1 = mix(E.xyz, pix1, blend1);
|
||||
vec3 res2 = mix(E.xyz, pix2, blend2);
|
||||
|
@ -1,5 +1,5 @@
|
||||
$input a_position, a_texcoord0, a_color0
|
||||
$output v_texcoord0, v_texcoord1, v_color0
|
||||
$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4, v_texcoord5, v_texcoord6, v_texcoord7, v_color0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Dario Manesku
|
||||
@ -18,6 +18,12 @@ void main()
|
||||
vec2 ps = XBR_RES.xx / u_tex_size0.xy;
|
||||
float dx = ps.x;
|
||||
float dy = ps.y;
|
||||
v_texcoord1 = vec4(dx, 0, 0, dy); // F H
|
||||
v_texcoord1 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, -2.0*dy); // A1 B1 C1
|
||||
v_texcoord2 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, -dy); // A B C
|
||||
v_texcoord3 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 0.0); // D E F
|
||||
v_texcoord4 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, dy); // G H I
|
||||
v_texcoord5 = v_texcoord0.xxxy + vec4( -dx, 0.0, dx, 2.0*dy); // G5 H5 I5
|
||||
v_texcoord6 = v_texcoord0.xyyy + vec4(-2.0*dx, -dy, 0.0, dy); // A0 D0 G0
|
||||
v_texcoord7 = v_texcoord0.xyyy + vec4( 2.0*dx, -dy, 0.0, dy); // C4 F4 I4
|
||||
v_color0 = a_color0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user