// 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 VARorig_tex;
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;
COMPAT_VARYING     vec2 _tex_coord;
struct orig {
    vec2 _tex_coord;
    vec2 _texture_size;
float _placeholder32;
};
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size1;
    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;
    vec2 VARorig_tex;
};
out_vertex _co1;
orig _ORIG1;
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;
 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform COMPAT_PRECISION vec2 OrigTextureSize;
COMPAT_ATTRIBUTE vec2 OrigTexCoord;
void main()
{
    vec2 _ps;
    _r0008 = VertexCoord.x*MVPMatrix[0];
    _r0008 = _r0008 + VertexCoord.y*MVPMatrix[1];
    _r0008 = _r0008 + VertexCoord.z*MVPMatrix[2];
    _r0008 = _r0008 + VertexCoord.w*MVPMatrix[3];
    _co1._position1 = _r0008;
    _co1._color1 = COLOR;
    _ps = vec2(1.00000000E+00/OrigTextureSize.x, 1.00000000E+00/OrigTextureSize.y);
    _co1._texCoord1 = TexCoord.xy;
    VARorig_tex = OrigTexCoord;
    _co1._t1 = OrigTexCoord.xyyy + vec4(0.00000000E+00, -_ps.y, 0.00000000E+00, _ps.y);
    _co1._t2 = OrigTexCoord.xxxy + vec4(-_ps.x, 0.00000000E+00, _ps.x, 0.00000000E+00);
    gl_Position = _r0008;
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy;
    TEX1 = _co1._t1;
    TEX2 = _co1._t2;
} 
#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 _orig_tex;
COMPAT_VARYING     vec4 _t3;
COMPAT_VARYING     vec4 _t2;
COMPAT_VARYING     vec4 _t1;
COMPAT_VARYING     vec2 _texCoord;
COMPAT_VARYING     vec4 _color;
COMPAT_VARYING     float _frame_rotation;
COMPAT_VARYING     vec2 _tex_coord;
struct orig {
    vec2 _tex_coord;
    vec2 _texture_size;
float _placeholder36;
};
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size1;
    vec2 _output_dummy_size;
    float _frame_count;
    float _frame_direction;
    float _frame_rotation;
};
struct out_vertex {
    vec4 _color;
    vec2 _texCoord;
    vec4 _t1;
    vec4 _t2;
    vec4 _t3;
    vec2 _orig_tex;
};
vec4 _ret_0;
float _TMP22;
vec3 _TMP15;
vec3 _TMP17;
vec3 _TMP19;
vec3 _TMP20;
vec3 _TMP18;
vec3 _TMP16;
vec3 _TMP9;
vec3 _TMP11;
vec3 _TMP13;
vec3 _TMP14;
vec3 _TMP12;
vec3 _TMP10;
vec4 _TMP6;
vec4 _TMP5;
float _TMP26;
float _TMP27;
float _TMP28;
float _TMP25;
float _TMP24;
vec3 _TMP23;
vec4 _TMP4;
vec4 _TMP3;
vec4 _TMP2;
vec4 _TMP1;
vec4 _TMP0;
uniform sampler2D Texture;
orig _ORIG1;
input_dummy _IN1;
vec2 _x0040;
vec4 _r0052;
vec4 _r0062;
vec4 _x0072;
vec4 _x0074;
vec4 _x0076;
vec3 _TMP79;
vec3 _x0084;
vec4 _info0086;
float _x0088;
float _x0092;
float _x0096;
float _x0098;
float _x0102;
float _x0106;
float _x0108;
float _x0112;
float _x0116;
vec4 _info0118;
float _x0120;
float _x0124;
float _x0128;
float _x0130;
float _x0134;
float _x0138;
float _x0140;
float _x0144;
float _x0148;
vec4 _info0150;
float _x0152;
float _x0156;
float _x0160;
float _x0162;
float _x0166;
float _x0170;
float _x0172;
float _x0176;
float _x0180;
vec4 _TMP185;
vec4 _a0188;
vec4 _TMP189;
vec4 _a0192;
vec2 _r0194;
vec2 _a0200;
COMPAT_VARYING vec4 TEX0;
COMPAT_VARYING vec4 TEX1;
COMPAT_VARYING vec4 TEX2;
 
uniform sampler2D OrigTexture;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
void main()
{
    bvec4 _px;
    bvec4 _nc;
    vec4 _fx;
    vec4 _fx_left;
    vec4 _fx_up;
    vec2 _fp;
    vec4 _info1;
    vec2 _df12;
    vec3 _res;
    _x0040 = TEX0.xy*TextureSize;
    _fp = fract(_x0040);
    _TMP0 = COMPAT_TEXTURE(OrigTexture, TEX1.xy);
    _TMP1 = COMPAT_TEXTURE(OrigTexture, TEX2.xw);
    _TMP2 = COMPAT_TEXTURE(OrigTexture, TEX2.yw);
    _TMP3 = COMPAT_TEXTURE(OrigTexture, TEX2.zw);
    _TMP4 = COMPAT_TEXTURE(OrigTexture, TEX1.xw);
    _r0052.x = dot(_TMP0.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0052.y = dot(_TMP1.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0052.z = dot(_TMP4.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0052.w = dot(_TMP3.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0062.x = dot(_TMP2.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0062.y = dot(_TMP2.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0062.z = dot(_TMP2.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0062.w = dot(_TMP2.xyz, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _x0072 = vec4( 1.00000000E+00, -1.00000000E+00, -1.00000000E+00, 1.00000000E+00)*_fp.y + vec4( 1.00000000E+00, 1.00000000E+00, -1.00000000E+00, -1.00000000E+00)*_fp.x;
    _fx = vec4(float((_x0072.x >= 1.50000000E+00)), float((_x0072.y >= 5.00000000E-01)), float((_x0072.z >= -5.00000000E-01)), float((_x0072.w >= 5.00000000E-01)));
    _x0074 = vec4( 1.00000000E+00, -1.00000000E+00, -1.00000000E+00, 1.00000000E+00)*_fp.y + vec4( 5.00000000E-01, 2.00000000E+00, -5.00000000E-01, -2.00000000E+00)*_fp.x;
    _fx_left = vec4(float((_x0074.x >= 1.00000000E+00)), float((_x0074.y >= 1.00000000E+00)), float((_x0074.z >= -5.00000000E-01)), float((_x0074.w >= 0.00000000E+00)));
    _x0076 = vec4( 1.00000000E+00, -1.00000000E+00, -1.00000000E+00, 1.00000000E+00)*_fp.y + vec4( 2.00000000E+00, 5.00000000E-01, -2.00000000E+00, -5.00000000E-01)*_fp.x;
    _fx_up = vec4(float((_x0076.x >= 2.00000000E+00)), float((_x0076.y >= 0.00000000E+00)), float((_x0076.z >= -1.00000000E+00)), float((_x0076.w >= 5.00000000E-01)));
    _info1 = COMPAT_TEXTURE(Texture, TEX0.xy);
    _TMP23 = _info1.xyz*vec3( 1.50000000E+01, 1.50000000E+01, 1.50000000E+01);
    _x0084 = _TMP23 + 5.00000000E-01;
    _TMP79 = floor(_x0084);
    _x0088 = _TMP79.x/2.00000000E+00;
    if (_x0088 < 0.00000000E+00) { 
        _x0092 = -_x0088;
        _TMP28 = floor(_x0092);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0088);
    } 
    _TMP24 = _x0088 - _TMP27;
    _x0096 = _TMP24 + 5.00000000E-01;
    _info0086.w = floor(_x0096);
    _x0098 = _TMP27/2.00000000E+00;
    if (_x0098 < 0.00000000E+00) { 
        _x0102 = -_x0098;
        _TMP28 = floor(_x0102);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0098);
    } 
    _TMP25 = _x0098 - _TMP27;
    _x0106 = _TMP25 + 5.00000000E-01;
    _info0086.z = floor(_x0106);
    _x0108 = _TMP27/2.00000000E+00;
    if (_x0108 < 0.00000000E+00) { 
        _x0112 = -_x0108;
        _TMP28 = floor(_x0112);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0108);
    } 
    _TMP26 = _x0108 - _TMP27;
    _x0116 = _TMP26 + 5.00000000E-01;
    _info0086.y = floor(_x0116);
    _info0086.x = _TMP27;
    _x0120 = _TMP79.y/2.00000000E+00;
    if (_x0120 < 0.00000000E+00) { 
        _x0124 = -_x0120;
        _TMP28 = floor(_x0124);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0120);
    } 
    _TMP24 = _x0120 - _TMP27;
    _x0128 = _TMP24 + 5.00000000E-01;
    _info0118.w = floor(_x0128);
    _x0130 = _TMP27/2.00000000E+00;
    if (_x0130 < 0.00000000E+00) { 
        _x0134 = -_x0130;
        _TMP28 = floor(_x0134);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0130);
    } 
    _TMP25 = _x0130 - _TMP27;
    _x0138 = _TMP25 + 5.00000000E-01;
    _info0118.z = floor(_x0138);
    _x0140 = _TMP27/2.00000000E+00;
    if (_x0140 < 0.00000000E+00) { 
        _x0144 = -_x0140;
        _TMP28 = floor(_x0144);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0140);
    } 
    _TMP26 = _x0140 - _TMP27;
    _x0148 = _TMP26 + 5.00000000E-01;
    _info0118.y = floor(_x0148);
    _info0118.x = _TMP27;
    _x0152 = _TMP79.z/2.00000000E+00;
    if (_x0152 < 0.00000000E+00) { 
        _x0156 = -_x0152;
        _TMP28 = floor(_x0156);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0152);
    } 
    _TMP24 = _x0152 - _TMP27;
    _x0160 = _TMP24 + 5.00000000E-01;
    _info0150.w = floor(_x0160);
    _x0162 = _TMP27/2.00000000E+00;
    if (_x0162 < 0.00000000E+00) { 
        _x0166 = -_x0162;
        _TMP28 = floor(_x0166);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0162);
    } 
    _TMP25 = _x0162 - _TMP27;
    _x0170 = _TMP25 + 5.00000000E-01;
    _info0150.z = floor(_x0170);
    _x0172 = _TMP27/2.00000000E+00;
    if (_x0172 < 0.00000000E+00) { 
        _x0176 = -_x0172;
        _TMP28 = floor(_x0176);
        _TMP27 = -_TMP28;
    } else {
        _TMP27 = floor(_x0172);
    } 
    _TMP26 = _x0172 - _TMP27;
    _x0180 = _TMP26 + 5.00000000E-01;
    _info0150.y = floor(_x0180);
    _info0150.x = _TMP27;
    _fx = _info0086*_fx;
    _fx_left = _info0118*_fx_left;
    _fx_up = _info0150*_fx_up;
    _TMP5 = max(_fx_left, _fx_up);
    _TMP6 = max(_fx, _TMP5);
    _nc = bvec4(bool(_TMP6.x), bool(_TMP6.y), bool(_TMP6.z), bool(_TMP6.w));
    _a0188 = _r0062 - _r0052.wxyz;
    _TMP185 = abs(_a0188);
    _a0192 = _r0062 - _r0052.zwxy;
    _TMP189 = abs(_a0192);
    _px = bvec4(_TMP185.x <= _TMP189.x, _TMP185.y <= _TMP189.y, _TMP185.z <= _TMP189.z, _TMP185.w <= _TMP189.w);
    if (_nc.x) { 
        if (_px.x) { 
            _TMP10 = _TMP3.xyz;
        } else {
            _TMP10 = _TMP4.xyz;
        } 
        _TMP9 = _TMP10;
    } else {
        if (_nc.y) { 
            if (_px.y) { 
                _TMP12 = _TMP0.xyz;
            } else {
                _TMP12 = _TMP3.xyz;
            } 
            _TMP11 = _TMP12;
        } else {
            if (_nc.z) { 
                if (_px.z) { 
                    _TMP14 = _TMP1.xyz;
                } else {
                    _TMP14 = _TMP0.xyz;
                } 
                _TMP13 = _TMP14;
            } else {
                _TMP13 = _TMP2.xyz;
            } 
            _TMP11 = _TMP13;
        } 
        _TMP9 = _TMP11;
    } 
    if (_nc.w) { 
        if (_px.w) { 
            _TMP16 = _TMP4.xyz;
        } else {
            _TMP16 = _TMP1.xyz;
        } 
        _TMP15 = _TMP16;
    } else {
        if (_nc.z) { 
            if (_px.z) { 
                _TMP18 = _TMP1.xyz;
            } else {
                _TMP18 = _TMP0.xyz;
            } 
            _TMP17 = _TMP18;
        } else {
            if (_nc.y) { 
                if (_px.y) { 
                    _TMP20 = _TMP0.xyz;
                } else {
                    _TMP20 = _TMP3.xyz;
                } 
                _TMP19 = _TMP20;
            } else {
                _TMP19 = _TMP2.xyz;
            } 
            _TMP17 = _TMP19;
        } 
        _TMP15 = _TMP17;
    } 
    _r0194.x = dot(_TMP9, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _r0194.y = dot(_TMP15, vec3( 1.43519993E+01, 2.81760006E+01, 5.47200012E+00));
    _a0200 = _r0194 - _r0062.xy;
    _df12 = abs(_a0200);
    _TMP22 = float((_df12.y >= _df12.x));
    _res = _TMP9 + _TMP22*(_TMP15 - _TMP9);
    _ret_0 = vec4(_res.x, _res.y, _res.z, 1.00000000E+00);
    FragColor = _ret_0;
    return;
} 
#endif
