// 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 _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;
COMPAT_VARYING     float _frame_rotation;
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size;
    vec2 _output_dummy_size;
    float _frame_count;
    float _frame_direction;
    float _frame_rotation;
};
struct out_vertex {
    vec4 _position1;
    vec4 _color1;
    vec2 _texCoord1;
    vec4 _t1;
    vec4 _t2;
    vec4 _t3;
    vec4 _t4;
};
out_vertex _ret_0;
input_dummy _IN1;
vec4 _r0008;
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;
 
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()
{
    vec2 _ps;
    out_vertex _TMP4;
    _ps = vec2(1.00000000E+00/TextureSize.x, 1.00000000E+00/TextureSize.y);
    _r0008 = VertexCoord.x*MVPMatrix[0];
    _r0008 = _r0008 + VertexCoord.y*MVPMatrix[1];
    _r0008 = _r0008 + VertexCoord.z*MVPMatrix[2];
    _r0008 = _r0008 + VertexCoord.w*MVPMatrix[3];
    _TMP4._t1 = TexCoord.xyxy + vec4(-2.00000000E+00*_ps.x, -2.00000000E+00*_ps.y, _ps.x, _ps.y);
    _TMP4._t2 = TexCoord.xyxy + vec4(-_ps.x, -2.00000000E+00*_ps.y, 0.00000000E+00, _ps.y);
    _TMP4._t3 = TexCoord.xyxy + vec4(-2.00000000E+00*_ps.x, -_ps.y, _ps.x, 0.00000000E+00);
    _TMP4._t4 = TexCoord.xyxy + vec4(-_ps.x, -_ps.y, 0.00000000E+00, 0.00000000E+00);
    _ret_0._position1 = _r0008;
    _ret_0._color1 = COLOR;
    _ret_0._texCoord1 = TexCoord.xy;
    _ret_0._t1 = _TMP4._t1;
    _ret_0._t2 = _TMP4._t2;
    _ret_0._t3 = _TMP4._t3;
    _ret_0._t4 = _TMP4._t4;
    gl_Position = _r0008;
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy;
    TEX1 = _TMP4._t1;
    TEX2 = _TMP4._t2;
    TEX3 = _TMP4._t3;
    TEX4 = _TMP4._t4;
    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;
} 
#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 _t4;
COMPAT_VARYING     vec4 _t3;
COMPAT_VARYING     vec4 _t2;
COMPAT_VARYING     vec4 _t1;
COMPAT_VARYING     vec2 _texCoord;
COMPAT_VARYING     vec4 _color2;
COMPAT_VARYING     float _frame_rotation;
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size;
    vec2 _output_dummy_size;
    float _frame_count;
    float _frame_direction;
    float _frame_rotation;
};
struct out_vertex {
    vec4 _color2;
    vec2 _texCoord;
    vec4 _t1;
    vec4 _t2;
    vec4 _t3;
    vec4 _t4;
};
vec4 _ret_0;
vec3 _TMP58;
vec3 _TMP30;
float _TMP29;
vec3 _TMP57;
vec3 _TMP56;
vec3 _TMP27;
float _TMP26;
vec3 _TMP55;
vec3 _TMP54;
vec3 _TMP24;
vec3 _TMP22;
float _TMP23;
float _TMP21;
float _TMP20;
float _TMP59;
float _TMP19;
float _TMP18;
float _TMP17;
float _TMP16;
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;
float _TMP100;
float _TMP104;
float _TMP108;
float _TMP112;
float _TMP116;
float _TMP120;
float _TMP124;
float _TMP128;
float _TMP132;
float _TMP140;
float _TMP148;
float _TMP156;
float _TMP166;
float _a0169;
float _TMP170;
float _a0173;
float _TMP174;
float _a0177;
float _TMP178;
float _a0181;
float _TMP202;
float _a0205;
float _TMP206;
float _a0209;
float _TMP220;
float _a0223;
float _TMP224;
float _a0227;
float _TMP228;
float _a0231;
float _TMP232;
float _a0235;
float _TMP256;
float _a0259;
float _TMP260;
float _a0263;
float _TMP282;
float _a0285;
float _TMP286;
float _a0289;
float _TMP290;
float _a0293;
float _TMP294;
float _a0297;
float _TMP324;
float _a0327;
float _TMP328;
float _a0331;
float _TMP332;
float _a0335;
float _TMP336;
float _a0339;
float _x0361;
float _TMP362;
vec3 _r0369;
vec3 _r0371;
vec3 _r0373;
vec3 _r0375;
float _t0385;
vec3 _TMP386;
vec3 _a0397;
vec3 _b0397;
vec3 _TMP398;
vec3 _a0409;
vec3 _b0409;
vec3 _TMP410;
COMPAT_VARYING vec4 TEX1;
COMPAT_VARYING vec4 TEX2;
COMPAT_VARYING vec4 TEX3;
COMPAT_VARYING vec4 TEX4;
 
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
    float _d_edge;
    float _hv_edge;
    float _edge_strength;
    vec3 _color1;
    vec3 _min_sample;
    vec3 _max_sample;
    vec3 _TMP64[4];
    vec3 _TMP65[4];
    _TMP0 = COMPAT_TEXTURE(Texture, TEX1.xy);
    _TMP1 = COMPAT_TEXTURE(Texture, TEX1.zy);
    _TMP2 = COMPAT_TEXTURE(Texture, TEX1.xw);
    _TMP3 = COMPAT_TEXTURE(Texture, TEX1.zw);
    _TMP4 = COMPAT_TEXTURE(Texture, TEX2.xy);
    _TMP5 = COMPAT_TEXTURE(Texture, TEX2.zy);
    _TMP6 = COMPAT_TEXTURE(Texture, TEX2.xw);
    _TMP7 = COMPAT_TEXTURE(Texture, TEX2.zw);
    _TMP8 = COMPAT_TEXTURE(Texture, TEX3.xy);
    _TMP9 = COMPAT_TEXTURE(Texture, TEX3.zy);
    _TMP10 = COMPAT_TEXTURE(Texture, TEX3.xw);
    _TMP11 = COMPAT_TEXTURE(Texture, TEX3.zw);
    _TMP12 = COMPAT_TEXTURE(Texture, TEX4.xy);
    _TMP13 = COMPAT_TEXTURE(Texture, TEX4.zy);
    _TMP14 = COMPAT_TEXTURE(Texture, TEX4.xw);
    _TMP15 = COMPAT_TEXTURE(Texture, TEX4.zw);
    _TMP100 = dot(_TMP4.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP104 = dot(_TMP5.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP108 = dot(_TMP8.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP112 = dot(_TMP12.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP116 = dot(_TMP13.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP120 = dot(_TMP10.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP124 = dot(_TMP14.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP128 = dot(_TMP15.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP132 = dot(_TMP11.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP140 = dot(_TMP7.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP148 = dot(_TMP6.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP156 = dot(_TMP9.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _a0169 = _TMP112 - _TMP104;
    _TMP166 = abs(_a0169);
    _a0173 = _TMP112 - _TMP120;
    _TMP170 = abs(_a0173);
    _a0177 = _TMP128 - _TMP148;
    _TMP174 = abs(_a0177);
    _a0181 = _TMP128 - _TMP156;
    _TMP178 = abs(_a0181);
    _a0205 = _TMP120 - _TMP104;
    _TMP202 = abs(_a0205);
    _a0209 = _TMP148 - _TMP156;
    _TMP206 = abs(_a0209);
    _TMP16 = _TMP166 + _TMP170 + _TMP174 + _TMP178 + -(_TMP202 + _TMP206);
    _a0223 = _TMP116 - _TMP132;
    _TMP220 = abs(_a0223);
    _a0227 = _TMP116 - _TMP100;
    _TMP224 = abs(_a0227);
    _a0231 = _TMP124 - _TMP108;
    _TMP228 = abs(_a0231);
    _a0235 = _TMP124 - _TMP140;
    _TMP232 = abs(_a0235);
    _a0259 = _TMP100 - _TMP132;
    _TMP256 = abs(_a0259);
    _a0263 = _TMP108 - _TMP140;
    _TMP260 = abs(_a0263);
    _TMP17 = _TMP220 + _TMP224 + _TMP228 + _TMP232 + -(_TMP256 + _TMP260);
    _d_edge = _TMP16 - _TMP17;
    _a0285 = _TMP116 - _TMP104;
    _TMP282 = abs(_a0285);
    _a0289 = _TMP128 - _TMP140;
    _TMP286 = abs(_a0289);
    _a0293 = _TMP112 - _TMP100;
    _TMP290 = abs(_a0293);
    _a0297 = _TMP124 - _TMP148;
    _TMP294 = abs(_a0297);
    _TMP18 = _TMP282 + _TMP286 + _TMP290 + _TMP294;
    _a0327 = _TMP112 - _TMP108;
    _TMP324 = abs(_a0327);
    _a0331 = _TMP116 - _TMP156;
    _TMP328 = abs(_a0331);
    _a0335 = _TMP124 - _TMP120;
    _TMP332 = abs(_a0335);
    _a0339 = _TMP128 - _TMP132;
    _TMP336 = abs(_a0339);
    _TMP19 = _TMP324 + _TMP328 + _TMP332 + _TMP336;
    _hv_edge = _TMP18 - _TMP19;
    _TMP20 = abs(_d_edge);
    _x0361 = _TMP20/9.99999997E-07;
    _TMP59 = min(1.00000000E+00, _x0361);
    _TMP362 = max(0.00000000E+00, _TMP59);
    _edge_strength = _TMP362*_TMP362*(3.00000000E+00 - 2.00000000E+00*_TMP362);
    _r0369 = 5.00000000E-01*_TMP14.xyz;
    _r0369 = _r0369 + 5.00000000E-01*_TMP13.xyz;
    _r0371 = 5.00000000E-01*_TMP12.xyz;
    _r0371 = _r0371 + 5.00000000E-01*_TMP15.xyz;
    _TMP65[1] = _TMP12.xyz + _TMP14.xyz;
    _TMP65[2] = _TMP13.xyz + _TMP15.xyz;
    _r0373 = 2.50000000E-01*_TMP65[1];
    _r0373 = _r0373 + 2.50000000E-01*_TMP65[2];
    _TMP64[1] = _TMP13.xyz + _TMP12.xyz;
    _TMP64[2] = _TMP15.xyz + _TMP14.xyz;
    _r0375 = 2.50000000E-01*_TMP64[1];
    _r0375 = _r0375 + 2.50000000E-01*_TMP64[2];
    _TMP21 = float((_d_edge >= 0.00000000E+00));
    _TMP22 = _r0369 + _TMP21*(_r0371 - _r0369);
    _TMP23 = float((_hv_edge >= 0.00000000E+00));
    _TMP24 = _r0373 + _TMP23*(_r0375 - _r0373);
    _t0385 = 1.00000000E+00 - _edge_strength;
    _color1 = _TMP22 + _t0385*(_TMP24 - _TMP22);
    _TMP54 = min(_TMP14.xyz, _TMP15.xyz);
    _TMP55 = min(_TMP13.xyz, _TMP54);
    _TMP386 = min(_TMP12.xyz, _TMP55);
    _TMP26 = float((_d_edge >= 0.00000000E+00));
    _a0397 = (_TMP2.xyz - _TMP14.xyz)*(_TMP13.xyz - _TMP1.xyz);
    _b0397 = (_TMP0.xyz - _TMP12.xyz)*(_TMP15.xyz - _TMP3.xyz);
    _TMP27 = _a0397 + _TMP26*(_b0397 - _a0397);
    _min_sample = _TMP386 + _TMP27;
    _TMP56 = max(_TMP14.xyz, _TMP15.xyz);
    _TMP57 = max(_TMP13.xyz, _TMP56);
    _TMP398 = max(_TMP12.xyz, _TMP57);
    _TMP29 = float((_d_edge >= 0.00000000E+00));
    _a0409 = (_TMP2.xyz - _TMP14.xyz)*(_TMP13.xyz - _TMP1.xyz);
    _b0409 = (_TMP0.xyz - _TMP12.xyz)*(_TMP15.xyz - _TMP3.xyz);
    _TMP30 = _a0409 + _TMP29*(_b0409 - _a0409);
    _max_sample = _TMP398 - _TMP30;
    _TMP58 = min(_max_sample, _color1);
    _TMP410 = max(_min_sample, _TMP58);
    _ret_0 = vec4(_TMP410.x, _TMP410.y, _TMP410.z, 1.00000000E+00);
    FragColor = _ret_0;
    return;
} 
#endif
