// 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 _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;
};
out_vertex _co1;
vec4 _r0007;
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()
{
    _r0007 = VertexCoord.x*MVPMatrix[0];
    _r0007 = _r0007 + VertexCoord.y*MVPMatrix[1];
    _r0007 = _r0007 + VertexCoord.z*MVPMatrix[2];
    _r0007 = _r0007 + VertexCoord.w*MVPMatrix[3];
    _co1._position1 = _r0007;
    _co1._color1 = COLOR;
    _co1._texCoord1 = TexCoord.xy;
    gl_Position = _r0007;
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy;
} 
#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 _color;
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 _color;
    vec2 _texCoord;
};
vec4 _ret_0;
float _TMP13;
float _TMP12;
float _TMP11;
float _TMP23;
float _TMP10;
float _TMP9;
float _TMP22;
float _TMP8;
float _TMP7;
float _TMP6;
float _TMP5;
float _TMP21;
float _TMP20;
float _TMP17;
float _TMP19;
float _TMP18;
vec3 _TMP4;
vec3 _TMP2;
vec3 _TMP3;
float _TMP16;
float _TMP15;
float _TMP14;
vec3 _TMP1;
vec3 _TMP24;
vec4 _TMP0;
uniform sampler2D Texture;
vec3 _TMP35;
vec3 _a0042;
vec3 _r0050;
vec3 _val0058;
vec3 _r0070;
float _t30078;
float _t10078;
float _t00078;
float _t40078;
float _a0094;
float _x0108;
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()
{
    vec3 _c0;
    float _A;
    float _l;
    float _t;
    float _J;
    float _M;
    float _Mp;
    _TMP0 = COMPAT_TEXTURE(Texture, TEX0.xy);
    _TMP24 = min(vec3( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00), _TMP0.xyz);
    _TMP35 = max(vec3( 0.00000000E+00, 0.00000000E+00, 0.00000000E+00), _TMP24);
    _a0042 = _TMP35 + 5.49999997E-02;
    _TMP14 = pow(_a0042.x, 2.40000010E+00);
    _TMP15 = pow(_a0042.y, 2.40000010E+00);
    _TMP16 = pow(_a0042.z, 2.40000010E+00);
    _TMP1 = vec3(_TMP14, _TMP15, _TMP16);
    _c0 = vec3(_TMP35.x <= 4.04499993E-02 ? (7.73993826E+00*_TMP35).x : (8.79415436E+01*_TMP1).x, _TMP35.y <= 4.04499993E-02 ? (7.73993826E+00*_TMP35).y : (8.79415436E+01*_TMP1).y, _TMP35.z <= 4.04499993E-02 ? (7.73993826E+00*_TMP35).z : (8.79415436E+01*_TMP1).z);
    _r0050.x = dot(vec3( 2.98584074E-01, 6.08947396E-01, 4.44424376E-02), _c0);
    _r0050.y = dot(vec3( 1.53912619E-01, 7.49942183E-01, 8.60572979E-02), _c0);
    _r0050.z = dot(vec3( 1.93000007E-02, 1.19199999E-01, 9.50500011E-01), _c0);
    _val0058 = vec3(float((_r0050.x > 0.00000000E+00)), float((_r0050.y > 0.00000000E+00)), float((_r0050.z > 0.00000000E+00)));
    _TMP2 = _val0058 - vec3(float((_r0050.x < 0.00000000E+00)), float((_r0050.y < 0.00000000E+00)), float((_r0050.z < 0.00000000E+00)));
    _TMP3 = abs(_r0050);
    _TMP14 = pow(_TMP3.x, 4.19999987E-01);
    _TMP15 = pow(_TMP3.y, 4.19999987E-01);
    _TMP16 = pow(_TMP3.z, 4.19999987E-01);
    _TMP4 = vec3(_TMP14, _TMP15, _TMP16);
    _c0 = 1.00000001E-01 + _TMP2*(4.00000000E+02 - 1.00000000E+00/(1.21279672E-05*_TMP4 + 2.49999994E-03));
    _r0070.x = dot(vec3( 1.00000000E+00, -1.09090912E+00, 9.09090936E-02), _c0);
    _r0070.y = dot(vec3( 1.11111112E-01, 1.11111112E-01, -2.22222224E-01), _c0);
    _r0070.z = dot(vec3( 2.00060797E+00, 1.00030398E+00, 5.00151999E-02), _c0);
    _A = _r0070.z - 3.05092722E-01;
    _t30078 = abs(_r0070.x);
    _t10078 = abs(_r0070.y);
    _t00078 = max(_t30078, _t10078);
    _t10078 = min(_t30078, _t10078);
    _t30078 = 1.00000000E+00/_t00078;
    _t30078 = _t10078*_t30078;
    _t40078 = _t30078*_t30078;
    _t00078 = -1.34804696E-02*_t40078 + 5.74773103E-02;
    _t00078 = _t00078*_t40078 - 1.21239103E-01;
    _t00078 = _t00078*_t40078 + 1.95635900E-01;
    _t00078 = _t00078*_t40078 - 3.32994610E-01;
    _t00078 = _t00078*_t40078 + 9.99995589E-01;
    _t30078 = _t00078*_t30078;
    _TMP18 = abs(_r0070.y);
    _TMP19 = abs(_r0070.x);
    if (_TMP18 > _TMP19) { 
        _TMP17 = 1.57079601E+00 - _t30078;
    } else {
        _TMP17 = _t30078;
    } 
    if (_r0070.x < 0.00000000E+00) { 
        _TMP20 = 3.14159298E+00 - _TMP17;
    } else {
        _TMP20 = _TMP17;
    } 
    if (_r0070.y < 0.00000000E+00) { 
        _TMP21 = -_TMP20;
    } else {
        _TMP21 = _TMP20;
    } 
    _l = length(_r0070.xy);
    _a0094 = _TMP21 + 2.00000000E+00;
    _TMP5 = cos(_a0094);
    _TMP6 = cos(_TMP21);
    _TMP7 = sin(_TMP21);
    _t = (1.60888062E+03*_l*(_TMP5 + 3.79999995E+00))/((2.09027362E+00*_A - _l*(_TMP6 + 9.81818199E+00*_TMP7)) + 6.37727261E-01);
    _TMP8 = pow(_A, 1.01178718E+00);
    _J = 2.45046711E+00*_TMP8;
    _TMP22 = inversesqrt(_J);
    _TMP9 = 1.00000000E+00/_TMP22;
    _TMP10 = pow(_t, 8.99999976E-01);
    _M = 8.46644789E-02*_TMP9*_TMP10;
    _x0108 = 5.29999984E-03*_M + 1.00000000E+00;
    _TMP23 = log2(_x0108);
    _TMP11 = _TMP23*6.93147182E-01;
    _Mp = 1.88679245E+02*_TMP11;
    _c0.x = (2.42857147E+02*_J)/(1.42857147E+02 + _J);
    _TMP12 = cos(_TMP21);
    _c0.y = _Mp*_TMP12;
    _TMP13 = sin(_TMP21);
    _c0.z = _Mp*_TMP13;
    _c0 = (_c0 + 6.99499969E+01)/1.70000000E+02;
    _ret_0 = vec4(_c0.x, _c0.y, _c0.z, 1.00000000E+00);
    FragColor = _ret_0;
    return;
} 
#endif
