// GLSL shader autogenerated by cg2glsl.py.
#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_VARYING     vec4 _t7;
COMPAT_VARYING     vec4 _t6;
COMPAT_VARYING     vec4 _t5;
COMPAT_VARYING     vec4 _t4;
COMPAT_VARYING     vec4 _t3;
COMPAT_VARYING     vec4 _t2;
COMPAT_VARYING     vec4 _t1;
COMPAT_VARYING     vec2 _texCoord1;
COMPAT_VARYING     vec4 _color1;
COMPAT_VARYING     vec4 _position1;
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size;
    vec2 _output_dummy_size;
};
struct out_vertex {
    vec4 _position1;
    vec4 _color1;
    vec2 _texCoord1;
    vec4 _t1;
    vec4 _t2;
    vec4 _t3;
    vec4 _t4;
    vec4 _t5;
    vec4 _t6;
    vec4 _t7;
};
out_vertex _ret_0;
input_dummy _IN1;
vec4 _r0010;
COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec4 TEX1;
COMPAT_VARYING vec4 TEX2;
COMPAT_VARYING vec4 TEX3;
COMPAT_VARYING vec4 TEX4;
COMPAT_VARYING vec4 TEX5;
COMPAT_VARYING vec4 TEX6;
COMPAT_VARYING vec4 TEX7;
 
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()
{
    out_vertex _OUT;
    vec2 _ps;
    _r0010 = VertexCoord.x*MVPMatrix[0];
    _r0010 = _r0010 + VertexCoord.y*MVPMatrix[1];
    _r0010 = _r0010 + VertexCoord.z*MVPMatrix[2];
    _r0010 = _r0010 + VertexCoord.w*MVPMatrix[3];
    _ps = vec2(1.00000000E+00/TextureSize.x, 1.00000000E+00/TextureSize.y);
    _OUT._t1 = TexCoord.xxxy + vec4(float(float(-_ps.x)), 0.00000000E+00, float(float(_ps.x)), float(float((-2.00000000E+00*_ps.y))));
    _OUT._t2 = TexCoord.xxxy + vec4(float(float(-_ps.x)), 0.00000000E+00, float(float(_ps.x)), float(float(-_ps.y)));
    _OUT._t3 = TexCoord.xxxy + vec4(float(float(-_ps.x)), 0.00000000E+00, float(float(_ps.x)), 0.00000000E+00);
    _OUT._t4 = TexCoord.xxxy + vec4(float(float(-_ps.x)), 0.00000000E+00, float(float(_ps.x)), float(float(_ps.y)));
    _OUT._t5 = TexCoord.xxxy + vec4(float(float(-_ps.x)), 0.00000000E+00, float(float(_ps.x)), float(float((2.00000000E+00*_ps.y))));
    _OUT._t6 = TexCoord.xyyy + vec4(float(float((2.00000000E+00*_ps.x))), float(float((2.00000000E+00*_ps.y))), 0.00000000E+00, float(float(_ps.y)));
    _OUT._t7 = TexCoord.xyyy + vec4(float(float((2.00000000E+00*_ps.x))), float(float(-_ps.y)), 0.00000000E+00, float(float(_ps.y)));
    _ret_0._position1 = _r0010;
    _ret_0._color1 = COLOR;
    _ret_0._texCoord1 = TexCoord.xy;
    _ret_0._t1 = _OUT._t1;
    _ret_0._t2 = _OUT._t2;
    _ret_0._t3 = _OUT._t3;
    _ret_0._t4 = _OUT._t4;
    _ret_0._t5 = _OUT._t5;
    _ret_0._t6 = _OUT._t6;
    _ret_0._t7 = _OUT._t7;
    gl_Position = vec4(float(_r0010.x), float(_r0010.y), float(_r0010.z), float(_r0010.w));
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy;
    TEX1 = _OUT._t1;
    TEX2 = _OUT._t2;
    TEX3 = _OUT._t3;
    TEX4 = _OUT._t4;
    TEX5 = _OUT._t5;
    TEX6 = _OUT._t6;
    TEX7 = _OUT._t7;
    return;
    COL0 = _ret_0._color1;
    TEX0.xy = _ret_0._texCoord1;
    TEX1 = _ret_0._t1;
    TEX2 = _ret_0._t2;
    TEX3 = _ret_0._t3;
    TEX4 = _ret_0._t4;
    TEX5 = _ret_0._t5;
    TEX6 = _ret_0._t6;
    TEX7 = _ret_0._t7;
} 
#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
COMPAT_VARYING     vec4 _t7;
COMPAT_VARYING     vec4 _t6;
COMPAT_VARYING     vec4 _t5;
COMPAT_VARYING     vec4 _t4;
COMPAT_VARYING     vec4 _t3;
COMPAT_VARYING     vec4 _t2;
COMPAT_VARYING     vec4 _t1;
COMPAT_VARYING     vec2 _texCoord;
COMPAT_VARYING     vec4 _color;
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size;
    vec2 _output_dummy_size;
};
struct out_vertex {
    vec4 _color;
    vec2 _texCoord;
    vec4 _t1;
    vec4 _t2;
    vec4 _t3;
    vec4 _t4;
    vec4 _t5;
    vec4 _t6;
    vec4 _t7;
};
vec4 _ret_0;
vec3 _TMP40;
vec3 _TMP42;
vec3 _TMP41;
float _TMP43;
vec4 _TMP15;
vec4 _TMP14;
vec4 _TMP13;
vec4 _TMP12;
vec4 _TMP11;
vec4 _TMP10;
vec4 _TMP9;
vec4 _TMP8;
vec4 _TMP7;
vec4 _TMP6;
vec4 _TMP5;
vec4 _TMP4;
vec4 _TMP3;
vec4 _TMP2;
vec4 _TMP1;
vec4 _TMP0;
uniform sampler2D Texture;
input_dummy _IN1;
vec2 _x0055;
vec4 _r0089;
vec4 _r0099;
vec4 _r0109;
vec4 _r0119;
float _TMP128;
float _A0129;
float _B0129;
float _a0131;
float _TMP132;
float _A0133;
float _B0133;
float _a0135;
float _TMP136;
float _A0137;
float _B0137;
float _a0139;
float _TMP140;
float _A0141;
float _B0141;
float _a0143;
float _TMP144;
float _A0145;
float _B0145;
float _a0147;
float _TMP148;
float _A0149;
float _B0149;
float _a0151;
float _TMP152;
float _A0153;
float _B0153;
float _a0155;
float _TMP156;
float _A0157;
float _B0157;
float _a0159;
float _TMP160;
float _A0161;
float _B0161;
float _a0163;
float _TMP164;
float _A0165;
float _B0165;
float _a0167;
float _TMP168;
float _A0169;
float _B0169;
float _a0171;
float _TMP172;
float _A0173;
float _B0173;
float _a0175;
float _TMP176;
float _a0179;
float _TMP180;
float _a0183;
float _TMP184;
float _a0187;
float _TMP188;
float _a0191;
float _TMP192;
float _a0195;
float _TMP196;
float _a0199;
float _TMP200;
float _a0203;
float _TMP204;
float _a0207;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec4 TEX2;
COMPAT_VARYING vec4 TEX3;
COMPAT_VARYING vec4 TEX4;
COMPAT_VARYING vec4 TEX5;
COMPAT_VARYING vec4 TEX6;
COMPAT_VARYING vec4 TEX7;
 
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
    vec2 _fp;
    vec3 _HH;
    vec3 _HV;
    vec3 _HD;
    vec3 _b;
    vec3 _c;
    vec3 _d;
    vec3 _e;
    vec3 _f;
    vec3 _g;
    vec3 _h;
    vec3 _o;
    vec3 _p;
    vec3 _q;
    vec3 _r;
    vec3 _s;
    vec3 _t;
    vec3 _u;
    vec3 _v;
    vec3 _w;
    vec4 _l1;
    vec4 _l2;
    vec4 _l3;
    vec4 _l4;
    bool _horizHH_edge;
    bool _vertHH_edge;
    bool _vertHV_edge;
    bool _horizHV_edge;
    bool _hqHD_edge;
    bool _grHD_edge;
    bool _edge_qd;
    bool _edge_rc;
    bool _edge_fr;
    bool _edge_ph;
    _x0055 = TEX0.xy*TextureSize;
    _fp = fract(_x0055);
    _TMP0 = COMPAT_TEXTURE(Texture, TEX2.xw);
    _b = vec3(float(_TMP0.x), float(_TMP0.y), float(_TMP0.z));
    _TMP1 = COMPAT_TEXTURE(Texture, TEX2.yw);
    _c = vec3(float(_TMP1.x), float(_TMP1.y), float(_TMP1.z));
    _TMP2 = COMPAT_TEXTURE(Texture, TEX2.zw);
    _d = vec3(float(_TMP2.x), float(_TMP2.y), float(_TMP2.z));
    _TMP3 = COMPAT_TEXTURE(Texture, TEX7.xy);
    _e = vec3(float(_TMP3.x), float(_TMP3.y), float(_TMP3.z));
    _TMP4 = COMPAT_TEXTURE(Texture, TEX3.xw);
    _f = vec3(float(_TMP4.x), float(_TMP4.y), float(_TMP4.z));
    _TMP5 = COMPAT_TEXTURE(Texture, TEX3.yw);
    _g = vec3(float(_TMP5.x), float(_TMP5.y), float(_TMP5.z));
    _TMP6 = COMPAT_TEXTURE(Texture, TEX3.zw);
    _h = vec3(float(_TMP6.x), float(_TMP6.y), float(_TMP6.z));
    _TMP7 = COMPAT_TEXTURE(Texture, TEX7.xz);
    _o = vec3(float(_TMP7.x), float(_TMP7.y), float(_TMP7.z));
    _TMP8 = COMPAT_TEXTURE(Texture, TEX4.xw);
    _p = vec3(float(_TMP8.x), float(_TMP8.y), float(_TMP8.z));
    _TMP9 = COMPAT_TEXTURE(Texture, TEX4.yw);
    _q = vec3(float(_TMP9.x), float(_TMP9.y), float(_TMP9.z));
    _TMP10 = COMPAT_TEXTURE(Texture, TEX4.zw);
    _r = vec3(float(_TMP10.x), float(_TMP10.y), float(_TMP10.z));
    _TMP11 = COMPAT_TEXTURE(Texture, TEX7.xw);
    _s = vec3(float(_TMP11.x), float(_TMP11.y), float(_TMP11.z));
    _TMP12 = COMPAT_TEXTURE(Texture, TEX5.xw);
    _t = vec3(float(_TMP12.x), float(_TMP12.y), float(_TMP12.z));
    _TMP13 = COMPAT_TEXTURE(Texture, TEX5.yw);
    _u = vec3(float(_TMP13.x), float(_TMP13.y), float(_TMP13.z));
    _TMP14 = COMPAT_TEXTURE(Texture, TEX5.zw);
    _v = vec3(float(_TMP14.x), float(_TMP14.y), float(_TMP14.z));
    _TMP15 = COMPAT_TEXTURE(Texture, TEX6.xy);
    _w = vec3(float(_TMP15.x), float(_TMP15.y), float(_TMP15.z));
    _TMP43 = dot(vec3(float(_b.x), float(_b.y), float(_b.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0089.x = float(_TMP43);
    _TMP43 = dot(vec3(float(_c.x), float(_c.y), float(_c.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0089.y = float(_TMP43);
    _TMP43 = dot(vec3(float(_d.x), float(_d.y), float(_d.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0089.z = float(_TMP43);
    _TMP43 = dot(vec3(float(_e.x), float(_e.y), float(_e.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0089.w = float(_TMP43);
    _l1 = vec4(float(_r0089.x), float(_r0089.y), float(_r0089.z), float(_r0089.w));
    _TMP43 = dot(vec3(float(_f.x), float(_f.y), float(_f.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0099.x = float(_TMP43);
    _TMP43 = dot(vec3(float(_g.x), float(_g.y), float(_g.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0099.y = float(_TMP43);
    _TMP43 = dot(vec3(float(_h.x), float(_h.y), float(_h.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0099.z = float(_TMP43);
    _TMP43 = dot(vec3(float(_o.x), float(_o.y), float(_o.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0099.w = float(_TMP43);
    _l2 = vec4(float(_r0099.x), float(_r0099.y), float(_r0099.z), float(_r0099.w));
    _TMP43 = dot(vec3(float(_p.x), float(_p.y), float(_p.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0109.x = float(_TMP43);
    _TMP43 = dot(vec3(float(_q.x), float(_q.y), float(_q.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0109.y = float(_TMP43);
    _TMP43 = dot(vec3(float(_r.x), float(_r.y), float(_r.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0109.z = float(_TMP43);
    _TMP43 = dot(vec3(float(_s.x), float(_s.y), float(_s.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0109.w = float(_TMP43);
    _l3 = vec4(float(_r0109.x), float(_r0109.y), float(_r0109.z), float(_r0109.w));
    _TMP43 = dot(vec3(float(_t.x), float(_t.y), float(_t.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0119.x = float(_TMP43);
    _TMP43 = dot(vec3(float(_u.x), float(_u.y), float(_u.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0119.y = float(_TMP43);
    _TMP43 = dot(vec3(float(_v.x), float(_v.y), float(_v.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0119.z = float(_TMP43);
    _TMP43 = dot(vec3(float(_w.x), float(_w.y), float(_w.z)), vec3( 1.43593750E+01, 2.81718750E+01, 5.47265625E+00));
    _r0119.w = float(_TMP43);
    _l4 = vec4(float(_r0119.x), float(_r0119.y), float(_r0119.z), float(_r0119.w));
    _A0129 = _l2.x + _l2.y;
    _B0129 = _l2.z + _l2.w;
    _a0131 = _A0129 - _B0129;
    _TMP128 = abs(_a0131);
    _A0133 = _l1.y + _l1.z;
    _B0133 = _l3.y + _l3.z;
    _a0135 = _A0133 - _B0133;
    _TMP132 = abs(_a0135);
    _horizHH_edge = _TMP128 < _TMP132;
    _A0137 = _l2.x + _l2.y;
    _B0137 = _l2.z + _l2.w;
    _a0139 = _A0137 - _B0137;
    _TMP136 = abs(_a0139);
    _A0141 = _l1.y + _l1.z;
    _B0141 = _l3.y + _l3.z;
    _a0143 = _A0141 - _B0141;
    _TMP140 = abs(_a0143);
    _vertHH_edge = _TMP136 > _TMP140;
    _A0145 = _l1.y + _l2.y;
    _B0145 = _l3.y + _l4.y;
    _a0147 = _A0145 - _B0145;
    _TMP144 = abs(_a0147);
    _A0149 = _l2.x + _l3.x;
    _B0149 = _l2.z + _l3.z;
    _a0151 = _A0149 - _B0149;
    _TMP148 = abs(_a0151);
    _vertHV_edge = _TMP144 < _TMP148;
    _A0153 = _l1.y + _l2.y;
    _B0153 = _l3.y + _l4.y;
    _a0155 = _A0153 - _B0153;
    _TMP152 = abs(_a0155);
    _A0157 = _l2.x + _l3.x;
    _B0157 = _l2.z + _l3.z;
    _a0159 = _A0157 - _B0157;
    _TMP156 = abs(_a0159);
    _horizHV_edge = _TMP152 > _TMP156;
    _A0161 = _l1.x + _l2.y;
    _B0161 = _l3.z + _l4.w;
    _a0163 = _A0161 - _B0161;
    _TMP160 = abs(_a0163);
    _A0165 = _l1.w + _l2.z;
    _B0165 = _l3.y + _l4.x;
    _a0167 = _A0165 - _B0165;
    _TMP164 = abs(_a0167);
    _hqHD_edge = _TMP160 > _TMP164;
    _A0169 = _l1.x + _l2.y;
    _B0169 = _l3.z + _l4.w;
    _a0171 = _A0169 - _B0169;
    _TMP168 = abs(_a0171);
    _A0173 = _l1.w + _l2.z;
    _B0173 = _l3.y + _l4.x;
    _a0175 = _A0173 - _B0173;
    _TMP172 = abs(_a0175);
    _grHD_edge = _TMP168 < _TMP172;
    _a0179 = _l1.y - _l3.z;
    _TMP176 = abs(_a0179);
    _a0183 = _l1.z - _l3.y;
    _TMP180 = abs(_a0183);
    _edge_qd = _TMP176 > _TMP180;
    _a0187 = _l1.y - _l3.z;
    _TMP184 = abs(_a0187);
    _a0191 = _l1.z - _l3.y;
    _TMP188 = abs(_a0191);
    _edge_rc = _TMP184 < _TMP188;
    _a0195 = _l3.x - _l2.z;
    _TMP192 = abs(_a0195);
    _a0199 = _l2.x - _l3.z;
    _TMP196 = abs(_a0199);
    _edge_fr = _TMP192 > _TMP196;
    _a0203 = _l3.x - _l2.z;
    _TMP200 = abs(_a0203);
    _a0207 = _l2.x - _l3.z;
    _TMP204 = abs(_a0207);
    _edge_ph = _TMP200 < _TMP204;
    if (_horizHH_edge) { 
        _HH = (_g + _h)/2.00000000E+00;
    } else {
        if (_vertHH_edge) { 
            if (_edge_qd) { 
                _HH = (_d + _q)/2.00000000E+00;
            } else {
                if (_edge_rc) { 
                    _HH = (_r + _c)/2.00000000E+00;
                } else {
                    _HH = (_g + _h)/2.00000000E+00;
                } 
            } 
        } else {
            _HH = (_g + _h)/2.00000000E+00;
        } 
    } 
    if (_vertHV_edge) { 
        _HV = (_g + _q)/2.00000000E+00;
    } else {
        if (_horizHV_edge) { 
            if (_edge_ph) { 
                _HV = (_h + _p)/2.00000000E+00;
            } else {
                if (_edge_fr) { 
                    _HV = (_r + _f)/2.00000000E+00;
                } else {
                    _HV = (_g + _q)/2.00000000E+00;
                } 
            } 
        } else {
            _HV = (_g + _q)/2.00000000E+00;
        } 
    } 
    if (_hqHD_edge) { 
        _HD = (_h + _q)/2.00000000E+00;
    } else {
        if (_grHD_edge) { 
            _HD = (_g + _r)/2.00000000E+00;
        } else {
            _HD = (_g + _h + _q + _r)/4.00000000E+00;
        } 
    } 
    if (_fp.x < 5.00000000E-01) { 
        if (_fp.y < 5.00000000E-01) { 
            _TMP41 = _g;
        } else {
            _TMP41 = _HV;
        } 
        _TMP40 = _TMP41;
    } else {
        if (_fp.y < 5.00000000E-01) { 
            _TMP42 = _HH;
        } else {
            _TMP42 = _HD;
        } 
        _TMP40 = _TMP42;
    } 
    _ret_0 = vec4(_TMP40.x, _TMP40.y, _TMP40.z, 1.00000000E+00);
    FragColor = vec4(float(_ret_0.x), float(_ret_0.y), float(_ret_0.z), float(_ret_0.w));
    return;
} 
#endif
