mirror of
https://github.com/libretro/glsl-shaders.git
synced 2024-11-23 15:50:12 +00:00
add super-xbr-3d shaders and presets
This commit is contained in:
parent
f6caee3450
commit
b665bcc58d
313
xbr/shaders/super-xbr/super-2xbr-3d-pass0.glsl
Normal file
313
xbr/shaders/super-xbr/super-2xbr-3d-pass0.glsl
Normal file
@ -0,0 +1,313 @@
|
||||
/*
|
||||
|
||||
******* Super XBR 3D Shader - pass0 *******
|
||||
|
||||
Copyright (c) 2016 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// Parameter lines go here:
|
||||
#pragma parameter XBR_EDGE_STR "Xbr - Edge Strength p0" 0.6 0.0 5.0 0.5
|
||||
#pragma parameter XBR_WEIGHT "Xbr - Filter Weight" 1.0 0.00 1.50 0.05
|
||||
#pragma parameter XBR_ANTI_RINGING "Xbr - Anti-Ringing Level" 1.0 0.0 1.0 1.0
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
uniform COMPAT_PRECISION float XBR_EDGE_STR;
|
||||
uniform COMPAT_PRECISION float XBR_WEIGHT;
|
||||
uniform COMPAT_PRECISION float XBR_ANTI_RINGING;
|
||||
#else
|
||||
#define XBR_EDGE_STR 0.6
|
||||
#define XBR_WEIGHT 1.0
|
||||
#define XBR_ANTI_RINGING 1.0
|
||||
#endif
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 2.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 2.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
//Skip pixels on wrong grid
|
||||
if (any(lessThan(fract(vTexCoord.xy*SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
|
||||
{
|
||||
FragColor = texture(Source, vTexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2(XBR_RES/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, XBR_RES/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, vTexCoord -g1 -g2).xyz;
|
||||
vec3 P1 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
|
||||
vec3 P2 = texture(Source, vTexCoord -g1+2.0*g2).xyz;
|
||||
vec3 P3 = texture(Source, vTexCoord +2.0*g1+2.0*g2).xyz;
|
||||
|
||||
vec3 B = texture(Source, vTexCoord -g2).xyz;
|
||||
vec3 C = texture(Source, vTexCoord +g1-g2).xyz;
|
||||
vec3 D = texture(Source, vTexCoord -g1 ).xyz;
|
||||
vec3 E = texture(Source, vTexCoord ).xyz;
|
||||
vec3 F = texture(Source, vTexCoord +g1 ).xyz;
|
||||
vec3 G = texture(Source, vTexCoord -g1+g2).xyz;
|
||||
vec3 H = texture(Source, vTexCoord +g2).xyz;
|
||||
vec3 I = texture(Source, vTexCoord +g1+g2).xyz;
|
||||
|
||||
vec3 F4 = texture(Source, vTexCoord +2.0*g1 ).xyz;
|
||||
vec3 I4 = texture(Source, vTexCoord +g2+2.0*g1 ).xyz;
|
||||
vec3 H5 = texture(Source, vTexCoord +2.0*g2 ).xyz;
|
||||
vec3 I5 = texture(Source, vTexCoord +2.0*g2+g1 ).xyz;
|
||||
|
||||
vec3 F6 = texture(Source, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Source, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Source, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Source, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Source, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Source, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Source, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Source, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz == f0.yzw) && (h0.xyz == h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1 - edge_strength);
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : E;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
}
|
||||
#endif
|
249
xbr/shaders/super-xbr/super-2xbr-3d-pass1.glsl
Normal file
249
xbr/shaders/super-xbr/super-2xbr-3d-pass1.glsl
Normal file
@ -0,0 +1,249 @@
|
||||
/*
|
||||
|
||||
******* Super XBR Shader - pass1 *******
|
||||
|
||||
Copyright (c) 2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.6;
|
||||
const float XBR_WEIGHT = 1.0;
|
||||
const float XBR_ANTI_RINGING = 1.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 4.0
|
||||
#define wp5 0.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.75068/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
// Paste vertex contents here:
|
||||
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D OrigTexture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define Original OrigTexture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
//Skip pixels on wrong grid
|
||||
vec2 fp = fract(vTexCoord*SourceSize.xy);
|
||||
vec2 dir = fp - vec2(0.5,0.5);
|
||||
if ((dir.x*dir.y)>0.0){
|
||||
FragColor = (fp.x>0.5) ? texture(Source, vTexCoord) : texture(Original, vTexCoord);
|
||||
}else{
|
||||
|
||||
vec2 g1 = (fp.x>0.5) ? vec2(0.5/SourceSize.x, 0.0) : vec2(0.0, 0.5/SourceSize.y);
|
||||
vec2 g2 = (fp.x>0.5) ? vec2(0.0, 0.5/SourceSize.y) : vec2(0.5/SourceSize.x, 0.0);
|
||||
|
||||
vec3 P0 = texture(Original, vTexCoord -3.0*g1 ).xyz;
|
||||
vec3 P1 = texture(Source, vTexCoord -3.0*g2).xyz;
|
||||
vec3 P2 = texture(Source, vTexCoord +3.0*g2).xyz;
|
||||
vec3 P3 = texture(Original, vTexCoord +3.0*g1 ).xyz;
|
||||
|
||||
vec3 B = texture(Source, vTexCoord -2.0*g1 -g2).xyz;
|
||||
vec3 C = texture(Original, vTexCoord -g1 -2.0*g2).xyz;
|
||||
vec3 D = texture(Source, vTexCoord -2.0*g1 +g2).xyz;
|
||||
vec3 E = texture(Original, vTexCoord -g1 ).xyz;
|
||||
vec3 F = texture(Source, vTexCoord -g2).xyz;
|
||||
vec3 G = texture(Original, vTexCoord -g1 +2.0*g2).xyz;
|
||||
vec3 H = texture(Source, vTexCoord +g2).xyz;
|
||||
vec3 I = texture(Original, vTexCoord +g1 ).xyz;
|
||||
|
||||
vec3 F4 = texture(Original, vTexCoord +g1 -2.0*g2).xyz;
|
||||
vec3 I4 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
|
||||
vec3 H5 = texture(Original, vTexCoord +g1 +2.0*g2).xyz;
|
||||
vec3 I5 = texture(Source, vTexCoord +2.0*g1 +g2).xyz;
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
}
|
||||
#endif
|
259
xbr/shaders/super-xbr/super-2xbr-3d-pass2.glsl
Normal file
259
xbr/shaders/super-xbr/super-2xbr-3d-pass2.glsl
Normal file
@ -0,0 +1,259 @@
|
||||
/*
|
||||
|
||||
******* Super XBR Shader - pass2 ******* This pass is optional.
|
||||
|
||||
Copyright (c) 2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.6;
|
||||
const float XBR_WEIGHT = 1.0;
|
||||
const float XBR_ANTI_RINGING = 1.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 0.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize)
|
||||
#define vTexCoord TEX0.xy
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
float dx = SourceSize.z;
|
||||
float dy = SourceSize.w;
|
||||
t1 = vTexCoord.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
|
||||
t2 = vTexCoord.xyxy + vec4( -dx, -2.0*dy, 0, dy);
|
||||
t3 = vTexCoord.xyxy + vec4(-2.0*dx, -dy, dx, 0);
|
||||
t4 = vTexCoord.xyxy + vec4( -dx, -dy, 0, 0);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 P0 = texture(Source, t1.xy).xyz;
|
||||
vec3 P1 = texture(Source, t1.zy).xyz;
|
||||
vec3 P2 = texture(Source, t1.xw).xyz;
|
||||
vec3 P3 = texture(Source, t1.zw).xyz;
|
||||
|
||||
vec3 B = texture(Source, t2.xy).xyz;
|
||||
vec3 C = texture(Source, t2.zy).xyz;
|
||||
vec3 H5 = texture(Source, t2.xw).xyz;
|
||||
vec3 I5 = texture(Source, t2.zw).xyz;
|
||||
|
||||
vec3 D = texture(Source, t3.xy).xyz;
|
||||
vec3 F4 = texture(Source, t3.zy).xyz;
|
||||
vec3 G = texture(Source, t3.xw).xyz;
|
||||
vec3 I4 = texture(Source, t3.zw).xyz;
|
||||
|
||||
vec3 E = texture(Source, t4.xy).xyz;
|
||||
vec3 F = texture(Source, t4.zy).xyz;
|
||||
vec3 H = texture(Source, t4.xw).xyz;
|
||||
vec3 I = texture(Source, t4.zw).xyz;
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
#endif
|
313
xbr/shaders/super-xbr/super-4xbr-3d-pass0.glsl
Normal file
313
xbr/shaders/super-xbr/super-4xbr-3d-pass0.glsl
Normal file
@ -0,0 +1,313 @@
|
||||
/*
|
||||
|
||||
******* Super 4XBR 3D Shader - pass0 *******
|
||||
|
||||
Copyright (c) 2016 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// Parameter lines go here:
|
||||
#pragma parameter XBR_EDGE_STR "Xbr - Edge Strength p0" 0.6 0.0 5.0 0.5
|
||||
#pragma parameter XBR_WEIGHT "Xbr - Filter Weight" 1.0 0.00 1.50 0.05
|
||||
#pragma parameter XBR_ANTI_RINGING "Xbr - Anti-Ringing Level" 1.0 0.0 1.0 1.0
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
uniform COMPAT_PRECISION float XBR_EDGE_STR;
|
||||
uniform COMPAT_PRECISION float XBR_WEIGHT;
|
||||
uniform COMPAT_PRECISION float XBR_ANTI_RINGING;
|
||||
#else
|
||||
#define XBR_EDGE_STR 0.6
|
||||
#define XBR_WEIGHT 1.0
|
||||
#define XBR_ANTI_RINGING 1.0
|
||||
#endif
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 4.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 2.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
//Skip pixels on wrong grid
|
||||
if (any(lessThan(fract(vTexCoord*SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
|
||||
{
|
||||
FragColor = texture(Source, vTexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2(XBR_RES/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, XBR_RES/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, vTexCoord -g1 -g2).xyz;
|
||||
vec3 P1 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
|
||||
vec3 P2 = texture(Source, vTexCoord -g1+2.0*g2).xyz;
|
||||
vec3 P3 = texture(Source, vTexCoord +2.0*g1+2.0*g2).xyz;
|
||||
|
||||
vec3 B = texture(Source, vTexCoord -g2).xyz;
|
||||
vec3 C = texture(Source, vTexCoord +g1-g2).xyz;
|
||||
vec3 D = texture(Source, vTexCoord -g1 ).xyz;
|
||||
vec3 E = texture(Source, vTexCoord ).xyz;
|
||||
vec3 F = texture(Source, vTexCoord +g1 ).xyz;
|
||||
vec3 G = texture(Source, vTexCoord -g1+g2).xyz;
|
||||
vec3 H = texture(Source, vTexCoord +g2).xyz;
|
||||
vec3 I = texture(Source, vTexCoord +g1+g2).xyz;
|
||||
|
||||
vec3 F4 = texture(Source, vTexCoord +2.0*g1 ).xyz;
|
||||
vec3 I4 = texture(Source, vTexCoord +g2+2.0*g1 ).xyz;
|
||||
vec3 H5 = texture(Source, vTexCoord +2.0*g2 ).xyz;
|
||||
vec3 I5 = texture(Source, vTexCoord +2.0*g2+g1 ).xyz;
|
||||
|
||||
vec3 F6 = texture(Source, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Source, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Source, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Source, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Source, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Source, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Source, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Source, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz == f0.yzw) && (h0.xyz == h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1 - edge_strength);
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : E;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
}
|
||||
#endif
|
303
xbr/shaders/super-xbr/super-4xbr-3d-pass1.glsl
Normal file
303
xbr/shaders/super-xbr/super-4xbr-3d-pass1.glsl
Normal file
@ -0,0 +1,303 @@
|
||||
/*
|
||||
|
||||
******* Super 4XBR 3D Shader - pass1 *******
|
||||
|
||||
Copyright (c) 2016 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.0;
|
||||
const float XBR_WEIGHT = 0.0;
|
||||
const float XBR_ANTI_RINGING = 0.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 4.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 0.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
float dx = SourceSize.z;
|
||||
float dy = SourceSize.w;
|
||||
t1 = vTexCoord.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
|
||||
t2 = vTexCoord.xyxy + vec4( -dx, -2.0*dy, 0, dy);
|
||||
t3 = vTexCoord.xyxy + vec4(-2.0*dx, -dy, dx, 0);
|
||||
t4 = vTexCoord.xyxy + vec4( -dx, -dy, 0, 0);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D OrigTexture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define Original OrigTexture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2((XBR_RES/2.0)/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, (XBR_RES/2.0)/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, t1.xy).xyz;
|
||||
vec3 P1 = texture(Source, t1.zy).xyz;
|
||||
vec3 P2 = texture(Source, t1.xw).xyz;
|
||||
vec3 P3 = texture(Source, t1.zw).xyz;
|
||||
|
||||
vec3 B = texture(Source, t2.xy).xyz;
|
||||
vec3 C = texture(Source, t2.zy).xyz;
|
||||
vec3 H5 = texture(Source, t2.xw).xyz;
|
||||
vec3 I5 = texture(Source, t2.zw).xyz;
|
||||
|
||||
vec3 D = texture(Source, t3.xy).xyz;
|
||||
vec3 F4 = texture(Source, t3.zy).xyz;
|
||||
vec3 G = texture(Source, t3.xw).xyz;
|
||||
vec3 I4 = texture(Source, t3.zw).xyz;
|
||||
|
||||
vec3 E = texture(Source, t4.xy).xyz;
|
||||
vec3 F = texture(Source, t4.zy).xyz;
|
||||
vec3 H = texture(Source, t4.xw).xyz;
|
||||
vec3 I = texture(Source, t4.zw).xyz;
|
||||
|
||||
vec3 A = texture(Source, vTexCoord).xyz;
|
||||
|
||||
vec3 F6 = texture(Original, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Original, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Original, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Original, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Original, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Original, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Original, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Original, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : A;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
#endif
|
303
xbr/shaders/super-xbr/super-4xbr-3d-pass1f.glsl
Normal file
303
xbr/shaders/super-xbr/super-4xbr-3d-pass1f.glsl
Normal file
@ -0,0 +1,303 @@
|
||||
/*
|
||||
|
||||
******* Super 4XBR 3D Shader - pass1 *******
|
||||
|
||||
Copyright (c) 2016 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.0;
|
||||
const float XBR_WEIGHT = 0.0;
|
||||
const float XBR_ANTI_RINGING = 0.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 4.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 0.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
float dx = SourceSize.z;
|
||||
float dy = SourceSize.w;
|
||||
t1 = vTexCoord.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
|
||||
t2 = vTexCoord.xyxy + vec4( -dx, -2.0*dy, 0, dy);
|
||||
t3 = vTexCoord.xyxy + vec4(-2.0*dx, -dy, dx, 0);
|
||||
t4 = vTexCoord.xyxy + vec4( -dx, -dy, 0, 0);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D OrigTexture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define Original OrigTexture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2((XBR_RES/2.0)/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, (XBR_RES/2.0)/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, t1.xy).xyz;
|
||||
vec3 P1 = texture(Source, t1.zy).xyz;
|
||||
vec3 P2 = texture(Source, t1.xw).xyz;
|
||||
vec3 P3 = texture(Source, t1.zw).xyz;
|
||||
|
||||
vec3 B = texture(Source, t2.xy).xyz;
|
||||
vec3 C = texture(Source, t2.zy).xyz;
|
||||
vec3 H5 = texture(Source, t2.xw).xyz;
|
||||
vec3 I5 = texture(Source, t2.zw).xyz;
|
||||
|
||||
vec3 D = texture(Source, t3.xy).xyz;
|
||||
vec3 F4 = texture(Source, t3.zy).xyz;
|
||||
vec3 G = texture(Source, t3.xw).xyz;
|
||||
vec3 I4 = texture(Source, t3.zw).xyz;
|
||||
|
||||
vec3 E = texture(Source, t4.xy).xyz;
|
||||
vec3 F = texture(Source, t4.zy).xyz;
|
||||
vec3 H = texture(Source, t4.xw).xyz;
|
||||
vec3 I = texture(Source, t4.zw).xyz;
|
||||
|
||||
vec3 A = texture(Source, vTexCoord).xyz;
|
||||
|
||||
vec3 F6 = texture(Original, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Original, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Original, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Original, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Original, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Original, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Original, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Original, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : A;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
#endif
|
302
xbr/shaders/super-xbr/super-4xbr-3d-pass2.glsl
Normal file
302
xbr/shaders/super-xbr/super-4xbr-3d-pass2.glsl
Normal file
@ -0,0 +1,302 @@
|
||||
/*
|
||||
|
||||
******* Super 4XBR Shader - pass2 *******
|
||||
|
||||
Copyright (c) 2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.0;
|
||||
const float XBR_WEIGHT = 0.0;
|
||||
const float XBR_ANTI_RINGING = 0.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 2.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 2.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D OrigTexture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define Original OrigTexture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
//Skip pixels on wrong grid
|
||||
if (any(lessThan(fract(vTexCoord*SourceSize.xy/XBR_RES) , vec2(0.5,0.5))))
|
||||
{
|
||||
FragColor = texture(Source, vTexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2(XBR_RES/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, XBR_RES/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, vTexCoord -g1 -g2).xyz;
|
||||
vec3 P1 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
|
||||
vec3 P2 = texture(Source, vTexCoord -g1+2.0*g2).xyz;
|
||||
vec3 P3 = texture(Source, vTexCoord +2.0*g1+2.0*g2).xyz;
|
||||
|
||||
vec3 B = texture(Source, vTexCoord -g2).xyz;
|
||||
vec3 C = texture(Source, vTexCoord +g1-g2).xyz;
|
||||
vec3 D = texture(Source, vTexCoord -g1 ).xyz;
|
||||
vec3 E = texture(Source, vTexCoord ).xyz;
|
||||
vec3 F = texture(Source, vTexCoord +g1 ).xyz;
|
||||
vec3 G = texture(Source, vTexCoord -g1+g2).xyz;
|
||||
vec3 H = texture(Source, vTexCoord +g2).xyz;
|
||||
vec3 I = texture(Source, vTexCoord +g1+g2).xyz;
|
||||
|
||||
vec3 F4 = texture(Source, vTexCoord +2.0*g1 ).xyz;
|
||||
vec3 I4 = texture(Source, vTexCoord +g2+2.0*g1 ).xyz;
|
||||
vec3 H5 = texture(Source, vTexCoord +2.0*g2 ).xyz;
|
||||
vec3 I5 = texture(Source, vTexCoord +2.0*g2+g1 ).xyz;
|
||||
|
||||
vec3 F6 = texture(Source, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Source, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Source, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Source, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Source, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Source, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Source, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Source, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz == f0.yzw) && (h0.xyz == h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : E;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
}
|
||||
#endif
|
305
xbr/shaders/super-xbr/super-4xbr-3d-pass3.glsl
Normal file
305
xbr/shaders/super-xbr/super-4xbr-3d-pass3.glsl
Normal file
@ -0,0 +1,305 @@
|
||||
/*
|
||||
|
||||
******* Super 4XBR Shader - pass3 *******
|
||||
|
||||
Copyright (c) 2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.0;
|
||||
const float XBR_WEIGHT = 0.0;
|
||||
const float XBR_ANTI_RINGING = 0.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 2.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 4.0
|
||||
#define wp5 0.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.75068/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D OrigTexture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define Original OrigTexture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
//Skip pixels on wrong grid
|
||||
vec2 dir = fract(vTexCoord*SourceSize.xy/XBR_RES) - vec2(0.5,0.5);
|
||||
if ((dir.x*dir.y)>0.0) {
|
||||
FragColor = texture(Source, vTexCoord);
|
||||
}else{
|
||||
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2((XBR_RES/2.0)/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, (XBR_RES/2.0)/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, vTexCoord -3.0*g1 ).xyz;
|
||||
vec3 P1 = texture(Source, vTexCoord -3.0*g2).xyz;
|
||||
vec3 P2 = texture(Source, vTexCoord +3.0*g2).xyz;
|
||||
vec3 P3 = texture(Source, vTexCoord +3.0*g1 ).xyz;
|
||||
|
||||
vec3 B = texture(Source, vTexCoord -2.0*g1 -g2).xyz;
|
||||
vec3 C = texture(Source, vTexCoord -g1 -2.0*g2).xyz;
|
||||
vec3 D = texture(Source, vTexCoord -2.0*g1 +g2).xyz;
|
||||
vec3 E = texture(Source, vTexCoord -g1 ).xyz;
|
||||
vec3 F = texture(Source, vTexCoord -g2).xyz;
|
||||
vec3 G = texture(Source, vTexCoord -g1 +2.0*g2).xyz;
|
||||
vec3 H = texture(Source, vTexCoord +g2).xyz;
|
||||
vec3 I = texture(Source, vTexCoord +g1 ).xyz;
|
||||
|
||||
vec3 F4 = texture(Source, vTexCoord +g1 -2.0*g2).xyz;
|
||||
vec3 I4 = texture(Source, vTexCoord +2.0*g1 -g2).xyz;
|
||||
vec3 H5 = texture(Source, vTexCoord +g1 +2.0*g2).xyz;
|
||||
vec3 I5 = texture(Source, vTexCoord +2.0*g1 +g2).xyz;
|
||||
|
||||
vec3 A = texture(Source, vTexCoord).xyz;
|
||||
|
||||
g1 *= 2.0;
|
||||
g2 *= 2.0;
|
||||
|
||||
vec3 F6 = texture(Original, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Original, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Original, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Original, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Original, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Original, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Original, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Original, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz == f0.yzw) && (h0.xyz == h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : E;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
}
|
||||
#endif
|
304
xbr/shaders/super-xbr/super-4xbr-3d-pass3f.glsl
Normal file
304
xbr/shaders/super-xbr/super-4xbr-3d-pass3f.glsl
Normal file
@ -0,0 +1,304 @@
|
||||
/*
|
||||
|
||||
******* Super 4XBR Shader - pass3f ******* This pass is optional.
|
||||
|
||||
Copyright (c) 2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
const float XBR_EDGE_STR = 0.0;
|
||||
const float XBR_WEIGHT = 0.0;
|
||||
const float XBR_ANTI_RINGING = 0.0;
|
||||
|
||||
#define mul(a,b) (b*a)
|
||||
|
||||
#define XBR_RES 2.0
|
||||
|
||||
#define wp1 1.0
|
||||
#define wp2 0.0
|
||||
#define wp3 0.0
|
||||
#define wp4 0.0
|
||||
#define wp5 -1.0
|
||||
#define wp6 0.0
|
||||
|
||||
#define weight1 (XBR_WEIGHT*1.29633/10.0)
|
||||
#define weight2 (XBR_WEIGHT*1.75068/10.0/2.0)
|
||||
|
||||
const vec3 Y = vec3(.2126, .7152, .0722);
|
||||
|
||||
const vec3 dtt = vec3(65536.,255.,1.);
|
||||
|
||||
vec4 reduce4(vec3 A, vec3 B, vec3 C, vec3 D)
|
||||
{
|
||||
return mul(mat4x3(A, B, C, D), dtt);
|
||||
}
|
||||
|
||||
float RGBtoYUV(vec3 color)
|
||||
{
|
||||
return dot(color, Y);
|
||||
}
|
||||
|
||||
float df(float A, float B)
|
||||
{
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
bool eq(float A, float B)
|
||||
{
|
||||
return (df(A, B) < 15.0);
|
||||
}
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
float d_wd(float b0, float b1, float c0, float c1, float c2, float d0, float d1, float d2, float d3, float e1, float e2, float e3, float f2, float f3)
|
||||
{
|
||||
return (wp1*(df(c1,c2) + df(c1,c0) + df(e2,e1) + df(e2,e3)) + wp2*(df(d2,d3) + df(d0,d1)) + wp3*(df(d1,d3) + df(d0,d2)) + wp4*df(d1,d2) + wp5*(df(c0,c2) + df(e1,e3)) + wp6*(df(b0,b1) + df(f2,f3)));
|
||||
}
|
||||
|
||||
float hv_wd(float i1, float i2, float i3, float i4, float e1, float e2, float e3, float e4)
|
||||
{
|
||||
return ( wp4*(df(i1,i2)+df(i3,i4)) + wp1*(df(i1,e1)+df(i2,e2)+df(i3,e3)+df(i4,e4)) + wp3*(df(i1,e2)+df(i3,e4)+df(e1,i2)+df(e3,i4)));
|
||||
}
|
||||
|
||||
vec3 min4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return min(a, min(b, min(c, d)));
|
||||
}
|
||||
vec3 max4(vec3 a, vec3 b, vec3 c, vec3 d)
|
||||
{
|
||||
return max(a, max(b, max(c, d)));
|
||||
}
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
vec4 _oPosition1;
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
float dx = SourceSize.z;
|
||||
float dy = SourceSize.w;
|
||||
t1 = vTexCoord.xyxy + vec4(-2.0*dx, -2.0*dy, dx, dy);
|
||||
t2 = vTexCoord.xyxy + vec4( -dx, -2.0*dy, 0, dy);
|
||||
t3 = vTexCoord.xyxy + vec4(-2.0*dx, -dy, dx, 0);
|
||||
t4 = vTexCoord.xyxy + vec4( -dx, -dy, 0, 0);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D OrigTexture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec4 t1;
|
||||
COMPAT_VARYING vec4 t2;
|
||||
COMPAT_VARYING vec4 t3;
|
||||
COMPAT_VARYING vec4 t4;
|
||||
|
||||
// compatibility #defines
|
||||
#define Source Texture
|
||||
#define Original OrigTexture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tex = (floor(vTexCoord*SourceSize.xy/XBR_RES) + vec2(0.5, 0.5))*XBR_RES/SourceSize.xy;
|
||||
|
||||
vec2 g1 = vec2(XBR_RES/SourceSize.x, 0.0);
|
||||
vec2 g2 = vec2(0.0, XBR_RES/SourceSize.y);
|
||||
|
||||
vec3 P0 = texture(Source, t1.xy).xyz;
|
||||
vec3 P1 = texture(Source, t1.zy).xyz;
|
||||
vec3 P2 = texture(Source, t1.xw).xyz;
|
||||
vec3 P3 = texture(Source, t1.zw).xyz;
|
||||
|
||||
vec3 B = texture(Source, t2.xy).xyz;
|
||||
vec3 C = texture(Source, t2.zy).xyz;
|
||||
vec3 H5 = texture(Source, t2.xw).xyz;
|
||||
vec3 I5 = texture(Source, t2.zw).xyz;
|
||||
|
||||
vec3 D = texture(Source, t3.xy).xyz;
|
||||
vec3 F4 = texture(Source, t3.zy).xyz;
|
||||
vec3 G = texture(Source, t3.xw).xyz;
|
||||
vec3 I4 = texture(Source, t3.zw).xyz;
|
||||
|
||||
vec3 E = texture(Source, t4.xy).xyz;
|
||||
vec3 F = texture(Source, t4.zy).xyz;
|
||||
vec3 H = texture(Source, t4.xw).xyz;
|
||||
vec3 I = texture(Source, t4.zw).xyz;
|
||||
|
||||
vec3 A = texture(Source, vTexCoord).xyz;
|
||||
|
||||
vec3 F6 = texture(Original, tex +g1+0.25*g1+0.25*g2).xyz;
|
||||
vec3 F7 = texture(Original, tex +g1+0.25*g1-0.25*g2).xyz;
|
||||
vec3 F8 = texture(Original, tex +g1-0.25*g1-0.25*g2).xyz;
|
||||
vec3 F9 = texture(Original, tex +g1-0.25*g1+0.25*g2).xyz;
|
||||
|
||||
vec3 H6 = texture(Original, tex +0.25*g1+0.25*g2+g2).xyz;
|
||||
vec3 H7 = texture(Original, tex +0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H8 = texture(Original, tex -0.25*g1-0.25*g2+g2).xyz;
|
||||
vec3 H9 = texture(Original, tex -0.25*g1+0.25*g2+g2).xyz;
|
||||
|
||||
vec4 f0 = reduce4(F6, F7, F8, F9);
|
||||
vec4 h0 = reduce4(H6, H7, H8, H9);
|
||||
|
||||
bool block_3d = ((f0.xyz==f0.yzw) && (h0.xyz==h0.yzw));
|
||||
|
||||
float b = RGBtoYUV( B );
|
||||
float c = RGBtoYUV( C );
|
||||
float d = RGBtoYUV( D );
|
||||
float e = RGBtoYUV( E );
|
||||
float f = RGBtoYUV( F );
|
||||
float g = RGBtoYUV( G );
|
||||
float h = RGBtoYUV( H );
|
||||
float i = RGBtoYUV( I );
|
||||
|
||||
float i4 = RGBtoYUV( I4 ); float p0 = RGBtoYUV( P0 );
|
||||
float i5 = RGBtoYUV( I5 ); float p1 = RGBtoYUV( P1 );
|
||||
float h5 = RGBtoYUV( H5 ); float p2 = RGBtoYUV( P2 );
|
||||
float f4 = RGBtoYUV( F4 ); float p3 = RGBtoYUV( P3 );
|
||||
|
||||
/*
|
||||
P1
|
||||
|P0|B |C |P1| C F4 |a0|b1|c2|d3|
|
||||
|D |E |F |F4| B F I4 |b0|c1|d2|e3| |e1|i1|i2|e2|
|
||||
|G |H |I |I4| P0 E A I P3 |c0|d1|e2|f3| |e3|i3|i4|e4|
|
||||
|P2|H5|I5|P3| D H I5 |d0|e1|f2|g3|
|
||||
G H5
|
||||
P2
|
||||
*/
|
||||
|
||||
/* Calc edgeness in diagonal directions. */
|
||||
float d_edge = (d_wd( d, b, g, e, c, p2, h, f, p1, h5, i, f4, i5, i4 ) - d_wd( c, f4, b, f, i4, p0, e, i, p3, d, h, i5, g, h5 ));
|
||||
|
||||
/* Calc edgeness in horizontal/vertical directions. */
|
||||
float hv_edge = (hv_wd(f, i, e, h, c, i5, b, h5) - hv_wd(e, f, h, i, d, f4, g, i4));
|
||||
|
||||
float limits = XBR_EDGE_STR + 0.000001;
|
||||
float edge_strength = smoothstep(0.0, limits, abs(d_edge));
|
||||
|
||||
/* Filter weights. Two taps only. */
|
||||
vec4 w1 = vec4(-weight1, weight1+0.5, weight1+0.5, -weight1);
|
||||
vec4 w2 = vec4(-weight2, weight2+0.25, weight2+0.25, -weight2);
|
||||
|
||||
/* Filtering and normalization in four direction generating four colors. */
|
||||
vec3 c1 = mul(w1, mat4x3( P2, H, F, P1 ));
|
||||
vec3 c2 = mul(w1, mat4x3( P0, E, I, P3 ));
|
||||
vec3 c3 = mul(w2, mat4x3(D+G, E+H, F+I, F4+I4));
|
||||
vec3 c4 = mul(w2, mat4x3(C+B, F+E, I+H, I5+H5));
|
||||
|
||||
bool ir_lv1 = (((e!=f) && (e!=h)) && ( !eq(f,b) && !eq(f,c) || !eq(h,d) && !eq(h,g) || eq(e,i) && (!eq(f,f4) && !eq(f,i4) || !eq(h,h5) && !eq(h,i5)) || eq(e,g) || eq(e,c)) );
|
||||
|
||||
|
||||
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
|
||||
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1. - edge_strength);
|
||||
|
||||
/* Anti-ringing code. */
|
||||
vec3 min_sample = min4( E, F, H, I ) + (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
vec3 max_sample = max4( E, F, H, I ) - (1.-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));
|
||||
|
||||
color = clamp(color, min_sample, max_sample);
|
||||
|
||||
color = block_3d ? color : A;
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
#endif
|
16
xbr/super-2xbr-3d-2p.glslp
Normal file
16
xbr/super-2xbr-3d-2p.glslp
Normal file
@ -0,0 +1,16 @@
|
||||
shaders = "3"
|
||||
shader0 = "shaders/super-xbr/super-2xbr-3d-pass0.glsl"
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "shaders/super-xbr/super-2xbr-3d-pass1.glsl"
|
||||
filter_linear1 = false
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "shaders/super-xbr/custom-jinc2-sharper.glsl"
|
||||
filter_linear2 = false
|
||||
|
21
xbr/super-2xbr-3d-3p-smoother.glslp
Normal file
21
xbr/super-2xbr-3d-3p-smoother.glslp
Normal file
@ -0,0 +1,21 @@
|
||||
shaders = "4"
|
||||
shader0 = "shaders/super-xbr/super-2xbr-3d-pass0.glsl"
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "shaders/super-xbr/super-2xbr-3d-pass1.glsl"
|
||||
filter_linear1 = false
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "shaders/super-xbr/super-2xbr-3d-pass2.glsl"
|
||||
filter_linear2 = false
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "1.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "1.000000"
|
||||
shader3 = "shaders/super-xbr/custom-jinc2-sharper.glsl"
|
||||
filter_linear3 = false
|
28
xbr/super-4xbr-3d-4p.glslp
Normal file
28
xbr/super-4xbr-3d-4p.glslp
Normal file
@ -0,0 +1,28 @@
|
||||
shaders = "5"
|
||||
shader0 = "shaders/super-xbr/super-4xbr-3d-pass0.glsl"
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "shaders/super-xbr/super-4xbr-3d-pass1.glsl"
|
||||
filter_linear1 = false
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "shaders/super-xbr/super-4xbr-3d-pass2.glsl"
|
||||
filter_linear2 = false
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "1.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "1.000000"
|
||||
shader3 = "shaders/super-xbr/super-4xbr-3d-pass3.glsl"
|
||||
filter_linear3 = false
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
shader4 = "shaders/super-xbr/custom-jinc2-sharper.glsl"
|
||||
filter_linear4 = false
|
||||
|
40
xbr/super-4xbr-3d-6p-smoother.glslp
Normal file
40
xbr/super-4xbr-3d-6p-smoother.glslp
Normal file
@ -0,0 +1,40 @@
|
||||
shaders = "7"
|
||||
shader0 = "shaders/super-xbr/super-4xbr-3d-pass0.glsl"
|
||||
filter_linear0 = false
|
||||
scale_type_x0 = "source"
|
||||
scale_x0 = "1.000000"
|
||||
scale_type_y0 = "source"
|
||||
scale_y0 = "1.000000"
|
||||
shader1 = "shaders/super-xbr/super-4xbr-3d-pass1.glsl"
|
||||
filter_linear1 = false
|
||||
scale_type_x1 = "source"
|
||||
scale_x1 = "1.000000"
|
||||
scale_type_y1 = "source"
|
||||
scale_y1 = "1.000000"
|
||||
shader2 = "shaders/super-xbr/super-4xbr-3d-pass1f.glsl"
|
||||
filter_linear2 = false
|
||||
scale_type_x2 = "source"
|
||||
scale_x2 = "1.000000"
|
||||
scale_type_y2 = "source"
|
||||
scale_y2 = "1.000000"
|
||||
shader3 = "shaders/super-xbr/super-4xbr-3d-pass2.glsl"
|
||||
filter_linear3 = false
|
||||
scale_type_x3 = "source"
|
||||
scale_x3 = "1.000000"
|
||||
scale_type_y3 = "source"
|
||||
scale_y3 = "1.000000"
|
||||
shader4 = "shaders/super-xbr/super-4xbr-3d-pass3.glsl"
|
||||
filter_linear4 = false
|
||||
scale_type_x4 = "source"
|
||||
scale_x4 = "1.000000"
|
||||
scale_type_y4 = "source"
|
||||
scale_y4 = "1.000000"
|
||||
shader5 = "shaders/super-xbr/super-4xbr-3d-pass3f.glsl"
|
||||
filter_linear5 = false
|
||||
scale_type_x5 = "source"
|
||||
scale_x5 = "1.000000"
|
||||
scale_type_y5 = "source"
|
||||
scale_y5 = "1.000000"
|
||||
shader6 = "../stock.glsl"
|
||||
filter_linear6 = true
|
||||
|
Loading…
Reference in New Issue
Block a user