// 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     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;
};
vec4 _oPosition1;
vec4 _r0006;
COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_VARYING vec4 COL0;
COMPAT_ATTRIBUTE vec4 TexCoord;
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()
{
    vec4 _oColor;
    vec2 _oTexCoord;
    _r0006 = VertexCoord.x*MVPMatrix[0];
    _r0006 = _r0006 + VertexCoord.y*MVPMatrix[1];
    _r0006 = _r0006 + VertexCoord.z*MVPMatrix[2];
    _r0006 = _r0006 + VertexCoord.w*MVPMatrix[3];
    _oPosition1 = _r0006;
    _oColor = COLOR;
    _oTexCoord = TexCoord.xy;
    gl_Position = _r0006;
    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     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;
};
vec3 _TMP8;
float _TMP12;
float _TMP11;
float _TMP10;
float _TMP9;
vec4 _TMP7;
vec4 _TMP6;
vec4 _TMP5;
vec4 _TMP4;
vec4 _TMP3;
vec4 _TMP2;
vec4 _TMP1;
vec4 _TMP0;
uniform sampler2D Texture;
input_dummy _IN1;
vec3 _TMP16;
float _minfull0017;
float _maxfull0017;
float _realfull0017;
bool _TMP18;
vec3 _TMP21;
float _minfull0022;
float _maxfull0022;
float _realfull0022;
bool _TMP23;
vec2 _c0027;
vec2 _c0041;
vec2 _c0055;
vec2 _c0069;
float _f0091;
vec4 _n0093;
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()
{
    vec4 _a;
    vec4 _b;
    vec4 _c;
    vec4 _d;
    vec4 _gammaLQVresult;
    vec4 _LQVresult;
    vec4 _c1;
    _TMP18 = true;
    _minfull0017 = ((TEX0.x*OutputSize.x - 5.00000000E-01)/OutputSize.x)*TextureSize.x;
    _maxfull0017 = ((TEX0.x*OutputSize.x + 5.00000000E-01)/OutputSize.x)*TextureSize.x;
    _realfull0017 = floor(_maxfull0017);
    if (_minfull0017 > _realfull0017) { 
        _TMP16 = vec3(1.00000000E+00, (_realfull0017 + 5.00000000E-01)/TextureSize.x, (_realfull0017 + 5.00000000E-01)/TextureSize.x);
        _TMP18 = false;
    } 
    if (_TMP18) { 
        _TMP16 = vec3((_maxfull0017 - _realfull0017)/(_maxfull0017 - _minfull0017), (_realfull0017 - 5.00000000E-01)/TextureSize.x, (_realfull0017 + 5.00000000E-01)/TextureSize.x);
    } 
    _TMP23 = true;
    _minfull0022 = ((TEX0.y*OutputSize.y - 5.00000000E-01)/OutputSize.y)*TextureSize.y;
    _maxfull0022 = ((TEX0.y*OutputSize.y + 5.00000000E-01)/OutputSize.y)*TextureSize.y;
    _realfull0022 = floor(_maxfull0022);
    if (_minfull0022 > _realfull0022) { 
        _TMP21 = vec3(1.00000000E+00, (_realfull0022 + 5.00000000E-01)/TextureSize.y, (_realfull0022 + 5.00000000E-01)/TextureSize.y);
        _TMP23 = false;
    } 
    if (_TMP23) { 
        _TMP21 = vec3((_maxfull0022 - _realfull0022)/(_maxfull0022 - _minfull0022), (_realfull0022 - 5.00000000E-01)/TextureSize.y, (_realfull0022 + 5.00000000E-01)/TextureSize.y);
    } 
    _c0027 = vec2(_TMP16.y, _TMP21.y);
    _TMP0 = COMPAT_TEXTURE(Texture, _c0027);
    _TMP9 = pow(_TMP0.x, 2.09999990E+00);
    _TMP10 = pow(_TMP0.y, 2.09999990E+00);
    _TMP11 = pow(_TMP0.z, 2.09999990E+00);
    _TMP12 = pow(_TMP0.w, 2.09999990E+00);
    _TMP1 = vec4(_TMP9, _TMP10, _TMP11, _TMP12);
    _a = vec4(_TMP1.x, _TMP1.y, _TMP1.z, (_TMP1.x + _TMP1.y + _TMP1.z)/3.00000000E+00);
    _c0041 = vec2(_TMP16.z, _TMP21.y);
    _TMP2 = COMPAT_TEXTURE(Texture, _c0041);
    _TMP9 = pow(_TMP2.x, 2.09999990E+00);
    _TMP10 = pow(_TMP2.y, 2.09999990E+00);
    _TMP11 = pow(_TMP2.z, 2.09999990E+00);
    _TMP12 = pow(_TMP2.w, 2.09999990E+00);
    _TMP3 = vec4(_TMP9, _TMP10, _TMP11, _TMP12);
    _b = vec4(_TMP3.x, _TMP3.y, _TMP3.z, (_TMP3.x + _TMP3.y + _TMP3.z)/3.00000000E+00);
    _c0055 = vec2(_TMP16.y, _TMP21.z);
    _TMP4 = COMPAT_TEXTURE(Texture, _c0055);
    _TMP9 = pow(_TMP4.x, 2.09999990E+00);
    _TMP10 = pow(_TMP4.y, 2.09999990E+00);
    _TMP11 = pow(_TMP4.z, 2.09999990E+00);
    _TMP12 = pow(_TMP4.w, 2.09999990E+00);
    _TMP5 = vec4(_TMP9, _TMP10, _TMP11, _TMP12);
    _c = vec4(_TMP5.x, _TMP5.y, _TMP5.z, (_TMP5.x + _TMP5.y + _TMP5.z)/3.00000000E+00);
    _c0069 = vec2(_TMP16.z, _TMP21.z);
    _TMP6 = COMPAT_TEXTURE(Texture, _c0069);
    _TMP9 = pow(_TMP6.x, 2.09999990E+00);
    _TMP10 = pow(_TMP6.y, 2.09999990E+00);
    _TMP11 = pow(_TMP6.z, 2.09999990E+00);
    _TMP12 = pow(_TMP6.w, 2.09999990E+00);
    _TMP7 = vec4(_TMP9, _TMP10, _TMP11, _TMP12);
    _d = vec4(_TMP7.x, _TMP7.y, _TMP7.z, (_TMP7.x + _TMP7.y + _TMP7.z)/3.00000000E+00);
    _a.w = pow(_a.w, 3.33333343E-01);
    _b.w = pow(_b.w, 3.33333343E-01);
    _c.w = pow(_c.w, 3.33333343E-01);
    _d.w = pow(_d.w, 3.33333343E-01);
    _gammaLQVresult = ((1.00000000E+00 - _TMP16.x)*(1.00000000E+00 - _TMP21.x))*_a + (_TMP16.x*(1.00000000E+00 - _TMP21.x))*_b + ((1.00000000E+00 - _TMP16.x)*_TMP21.x)*_c + (_TMP16.x*_TMP21.x)*_d;
    _LQVresult.w = _gammaLQVresult.w*_gammaLQVresult.w*_gammaLQVresult.w;
    _f0091 = (_LQVresult.w/(_gammaLQVresult.x + _gammaLQVresult.y + _gammaLQVresult.z))*3.00000000E+00;
    _TMP8 = _gammaLQVresult.xyz*_f0091;
    _n0093 = vec4(_TMP8.x, _TMP8.y, _TMP8.z, 1.00000000E+00);
    _TMP9 = pow(_n0093.x, 4.76190507E-01);
    _TMP10 = pow(_n0093.y, 4.76190507E-01);
    _TMP11 = pow(_n0093.z, 4.76190507E-01);
    _TMP12 = pow(_n0093.w, 4.76190507E-01);
    _c1 = vec4(_TMP9, _TMP10, _TMP11, _TMP12);
    FragColor = _c1;
    return;
} 
#endif
