// 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     vec2 _texCoord;
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 _texCoord;
};
out_vertex _ret_0;
vec4 _r0008;
COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;
 
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()
{
    _r0008 = VertexCoord.x*MVPMatrix[0];
    _r0008 = _r0008 + VertexCoord.y*MVPMatrix[1];
    _r0008 = _r0008 + VertexCoord.z*MVPMatrix[2];
    _r0008 = _r0008 + VertexCoord.w*MVPMatrix[3];
    _ret_0._position1 = _r0008;
    _ret_0._color1 = COLOR;
    _ret_0._texCoord = TexCoord.xy;
    gl_Position = _r0008;
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy;
    return;
    COL0 = _ret_0._color1;
    TEX0.xy = _ret_0._texCoord;
} 
#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     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 _ret_0;
vec3 _TMP42;
vec3 _TMP24;
float _TMP23;
vec3 _TMP41;
vec3 _TMP40;
vec3 _TMP21;
float _TMP20;
vec3 _TMP39;
vec3 _TMP38;
float _TMP43;
float _TMP18;
float _TMP17;
vec4 _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;
vec2 _TMP0;
uniform sampler2D Texture;
input_dummy _IN1;
vec2 _x0051;
bvec2 _a0055;
vec2 _c0057;
vec2 _c0059;
vec2 _c0061;
vec2 _c0063;
vec2 _c0065;
vec2 _c0067;
vec2 _c0069;
vec2 _c0073;
vec2 _c0075;
vec2 _c0077;
vec2 _c0079;
vec2 _c0081;
vec2 _c0083;
vec2 _c0085;
vec2 _c0087;
float _TMP88;
float _TMP92;
float _TMP96;
float _TMP100;
float _TMP104;
float _TMP108;
float _TMP112;
float _TMP116;
float _TMP120;
float _TMP128;
float _TMP136;
float _TMP144;
float _TMP154;
float _a0157;
float _TMP158;
float _a0161;
float _TMP162;
float _a0165;
float _TMP166;
float _a0169;
float _TMP186;
float _a0189;
float _TMP190;
float _a0193;
float _TMP194;
float _a0197;
float _TMP208;
float _a0211;
float _TMP212;
float _a0215;
float _TMP216;
float _a0219;
float _TMP220;
float _a0223;
float _TMP240;
float _a0243;
float _TMP244;
float _a0247;
float _TMP248;
float _a0251;
float _x0263;
float _TMP264;
vec3 _r0271;
vec3 _r0273;
vec3 _TMP276;
vec3 _a0287;
vec3 _b0287;
vec3 _TMP288;
vec3 _a0299;
vec3 _b0299;
vec3 _TMP300;
COMPAT_VARYING vec4 TEX0;
 
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
    vec2 _g1;
    vec2 _g2;
    float _d_edge;
    float _edge_strength;
    vec3 _color1;
    vec3 _min_sample;
    vec3 _max_sample;
    _x0051 = TEX0.xy*TextureSize;
    _TMP0 = fract(_x0051);
    _a0055 = bvec2(_TMP0.x < 5.00000000E-01, _TMP0.y < 5.00000000E-01);
    if (_a0055.x || _a0055.y) { 
        _ret_0 = COMPAT_TEXTURE(Texture, TEX0.xy);
        FragColor = _ret_0;
        return;
    } 
    _g1 = vec2(1.00000000E+00/TextureSize.x, 0.00000000E+00);
    _g2 = vec2(0.00000000E+00, 1.00000000E+00/TextureSize.y);
    _c0057 = (TEX0.xy - _g1) - _g2;
    _TMP1 = COMPAT_TEXTURE(Texture, _c0057);
    _c0059 = (TEX0.xy + 2.00000000E+00*_g1) - _g2;
    _TMP2 = COMPAT_TEXTURE(Texture, _c0059);
    _c0061 = (TEX0.xy - _g1) + 2.00000000E+00*_g2;
    _TMP3 = COMPAT_TEXTURE(Texture, _c0061);
    _c0063 = TEX0.xy + 2.00000000E+00*_g1 + 2.00000000E+00*_g2;
    _TMP4 = COMPAT_TEXTURE(Texture, _c0063);
    _c0065 = TEX0.xy - _g2;
    _TMP5 = COMPAT_TEXTURE(Texture, _c0065);
    _c0067 = (TEX0.xy + _g1) - _g2;
    _TMP6 = COMPAT_TEXTURE(Texture, _c0067);
    _c0069 = TEX0.xy - _g1;
    _TMP7 = COMPAT_TEXTURE(Texture, _c0069);
    _TMP8 = COMPAT_TEXTURE(Texture, TEX0.xy);
    _c0073 = TEX0.xy + _g1;
    _TMP9 = COMPAT_TEXTURE(Texture, _c0073);
    _c0075 = (TEX0.xy - _g1) + _g2;
    _TMP10 = COMPAT_TEXTURE(Texture, _c0075);
    _c0077 = TEX0.xy + _g2;
    _TMP11 = COMPAT_TEXTURE(Texture, _c0077);
    _c0079 = TEX0.xy + _g1 + _g2;
    _TMP12 = COMPAT_TEXTURE(Texture, _c0079);
    _c0081 = TEX0.xy + 2.00000000E+00*_g1;
    _TMP13 = COMPAT_TEXTURE(Texture, _c0081);
    _c0083 = TEX0.xy + _g2 + 2.00000000E+00*_g1;
    _TMP14 = COMPAT_TEXTURE(Texture, _c0083);
    _c0085 = TEX0.xy + 2.00000000E+00*_g2;
    _TMP15 = COMPAT_TEXTURE(Texture, _c0085);
    _c0087 = TEX0.xy + 2.00000000E+00*_g2 + _g1;
    _TMP16 = COMPAT_TEXTURE(Texture, _c0087);
    _TMP88 = dot(_TMP5.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP92 = dot(_TMP6.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP96 = dot(_TMP7.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP100 = dot(_TMP8.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP104 = dot(_TMP9.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP108 = dot(_TMP10.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP112 = dot(_TMP11.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP116 = dot(_TMP12.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP120 = dot(_TMP14.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP128 = dot(_TMP16.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP136 = dot(_TMP15.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _TMP144 = dot(_TMP13.xyz, vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02));
    _a0157 = _TMP100 - _TMP92;
    _TMP154 = abs(_a0157);
    _a0161 = _TMP100 - _TMP108;
    _TMP158 = abs(_a0161);
    _a0165 = _TMP116 - _TMP136;
    _TMP162 = abs(_a0165);
    _a0169 = _TMP116 - _TMP144;
    _TMP166 = abs(_a0169);
    _a0189 = _TMP112 - _TMP104;
    _TMP186 = abs(_a0189);
    _a0193 = _TMP108 - _TMP92;
    _TMP190 = abs(_a0193);
    _a0197 = _TMP136 - _TMP144;
    _TMP194 = abs(_a0197);
    _TMP17 = _TMP154 + _TMP158 + _TMP162 + _TMP166 + 2.00000000E+00*_TMP186 + -(_TMP190 + _TMP194);
    _a0211 = _TMP104 - _TMP120;
    _TMP208 = abs(_a0211);
    _a0215 = _TMP104 - _TMP88;
    _TMP212 = abs(_a0215);
    _a0219 = _TMP112 - _TMP96;
    _TMP216 = abs(_a0219);
    _a0223 = _TMP112 - _TMP128;
    _TMP220 = abs(_a0223);
    _a0243 = _TMP100 - _TMP116;
    _TMP240 = abs(_a0243);
    _a0247 = _TMP88 - _TMP120;
    _TMP244 = abs(_a0247);
    _a0251 = _TMP96 - _TMP128;
    _TMP248 = abs(_a0251);
    _TMP18 = _TMP208 + _TMP212 + _TMP216 + _TMP220 + 2.00000000E+00*_TMP240 + -(_TMP244 + _TMP248);
    _d_edge = _TMP17 - _TMP18;
    _x0263 = (_d_edge - -9.99999997E-07)/1.99999999E-06;
    _TMP43 = min(1.00000000E+00, _x0263);
    _TMP264 = max(0.00000000E+00, _TMP43);
    _edge_strength = _TMP264*_TMP264*(3.00000000E+00 - 2.00000000E+00*_TMP264);
    _r0271 = 5.00000000E-01*_TMP11.xyz;
    _r0271 = _r0271 + 5.00000000E-01*_TMP9.xyz;
    _r0273 = 5.00000000E-01*_TMP8.xyz;
    _r0273 = _r0273 + 5.00000000E-01*_TMP12.xyz;
    _color1 = _r0271 + _edge_strength*(_r0273 - _r0271);
    _TMP38 = min(_TMP11.xyz, _TMP12.xyz);
    _TMP39 = min(_TMP9.xyz, _TMP38);
    _TMP276 = min(_TMP8.xyz, _TMP39);
    _TMP20 = float((_d_edge >= 0.00000000E+00));
    _a0287 = (_TMP3.xyz - _TMP11.xyz)*(_TMP9.xyz - _TMP2.xyz);
    _b0287 = (_TMP1.xyz - _TMP8.xyz)*(_TMP12.xyz - _TMP4.xyz);
    _TMP21 = _a0287 + _TMP20*(_b0287 - _a0287);
    _min_sample = _TMP276 + _TMP21;
    _TMP40 = max(_TMP11.xyz, _TMP12.xyz);
    _TMP41 = max(_TMP9.xyz, _TMP40);
    _TMP288 = max(_TMP8.xyz, _TMP41);
    _TMP23 = float((_d_edge >= 0.00000000E+00));
    _a0299 = (_TMP3.xyz - _TMP11.xyz)*(_TMP9.xyz - _TMP2.xyz);
    _b0299 = (_TMP1.xyz - _TMP8.xyz)*(_TMP12.xyz - _TMP4.xyz);
    _TMP24 = _a0299 + _TMP23*(_b0299 - _a0299);
    _max_sample = _TMP288 - _TMP24;
    _TMP42 = min(_max_sample, _color1);
    _TMP300 = max(_min_sample, _TMP42);
    _ret_0 = vec4(_TMP300.x, _TMP300.y, _TMP300.z, 1.00000000E+00);
    FragColor = _ret_0;
    return;
} 
#endif
