mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-26 01:11:32 +11:00
add xbr-mlv4-multipass finally working w00t
This commit is contained in:
parent
bd3f8eff56
commit
6a5b182294
|
@ -39,68 +39,72 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#define round(X) floor((X)+0.5)
|
// compatibility macros
|
||||||
#define TEX(dx,dy) texture(Source, vTexCoord+vec2((dx),(dy))*t1).rgb
|
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
|
#define float2 vec2
|
||||||
|
#define float3 vec3
|
||||||
|
#define float4 vec4
|
||||||
|
#define bool2 bvec2
|
||||||
|
#define bool3 bvec3
|
||||||
|
#define bool4 bvec4
|
||||||
|
#define float3x3 mat3x3
|
||||||
|
#define float4x3 mat4x3
|
||||||
|
#define texture_size params.SourceSize
|
||||||
|
#define video_size params.SourceSize
|
||||||
|
#define output_size params.OutputSize
|
||||||
|
|
||||||
|
#define round(X) floor((X)+0.5)
|
||||||
|
#define TEX(dx,dy) texture(Source, vTexCoord+float2((dx),(dy))*t1).rgb
|
||||||
|
|
||||||
const float cf2 = 2.0;
|
const float cf2 = 2.0;
|
||||||
const float cf3 = 4.0;
|
const float cf3 = 4.0;
|
||||||
const float cf4 = 4.0;
|
const float cf4 = 4.0;
|
||||||
const vec4 eq_thresholdold = vec4(15.0, 15.0, 15.0, 15.0);
|
const float4 eq_thresholdold= float4(15.0, 15.0, 15.0, 15.0);
|
||||||
const vec4 eq_threshold = vec4( 2.0, 2.0, 2.0, 2.0);
|
const float4 eq_threshold = float4( 2.0, 2.0, 2.0, 2.0);
|
||||||
const vec4 eq_threshold3 = vec4(25.0, 25.0, 25.0, 25.0);
|
const float4 eq_threshold3 = float4(25.0, 25.0, 25.0, 25.0);
|
||||||
const vec3 Yuv_weight = vec3(4.0, 1.0, 2.0);
|
const float3 Yuv_weight = float3(4.0, 1.0, 2.0);
|
||||||
const mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813);
|
const float3x3 yuv = float3x3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813);
|
||||||
const mat3 yuvT = mat3(0.299, -0.169, 0.499, 0.587, -0.331, -0.418, 0.114, 0.499, -0.0813);
|
const float3x3 yuvT = float3x3(0.299, -0.169, 0.499,
|
||||||
const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0);
|
0.587, -0.331, -0.418,
|
||||||
|
0.114, 0.499, -0.0813);
|
||||||
|
const float3x3 yuv_weighted = float3x3(Yuv_weight.x*yuv[0], Yuv_weight.y*yuv[1], Yuv_weight.z*yuv[2]);
|
||||||
|
const float4 maximo = float4(255.0, 255.0, 255.0, 255.0);
|
||||||
|
|
||||||
|
float4 df(float4 A, float4 B)
|
||||||
vec4 df(vec4 A, vec4 B)
|
|
||||||
{
|
{
|
||||||
return vec4(abs(A-B));
|
return float4(abs(A-B));
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 rd(vec4 A, vec4 B, vec4 C, vec4 D)
|
bool4 rd(float4 A, float4 B, float4 C, float4 D)
|
||||||
{
|
{
|
||||||
return (greaterThan(df(C,D)/(df(A,B)+0.000000001) , vec4(2.0)));
|
return greaterThan((df(C,D)/(df(A,B)+0.000000001)) , vec4(2.,2.,2.,2.));
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 id(vec4 A, vec4 B, vec4 C, vec4 D)
|
bool4 id(float4 A, float4 B, float4 C, float4 D)
|
||||||
{
|
{
|
||||||
return greaterThan(df(C,D) , df(A,B));
|
return greaterThan(df(C,D) , df(A,B));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float4 remapTo01(float4 v, float4 high)
|
||||||
vec4 remapTo01(vec4 v, vec4 high)
|
|
||||||
{
|
{
|
||||||
return (v/high);
|
return (v/high);
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 eq(vec4 A, vec4 B)
|
bool4 eq(float4 A, float4 B)
|
||||||
{
|
{
|
||||||
return lessThan(df(A, B) , eq_threshold);
|
return lessThan(df(A, B) , eq_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 eq3(vec4 A, vec4 B)
|
bool4 eq3(float4 A, float4 B)
|
||||||
{
|
{
|
||||||
return lessThan(df(A, B) , eq_threshold3);
|
return lessThan(df(A, B) , eq_threshold3);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
|
float4 weighted_distance(float4 a, float4 b, float4 c, float4 d, float4 e, float4 f, float4 g, float4 h)
|
||||||
{
|
{
|
||||||
return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
|
return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 and(bvec4 A, bvec4 B)
|
|
||||||
{
|
|
||||||
return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w);
|
|
||||||
}
|
|
||||||
|
|
||||||
bvec4 or(bvec4 A, bvec4 B)
|
|
||||||
{
|
|
||||||
return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
layout(location = 1) in vec2 TexCoord;
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
@ -112,6 +116,10 @@ void main()
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord * 1.0004;
|
vTexCoord = TexCoord * 1.0004;
|
||||||
|
|
||||||
|
float2 ps = float2(1.0/texture_size.x, 1.0/texture_size.y);
|
||||||
|
float dx = ps.x;
|
||||||
|
float dy = ps.y;
|
||||||
|
|
||||||
// A3 B3 C3
|
// A3 B3 C3
|
||||||
// A1 B1 C1
|
// A1 B1 C1
|
||||||
//A2 A0 A B C C4 C6
|
//A2 A0 A B C C4 C6
|
||||||
|
@ -120,7 +128,7 @@ void main()
|
||||||
// G5 H5 I5
|
// G5 H5 I5
|
||||||
// G7 H7 I7
|
// G7 H7 I7
|
||||||
|
|
||||||
t1 = vec2(params.SourceSize.z, params.SourceSize.w); // F H
|
t1 = float2(dx, dy); // F H
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma stage fragment
|
#pragma stage fragment
|
||||||
|
@ -131,205 +139,177 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
bvec4 edr0, edr, edr_left, edr_up, edr3_left, edr3_up, edr4_left, edr4_up; // edr = edge detection rule
|
bool4 edr0, edr, edr_left, edr_up, edr3_left, edr3_up, edr4_left, edr4_up; // edr = edge detection rule
|
||||||
bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
|
bool4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
|
||||||
bvec4 interp_restriction_lv3_left, interp_restriction_lv3_up;
|
bool4 interp_restriction_lv3_left, interp_restriction_lv3_up;
|
||||||
bvec4 interp_restriction_lv4_left, interp_restriction_lv4_up;
|
bool4 interp_restriction_lv4_left, interp_restriction_lv4_up;
|
||||||
|
|
||||||
vec3 A3 = TEX(-1,-3); vec3 B3 = TEX( 0,-3); vec3 C3 = TEX( 1,-3);
|
|
||||||
vec3 A1 = TEX(-1,-2); vec3 B1 = TEX( 0,-2); vec3 C1 = TEX( 1,-2);
|
|
||||||
vec3 A2 = TEX(-3,-1); vec3 A0 = TEX(-2,-1); vec3 A = TEX(-1,-1); vec3 B = TEX( 0,-1); vec3 C = TEX( 1,-1); vec3 C4 = TEX( 2,-1); vec3 C6 = TEX( 3,-1);
|
|
||||||
vec3 D2 = TEX(-3, 0); vec3 D0 = TEX(-2, 0); vec3 D = TEX(-1, 0); vec3 E = TEX( 0, 0); vec3 F = TEX( 1, 0); vec3 F4 = TEX( 2, 0); vec3 F6 = TEX( 3, 0);
|
|
||||||
vec3 G2 = TEX(-3, 1); vec3 G0 = TEX(-2, 1); vec3 G = TEX(-1, 1); vec3 H = TEX( 0, 1); vec3 I = TEX( 1, 1); vec3 I4 = TEX( 2, 1); vec3 I6 = TEX( 3, 1);
|
|
||||||
vec3 G5 = TEX(-1, 2); vec3 H5 = TEX( 0, 2); vec3 I5 = TEX( 1, 2);
|
|
||||||
vec3 G7 = TEX(-1, 3); vec3 H7 = TEX( 0, 3); vec3 I7 = TEX( 1, 3);
|
|
||||||
|
|
||||||
mat4x3 bdhf = mul( mat4x3(B, D, H, F), yuvT );
|
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
|
||||||
vec4 b = mul( bdhf, Yuv_weight);
|
|
||||||
|
|
||||||
bdhf = mul( mat4x3(C, A, G, I), yuvT );
|
float3 A3=TEX(-1,-3); float3 B3=TEX( 0,-3); float3 C3=TEX( 1,-3);
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
float3 A1=TEX(-1,-2); float3 B1=TEX( 0,-2); float3 C1=TEX( 1,-2);
|
||||||
vec4 c = mul( bdhf, Yuv_weight);
|
float3 A2=TEX(-3,-1); float3 A0=TEX(-2,-1); float3 A =TEX(-1,-1);
|
||||||
|
float3 B =TEX( 0,-1); float3 C =TEX( 1,-1); float3 C4=TEX( 2,-1); float3 C6=TEX( 3,-1);
|
||||||
|
float3 D2=TEX(-3, 0); float3 D0=TEX(-2, 0); float3 D =TEX(-1, 0); float3 E =TEX( 0, 0);
|
||||||
|
float3 F =TEX( 1, 0); float3 F4=TEX( 2, 0); float3 F6=TEX( 3, 0);
|
||||||
|
float3 G2=TEX(-3, 1); float3 G0=TEX(-2, 1); float3 G =TEX(-1, 1); float3 H =TEX( 0, 1);
|
||||||
|
float3 I =TEX( 1, 1); float3 I4=TEX( 2, 1); float3 I6=TEX( 3, 1);
|
||||||
|
float3 G5=TEX(-1, 2); float3 H5=TEX( 0, 2); float3 I5=TEX( 1, 2);
|
||||||
|
float3 G7=TEX(-1, 3); float3 H7=TEX( 0, 3); float3 I7=TEX( 1, 3);
|
||||||
|
|
||||||
bdhf = mul( mat4x3(E, E, E, E), yuvT );
|
float4x3 bdhf = mul( float4x3(B, D, H, F), yuvT );
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
vec4 e = mul( bdhf, Yuv_weight);
|
float4 b = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
vec4 d = b.yzwx;
|
|
||||||
vec4 f = b.wxyz;
|
|
||||||
vec4 g = c.zwxy;
|
|
||||||
vec4 h = b.zwxy;
|
|
||||||
vec4 i = c.wxyz;
|
|
||||||
|
|
||||||
bdhf = mul( mat4x3(I4, C1, A0, G5), yuvT );
|
bdhf = mul( float4x3(C, A, G, I), yuvT );
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
vec4 i4 = mul( bdhf, Yuv_weight);
|
float4 c = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
bdhf = mul( mat4x3(I5, C4, A1, G0), yuvT );
|
bdhf = mul( float4x3(E, E, E, E), yuvT );
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
vec4 i5 = mul( bdhf, Yuv_weight);
|
float4 e = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
bdhf = mul( mat4x3(H5, F4, B1, D0), yuvT );
|
float4 d = b.yzwx;
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
float4 f = b.wxyz;
|
||||||
vec4 h5 = mul( bdhf, Yuv_weight);
|
float4 g = c.zwxy;
|
||||||
|
float4 h = b.zwxy;
|
||||||
|
float4 i = c.wxyz;
|
||||||
|
|
||||||
vec4 f4 = h5.yzwx;
|
bdhf = mul( float4x3(I4, C1, A0, G5), yuvT );
|
||||||
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
|
float4 i4 = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
vec4 c1 = i4.yzwx;
|
bdhf = mul( float4x3(I5, C4, A1, G0), yuvT );
|
||||||
vec4 g0 = i5.wxyz;
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
vec4 b1 = h5.zwxy;
|
float4 i5 = mul( bdhf, Yuv_weight);
|
||||||
vec4 d0 = h5.wxyz;
|
|
||||||
|
|
||||||
bdhf = mul( mat4x3(I6, C3, A2, G7), yuvT );
|
bdhf = mul( float4x3(H5, F4, B1, D0), yuvT );
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
vec4 i6 = mul( bdhf, Yuv_weight);
|
float4 h5 = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
bdhf = mul( mat4x3(I7, C6, A3, G2), yuvT );
|
float4 f4 = h5.yzwx;
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
|
||||||
vec4 i7 = mul( bdhf, Yuv_weight);
|
|
||||||
|
|
||||||
bdhf = mul( mat4x3(H7, F6, B3, D2), yuvT );
|
float4 c1 = i4.yzwx;
|
||||||
bdhf = mat4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
float4 g0 = i5.wxyz;
|
||||||
vec4 h7 = mul( bdhf, Yuv_weight);
|
float4 b1 = h5.zwxy;
|
||||||
|
float4 d0 = h5.wxyz;
|
||||||
|
|
||||||
|
bdhf = mul( float4x3(I6, C3, A2, G7), yuvT );
|
||||||
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
|
float4 i6 = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
|
bdhf = mul( float4x3(I7, C6, A3, G2), yuvT );
|
||||||
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
|
float4 i7 = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
|
bdhf = mul( float4x3(H7, F6, B3, D2), yuvT );
|
||||||
|
bdhf = float4x3(abs(bdhf[0]), abs(bdhf[1]), abs(bdhf[2]), abs(bdhf[3]));
|
||||||
|
float4 h7 = mul( bdhf, Yuv_weight);
|
||||||
|
|
||||||
|
float4 f6 = h7.yzwx;
|
||||||
|
|
||||||
|
float4 c3 = i6.yzwx;
|
||||||
|
float4 g2 = i7.wxyz;
|
||||||
|
float4 b3 = h7.zwxy;
|
||||||
|
float4 d2 = h7.wxyz;
|
||||||
|
|
||||||
vec4 f6 = h7.yzwx;
|
// interp_restriction_lv1 = (e !=f && e !=h );
|
||||||
vec4 c3 = i6.yzwx;
|
interp_restriction_lv1.x = (e.x!=f.x && e.x!=h.x);
|
||||||
vec4 g2 = i7.wxyz;
|
interp_restriction_lv1.y = (e.y!=f.y && e.y!=h.y);
|
||||||
vec4 b3 = h7.zwxy;
|
interp_restriction_lv1.z = (e.z!=f.z && e.z!=h.z);
|
||||||
vec4 d2 = h7.wxyz;
|
interp_restriction_lv1.w = (e.w!=f.w && e.w!=h.w);
|
||||||
|
|
||||||
//groan, gotta separate these into their components???
|
// interp_restriction_lv2_left = (e !=g && d !=g && (eq(e, d) || eq(h, g) ));
|
||||||
interp_restriction_lv1.x = !(e.x==f.x) && !(e.x==h.x);
|
interp_restriction_lv2_left.x = (e.x!=g.x && d.x!=g.x && (eq(e, d).x || eq(h, g).x));
|
||||||
interp_restriction_lv1.y = !(e.y==f.y) && !(e.y==h.y);
|
interp_restriction_lv2_left.y = (e.y!=g.y && d.y!=g.y && (eq(e, d).y || eq(h, g).y));
|
||||||
interp_restriction_lv1.z = !(e.z==f.z) && !(e.z==h.z);
|
interp_restriction_lv2_left.z = (e.z!=g.z && d.z!=g.z && (eq(e, d).z || eq(h, g).z));
|
||||||
interp_restriction_lv1.w = !(e.w==f.w) && !(e.w==h.w);
|
interp_restriction_lv2_left.w = (e.w!=g.w && d.w!=g.w && (eq(e, d).w || eq(h, g).w));
|
||||||
interp_restriction_lv2_left.x = (e.x!=g.x && d.x!=g.x && (eq(e, d).x || eq(h, g).x));
|
|
||||||
interp_restriction_lv2_left.y = (e.y!=g.y && d.y!=g.y && (eq(e, d).y || eq(h, g).y));
|
// interp_restriction_lv2_up = (e !=c && b !=c && (eq(e, b) || eq(f, c) ));
|
||||||
interp_restriction_lv2_left.z = (e.z!=g.z && d.z!=g.z && (eq(e, d).z || eq(h, g).z));
|
interp_restriction_lv2_up.x = (e.x!=c.x && b.x!=c.x && (eq(e, b).x || eq(f, c).x));
|
||||||
interp_restriction_lv2_left.w = (e.w!=g.w && d.w!=g.w && (eq(e, d).w || eq(h, g).w));
|
interp_restriction_lv2_up.y = (e.y!=c.y && b.y!=c.y && (eq(e, b).y || eq(f, c).y));
|
||||||
interp_restriction_lv2_up.x = (e.x!=c.x && b.x!=c.x && (eq(e, b).x || eq(f, c).x));
|
interp_restriction_lv2_up.z = (e.z!=c.z && b.z!=c.z && (eq(e, b).z || eq(f, c).z));
|
||||||
interp_restriction_lv2_up.y = (e.y!=c.y && b.y!=c.y && (eq(e, b).y || eq(f, c).y));
|
interp_restriction_lv2_up.w = (e.w!=c.w && b.w!=c.w && (eq(e, b).w || eq(f, c).w));
|
||||||
interp_restriction_lv2_up.z = (e.z!=c.z && b.z!=c.z && (eq(e, b).z || eq(f, c).z));
|
|
||||||
interp_restriction_lv2_up.w = (e.w!=c.w && b.w!=c.w && (eq(e, b).w || eq(f, c).w));
|
// interp_restriction_lv3_left = (e !=g0 && d0 !=g0 && (eq(d,d0) || eq(g,g0) ));
|
||||||
interp_restriction_lv3_left.x = (e.x!=g0.x && d0.x!=g0.x && (eq(d,d0).x || eq(g,g0).x));
|
interp_restriction_lv3_left.x = (e.x!=g0.x && d0.x!=g0.x && (eq(d,d0).x || eq(g,g0).x));
|
||||||
interp_restriction_lv3_left.y = (e.y!=g0.y && d0.y!=g0.y && (eq(d,d0).y || eq(g,g0).y));
|
interp_restriction_lv3_left.y = (e.y!=g0.y && d0.y!=g0.y && (eq(d,d0).y || eq(g,g0).y));
|
||||||
interp_restriction_lv3_left.z = (e.z!=g0.z && d0.z!=g0.z && (eq(d,d0).z || eq(g,g0).z));
|
interp_restriction_lv3_left.z = (e.z!=g0.z && d0.z!=g0.z && (eq(d,d0).z || eq(g,g0).z));
|
||||||
interp_restriction_lv3_left.w = (e.w!=g0.w && d0.w!=g0.w && (eq(d,d0).w || eq(g,g0).w));
|
interp_restriction_lv3_left.w = (e.w!=g0.w && d0.w!=g0.w && (eq(d,d0).w || eq(g,g0).w));
|
||||||
interp_restriction_lv3_up.x = (e.x!=c1.x && b1.x!=c1.x && (eq(b,b1).x || eq(c,c1).x));
|
|
||||||
interp_restriction_lv3_up.y = (e.y!=c1.y && b1.y!=c1.y && (eq(b,b1).y || eq(c,c1).y));
|
// interp_restriction_lv3_up = (e !=c1 && b1 !=c1 && (eq(b,b1) || eq(c,c1) ));
|
||||||
interp_restriction_lv3_up.z = (e.z!=c1.z && b1.z!=c1.z && (eq(b,b1).z || eq(c,c1).z));
|
interp_restriction_lv3_up.x = (e.x!=c1.x && b1.x!=c1.x && (eq(b,b1).x || eq(c,c1).x));
|
||||||
interp_restriction_lv3_up.w = (e.w!=c1.w && b1.w!=c1.w && (eq(b,b1).w || eq(c,c1).w));
|
interp_restriction_lv3_up.y = (e.y!=c1.y && b1.y!=c1.y && (eq(b,b1).y || eq(c,c1).y));
|
||||||
interp_restriction_lv4_left.x = (e.x!=g2.x && d2.x!=g2.x && (eq(d0,d2).x || eq(g0,g2).x));
|
interp_restriction_lv3_up.z = (e.z!=c1.z && b1.z!=c1.z && (eq(b,b1).z || eq(c,c1).z));
|
||||||
interp_restriction_lv4_left.y = (e.y!=g2.y && d2.y!=g2.y && (eq(d0,d2).y || eq(g0,g2).y));
|
interp_restriction_lv3_up.w = (e.w!=c1.w && b1.w!=c1.w && (eq(b,b1).w || eq(c,c1).w));
|
||||||
interp_restriction_lv4_left.z = (e.z!=g2.z && d2.z!=g2.z && (eq(d0,d2).z || eq(g0,g2).z));
|
|
||||||
interp_restriction_lv4_left.w = (e.w!=g2.w && d2.w!=g2.w && (eq(d0,d2).w || eq(g0,g2).w));
|
// interp_restriction_lv4_left = (e !=g2 && d2 !=g2 && (eq(d0,d2) || eq(g0,g2) ));
|
||||||
interp_restriction_lv4_up.x = (e.x!=c3.x && b3.x!=c3.x && (eq(b1,b3).x || eq(c1,c3).x));
|
interp_restriction_lv4_left.x = (e.x!=g2.x && d2.x!=g2.x && (eq(d0,d2).x || eq(g0,g2).x));
|
||||||
interp_restriction_lv4_up.y = (e.y!=c3.y && b3.y!=c3.y && (eq(b1,b3).y || eq(c1,c3).y));
|
interp_restriction_lv4_left.y = (e.y!=g2.y && d2.y!=g2.y && (eq(d0,d2).y || eq(g0,g2).y));
|
||||||
interp_restriction_lv4_up.z = (e.z!=c3.z && b3.z!=c3.z && (eq(b1,b3).z || eq(c1,c3).z));
|
interp_restriction_lv4_left.z = (e.z!=g2.z && d2.z!=g2.z && (eq(d0,d2).z || eq(g0,g2).z));
|
||||||
interp_restriction_lv4_up.w = (e.w!=c3.w && b3.w!=c3.w && (eq(b1,b3).w || eq(c1,c3).w));
|
interp_restriction_lv4_left.w = (e.w!=g2.w && d2.w!=g2.w && (eq(d0,d2).w || eq(g0,g2).w));
|
||||||
|
|
||||||
vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f);
|
// interp_restriction_lv4_up = (e !=c3 && b3 !=c3 && (eq(b1,b3) || eq(c1,c3) ));
|
||||||
vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i);
|
interp_restriction_lv4_up.x = (e.x!=c3.x && b3.x!=c3.x && (eq(b1,b3).x || eq(c1,c3).x));
|
||||||
|
interp_restriction_lv4_up.y = (e.y!=c3.y && b3.y!=c3.y && (eq(b1,b3).y || eq(c1,c3).y));
|
||||||
edr0.x = (wd1.x <= wd2.x) && interp_restriction_lv1.x;
|
interp_restriction_lv4_up.z = (e.z!=c3.z && b3.z!=c3.z && (eq(b1,b3).z || eq(c1,c3).z));
|
||||||
edr0.y = (wd1.y <= wd2.y) && interp_restriction_lv1.y;
|
interp_restriction_lv4_up.w = (e.w!=c3.w && b3.w!=c3.w && (eq(b1,b3).w || eq(c1,c3).w));
|
||||||
edr0.z = (wd1.z <= wd2.z) && interp_restriction_lv1.z;
|
|
||||||
edr0.w = (wd1.w <= wd2.w) && interp_restriction_lv1.w;
|
float4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f);
|
||||||
edr.x = (wd1.x < wd2.x) && interp_restriction_lv1.x && ( !eq(f,b).x && !id(f,c,f,b).x || !eq(h,d).x && !id(h,g,h,d).x || eq(e,g).x || eq(e,c).x);
|
float4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i);
|
||||||
edr.y = (wd1.y < wd2.y) && interp_restriction_lv1.y && ( !eq(f,b).y && !id(f,c,f,b).y || !eq(h,d).y && !id(h,g,h,d).y || eq(e,g).y || eq(e,c).y);
|
|
||||||
edr.z = (wd1.z < wd2.z) && interp_restriction_lv1.z && ( !eq(f,b).z && !id(f,c,f,b).z || !eq(h,d).z && !id(h,g,h,d).z || eq(e,g).z || eq(e,c).z);
|
// edr0 = (wd1 <= wd2 ) && interp_restriction_lv1;
|
||||||
edr.w = (wd1.w < wd2.w) && interp_restriction_lv1.w && ( !eq(f,b).w && !id(f,c,f,b).w || !eq(h,d).w && !id(h,g,h,d).w || eq(e,g).w || eq(e,c).w);
|
edr0.x = (wd1.x <= wd2.x) && interp_restriction_lv1.x;
|
||||||
edr_left.x = ((cf2*df(f,g).x) <= df(h,c).x) && interp_restriction_lv2_left.x && edr.x;
|
edr0.y = (wd1.y <= wd2.y) && interp_restriction_lv1.y;
|
||||||
edr_left.y = ((cf2*df(f,g).y) <= df(h,c).y) && interp_restriction_lv2_left.y && edr.y;
|
edr0.z = (wd1.z <= wd2.z) && interp_restriction_lv1.z;
|
||||||
edr_left.z = ((cf2*df(f,g).z) <= df(h,c).z) && interp_restriction_lv2_left.z && edr.z;
|
edr0.w = (wd1.w <= wd2.w) && interp_restriction_lv1.w;
|
||||||
edr_left.w = ((cf2*df(f,g).w) <= df(h,c).w) && interp_restriction_lv2_left.w && edr.w;
|
|
||||||
edr_up.x = (df(f,g).x >= (cf2*df(h,c).x)) && interp_restriction_lv2_up.x && edr.x;
|
// edr = (wd1 < wd2 ) && interp_restriction_lv1 && ( !eq(f,b) && !id(f,c,f,b) || !eq(h,d) && !id(h,g,h,d) || eq(e,g) || eq(e,c) );
|
||||||
edr_up.y = (df(f,g).y >= (cf2*df(h,c).y)) && interp_restriction_lv2_up.y && edr.y;
|
edr.x = (wd1.x < wd2.x) && interp_restriction_lv1.x && ( !eq(f,b).x && !id(f,c,f,b).x || !eq(h,d).x && !id(h,g,h,d).x || eq(e,g).x || eq(e,c).x );
|
||||||
edr_up.z = (df(f,g).z >= (cf2*df(h,c).z)) && interp_restriction_lv2_up.z && edr.z;
|
edr.y = (wd1.y < wd2.y) && interp_restriction_lv1.y && ( !eq(f,b).y && !id(f,c,f,b).y || !eq(h,d).y && !id(h,g,h,d).y || eq(e,g).y || eq(e,c).y );
|
||||||
edr_up.w = (df(f,g).w >= (cf2*df(h,c).w)) && interp_restriction_lv2_up.w && edr.w;
|
edr.z = (wd1.z < wd2.z) && interp_restriction_lv1.z && ( !eq(f,b).z && !id(f,c,f,b).z || !eq(h,d).z && !id(h,g,h,d).z || eq(e,g).z || eq(e,c).z );
|
||||||
edr3_left.x = ((cf3*df(f,g0).x) <= df(h,c1).x) && interp_restriction_lv3_left.x && edr_left.x;
|
edr.w = (wd1.w < wd2.w) && interp_restriction_lv1.w && ( !eq(f,b).w && !id(f,c,f,b).w || !eq(h,d).w && !id(h,g,h,d).w || eq(e,g).w || eq(e,c).w );
|
||||||
edr3_left.y = ((cf3*df(f,g0).y) <= df(h,c1).y) && interp_restriction_lv3_left.y && edr_left.y;
|
|
||||||
edr3_left.z = ((cf3*df(f,g0).z) <= df(h,c1).z) && interp_restriction_lv3_left.z && edr_left.z;
|
// edr_left = ((cf2*df(f,g) ) <= df(h,c) ) && interp_restriction_lv2_left && edr;
|
||||||
edr3_left.w = ((cf3*df(f,g0).w) <= df(h,c1).w) && interp_restriction_lv3_left.w && edr_left.w;
|
edr_left.x = ((cf2*df(f,g).x) <= df(h,c).x) && interp_restriction_lv2_left.x && edr.x;
|
||||||
edr3_up.x = (df(f,g0).x >= (cf3*df(h,c1).x)) && interp_restriction_lv3_up.x && edr_up.x;
|
edr_left.y = ((cf2*df(f,g).y) <= df(h,c).y) && interp_restriction_lv2_left.y && edr.y;
|
||||||
edr3_up.y = (df(f,g0).y >= (cf3*df(h,c1).y)) && interp_restriction_lv3_up.y && edr_up.y;
|
edr_left.z = ((cf2*df(f,g).z) <= df(h,c).z) && interp_restriction_lv2_left.z && edr.z;
|
||||||
edr3_up.z = (df(f,g0).z >= (cf3*df(h,c1).z)) && interp_restriction_lv3_up.z && edr_up.z;
|
edr_left.w = ((cf2*df(f,g).w) <= df(h,c).w) && interp_restriction_lv2_left.w && edr.w;
|
||||||
edr3_up.w = (df(f,g0).w >= (cf3*df(h,c1).w)) && interp_restriction_lv3_up.w && edr_up.w;
|
|
||||||
edr4_left.x = ((cf4*df(f,g2).x) <= df(h,c3).x) && interp_restriction_lv4_left.x && edr3_left.x;
|
// edr_up = (df(f,g) >= (cf2*df(h,c) )) && interp_restriction_lv2_up && edr;
|
||||||
edr4_left.y = ((cf4*df(f,g2).y) <= df(h,c3).y) && interp_restriction_lv4_left.y && edr3_left.y;
|
edr_up.x = (df(f,g).x >= (cf2*df(h,c).x)) && interp_restriction_lv2_up.x && edr.x;
|
||||||
edr4_left.z = ((cf4*df(f,g2).z) <= df(h,c3).z) && interp_restriction_lv4_left.z && edr3_left.z;
|
edr_up.y = (df(f,g).y >= (cf2*df(h,c).y)) && interp_restriction_lv2_up.y && edr.y;
|
||||||
edr4_left.w = ((cf4*df(f,g2).w) <= df(h,c3).w) && interp_restriction_lv4_left.w && edr3_left.w;
|
edr_up.z = (df(f,g).z >= (cf2*df(h,c).z)) && interp_restriction_lv2_up.z && edr.z;
|
||||||
edr4_up.x = (df(f,g2).x >= (cf4*df(h,c3).x)) && interp_restriction_lv4_up.x && edr3_up.x;
|
edr_up.w = (df(f,g).w >= (cf2*df(h,c).w)) && interp_restriction_lv2_up.w && edr.w;
|
||||||
edr4_up.y = (df(f,g2).y >= (cf4*df(h,c3).y)) && interp_restriction_lv4_up.y && edr3_up.y;
|
|
||||||
edr4_up.z = (df(f,g2).z >= (cf4*df(h,c3).z)) && interp_restriction_lv4_up.z && edr3_up.z;
|
// edr3_left = ((cf3*df(f,g0) ) <= df(h,c1) ) && interp_restriction_lv3_left && edr_left;
|
||||||
edr4_up.w = (df(f,g2).w >= (cf4*df(h,c3).w)) && interp_restriction_lv4_up.w && edr3_up.w;
|
edr3_left.x = ((cf3*df(f,g0).x) <= df(h,c1).x) && interp_restriction_lv3_left.x && edr_left.x;
|
||||||
|
edr3_left.y = ((cf3*df(f,g0).y) <= df(h,c1).y) && interp_restriction_lv3_left.y && edr_left.y;
|
||||||
/* condensed
|
edr3_left.w = ((cf3*df(f,g0).w) <= df(h,c1).w) && interp_restriction_lv3_left.w && edr_left.w;
|
||||||
interp_restriction_lv2_left = or(and(and(notEqual(e,g) , notEqual(d,g)) , eq(e, d)) , eq(h, g));
|
edr3_left.z = ((cf3*df(f,g0).z) <= df(h,c1).z) && interp_restriction_lv3_left.z && edr_left.z;
|
||||||
interp_restriction_lv2_up = or(and(and(notEqual(e,c) , notEqual(b,c)) , eq(e, b)) , eq(f, c));
|
|
||||||
interp_restriction_lv3_left = or(and(and(notEqual(e,g0) , notEqual(d0,g0)) , eq(d,d0)) , eq(g,g0));
|
// edr3_up = (df(f,g0) >= (cf3*df(h,c1) )) && interp_restriction_lv3_up && edr_up;
|
||||||
interp_restriction_lv3_up = or(and(and(notEqual(e,c1) , notEqual(b1,c1)) , eq(b,b1)) , eq(c,c1));
|
edr3_up.x = (df(f,g0).x >= (cf3*df(h,c1).x)) && interp_restriction_lv3_up.x && edr_up.x;
|
||||||
interp_restriction_lv4_left = or(and(and(notEqual(e,g2) , notEqual(d2,g2)) , eq(d0,d2)) , eq(g0,g2));
|
edr3_up.y = (df(f,g0).y >= (cf3*df(h,c1).y)) && interp_restriction_lv3_up.y && edr_up.y;
|
||||||
interp_restriction_lv4_up = or(and(and(notEqual(e,c3) , notEqual(b3,c3)) , eq(b1,b3)) , eq(c1,c3));
|
edr3_up.w = (df(f,g0).w >= (cf3*df(h,c1).w)) && interp_restriction_lv3_up.w && edr_up.w;
|
||||||
|
edr3_up.z = (df(f,g0).z >= (cf3*df(h,c1).z)) && interp_restriction_lv3_up.z && edr_up.z;
|
||||||
vec4 wd1 = weighted_distance( e, c, g, i, h5, f4, h, f);
|
|
||||||
vec4 wd2 = weighted_distance( h, d, i5, f, i4, b, e, i);
|
// edr4_left = ((cf4*df(f,g2) ) <= df(h,c3) ) && interp_restriction_lv4_left && edr3_left;
|
||||||
|
edr4_left.x = ((cf4*df(f,g2).x) <= df(h,c3).x) && interp_restriction_lv4_left.x && edr3_left.x;
|
||||||
bvec4 comp1 = and(not(eq(h,d)) , not(id(h,g,h,d)));
|
edr4_left.y = ((cf4*df(f,g2).y) <= df(h,c3).y) && interp_restriction_lv4_left.y && edr3_left.y;
|
||||||
bvec4 comp2 = and(not(eq(f,b)) , not(id(f,c,f,b)));
|
edr4_left.z = ((cf4*df(f,g2).z) <= df(h,c3).z) && interp_restriction_lv4_left.z && edr3_left.z;
|
||||||
|
edr4_left.w = ((cf4*df(f,g2).w) <= df(h,c3).w) && interp_restriction_lv4_left.w && edr3_left.w;
|
||||||
edr0 = and(lessThanEqual(wd1 , wd2) , interp_restriction_lv1);
|
|
||||||
edr = and(lessThan(wd1 , wd2) , and(interp_restriction_lv1 , ( or(comp2 , or(comp1 , or(eq(e,g) , eq(e,c)))) ) ));
|
// edr4_up = (df(f,g2) >= (cf4*df(h,c3) )) && interp_restriction_lv4_up && edr3_up;
|
||||||
edr_left = and(lessThanEqual((cf2*df(f,g)) , df(h,c)) , and(interp_restriction_lv2_left , edr));
|
edr4_up.x = (df(f,g2).x >= (cf4*df(h,c3).x)) && interp_restriction_lv4_up.x && edr3_up.x;
|
||||||
edr_up = and(greaterThanEqual(df(f,g) , (cf2*df(h,c))) , and(interp_restriction_lv2_up , edr));
|
edr4_up.y = (df(f,g2).y >= (cf4*df(h,c3).y)) && interp_restriction_lv4_up.y && edr3_up.y;
|
||||||
edr3_left = and(lessThanEqual((cf3*df(f,g0)) , df(h,c1)) , and(interp_restriction_lv3_left , edr_left));
|
edr4_up.z = (df(f,g2).z >= (cf4*df(h,c3).z)) && interp_restriction_lv4_up.z && edr3_up.z;
|
||||||
edr3_up = and(greaterThanEqual(df(f,g0) , (cf3*df(h,c1))) , and(interp_restriction_lv3_up , edr_up));
|
edr4_up.w = (df(f,g2).w >= (cf4*df(h,c3).w)) && interp_restriction_lv4_up.w && edr3_up.w;
|
||||||
edr4_left = and(lessThanEqual((cf4*df(f,g2)) , df(h,c3)) , and(interp_restriction_lv4_left , edr3_left));
|
|
||||||
edr4_up = and(greaterThanEqual(df(f,g2) , (cf4*df(h,c3))) , and(interp_restriction_lv4_up , edr3_up));
|
|
||||||
*/
|
|
||||||
|
|
||||||
vec4 info;
|
vec4 info;
|
||||||
|
// info = (edr4_left && !edr4_up ) ? float4(8.0) : ((edr4_up && !edr4_left ) ? float4(7.0) : ((edr3_left && !edr3_up ) ? float4(6.0) : ((edr3_up && !edr3_left ) ? float4(5.0) : ((edr_left && !edr_up ) ? float4(4.0) : ((edr_up && !edr_left ) ? float4(3.0) : (edr ? float4(2.0) : (edr0 ? float4(1.0) : float4(0.0))))))));
|
||||||
|
info.x = (edr4_left.x && !edr4_up.x) ? float(8.0) : ((edr4_up.x && !edr4_left.x) ? float(7.0) : ((edr3_left.x && !edr3_up.x) ? float(6.0) : ((edr3_up.x && !edr3_left.x) ? float(5.0) : ((edr_left.x && !edr_up.x) ? float(4.0) : ((edr_up.x && !edr_left.x) ? float(3.0) : (edr.x ? float(2.0) : (edr0.x ? float(1.0) : float(0.0))))))));
|
||||||
|
info.y = (edr4_left.y && !edr4_up.y) ? float(8.0) : ((edr4_up.y && !edr4_left.y) ? float(7.0) : ((edr3_left.y && !edr3_up.y) ? float(6.0) : ((edr3_up.y && !edr3_left.y) ? float(5.0) : ((edr_left.y && !edr_up.y) ? float(4.0) : ((edr_up.y && !edr_left.y) ? float(3.0) : (edr.y ? float(2.0) : (edr0.y ? float(1.0) : float(0.0))))))));
|
||||||
|
info.z = (edr4_left.z && !edr4_up.z) ? float(8.0) : ((edr4_up.z && !edr4_left.z) ? float(7.0) : ((edr3_left.z && !edr3_up.z) ? float(6.0) : ((edr3_up.z && !edr3_left.z) ? float(5.0) : ((edr_left.z && !edr_up.z) ? float(4.0) : ((edr_up.z && !edr_left.z) ? float(3.0) : (edr.z ? float(2.0) : (edr0.z ? float(1.0) : float(0.0))))))));
|
||||||
|
info.w = (edr4_left.w && !edr4_up.w) ? float(8.0) : ((edr4_up.w && !edr4_left.w) ? float(7.0) : ((edr3_left.w && !edr3_up.w) ? float(6.0) : ((edr3_up.w && !edr3_left.w) ? float(5.0) : ((edr_left.w && !edr_up.w) ? float(4.0) : ((edr_up.w && !edr_left.w) ? float(3.0) : (edr.w ? float(2.0) : (edr0.w ? float(1.0) : float(0.0))))))));
|
||||||
|
|
||||||
info.x = (edr0.x == true) ? 1.0 : 0.0;
|
FragColor = float4(remapTo01(info, maximo));
|
||||||
info.y = (edr0.y == true) ? 1.0 : 0.0;
|
}
|
||||||
info.z = (edr0.z == true) ? 1.0 : 0.0;
|
|
||||||
info.w = (edr0.w == true) ? 1.0 : 0.0;
|
|
||||||
|
|
||||||
info.x = (edr.x == true) ? 2.0 : info.x;
|
|
||||||
info.y = (edr.y == true) ? 2.0 : info.y;
|
|
||||||
info.z = (edr.z == true) ? 2.0 : info.z;
|
|
||||||
info.w = (edr.w == true) ? 2.0 : info.w;
|
|
||||||
|
|
||||||
info.x = and(edr_up , not(edr_left)).x == true ? 3.0 : info.x;
|
|
||||||
info.y = and(edr_up , not(edr_left)).y == true ? 3.0 : info.y;
|
|
||||||
info.z = and(edr_up , not(edr_left)).z == true ? 3.0 : info.z;
|
|
||||||
info.w = and(edr_up , not(edr_left)).w == true ? 3.0 : info.w;
|
|
||||||
|
|
||||||
info.x = and(edr_left , not(edr_up)).x == true ? 4.0 : info.x;
|
|
||||||
info.y = and(edr_left , not(edr_up)).y == true ? 4.0 : info.y;
|
|
||||||
info.z = and(edr_left , not(edr_up)).z == true ? 4.0 : info.z;
|
|
||||||
info.w = and(edr_left , not(edr_up)).w == true ? 4.0 : info.w;
|
|
||||||
|
|
||||||
info.x = and(edr3_up , not(edr3_left)).x == true ? 5.0 : info.x;
|
|
||||||
info.y = and(edr3_up , not(edr3_left)).y == true ? 5.0 : info.y;
|
|
||||||
info.z = and(edr3_up , not(edr3_left)).z == true ? 5.0 : info.z;
|
|
||||||
info.w = and(edr3_up , not(edr3_left)).w == true ? 5.0 : info.w;
|
|
||||||
|
|
||||||
info.x = and(edr3_left , not(edr3_up)).x == true ? 6.0 : info.x;
|
|
||||||
info.y = and(edr3_left , not(edr3_up)).y == true ? 6.0 : info.y;
|
|
||||||
info.z = and(edr3_left , not(edr3_up)).z == true ? 6.0 : info.z;
|
|
||||||
info.w = and(edr3_left , not(edr3_up)).w == true ? 6.0 : info.w;
|
|
||||||
|
|
||||||
info.x = and(edr4_up , not(edr4_left)).x == true ? 7.0 : info.x;
|
|
||||||
info.y = and(edr4_up , not(edr4_left)).y == true ? 7.0 : info.y;
|
|
||||||
info.z = and(edr4_up , not(edr4_left)).z == true ? 7.0 : info.z;
|
|
||||||
info.w = and(edr4_up , not(edr4_left)).w == true ? 7.0 : info.w;
|
|
||||||
|
|
||||||
info.x = and(edr4_left , not(edr4_up)).x == true ? 8.0 : info.x;
|
|
||||||
info.y = and(edr4_left , not(edr4_up)).y == true ? 8.0 : info.y;
|
|
||||||
info.z = and(edr4_left , not(edr4_up)).z == true ? 8.0 : info.z;
|
|
||||||
info.w = and(edr4_left , not(edr4_up)).w == true ? 8.0 : info.w;
|
|
||||||
|
|
||||||
FragColor = vec4(remapTo01(info, maximo));
|
|
||||||
}
|
|
||||||
|
|
|
@ -39,79 +39,81 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#define round(X) floor((X)+0.5)
|
// compatibility macros
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
#define float2 vec2
|
||||||
|
#define float3 vec3
|
||||||
|
#define float4 vec4
|
||||||
|
#define bool2 bvec2
|
||||||
|
#define bool3 bvec3
|
||||||
|
#define bool4 bvec4
|
||||||
|
#define float3x3 mat3x3
|
||||||
|
#define float4x3 mat4x3
|
||||||
|
#define texture_size params.SourceSize
|
||||||
|
#define video_size param.SourceSize
|
||||||
|
#define output_size params.OutputSize
|
||||||
|
|
||||||
const float cf2 = 2.0;
|
#define round(X) floor((X)+0.5)
|
||||||
const float cf3 = 4.0;
|
|
||||||
const float cf4 = 4.0;
|
|
||||||
const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
|
|
||||||
const vec4 eq_threshold2 = vec4( 5.0, 5.0, 5.0, 5.0);
|
|
||||||
const vec4 eq_threshold3 = vec4(25.0, 25.0, 25.0, 25.0);
|
|
||||||
const float y_weight = 48.0;
|
|
||||||
const float u_weight = 7.0;
|
|
||||||
const float v_weight = 6.0;
|
|
||||||
const mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813);
|
|
||||||
const mat3 yuv_weighted = mat3(y_weight*yuv[0], u_weight*yuv[1], v_weight*yuv[2]);
|
|
||||||
const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0);
|
|
||||||
|
|
||||||
|
const float cf2 = 2.0;
|
||||||
|
const float cf3 = 4.0;
|
||||||
|
const float cf4 = 4.0;
|
||||||
|
const float4 eq_threshold = float4(15.0, 15.0, 15.0, 15.0);
|
||||||
|
const float4 eq_threshold2 = float4( 5.0, 5.0, 5.0, 5.0);
|
||||||
|
const float4 eq_threshold3 = float4(25.0, 25.0, 25.0, 25.0);
|
||||||
|
const float y_weight = 48.0;
|
||||||
|
const float u_weight = 7.0;
|
||||||
|
const float v_weight = 6.0;
|
||||||
|
const float3x3 yuv = float3x3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813);
|
||||||
|
const float3x3 yuv_weighted = float3x3(y_weight*yuv[0], u_weight*yuv[1], v_weight*yuv[2]);
|
||||||
|
const float4 maximo = float4(255.0, 255.0, 255.0, 255.0);
|
||||||
|
|
||||||
vec4 df(vec4 A, vec4 B)
|
float4 df(float4 A, float4 B)
|
||||||
{
|
{
|
||||||
return vec4(abs(A-B));
|
return float4(abs(A-B));
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 rd(vec4 A, vec4 B, vec4 C, vec4 D)
|
bool4 rd(float4 A, float4 B, float4 C, float4 D)
|
||||||
{
|
{
|
||||||
return (greaterThan(df(C,D)/(df(A,B)+0.000000001) , vec4(2.0)));
|
return greaterThan((df(C,D)/(df(A,B)+0.000000001)) , vec4(2.,2.,2.,2.));
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 id(vec4 A, vec4 B, vec4 C, vec4 D)
|
bool4 id(float4 A, float4 B, float4 C, float4 D)
|
||||||
{
|
{
|
||||||
return greaterThan(df(C,D) , df(A,B));
|
return greaterThan(df(C,D) , df(A,B));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 remapTo01(vec4 v, vec4 high)
|
float4 remapTo01(float4 v, float4 high)
|
||||||
{
|
{
|
||||||
return (v/high);
|
return (v/high);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 remapFrom01(vec4 v, vec4 high)
|
float4 remapFrom01(float4 v, float4 high)
|
||||||
{
|
{
|
||||||
return round(high*v);
|
return round(high*v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 eq(vec4 A, vec4 B)
|
|
||||||
|
bool4 eq(float4 A, float4 B)
|
||||||
{
|
{
|
||||||
return lessThan(df(A, B) , eq_threshold);
|
return lessThan(df(A, B) , eq_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 eq2(vec4 A, vec4 B)
|
bool4 eq2(float4 A, float4 B)
|
||||||
{
|
{
|
||||||
return lessThan(df(A, B) , eq_threshold2);
|
return lessThan(df(A, B) , eq_threshold2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 eq3(vec4 A, vec4 B)
|
bool4 eq3(float4 A, float4 B)
|
||||||
{
|
{
|
||||||
return lessThan(df(A, B) , eq_threshold3);
|
return lessThan(df(A, B) , eq_threshold3);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
|
float4 weighted_distance(float4 a, float4 b, float4 c, float4 d, float4 e, float4 f, float4 g, float4 h)
|
||||||
{
|
{
|
||||||
return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
|
return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec4 and(bvec4 A, bvec4 B)
|
|
||||||
{
|
|
||||||
return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w);
|
|
||||||
}
|
|
||||||
|
|
||||||
bvec4 or(bvec4 A, bvec4 B)
|
|
||||||
{
|
|
||||||
return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
layout(location = 1) in vec2 TexCoord;
|
layout(location = 1) in vec2 TexCoord;
|
||||||
|
@ -129,22 +131,23 @@ void main()
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord * 1.0004;
|
vTexCoord = TexCoord * 1.0004;
|
||||||
|
|
||||||
float dx = params.SourceSize.z;
|
float2 ps = float2(1.0/texture_size.x, 1.0/texture_size.y);
|
||||||
float dy = params.SourceSize.w;
|
float dx = ps.x;
|
||||||
|
float dy = ps.y;
|
||||||
|
|
||||||
// A1 B1 C1
|
// A1 B1 C1
|
||||||
// A0 A B C C4
|
// A0 A B C C4
|
||||||
// D0 D E F F4
|
// D0 D E F F4
|
||||||
// G0 G H I I4
|
// G0 G H I I4
|
||||||
// G5 H5 I5
|
// G5 H5 I5
|
||||||
|
|
||||||
t1 = vTexCoord.xxxy + vec4( -dx, 0., dx,-2.0*dy); // A1 B1 C1
|
t1 = vTexCoord.xxxy + float4( -dx, 0., dx,-2.0*dy); // A1 B1 C1
|
||||||
t2 = vTexCoord.xxxy + vec4( -dx, 0., dx, -dy); // A B C
|
t2 = vTexCoord.xxxy + float4( -dx, 0., dx, -dy); // A B C
|
||||||
t3 = vTexCoord.xxxy + vec4( -dx, 0., dx, 0); // D E F
|
t3 = vTexCoord.xxxy + float4( -dx, 0., dx, 0.); // D E F
|
||||||
t4 = vTexCoord.xxxy + vec4( -dx, 0., dx, dy); // G H I
|
t4 = vTexCoord.xxxy + float4( -dx, 0., dx, dy); // G H I
|
||||||
t5 = vTexCoord.xxxy + vec4( -dx, 0., dx, 2.0*dy); // G5 H5 I5
|
t5 = vTexCoord.xxxy + float4( -dx, 0., dx, 2.0*dy); // G5 H5 I5
|
||||||
t6 = vTexCoord.xyyy + vec4(-2.0*dx,-dy, 0., dy); // A0 D0 G0
|
t6 = vTexCoord.xyyy + float4(-2.0*dx,-dy, 0., dy); // A0 D0 G0
|
||||||
t7 = vTexCoord.xyyy + vec4( 2.0*dx,-dy, 0., dy); // C4 F4 I4
|
t7 = vTexCoord.xyyy + float4( 2.0*dx,-dy, 0., dy); // C4 F4 I4
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma stage fragment
|
#pragma stage fragment
|
||||||
|
@ -158,7 +161,7 @@ layout(location = 6) in vec4 t6;
|
||||||
layout(location = 7) in vec4 t7;
|
layout(location = 7) in vec4 t7;
|
||||||
layout(location = 0) out vec4 FragColor;
|
layout(location = 0) out vec4 FragColor;
|
||||||
layout(set = 0, binding = 2) uniform sampler2D Source;
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
layout(set = 0, binding = 3) uniform sampler2D Original;
|
layout(set = 0, binding = 3) uniform sampler2D REF;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -174,118 +177,128 @@ void main()
|
||||||
vec4 PH = texture(Source, t4.yw);
|
vec4 PH = texture(Source, t4.yw);
|
||||||
vec4 PI = texture(Source, t4.zw);
|
vec4 PI = texture(Source, t4.zw);
|
||||||
|
|
||||||
vec3 A1 = texture(Original, t1.xw).rgb;
|
vec3 A1 = texture(REF, t1.xw).rgb;
|
||||||
vec3 B1 = texture(Original, t1.yw).rgb;
|
vec3 B1 = texture(REF, t1.yw).rgb;
|
||||||
vec3 C1 = texture(Original, t1.zw).rgb;
|
vec3 C1 = texture(REF, t1.zw).rgb;
|
||||||
|
|
||||||
vec3 A = texture(Original, t2.xw).rgb;
|
vec3 A = texture(REF, t2.xw).rgb;
|
||||||
vec3 B = texture(Original, t2.yw).rgb;
|
vec3 B = texture(REF, t2.yw).rgb;
|
||||||
vec3 C = texture(Original, t2.zw).rgb;
|
vec3 C = texture(REF, t2.zw).rgb;
|
||||||
|
|
||||||
vec3 D = texture(Original, t3.xw).rgb;
|
vec3 D = texture(REF, t3.xw).rgb;
|
||||||
vec3 E = texture(Original, t3.yw).rgb;
|
vec3 E = texture(REF, t3.yw).rgb;
|
||||||
vec3 F = texture(Original, t3.zw).rgb;
|
vec3 F = texture(REF, t3.zw).rgb;
|
||||||
|
|
||||||
vec3 G = texture(Original, t4.xw).rgb;
|
vec3 G = texture(REF, t4.xw).rgb;
|
||||||
vec3 H = texture(Original, t4.yw).rgb;
|
vec3 H = texture(REF, t4.yw).rgb;
|
||||||
vec3 I = texture(Original, t4.zw).rgb;
|
vec3 I = texture(REF, t4.zw).rgb;
|
||||||
|
|
||||||
vec3 G5 = texture(Original, t5.xw).rgb;
|
vec3 G5 = texture(REF, t5.xw).rgb;
|
||||||
vec3 H5 = texture(Original, t5.yw).rgb;
|
vec3 H5 = texture(REF, t5.yw).rgb;
|
||||||
vec3 I5 = texture(Original, t5.zw).rgb;
|
vec3 I5 = texture(REF, t5.zw).rgb;
|
||||||
|
|
||||||
vec3 A0 = texture(Original, t6.xy).rgb;
|
vec3 A0 = texture(REF, t6.xy).rgb;
|
||||||
vec3 D0 = texture(Original, t6.xz).rgb;
|
vec3 D0 = texture(REF, t6.xz).rgb;
|
||||||
vec3 G0 = texture(Original, t6.xw).rgb;
|
vec3 G0 = texture(REF, t6.xw).rgb;
|
||||||
|
|
||||||
vec3 C4 = texture(Original, t7.xy).rgb;
|
vec3 C4 = texture(REF, t7.xy).rgb;
|
||||||
vec3 F4 = texture(Original, t7.xz).rgb;
|
vec3 F4 = texture(REF, t7.xz).rgb;
|
||||||
vec3 I4 = texture(Original, t7.xw).rgb;
|
vec3 I4 = texture(REF, t7.xw).rgb;
|
||||||
|
|
||||||
vec4 b = mul( mat4x3(B, D, H, F), yuv_weighted[0] );
|
float4 b = mul( float4x3(B, D, H, F), yuv_weighted[0] );
|
||||||
vec4 c = mul( mat4x3(C, A, G, I), yuv_weighted[0] );
|
float4 c = mul( float4x3(C, A, G, I), yuv_weighted[0] );
|
||||||
vec4 e = mul( mat4x3(E, E, E, E), yuv_weighted[0] );
|
float4 e = mul( float4x3(E, E, E, E), yuv_weighted[0] );
|
||||||
vec4 d = b.yzwx;
|
float4 d = b.yzwx;
|
||||||
vec4 f = b.wxyz;
|
float4 f = b.wxyz;
|
||||||
vec4 g = c.zwxy;
|
float4 g = c.zwxy;
|
||||||
vec4 h = b.zwxy;
|
float4 h = b.zwxy;
|
||||||
vec4 i = c.wxyz;
|
float4 i = c.wxyz;
|
||||||
|
|
||||||
vec4 i4 = mul( mat4x3(I4, C1, A0, G5), yuv_weighted[0] );
|
|
||||||
vec4 i5 = mul( mat4x3(I5, C4, A1, G0), yuv_weighted[0] );
|
|
||||||
vec4 h5 = mul( mat4x3(H5, F4, B1, D0), yuv_weighted[0] );
|
|
||||||
vec4 f4 = h5.yzwx;
|
|
||||||
|
|
||||||
vec4 pe = remapFrom01(PE, maximo);
|
float4 i4 = mul( float4x3(I4, C1, A0, G5), yuv_weighted[0] );
|
||||||
vec4 pf = remapFrom01(PF, maximo);
|
float4 i5 = mul( float4x3(I5, C4, A1, G0), yuv_weighted[0] );
|
||||||
vec4 ph = remapFrom01(PH, maximo);
|
float4 h5 = mul( float4x3(H5, F4, B1, D0), yuv_weighted[0] );
|
||||||
vec4 pb = remapFrom01(PB, maximo);
|
float4 f4 = h5.yzwx;
|
||||||
vec4 pd = remapFrom01(PD, maximo);
|
|
||||||
|
|
||||||
vec4 f2 = vec4(pf.z, pb.w, pd.x, ph.y);
|
|
||||||
vec4 h2 = vec4(ph.z, pf.w, pb.x, pd.y);
|
|
||||||
vec4 f1 = vec4(pf.y, pb.z, pd.w, ph.x);
|
|
||||||
vec4 h3 = vec4(ph.w, pf.x, pb.y, pd.z);
|
|
||||||
|
|
||||||
bvec4 nbrs;
|
float4 pe = remapFrom01(PE, maximo);
|
||||||
nbrs.x = (pe.y > 1.0) || (pe.w > 1.0) ? true : false;
|
float4 pf = remapFrom01(PF, maximo);
|
||||||
nbrs.y = (pe.z > 1.0) || (pe.x > 1.0) ? true : false;
|
float4 ph = remapFrom01(PH, maximo);
|
||||||
nbrs.z = (pe.w > 1.0) || (pe.y > 1.0) ? true : false;
|
float4 pb = remapFrom01(PB, maximo);
|
||||||
nbrs.w = (pe.x > 1.0) || (pe.z > 1.0) ? true : false;
|
float4 pd = remapFrom01(PD, maximo);
|
||||||
|
|
||||||
bvec4 jag1;
|
|
||||||
jag1.x = (f2.x > 1.0) || (h2.x > 1.0) ? true : false;
|
|
||||||
jag1.y = (f2.y > 1.0) || (h2.y > 1.0) ? true : false;
|
|
||||||
jag1.z = (f2.z > 1.0) || (h2.z > 1.0) ? true : false;
|
|
||||||
jag1.w = (f2.w > 1.0) || (h2.w > 1.0) ? true : false;
|
|
||||||
|
|
||||||
bvec4 jag2;
|
|
||||||
jag2.x = (f2.x > 2.0) || (h2.x > 2.0) ? true : false;
|
|
||||||
jag2.x = (f2.y > 2.0) || (h2.y > 2.0) ? true : false;
|
|
||||||
jag2.x = (f2.z > 2.0) || (h2.z > 2.0) ? true : false;
|
|
||||||
jag2.x = (f2.w > 2.0) || (h2.w > 2.0) ? true : false;
|
|
||||||
|
|
||||||
bvec4 jag3;
|
|
||||||
jag3.x = (f2.x > 4.0) || (h2.x > 4.0) ? true : false;
|
|
||||||
jag3.y = (f2.y > 4.0) || (h2.y > 4.0) ? true : false;
|
|
||||||
jag3.z = (f2.z > 4.0) || (h2.z > 4.0) ? true : false;
|
|
||||||
jag3.w = (f2.w > 4.0) || (h2.w > 4.0) ? true : false;
|
|
||||||
|
|
||||||
pe.x = (pe.x == 7.0 || pe.x == 8.0) ? ((jag3.x) ? pe.x : (pe.x - 2.0)) : pe.x;
|
float4 f2 = float4(pf.z, pb.w, pd.x, ph.y);
|
||||||
pe.y = (pe.y == 7.0 || pe.y == 8.0) ? ((jag3.y) ? pe.y : (pe.y - 2.0)) : pe.y;
|
float4 h2 = float4(ph.z, pf.w, pb.x, pd.y);
|
||||||
pe.z = (pe.z == 7.0 || pe.z == 8.0) ? ((jag3.z) ? pe.z : (pe.z - 2.0)) : pe.z;
|
float4 f1 = float4(pf.y, pb.z, pd.w, ph.x);
|
||||||
pe.w = (pe.w == 7.0 || pe.w == 8.0) ? ((jag3.w) ? pe.w : (pe.w - 2.0)) : pe.w;
|
float4 h3 = float4(ph.w, pf.x, pb.y, pd.z);
|
||||||
|
|
||||||
pe.x = (pe.x == 5.0 || pe.x == 6.0) ? ((jag2.x) ? pe.x : (pe.x - 2.0)) : pe.x;
|
|
||||||
pe.y = (pe.y == 5.0 || pe.y == 6.0) ? ((jag2.y) ? pe.y : (pe.y - 2.0)) : pe.y;
|
|
||||||
pe.z = (pe.z == 5.0 || pe.z == 6.0) ? ((jag2.z) ? pe.z : (pe.z - 2.0)) : pe.z;
|
|
||||||
pe.w = (pe.w == 5.0 || pe.w == 6.0) ? ((jag2.w) ? pe.w : (pe.w - 2.0)) : pe.w;
|
|
||||||
|
|
||||||
bvec4 jag91;
|
bool4 nbrs;
|
||||||
jag91.x = ((id(h,i,e,h).x || id(i4,i,f4,i4).x) && (f2.x > 1.0) && (f1.x > 1.0));
|
// bool4 nbrs = ((pe.yzwx > 1.0) || (pe.wxyz > 1.0)) ? bool4(true) : bool4(false);
|
||||||
jag91.y = ((id(h,i,e,h).y || id(i4,i,f4,i4).y) && (f2.y > 1.0) && (f1.y > 1.0));
|
nbrs.x = ((pe.y > 1.0) || (pe.w > 1.0));
|
||||||
jag91.z = ((id(h,i,e,h).z || id(i4,i,f4,i4).z) && (f2.z > 1.0) && (f1.z > 1.0));
|
nbrs.y = ((pe.z > 1.0) || (pe.x > 1.0));
|
||||||
jag91.w = ((id(h,i,e,h).w || id(i4,i,f4,i4).w) && (f2.w > 1.0) && (f1.w > 1.0));
|
nbrs.z = ((pe.w > 1.0) || (pe.y > 1.0));
|
||||||
|
nbrs.w = ((pe.x > 1.0) || (pe.z > 1.0));
|
||||||
|
|
||||||
|
bool4 jag1;
|
||||||
|
// bool4 jag1 = ((f2 > 1.0) || (h2 > 1.0)) ? bool4(true) : bool4(false);
|
||||||
|
jag1.x = ((f2.x > 1.0) || (h2.x > 1.0));
|
||||||
|
jag1.y = ((f2.y > 1.0) || (h2.y > 1.0));
|
||||||
|
jag1.z = ((f2.z > 1.0) || (h2.z > 1.0));
|
||||||
|
jag1.w = ((f2.w > 1.0) || (h2.w > 1.0));
|
||||||
|
|
||||||
|
bool4 jag2;
|
||||||
|
// bool4 jag2 = ((f2 > 2.0) || (h2 > 2.0)) ? bool4(true) : bool4(false);
|
||||||
|
jag2.x = ((f2.x > 2.0) || (h2.x > 2.0));
|
||||||
|
jag2.x = ((f2.y > 2.0) || (h2.y > 2.0));
|
||||||
|
jag2.x = ((f2.z > 2.0) || (h2.z > 2.0));
|
||||||
|
jag2.x = ((f2.w > 2.0) || (h2.w > 2.0));
|
||||||
|
|
||||||
|
bool4 jag3;
|
||||||
|
// bool4 jag3 = ((f2 > 4.0) || (h2 > 4.0)) ? bool4(true) : bool4(false);
|
||||||
|
jag3.x = ((f2.x > 4.0) || (h2.x > 4.0));
|
||||||
|
jag3.y = ((f2.y > 4.0) || (h2.y > 4.0));
|
||||||
|
jag3.z = ((f2.z > 4.0) || (h2.z > 4.0));
|
||||||
|
jag3.w = ((f2.w > 4.0) || (h2.w > 4.0));
|
||||||
|
|
||||||
bvec4 jag92;
|
// pe = (pe == 7.0 || pe == 8.0) ? ((jag3 ) ? pe : (pe - float(2.0))) : pe;
|
||||||
jag92.x = ((id(f,i,e,f).x || id(i5,i,h5,i5).x) && (h2.x > 1.0) && (h3.x > 1.0));
|
pe.x = (pe.x == 7.0 || pe.x == 8.0) ? ((jag3.x) ? pe.x : (pe.x - float(2.0))) : pe.x;
|
||||||
jag92.y = ((id(f,i,e,f).y || id(i5,i,h5,i5).y) && (h2.y > 1.0) && (h3.y > 1.0));
|
pe.y = (pe.y == 7.0 || pe.y == 8.0) ? ((jag3.y) ? pe.y : (pe.y - float(2.0))) : pe.y;
|
||||||
jag92.z = ((id(f,i,e,f).z || id(i5,i,h5,i5).z) && (h2.z > 1.0) && (h3.z > 1.0));
|
pe.z = (pe.z == 7.0 || pe.z == 8.0) ? ((jag3.z) ? pe.z : (pe.z - float(2.0))) : pe.z;
|
||||||
jag92.w = ((id(f,i,e,f).w || id(i5,i,h5,i5).w) && (h2.w > 1.0) && (h3.w > 1.0));
|
pe.w = (pe.w == 7.0 || pe.w == 8.0) ? ((jag3.w) ? pe.w : (pe.w - float(2.0))) : pe.w;
|
||||||
|
|
||||||
|
// pe = (pe == 5.0 || pe == 6.0) ? ((jag2 ) ? pe : (pe - float(2.0))) : pe;
|
||||||
|
pe.x = (pe.x == 5.0 || pe.x == 6.0) ? ((jag2.x) ? pe.x : (pe.x - float(2.0))) : pe.x;
|
||||||
|
pe.y = (pe.y == 5.0 || pe.y == 6.0) ? ((jag2.y) ? pe.y : (pe.y - float(2.0))) : pe.y;
|
||||||
|
pe.z = (pe.z == 5.0 || pe.z == 6.0) ? ((jag2.z) ? pe.z : (pe.z - float(2.0))) : pe.z;
|
||||||
|
pe.w = (pe.w == 5.0 || pe.w == 6.0) ? ((jag2.w) ? pe.w : (pe.w - float(2.0))) : pe.w;
|
||||||
|
|
||||||
|
bool4 jag91;
|
||||||
|
// bool4 jag91 = ((id(h,i,e,h) || id(i4,i,f4,i4) ) && (f2 > 1.0) && (f1 > 1.0));
|
||||||
|
jag91.x = ((id(h,i,e,h).x || id(i4,i,f4,i4).x) && (f2.x > 1.0) && (f1.x > 1.0));
|
||||||
|
jag91.y = ((id(h,i,e,h).y || id(i4,i,f4,i4).y) && (f2.y > 1.0) && (f1.y > 1.0));
|
||||||
|
jag91.z = ((id(h,i,e,h).z || id(i4,i,f4,i4).z) && (f2.z > 1.0) && (f1.z > 1.0));
|
||||||
|
jag91.w = ((id(h,i,e,h).w || id(i4,i,f4,i4).w) && (f2.w > 1.0) && (f1.w > 1.0));
|
||||||
|
|
||||||
|
bool4 jag92;
|
||||||
|
// bool4 jag92 = ((id(f,i,e,f) || id(i5,i,h5,i5) ) && (h2 > 1.0) && (h3 > 1.0));
|
||||||
|
jag92.x = ((id(f,i,e,f).x || id(i5,i,h5,i5).x) && (h2.x > 1.0) && (h3.x > 1.0));
|
||||||
|
jag92.y = ((id(f,i,e,f).y || id(i5,i,h5,i5).y) && (h2.y > 1.0) && (h3.y > 1.0));
|
||||||
|
jag92.z = ((id(f,i,e,f).z || id(i5,i,h5,i5).z) && (h2.z > 1.0) && (h3.z > 1.0));
|
||||||
|
jag92.w = ((id(f,i,e,f).w || id(i5,i,h5,i5).w) && (h2.w > 1.0) && (h3.w > 1.0));
|
||||||
|
|
||||||
bvec4 jag93 = ( rd(h,g,e,g));
|
bvec4 jag93 = ( rd(h,g,e,g));
|
||||||
bvec4 jag94 = ( rd(f,c,e,c));
|
bvec4 jag94 = ( rd(f,c,e,c));
|
||||||
|
|
||||||
bvec4 jag9;
|
|
||||||
jag9.x = (!(jag91.x && jag93.x || jag92.x && jag94.x));
|
|
||||||
jag9.y = (!(jag91.y && jag93.y || jag92.y && jag94.y));
|
|
||||||
jag9.z = (!(jag91.z && jag93.z || jag92.z && jag94.z));
|
|
||||||
jag9.w = (!(jag91.w && jag93.w || jag92.w && jag94.w));
|
|
||||||
|
|
||||||
pe.x = ((pe.x == 0.0) || (!nbrs.x || jag1.x) && jag9.x) ? pe.x : 1.0;
|
bool4 jag9;
|
||||||
pe.y = ((pe.y == 0.0) || (!nbrs.y || jag1.y) && jag9.y) ? pe.y : 1.0;
|
// bool4 jag9 = (!(jag91 && jag93 || jag92 && jag94 ));
|
||||||
pe.z = ((pe.z == 0.0) || (!nbrs.z || jag1.z) && jag9.z) ? pe.z : 1.0;
|
jag9.x = (!(jag91.x && jag93.x || jag92.x && jag94.x));
|
||||||
pe.w = ((pe.w == 0.0) || (!nbrs.w || jag1.w) && jag9.w) ? pe.w : 1.0;
|
jag9.y = (!(jag91.y && jag93.y || jag92.y && jag94.y));
|
||||||
|
jag9.z = (!(jag91.z && jag93.z || jag92.z && jag94.z));
|
||||||
|
jag9.w = (!(jag91.w && jag93.w || jag92.w && jag94.w));
|
||||||
|
|
||||||
|
// pe = ((pe == 0.0) || (!nbrs || jag1 ) && jag9 ) ? pe : float4(1.0);
|
||||||
|
pe.x = ((pe.x == 0.0) || (!nbrs.x || jag1.x) && jag9.x) ? pe.x : float(1.0);
|
||||||
|
pe.y = ((pe.y == 0.0) || (!nbrs.y || jag1.y) && jag9.y) ? pe.y : float(1.0);
|
||||||
|
pe.z = ((pe.z == 0.0) || (!nbrs.z || jag1.z) && jag9.z) ? pe.z : float(1.0);
|
||||||
|
pe.w = ((pe.w == 0.0) || (!nbrs.w || jag1.w) && jag9.w) ? pe.w : float(1.0);
|
||||||
|
|
||||||
FragColor = vec4(remapTo01(pe, maximo));
|
FragColor = vec4(remapTo01(pe, maximo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
|
vec4 REFSize;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
@ -39,43 +40,59 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#define round(X) floor((X)+0.5)
|
// compatibility macros
|
||||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
|
#define saturate(c) clamp(c, 0.0, 1.0)
|
||||||
|
#define frac(x) (fract(x))
|
||||||
|
#define float2 vec2
|
||||||
|
#define float3 vec3
|
||||||
|
#define float4 vec4
|
||||||
|
#define bool2 bvec2
|
||||||
|
#define bool3 bvec3
|
||||||
|
#define bool4 bvec4
|
||||||
|
#define float3x3 mat3x3
|
||||||
|
#define float4x3 mat4x3
|
||||||
|
#define float2x4 mat2x4
|
||||||
|
#define texture_size params.SourceSize
|
||||||
|
#define video_size params.SourceSize
|
||||||
|
#define output_size params.OutputSize
|
||||||
|
|
||||||
const float coef = 2.0;
|
#define round(X) floor((X)+0.5)
|
||||||
const float cf = 4.0;
|
|
||||||
const float eq_threshold = 15.0;
|
|
||||||
const float y_weight = 48.0;
|
|
||||||
const float u_weight = 7.0;
|
|
||||||
const float v_weight = 6.0;
|
|
||||||
const mat3 yuv = mat3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813);
|
|
||||||
const mat3 yuv_weighted = mat3(y_weight*yuv[0], u_weight*yuv[1], v_weight*yuv[2]);
|
|
||||||
const vec4 maximo = vec4(255.0, 255.0, 255.0, 255.0);
|
|
||||||
const vec4 low = vec4(-64.0, -64.0, -64.0, -64.0);
|
|
||||||
const vec4 high = vec4( 64.0, 64.0, 64.0, 64.0);
|
|
||||||
|
|
||||||
const mat2x4 sym_vectors = mat2x4(1., 1., -1., -1., 1., -1., -1., 1.);
|
const float coef = 2.0;
|
||||||
|
const float cf = 4.0;
|
||||||
|
const float eq_threshold = 15.0;
|
||||||
|
const float y_weight = 48.0;
|
||||||
|
const float u_weight = 7.0;
|
||||||
|
const float v_weight = 6.0;
|
||||||
|
const float3x3 yuv = float3x3(0.299, 0.587, 0.114, -0.169, -0.331, 0.499, 0.499, -0.418, -0.0813);
|
||||||
|
const float3x3 yuv_weighted = float3x3(y_weight*yuv[0], u_weight*yuv[1], v_weight*yuv[2]);
|
||||||
|
const float4 maximo = float4(255.0, 255.0, 255.0, 255.0);
|
||||||
|
const float4 low = float4(-64.0, -64.0, -64.0, -64.0);
|
||||||
|
const float4 high = float4( 64.0, 64.0, 64.0, 64.0);
|
||||||
|
|
||||||
|
|
||||||
|
const float2x4 sym_vectors = float2x4(1., 1., -1., -1., 1., -1., -1., 1.);
|
||||||
|
|
||||||
// Bx, Ay, C
|
// Bx, Ay, C
|
||||||
const vec3 lines[13] = {
|
const float3 lines[13] = float3[](
|
||||||
vec3(4.0, 4.0, 4.0), // 0 NL
|
float3(4.0, 4.0, 4.0), // 0 NL
|
||||||
vec3(4.0, 4.0, 3.0), // 1 LV0
|
float3(4.0, 4.0, 3.0), // 1 LV0
|
||||||
vec3(4.0, 4.0, 2.0), // 2 LV1
|
float3(4.0, 4.0, 2.0), // 2 LV1
|
||||||
vec3(8.0, 4.0, 2.0), // 3 LV2u
|
float3(8.0, 4.0, 2.0), // 3 LV2u
|
||||||
vec3(4.0, 8.0, 2.0), // 4 LV2l
|
float3(4.0, 8.0, 2.0), // 4 LV2l
|
||||||
vec3(12.0, 4.0, 2.0), // 5 LV3u
|
float3(12.0, 4.0, 2.0), // 5 LV3u
|
||||||
vec3(4.0,12.0, 2.0), // 6 LV3l
|
float3(4.0,12.0, 2.0), // 6 LV3l
|
||||||
vec3(16.0, 4.0, 2.0), // 7 LV4u
|
float3(16.0, 4.0, 2.0), // 7 LV4u
|
||||||
vec3(4.0,16.0, 2.0), // 8 LV4l
|
float3(4.0,16.0, 2.0), // 8 LV4l
|
||||||
|
|
||||||
vec3(12.0, 4.0, 6.0), // 9 LV3u
|
float3(12.0, 4.0, 6.0), // 9 LV3u
|
||||||
vec3(4.0,12.0, 6.0), // 10 LV3l
|
float3(4.0,12.0, 6.0), // 10 LV3l
|
||||||
vec3(16.0, 4.0, 6.0), // 11 LV4u
|
float3(16.0, 4.0, 6.0), // 11 LV4u
|
||||||
vec3(4.0,16.0, 6.0) // 12 LV4l
|
float3(4.0,16.0, 6.0) // 12 LV4l
|
||||||
};
|
);
|
||||||
|
|
||||||
vec4 remapTo01(vec4 v, vec4 low, vec4 high)
|
float4 remapTo01(float4 v, float4 low, float4 high)
|
||||||
{
|
{
|
||||||
return saturate((v - low)/(high-low));
|
return saturate((v - low)/(high-low));
|
||||||
}
|
}
|
||||||
|
@ -110,9 +127,10 @@ void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord * 1.0004;
|
vTexCoord = TexCoord * 1.0004;
|
||||||
float dx = params.OriginalSize.z;
|
float2 ps = float2(1.0/params.REFSize.x, 1.0/params.REFSize.y);
|
||||||
float dy = params.OriginalSize.w;
|
float dx = ps.x;
|
||||||
|
float dy = ps.y;
|
||||||
|
|
||||||
// A3 B3 C3
|
// A3 B3 C3
|
||||||
// A1 B1 C1
|
// A1 B1 C1
|
||||||
//A2 A0 A B C C4 C6
|
//A2 A0 A B C C4 C6
|
||||||
|
@ -120,8 +138,8 @@ void main()
|
||||||
//G2 G0 G H I I4 I6
|
//G2 G0 G H I I4 I6
|
||||||
// G5 H5 I5
|
// G5 H5 I5
|
||||||
// G7 H7 I7
|
// G7 H7 I7
|
||||||
|
|
||||||
t1 = vec4(dx, 0., 0., dy); // F H
|
t1 = float4(dx, 0., 0., dy); // F H
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma stage fragment
|
#pragma stage fragment
|
||||||
|
@ -129,103 +147,94 @@ layout(location = 0) in vec2 vTexCoord;
|
||||||
layout(location = 1) in vec4 t1;
|
layout(location = 1) in vec4 t1;
|
||||||
layout(location = 0) out vec4 FragColor;
|
layout(location = 0) out vec4 FragColor;
|
||||||
layout(set = 0, binding = 2) uniform sampler2D Source;
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
layout(set = 0, binding = 3) uniform sampler2D Original;
|
layout(set = 0, binding = 3) uniform sampler2D REF;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float px;
|
float px;
|
||||||
|
|
||||||
vec2 pos = fract(vTexCoord.xy * params.OriginalSize.xy) - vec2(0.4999, 0.4999); // pos = pixel position
|
float2 pos = frac(vTexCoord*params.REFSize.xy)-float2(0.5, 0.5); // pos = pixel position
|
||||||
vec2 dir = sign(pos); // dir = pixel direction
|
float2 dir = sign(pos); // dir = pixel direction
|
||||||
|
|
||||||
vec2 g1 = dir * ( saturate(-dir.y*dir.x) * t1.zw + saturate( dir.y*dir.x) * t1.xy );
|
float2 g1 = dir*( saturate(-dir.y*dir.x)*t1.zw + saturate( dir.y*dir.x)*t1.xy);
|
||||||
vec2 g2 = dir * ( saturate( dir.y*dir.x) * t1.zw + saturate(-dir.y*dir.x) * t1.xy );
|
float2 g2 = dir*( saturate( dir.y*dir.x)*t1.zw + saturate(-dir.y*dir.x)*t1.xy);
|
||||||
|
|
||||||
vec3 E = texture(Original, vTexCoord ).rgb;
|
float3 E = texture(REF, vTexCoord ).rgb;
|
||||||
vec3 F = texture(Original, vTexCoord + g1).rgb;
|
float3 F = texture(REF, vTexCoord +g1).rgb;
|
||||||
vec3 H = texture(Original, vTexCoord + g2).rgb;
|
float3 H = texture(REF, vTexCoord +g2).rgb;
|
||||||
vec3 I = texture(Original, vTexCoord + g1 + g2).rgb;
|
float3 I = texture(REF, vTexCoord +g1+g2).rgb;
|
||||||
vec3 F4 = texture(Original, vTexCoord + 2.0 * g1).rgb;
|
float3 F4 = texture(REF, vTexCoord +2.0*g1).rgb;
|
||||||
vec3 H5 = texture(Original, vTexCoord + 2.0 * g2).rgb;
|
float3 H5 = texture(REF, vTexCoord +2.0*g2).rgb;
|
||||||
|
|
||||||
float e = dot(E, yuv_weighted[0]);
|
float e = dot(E, yuv_weighted[0]);
|
||||||
float f = dot(F, yuv_weighted[0]);
|
float f = dot(F, yuv_weighted[0]);
|
||||||
float h = dot(H, yuv_weighted[0]);
|
float h = dot(H, yuv_weighted[0]);
|
||||||
float i = dot(I, yuv_weighted[0]);
|
float i = dot(I, yuv_weighted[0]);
|
||||||
float f4 = dot(F4, yuv_weighted[0]);
|
float f4= dot(F4, yuv_weighted[0]);
|
||||||
float h5 = dot(H5, yuv_weighted[0]);
|
float h5= dot(H5, yuv_weighted[0]);
|
||||||
|
|
||||||
vec4 icomp = round(saturate(mul(dir, sym_vectors))); // choose info component
|
|
||||||
|
|
||||||
float infoE = remapFrom01(dot(texture(Source, vTexCoord ), icomp), 255.0); // retrieve 1st pass info
|
float4 icomp = round(saturate(mul(dir, sym_vectors))); // choose info component
|
||||||
float infoF = remapFrom01(dot(texture(Source, vTexCoord+g1), icomp), 255.0); // 1st pass info from neighbor r
|
|
||||||
float infoH = remapFrom01(dot(texture(Source, vTexCoord+g2), icomp), 255.0); // 1st pass info from neighbor d
|
float infoE = remapFrom01(dot(texture(Source, vTexCoord ), icomp), 255.0); // retrieve 1st pass info
|
||||||
|
float infoF = remapFrom01(dot(texture(Source, vTexCoord+g1), icomp), 255.0); // 1st pass info from neighbor r
|
||||||
|
float infoH = remapFrom01(dot(texture(Source, vTexCoord+g2), icomp), 255.0); // 1st pass info from neighbor d
|
||||||
|
|
||||||
|
float4 lparam;
|
||||||
|
float2 addr;
|
||||||
|
|
||||||
vec4 lparam;
|
|
||||||
vec2 addr;
|
|
||||||
|
|
||||||
if (infoF == 8.0)
|
if (infoF == 8.0)
|
||||||
{
|
{
|
||||||
lparam.xyz = lines[12];
|
lparam.xyz = lines[12];
|
||||||
px = float(df(f,f4) <= df(f,i));
|
px = float(df(f,f4) <= df(f,i));
|
||||||
addr.x = 2. * px + saturate(1.0 - px);
|
addr.x = 2.*px + saturate(1.0-px);
|
||||||
addr.y = saturate(1.0 - px);
|
addr.y = saturate(1.0-px);
|
||||||
}
|
}
|
||||||
else if (infoH == 7.0)
|
else if (infoH == 7.0)
|
||||||
{
|
{
|
||||||
lparam.xyz = lines[11];
|
lparam.xyz = lines[11];
|
||||||
px = float(df(h,h5) <= df(h,i));
|
px = float(df(h,h5) <= df(h,i));
|
||||||
addr.x = saturate(1.0 - px);
|
addr.x = saturate(1.0-px);
|
||||||
addr.y = 2. * px + saturate(1.0 - px);
|
addr.y = 2.*px + saturate(1.0-px);
|
||||||
}
|
}
|
||||||
else if (infoF == 6.0)
|
else if (infoF == 6.0)
|
||||||
{
|
{
|
||||||
lparam.xyz = lines[10];
|
lparam.xyz = lines[10];
|
||||||
px = float(df(f,f4) <= df(f,i));
|
px = float(df(f,f4) <= df(f,i));
|
||||||
addr.x = 2. * px + saturate(1.0 - px);
|
addr.x = 2.*px + saturate(1.0-px);
|
||||||
addr.y = saturate(1.0 - px);
|
addr.y = saturate(1.0-px);
|
||||||
}
|
}
|
||||||
else if (infoH == 5.0)
|
else if (infoH == 5.0)
|
||||||
{
|
{
|
||||||
lparam.xyz = lines[9];
|
lparam.xyz = lines[9];
|
||||||
px = float(df(h,h5) <= df(h,i));
|
px = float(df(h,h5) <= df(h,i));
|
||||||
addr.x = saturate(1.0 - px);
|
addr.x = saturate(1.0-px);
|
||||||
addr.y = 2. * px + saturate(1.0 - px);
|
addr.y = 2.*px + saturate(1.0-px);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
px = float(df(e,f) <= df(e,h));
|
px = float(df(e,f) <= df(e,h));
|
||||||
addr.x = px;
|
addr.x = px;
|
||||||
addr.y = saturate(1.0 - px);
|
addr.y = saturate(1.0-px);
|
||||||
/*
|
|
||||||
lparam.xyz = ((infoE == 1.0) ? lines[1] : lines[0]);
|
|
||||||
lparam.xyz = ((infoE == 2.0) ? lines[2] : lparam.xyz);
|
|
||||||
lparam.xyz = ((infoE == 3.0) ? lines[3] : lparam.xyz);
|
|
||||||
lparam.xyz = ((infoE == 4.0) ? lines[4] : lparam.xyz);
|
|
||||||
lparam.xyz = ((infoE == 5.0) ? lines[5] : lparam.xyz);
|
|
||||||
lparam.xyz = ((infoE == 6.0) ? lines[6] : lparam.xyz);
|
|
||||||
lparam.xyz = ((infoE == 7.0) ? lines[7] : lparam.xyz);
|
|
||||||
lparam.xyz = ((infoE == 8.0) ? lines[8] : lparam.xyz);
|
|
||||||
*/
|
|
||||||
lparam.xyz = (infoE == 8.0) ? lines[8] : ((infoE == 7.0) ? lines[7] : ((infoE == 6.0) ? lines[6] : ((infoE == 5.0) ? lines[5] : ((infoE == 4.0) ? lines[4] : ((infoE == 3.0) ? lines[3] : ((infoE == 2.0) ? lines[2] : ((infoE == 1.0) ? lines[1] : lines[0])))))));
|
lparam.xyz = (infoE == 8.0) ? lines[8] : ((infoE == 7.0) ? lines[7] : ((infoE == 6.0) ? lines[6] : ((infoE == 5.0) ? lines[5] : ((infoE == 4.0) ? lines[4] : ((infoE == 3.0) ? lines[3] : ((infoE == 2.0) ? lines[2] : ((infoE == 1.0) ? lines[1] : lines[0])))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inv = (dir.x*dir.y) < 0.0 ? true : false;
|
bool inv = (dir.x*dir.y) < 0.0 ? true : false;
|
||||||
|
|
||||||
// Rotate address from relative to absolute.
|
// Rotate address from relative to absolute.
|
||||||
addr = addr * dir.yx;
|
addr = addr*dir.yx;
|
||||||
addr = inv ? addr.yx : addr;
|
addr = inv ? addr.yx : addr;
|
||||||
|
|
||||||
// Rotate straight line equation from relative to absolute.
|
// Rotate straight line equation from relative to absolute.
|
||||||
lparam.xy = lparam.xy * dir.yx;
|
lparam.xy = lparam.xy*dir.yx;
|
||||||
lparam.xy = inv ? lparam.yx : lparam.xy;
|
lparam.xy = inv ? lparam.yx : lparam.xy;
|
||||||
|
|
||||||
addr.x += 2.0;
|
addr.x+=2.0;
|
||||||
addr.y += 2.0;
|
addr.y+=2.0;
|
||||||
|
|
||||||
lparam.w = addr.x * 8.0 + addr.y;
|
lparam.w = addr.x*8.0 + addr.y;
|
||||||
|
|
||||||
FragColor = vec4(remapTo01(lparam, low, high));
|
FragColor = float4(remapTo01(lparam, low, high));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -247,4 +256,4 @@ void main()
|
||||||
0 1 2 3 4
|
0 1 2 3 4
|
||||||
-2 -1 0 1 2
|
-2 -1 0 1 2
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,6 +32,7 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
|
vec4 REFSize;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
layout(std140, set = 0, binding = 0) uniform UBO
|
layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
|
@ -39,36 +40,56 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
||||||
mat4 MVP;
|
mat4 MVP;
|
||||||
} global;
|
} global;
|
||||||
|
|
||||||
#define round(X) floor((X)+0.5)
|
// compatibility macros
|
||||||
#define mul(a,b) (b*a)
|
#define mul(a,b) (b*a)
|
||||||
|
#define lerp(a,b,c) mix(a,b,c)
|
||||||
#define saturate(c) clamp(c, 0.0, 1.0)
|
#define saturate(c) clamp(c, 0.0, 1.0)
|
||||||
|
#define frac(x) (fract(x))
|
||||||
|
#define float2 vec2
|
||||||
|
#define float3 vec3
|
||||||
|
#define float4 vec4
|
||||||
|
#define bool2 bvec2
|
||||||
|
#define bool3 bvec3
|
||||||
|
#define bool4 bvec4
|
||||||
|
#define float3x3 mat3x3
|
||||||
|
#define float4x3 mat4x3
|
||||||
|
#define float2x4 mat2x4
|
||||||
|
#define texture_size params.SourceSize
|
||||||
|
#define video_size params.SourceSize
|
||||||
|
#define output_size params.OutputSize
|
||||||
|
|
||||||
const vec3 bin = vec3( 4.0, 2.0, 1.0);
|
#define round(X) floor((X)+0.5)
|
||||||
const vec4 low = vec4(-64.0, -64.0, -64.0, -64.0);
|
|
||||||
const vec4 high = vec4( 64.0, 64.0, 64.0, 64.0);
|
|
||||||
|
|
||||||
vec4 remapFrom01(vec4 v, vec4 low, vec4 high)
|
const float3 bin = float3( 4.0, 2.0, 1.0);
|
||||||
|
const float4 low = float4(-64.0, -64.0, -64.0, -64.0);
|
||||||
|
const float4 high = float4( 64.0, 64.0, 64.0, 64.0);
|
||||||
|
|
||||||
|
const float2x4 sym_vectors = float2x4(1., 1., -1., -1., 1., -1., -1., 1.);
|
||||||
|
|
||||||
|
float4 remapFrom01(float4 v, float4 low, float4 high)
|
||||||
{
|
{
|
||||||
return round(mix(low, high, v));
|
return round(lerp(low, high, v));
|
||||||
}
|
}
|
||||||
|
|
||||||
float c_df(vec3 c1, vec3 c2)
|
float c_df(float3 c1, float3 c2)
|
||||||
{
|
{
|
||||||
vec3 df = abs(c1 - c2);
|
float3 df = abs(c1 - c2);
|
||||||
return df.r + df.g + df.b;
|
return df.r + df.g + df.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 unpack_info(float i)
|
|
||||||
|
float4 unpack_info(float i)
|
||||||
{
|
{
|
||||||
vec4 info;
|
float4 info;
|
||||||
info.x = round(modf(i / 2.0, i));
|
info.x = round(modf(i/2.0, i));
|
||||||
info.y = round(modf(i / 2.0, i));
|
info.y = round(modf(i/2.0, i));
|
||||||
info.z = round(modf(i / 2.0, i));
|
info.z = round(modf(i/2.0, i));
|
||||||
info.w = i;
|
info.w = i;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float df(float A, float B)
|
float df(float A, float B)
|
||||||
{
|
{
|
||||||
return abs(A-B);
|
return abs(A-B);
|
||||||
|
@ -76,15 +97,15 @@ float df(float A, float B)
|
||||||
|
|
||||||
#define GET_PIXEL(PARAM, PIXEL)\
|
#define GET_PIXEL(PARAM, PIXEL)\
|
||||||
info = PARAM;\
|
info = PARAM;\
|
||||||
ay.z = round( modf( info / 2.0, info ) );\
|
ay.z = round( modf( info/2.0, info ) );\
|
||||||
ay.y = round( modf( info / 2.0, info ) );\
|
ay.y = round( modf( info/2.0, info ) );\
|
||||||
ay.x = round( modf( info / 2.0, info ) );\
|
ay.x = round( modf( info/2.0, info ) );\
|
||||||
ax.z = round( modf( info / 2.0, info ) );\
|
ax.z = round( modf( info/2.0, info ) );\
|
||||||
ax.y = round( modf( info / 2.0, info ) );\
|
ax.y = round( modf( info/2.0, info ) );\
|
||||||
ax.x = round( info );\
|
ax.x = round( info );\
|
||||||
iq.x = dot( ax, bin ) - 2.0;\
|
iq.x = dot( ax, bin ) - 2.0;\
|
||||||
iq.y = dot( ay, bin ) - 2.0;\
|
iq.y = dot( ay, bin ) - 2.0;\
|
||||||
PIXEL = texture( Original, vTexCoord + iq.x * t1.xy + iq.y * t1.zw ).xyz;
|
PIXEL = texture( REF, vTexCoord + iq.x*t1.xy + iq.y*t1.zw ).xyz;\
|
||||||
|
|
||||||
#pragma stage vertex
|
#pragma stage vertex
|
||||||
layout(location = 0) in vec4 Position;
|
layout(location = 0) in vec4 Position;
|
||||||
|
@ -97,9 +118,10 @@ void main()
|
||||||
{
|
{
|
||||||
gl_Position = global.MVP * Position;
|
gl_Position = global.MVP * Position;
|
||||||
vTexCoord = TexCoord * 1.0004;
|
vTexCoord = TexCoord * 1.0004;
|
||||||
float dx = params.OriginalSize.z;
|
float2 ps = float2(1.0/params.REFSize.x, 1.0/params.REFSize.y);
|
||||||
float dy = params.OriginalSize.w;
|
float dx = ps.x;
|
||||||
|
float dy = ps.y;
|
||||||
|
|
||||||
// A3 B3 C3
|
// A3 B3 C3
|
||||||
// A1 B1 C1
|
// A1 B1 C1
|
||||||
//A2 A0 A B C C4 C6
|
//A2 A0 A B C C4 C6
|
||||||
|
@ -107,8 +129,9 @@ void main()
|
||||||
//G2 G0 G H I I4 I6
|
//G2 G0 G H I I4 I6
|
||||||
// G5 H5 I5
|
// G5 H5 I5
|
||||||
// G7 H7 I7
|
// G7 H7 I7
|
||||||
t1 = vec4(dx, 0., 0., dy); // F H
|
|
||||||
scale_factor = params.OutputSize.x * params.OriginalSize.z;
|
t1 = float4(dx, 0., 0., dy); // F H
|
||||||
|
scale_factor = output_size.x/params.REFSize.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma stage fragment
|
#pragma stage fragment
|
||||||
|
@ -117,59 +140,66 @@ layout(location = 1) in vec4 t1;
|
||||||
layout(location = 2) in float scale_factor;
|
layout(location = 2) in float scale_factor;
|
||||||
layout(location = 0) out vec4 FragColor;
|
layout(location = 0) out vec4 FragColor;
|
||||||
layout(set = 0, binding = 2) uniform sampler2D Source;
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
layout(set = 0, binding = 3) uniform sampler2D Original;
|
layout(set = 0, binding = 3) uniform sampler2D REF;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 fp = fract( vTexCoord * params.OriginalSize.xy ) - vec2( 0.4999, 0.4999 ); // pos = pixel position
|
float2 fp = frac( vTexCoord*params.REFSize.xy ) - float2( 0.5, 0.5 ); // pos = pixel position
|
||||||
|
|
||||||
vec2 pxcoord = floor(vTexCoord * params.OriginalSize.xy) * params.OriginalSize.zw;
|
float2 pxcoord = floor(vTexCoord*params.REFSize.xy)/params.REFSize.xy;
|
||||||
|
|
||||||
vec4 UL = texture(Source, pxcoord + 0.25 * t1.xy + 0.25 * t1.zw );
|
float4 UL = texture(Source, pxcoord + 0.25*t1.xy + 0.25*t1.zw );
|
||||||
vec4 UR = texture(Source, pxcoord + 0.75 * t1.xy + 0.25 * t1.zw );
|
float4 UR = texture(Source, pxcoord + 0.75*t1.xy + 0.25*t1.zw );
|
||||||
vec4 DL = texture(Source, pxcoord + 0.25 * t1.xy + 0.75 * t1.zw );
|
float4 DL = texture(Source, pxcoord + 0.25*t1.xy + 0.75*t1.zw );
|
||||||
vec4 DR = texture(Source, pxcoord + 0.75 * t1.xy + 0.75 * t1.zw );
|
float4 DR = texture(Source, pxcoord + 0.75*t1.xy + 0.75*t1.zw );
|
||||||
|
|
||||||
vec4 ulparam = remapFrom01( UL, low, high ); // retrieve 1st pass info
|
float4 ulparam = remapFrom01( UL, low, high ); // retrieve 1st pass info
|
||||||
vec4 urparam = remapFrom01( UR, low, high ); // retrieve 1st pass info
|
float4 urparam = remapFrom01( UR, low, high ); // retrieve 1st pass info
|
||||||
vec4 dlparam = remapFrom01( DL, low, high ); // retrieve 1st pass info
|
float4 dlparam = remapFrom01( DL, low, high ); // retrieve 1st pass info
|
||||||
vec4 drparam = remapFrom01( DR, low, high ); // retrieve 1st pass info
|
float4 drparam = remapFrom01( DR, low, high ); // retrieve 1st pass info
|
||||||
|
|
||||||
vec3 E = texture( Original, vTexCoord ).xyz;
|
|
||||||
|
|
||||||
vec3 ax, ay, PX, PY, PZ, PW;
|
float3 E = texture( REF, vTexCoord ).xyz;
|
||||||
|
|
||||||
|
float3 ax, ay, PX, PY, PZ, PW;
|
||||||
float info;
|
float info;
|
||||||
vec2 iq;
|
float2 iq;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
PX = unpack_info(ulparam.w).xyz;
|
||||||
|
PY = unpack_info(urparam.w).xyz;
|
||||||
|
PZ = unpack_info(dlparam.w).xyz;
|
||||||
|
PW = unpack_info(drparam.w).xyz;
|
||||||
|
#else
|
||||||
GET_PIXEL(ulparam.w, PX);
|
GET_PIXEL(ulparam.w, PX);
|
||||||
GET_PIXEL(urparam.w, PY);
|
GET_PIXEL(urparam.w, PY);
|
||||||
GET_PIXEL(dlparam.w, PZ);
|
GET_PIXEL(dlparam.w, PZ);
|
||||||
GET_PIXEL(drparam.w, PW);
|
GET_PIXEL(drparam.w, PW);
|
||||||
|
#endif
|
||||||
vec3 fp1 = vec3( fp, -1. );
|
|
||||||
|
|
||||||
vec3 color;
|
float3 fp1 = float3( fp, -1. );
|
||||||
vec4 fx;
|
|
||||||
|
|
||||||
vec4 inc = vec4(abs(ulparam.x / ulparam.y), abs(urparam.x / urparam.y), abs(dlparam.x / dlparam.y), abs(drparam.x / drparam.y));
|
float3 color;
|
||||||
vec4 level = max(inc, 1.0 / inc);
|
float4 fx;
|
||||||
|
|
||||||
fx.x = saturate( dot( fp1, ulparam.xyz ) * scale_factor / ( 8. * level.x ) + 0.5 );
|
float4 inc = float4(abs(ulparam.x/ulparam.y), abs(urparam.x/urparam.y), abs(dlparam.x/dlparam.y), abs(drparam.x/drparam.y));
|
||||||
fx.y = saturate( dot( fp1, urparam.xyz ) * scale_factor / ( 8. * level.y ) + 0.5 );
|
float4 level = max(inc, 1.0/inc);
|
||||||
fx.z = saturate( dot( fp1, dlparam.xyz ) * scale_factor / ( 8. * level.z ) + 0.5 );
|
|
||||||
fx.w = saturate( dot( fp1, drparam.xyz ) * scale_factor / ( 8. * level.w ) + 0.5 );
|
fx.x = saturate( dot( fp1, ulparam.xyz ) * scale_factor/( 8. * level.x ) + 0.5 );
|
||||||
|
fx.y = saturate( dot( fp1, urparam.xyz ) * scale_factor/( 8. * level.y ) + 0.5 );
|
||||||
vec3 c1, c2, c3, c4;
|
fx.z = saturate( dot( fp1, dlparam.xyz ) * scale_factor/( 8. * level.z ) + 0.5 );
|
||||||
|
fx.w = saturate( dot( fp1, drparam.xyz ) * scale_factor/( 8. * level.w ) + 0.5 );
|
||||||
|
|
||||||
|
float3 c1, c2, c3, c4;
|
||||||
|
|
||||||
|
c1 = lerp( E, PX, fx.x );
|
||||||
|
c2 = lerp( E, PY, fx.y );
|
||||||
|
c3 = lerp( E, PZ, fx.z );
|
||||||
|
c4 = lerp( E, PW, fx.w );
|
||||||
|
|
||||||
c1 = mix( E, PX, fx.x );
|
|
||||||
c2 = mix( E, PY, fx.y );
|
|
||||||
c3 = mix( E, PZ, fx.z );
|
|
||||||
c4 = mix( E, PW, fx.w );
|
|
||||||
|
|
||||||
color = c1;
|
color = c1;
|
||||||
color = ( (c_df(c2, E) > c_df(color, E)) ) ? c2 : color;
|
color = ( (c_df(c2, E) > c_df(color, E)) ) ? c2 : color;
|
||||||
color = ( (c_df(c3, E) > c_df(color, E)) ) ? c3 : color;
|
color = ( (c_df(c3, E) > c_df(color, E)) ) ? c3 : color;
|
||||||
color = ( (c_df(c4, E) > c_df(color, E)) ) ? c4 : color;
|
color = ( (c_df(c4, E) > c_df(color, E)) ) ? c4 : color;
|
||||||
|
|
||||||
FragColor = vec4(color, 1.0);
|
FragColor = float4( color, 1.0 );
|
||||||
}
|
}
|
||||||
|
|
37
xbr/xbr-mlv4-multipass.slangp
Normal file
37
xbr/xbr-mlv4-multipass.slangp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
shaders = "5"
|
||||||
|
|
||||||
|
shader0 = ../stock.slang
|
||||||
|
scale_type0 = "source"
|
||||||
|
scale0 = 1.0
|
||||||
|
alias0 = REF
|
||||||
|
|
||||||
|
shader1 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass1.slang
|
||||||
|
filter_linear1 = "false"
|
||||||
|
float_framebuffer1 = "false"
|
||||||
|
scale_type_x1 = "source"
|
||||||
|
scale_x1 = "1.000000"
|
||||||
|
scale_type_y1 = "source"
|
||||||
|
scale_y1 = "1.000000"
|
||||||
|
alias1 = "PASS1"
|
||||||
|
|
||||||
|
shader2 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass2.slang
|
||||||
|
filter_linear2 = "false"
|
||||||
|
float_framebuffer2 = "false"
|
||||||
|
scale_type_x2 = "source"
|
||||||
|
scale_x2 = "1.000000"
|
||||||
|
scale_type_y2 = "source"
|
||||||
|
scale_y2 = "1.000000"
|
||||||
|
alias2 = "PASS2"
|
||||||
|
|
||||||
|
shader3 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass3.slang
|
||||||
|
filter_linear3 = "false"
|
||||||
|
float_framebuffer3 = "false"
|
||||||
|
scale_type_x3 = "source"
|
||||||
|
scale_x3 = "2.000000"
|
||||||
|
scale_type_y3 = "source"
|
||||||
|
scale_y3 = "2.000000"
|
||||||
|
alias3 = "PASS3"
|
||||||
|
|
||||||
|
shader4 = shaders/xbr-mlv4-multipass/xbr-mlv4-pass4.slang
|
||||||
|
filter_linear4 = "false"
|
||||||
|
float_framebuffer4 = "false"
|
Loading…
Reference in a new issue