// 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 VARloc;
COMPAT_VARYING     vec4 _t1;
COMPAT_VARYING     vec2 _texCoord2;
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 _texCoord2;
    vec4 _t1;
    vec2 VARloc;
};
out_vertex _ret_0;
input_dummy _IN1;
vec4 _r0006;
COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec4 TEX1;
 
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;
    vec2 _texCoord;
    _r0006 = VertexCoord.x*MVPMatrix[0];
    _r0006 = _r0006 + VertexCoord.y*MVPMatrix[1];
    _r0006 = _r0006 + VertexCoord.z*MVPMatrix[2];
    _r0006 = _r0006 + VertexCoord.w*MVPMatrix[3];
    _ps = vec2(1.00000000E+00/TextureSize.x, 1.00000000E+00/TextureSize.y);
    _texCoord = TexCoord.xy + vec2( 1.00000001E-07, 1.00000001E-07);
    _OUT._t1.xy = vec2(_ps.x, 0.00000000E+00);
    _OUT._t1.zw = vec2(0.00000000E+00, _ps.y);
    _OUT.VARloc = _texCoord*TextureSize;
    _ret_0._position1 = _r0006;
    _ret_0._color1 = COLOR;
    _ret_0._texCoord2 = _texCoord;
    _ret_0._t1 = _OUT._t1;
    VARloc = _OUT.VARloc;
    gl_Position = _r0006;
    COL0 = COLOR;
    TEX0.xy = _texCoord;
    TEX1 = _OUT._t1;
    return;
    COL0 = _ret_0._color1;
    TEX0.xy = _ret_0._texCoord2;
    TEX1 = _ret_0._t1;
} 
#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 VARloc;
COMPAT_VARYING     vec4 _t1;
COMPAT_VARYING     vec2 _texCoord;
COMPAT_VARYING     vec4 _color2;
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size;
    vec2 _output_dummy_size;
};
struct out_vertex {
    vec4 _color2;
    vec2 _texCoord;
    vec4 _t1;
    vec2 VARloc;
};
vec4 _ret_0;
float _TMP52;
float _TMP51;
float _TMP50;
float _TMP49;
float _TMP48;
float _TMP47;
float _TMP46;
float _TMP45;
float _TMP44;
float _TMP43;
float _TMP42;
float _TMP41;
float _TMP40;
float _TMP39;
float _TMP38;
float _TMP37;
float _TMP36;
float _TMP35;
float _TMP34;
float _TMP33;
float _TMP32;
float _TMP31;
float _TMP30;
float _TMP29;
float _TMP28;
float _TMP27;
float _TMP26;
float _TMP25;
float _TMP24;
float _TMP23;
float _TMP22;
float _TMP21;
float _TMP20;
float _TMP19;
float _TMP18;
float _TMP17;
float _TMP53;
float _TMP54;
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;
out_vertex _VAR1;
uniform sampler2D Texture;
vec2 _val0062;
vec2 _c0066;
vec2 _c0068;
vec2 _c0070;
vec2 _c0072;
vec2 _c0074;
vec2 _c0076;
vec2 _c0078;
vec2 _c0080;
vec2 _c0082;
vec2 _c0084;
vec2 _c0086;
vec2 _c0088;
vec2 _c0090;
vec2 _c0092;
vec2 _c0094;
float _TMP95;
float _TMP99;
float _TMP103;
float _TMP107;
float _TMP111;
float _TMP115;
float _TMP119;
float _TMP123;
float _TMP127;
float _TMP131;
float _TMP135;
float _TMP139;
float _TMP143;
float _TMP147;
float _TMP151;
float _TMP155;
float _TMP163;
vec2 _v0164;
float _TMP171;
vec2 _v0172;
float _a0180;
float _a0182;
float _a0184;
float _a0186;
float _a0188;
float _a0190;
float _a0192;
float _a0194;
float _a0196;
float _a0198;
float _a0200;
float _a0202;
float _a0204;
float _a0206;
float _a0208;
float _a0210;
float _a0212;
float _a0214;
float _a0216;
float _a0218;
float _a0220;
float _a0222;
float _a0224;
float _a0226;
float _a0228;
float _a0230;
float _a0232;
float _a0234;
float _a0236;
float _a0238;
float _a0240;
float _a0242;
float _a0244;
float _a0246;
float _a0248;
float _a0250;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec4 TEX1;
 
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
    vec2 _pos;
    vec2 _dir;
    vec2 _g1;
    vec2 _g2;
    vec3 _B1;
    vec3 _C1;
    vec3 _D1;
    float _p1;
    float _q1;
    float _count1;
    float _count2;
    vec3 _color1;
    _TMP0 = fract(VARloc);
    _pos = _TMP0 - vec2( 5.00000000E-01, 5.00000000E-01);
    _val0062 = vec2(float((_pos.x > 0.00000000E+00)), float((_pos.y > 0.00000000E+00)));
    _dir = _val0062 - vec2(float((_pos.x < 0.00000000E+00)), float((_pos.y < 0.00000000E+00)));
    _g1 = _dir*TEX1.xy;
    _g2 = _dir*TEX1.zw;
    _TMP1 = COMPAT_TEXTURE(Texture, TEX0.xy);
    _c0066 = TEX0.xy + _g1;
    _TMP2 = COMPAT_TEXTURE(Texture, _c0066);
    _B1 = _TMP2.xyz;
    _c0068 = TEX0.xy + _g2;
    _TMP3 = COMPAT_TEXTURE(Texture, _c0068);
    _C1 = _TMP3.xyz;
    _c0070 = TEX0.xy + _g1 + _g2;
    _TMP4 = COMPAT_TEXTURE(Texture, _c0070);
    _D1 = _TMP4.xyz;
    _c0072 = (TEX0.xy - _g1) - _g2;
    _TMP5 = COMPAT_TEXTURE(Texture, _c0072);
    _c0074 = TEX0.xy - _g2;
    _TMP6 = COMPAT_TEXTURE(Texture, _c0074);
    _c0076 = (TEX0.xy + _g1) - _g2;
    _TMP7 = COMPAT_TEXTURE(Texture, _c0076);
    _c0078 = (TEX0.xy + 2.00000000E+00*_g1) - _g2;
    _TMP8 = COMPAT_TEXTURE(Texture, _c0078);
    _c0080 = TEX0.xy - _g1;
    _TMP9 = COMPAT_TEXTURE(Texture, _c0080);
    _c0082 = (TEX0.xy - _g1) + _g2;
    _TMP10 = COMPAT_TEXTURE(Texture, _c0082);
    _c0084 = TEX0.xy + 2.00000000E+00*_g1;
    _TMP11 = COMPAT_TEXTURE(Texture, _c0084);
    _c0086 = TEX0.xy + 2.00000000E+00*_g1 + _g2;
    _TMP12 = COMPAT_TEXTURE(Texture, _c0086);
    _c0088 = (TEX0.xy - _g1) + 2.00000000E+00*_g2;
    _TMP13 = COMPAT_TEXTURE(Texture, _c0088);
    _c0090 = TEX0.xy + 2.00000000E+00*_g2;
    _TMP14 = COMPAT_TEXTURE(Texture, _c0090);
    _c0092 = TEX0.xy + _g1 + 2.00000000E+00*_g2;
    _TMP15 = COMPAT_TEXTURE(Texture, _c0092);
    _c0094 = TEX0.xy + 2.00000000E+00*_g1 + 2.00000000E+00*_g2;
    _TMP16 = COMPAT_TEXTURE(Texture, _c0094);
    _TMP95 = dot(_TMP1.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP99 = dot(_TMP2.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP103 = dot(_TMP3.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP107 = dot(_TMP4.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP111 = dot(_TMP5.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP115 = dot(_TMP6.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP119 = dot(_TMP7.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP123 = dot(_TMP8.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP127 = dot(_TMP9.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP131 = dot(_TMP10.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP135 = dot(_TMP11.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP139 = dot(_TMP12.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP143 = dot(_TMP13.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP147 = dot(_TMP14.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP151 = dot(_TMP15.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP155 = dot(_TMP16.xyz, vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _p1 = abs(_pos.x);
    _q1 = abs(_pos.y);
    _v0164 = _g1 - _pos;
    _TMP53 = dot(_v0164, _v0164);
    _TMP54 = inversesqrt(_TMP53);
    _TMP163 = 1.00000000E+00/_TMP54;
    _v0172 = _g2 - _pos;
    _TMP53 = dot(_v0172, _v0172);
    _TMP54 = inversesqrt(_TMP53);
    _TMP171 = 1.00000000E+00/_TMP54;
    _a0180 = _TMP111 - _TMP95;
    _TMP17 = abs(_a0180);
    _a0182 = _TMP115 - _TMP127;
    _TMP18 = abs(_a0182);
    _count1 = float((_TMP17 < _TMP18));
    _a0184 = _TMP111 - _TMP95;
    _TMP19 = abs(_a0184);
    _a0186 = _TMP115 - _TMP127;
    _TMP20 = abs(_a0186);
    _count2 = float((_TMP19 > _TMP20));
    _a0188 = _TMP115 - _TMP99;
    _TMP21 = abs(_a0188);
    _a0190 = _TMP119 - _TMP95;
    _TMP22 = abs(_a0190);
    _count1 = _count1 + float((_TMP21 < _TMP22));
    _a0192 = _TMP115 - _TMP99;
    _TMP23 = abs(_a0192);
    _a0194 = _TMP119 - _TMP95;
    _TMP24 = abs(_a0194);
    _count2 = _count2 + float((_TMP23 > _TMP24));
    _a0196 = _TMP119 - _TMP135;
    _TMP25 = abs(_a0196);
    _a0198 = _TMP123 - _TMP99;
    _TMP26 = abs(_a0198);
    _count1 = _count1 + float((_TMP25 < _TMP26));
    _a0200 = _TMP119 - _TMP135;
    _TMP27 = abs(_a0200);
    _a0202 = _TMP123 - _TMP99;
    _TMP28 = abs(_a0202);
    _count2 = _count2 + float((_TMP27 > _TMP28));
    _a0204 = _TMP127 - _TMP103;
    _TMP29 = abs(_a0204);
    _a0206 = _TMP131 - _TMP95;
    _TMP30 = abs(_a0206);
    _count1 = _count1 + float((_TMP29 < _TMP30));
    _a0208 = _TMP127 - _TMP103;
    _TMP31 = abs(_a0208);
    _a0210 = _TMP131 - _TMP95;
    _TMP32 = abs(_a0210);
    _count2 = _count2 + float((_TMP31 > _TMP32));
    _a0212 = _TMP99 - _TMP139;
    _TMP33 = abs(_a0212);
    _a0214 = _TMP135 - _TMP107;
    _TMP34 = abs(_a0214);
    _count1 = _count1 + float((_TMP33 < _TMP34));
    _a0216 = _TMP99 - _TMP139;
    _TMP35 = abs(_a0216);
    _a0218 = _TMP135 - _TMP107;
    _TMP36 = abs(_a0218);
    _count2 = _count2 + float((_TMP35 > _TMP36));
    _a0220 = _TMP131 - _TMP147;
    _TMP37 = abs(_a0220);
    _a0222 = _TMP103 - _TMP143;
    _TMP38 = abs(_a0222);
    _count1 = _count1 + float((_TMP37 < _TMP38));
    _a0224 = _TMP131 - _TMP147;
    _TMP39 = abs(_a0224);
    _a0226 = _TMP103 - _TMP143;
    _TMP40 = abs(_a0226);
    _count2 = _count2 + float((_TMP39 > _TMP40));
    _a0228 = _TMP151 - _TMP103;
    _TMP41 = abs(_a0228);
    _a0230 = _TMP147 - _TMP107;
    _TMP42 = abs(_a0230);
    _count1 = _count1 + float((_TMP41 < _TMP42));
    _a0232 = _TMP151 - _TMP103;
    _TMP43 = abs(_a0232);
    _a0234 = _TMP147 - _TMP107;
    _TMP44 = abs(_a0234);
    _count2 = _count2 + float((_TMP43 > _TMP44));
    _a0236 = _TMP155 - _TMP107;
    _TMP45 = abs(_a0236);
    _a0238 = _TMP151 - _TMP139;
    _TMP46 = abs(_a0238);
    _count1 = _count1 + float((_TMP45 < _TMP46));
    _a0240 = _TMP155 - _TMP107;
    _TMP47 = abs(_a0240);
    _a0242 = _TMP151 - _TMP139;
    _TMP48 = abs(_a0242);
    _count2 = _count2 + float((_TMP47 > _TMP48));
    _a0244 = _TMP95 - _TMP107;
    _TMP49 = abs(_a0244);
    _a0246 = _TMP99 - _TMP103;
    _TMP50 = abs(_a0246);
    if (_count1 >= 5.00000000E+00 || _TMP49 < _TMP50 && _count2 <= 4.00000000E+00) { 
        if (_TMP163 < _TMP171) { 
            _C1 = (_TMP1.xyz + _TMP4.xyz) - _TMP2.xyz;
        } else {
            if (_TMP163 >= _TMP171) { 
                _B1 = (_TMP1.xyz + _TMP4.xyz) - _TMP3.xyz;
            } 
        } 
    } else {
        _a0248 = _TMP95 - _TMP107;
        _TMP51 = abs(_a0248);
        _a0250 = _TMP99 - _TMP103;
        _TMP52 = abs(_a0250);
        if (_count2 >= 5.00000000E+00 || _TMP51 > _TMP52) { 
            _D1 = (_TMP2.xyz + _TMP3.xyz) - _TMP1.xyz;
        } 
    } 
    _color1 = ((1.00000000E+00 - _p1)*(1.00000000E+00 - _q1))*_TMP1.xyz + (_p1*(1.00000000E+00 - _q1))*_B1 + ((1.00000000E+00 - _p1)*_q1)*_C1 + (_p1*_q1)*_D1;
    _ret_0 = vec4(_color1.x, _color1.y, _color1.z, 1.00000000E+00);
    FragColor = _ret_0;
    return;
} 
#endif
