// 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 VARt1;
COMPAT_VARYING     vec2 _texCoord1;
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 _texCoord1;
    vec4 VARt1;
    vec2 VARloc;
};
out_vertex _ret_0;
input_dummy _IN1;
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()
{
    out_vertex _OUT;
    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];
    _ps = vec2(float((1.00000000E+00/TextureSize.x)), float((1.00000000E+00/TextureSize.y)));
    _OUT.VARt1.xy = vec2(_ps.x, 0.00000000E+00);
    _OUT.VARt1.zw = vec2(0.00000000E+00, _ps.y);
    _OUT.VARloc = vec2(float((TexCoord.xy*TextureSize).x), float((TexCoord.xy*TextureSize).y));
    _ret_0._position1 = _r0008;
    _ret_0._color1 = COLOR;
    _ret_0._texCoord1 = TexCoord.xy;
    VARt1 = _OUT.VARt1;
    VARloc = _OUT.VARloc;
    gl_Position = vec4(float(_r0008.x), float(_r0008.y), float(_r0008.z), float(_r0008.w));
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy;
    return;
    COL0 = _ret_0._color1;
    TEX0.xy = _ret_0._texCoord1;
} 
#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 VARt1;
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 VARt1;
    vec2 VARloc;
};
vec4 _ret_0;
vec3 _TMP11;
vec3 _TMP19;
float _TMP18;
float _TMP17;
float _TMP16;
vec4 _TMP10;
vec4 _TMP9;
float _TMP8;
float _TMP7;
float _TMP6;
float _TMP5;
float _TMP15;
float _TMP21;
float _TMP14;
float _TMP20;
vec4 _TMP4;
vec4 _TMP3;
vec4 _TMP2;
vec4 _TMP1;
vec2 _TMP0;
vec2 _TMP13;
out_vertex _VAR1;
uniform sampler2D Texture;
vec2 _val0029;
vec2 _c0033;
vec2 _c0035;
vec2 _c0037;
float _TMP58;
vec2 _v0059;
float _TMP66;
vec2 _v0067;
float _a0075;
float _a0077;
float _a0079;
float _a0081;
vec2 _c0093;
vec2 _c0095;
vec3 _TMP112;
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 _pos;
    vec2 _dir;
    vec2 _g1;
    vec2 _g2;
    vec3 _A1;
    vec3 _B1;
    vec3 _C1;
    vec3 _D1;
    float _a;
    float _b;
    float _c;
    float _d;
    float _p1;
    float _q1;
    vec3 _res;
    vec3 _color1;
    float _ddy;
    float _v_weight_00;
    vec3 _coords10;
    vec3 _colorNB;
    float _v_weight_10;
    _TMP13 = fract(vec2(float(VARloc.x), float(VARloc.y)));
    _TMP0 = vec2(float(_TMP13.x), float(_TMP13.y));
    _pos = vec2(float(_TMP0.x), float(_TMP0.y)) - vec2( 5.00000000E-01, 5.00000000E-01);
    _val0029 = vec2(float((_pos.x > 0.00000000E+00)), float((_pos.y > 0.00000000E+00)));
    _dir = _val0029 - vec2(float((_pos.x < 0.00000000E+00)), float((_pos.y < 0.00000000E+00)));
    _g1 = _dir*vec2(float(VARt1.x), float(VARt1.y));
    _g2 = _dir*vec2(float(VARt1.z), float(VARt1.w));
    _TMP1 = COMPAT_TEXTURE(Texture, TEX0.xy);
    _A1 = vec3(float(_TMP1.x), float(_TMP1.y), float(_TMP1.z));
    _c0033 = TEX0.xy + _g1;
    _TMP2 = COMPAT_TEXTURE(Texture, _c0033);
    _B1 = vec3(float(_TMP2.x), float(_TMP2.y), float(_TMP2.z));
    _c0035 = TEX0.xy + _g2;
    _TMP3 = COMPAT_TEXTURE(Texture, _c0035);
    _C1 = vec3(float(_TMP3.x), float(_TMP3.y), float(_TMP3.z));
    _c0037 = TEX0.xy + _g1 + _g2;
    _TMP4 = COMPAT_TEXTURE(Texture, _c0037);
    _D1 = vec3(float(_TMP4.x), float(_TMP4.y), float(_TMP4.z));
    _TMP20 = dot(vec3(float(_A1.x), float(_A1.y), float(_A1.z)), vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP14 = float(_TMP20);
    _a = float(_TMP14);
    _TMP20 = dot(vec3(float(_B1.x), float(_B1.y), float(_B1.z)), vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP14 = float(_TMP20);
    _b = float(_TMP14);
    _TMP20 = dot(vec3(float(_C1.x), float(_C1.y), float(_C1.z)), vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP14 = float(_TMP20);
    _c = float(_TMP14);
    _TMP20 = dot(vec3(float(_D1.x), float(_D1.y), float(_D1.z)), vec3( 6.55360000E+04, 2.55000000E+02, 1.00000000E+00));
    _TMP14 = float(_TMP20);
    _d = float(_TMP14);
    _p1 = abs(_pos.x);
    _q1 = abs(_pos.y);
    _v0059 = _g1 - _pos;
    _TMP15 = dot(_v0059, _v0059);
    _TMP21 = inversesqrt(_TMP15);
    _TMP58 = 1.00000000E+00/_TMP21;
    _v0067 = _g2 - _pos;
    _TMP15 = dot(_v0067, _v0067);
    _TMP21 = inversesqrt(_TMP15);
    _TMP66 = 1.00000000E+00/_TMP21;
    _a0075 = _a - _d;
    _TMP5 = abs(_a0075);
    _a0077 = _b - _c;
    _TMP6 = abs(_a0077);
    if (_TMP5 < _TMP6) { 
        if (_TMP58 < _TMP66) { 
            _C1 = (_A1 + _D1) - _B1;
        } else {
            if (_TMP58 > _TMP66) { 
                _B1 = (_A1 + _D1) - _C1;
            } 
        } 
    } else {
        _a0079 = _a - _d;
        _TMP7 = abs(_a0079);
        _a0081 = _b - _c;
        _TMP8 = abs(_a0081);
        if (_TMP7 > _TMP8) { 
            _D1 = (_B1 + _C1) - _A1;
        } 
    } 
    _res = ((1.00000000E+00 - _p1)*(1.00000000E+00 - _q1))*vec3(float(_A1.x), float(_A1.y), float(_A1.z)) + (_p1*(1.00000000E+00 - _q1))*vec3(float(_B1.x), float(_B1.y), float(_B1.z)) + ((1.00000000E+00 - _p1)*_q1)*vec3(float(_C1.x), float(_C1.y), float(_C1.z)) + (_p1*_q1)*vec3(float(_D1.x), float(_D1.y), float(_D1.z));
    _TMP16 = pow(_res.x, 2.40000010E+00);
    _TMP17 = pow(_res.y, 2.40000010E+00);
    _TMP18 = pow(_res.z, 2.40000010E+00);
    _color1 = vec3(_TMP16, _TMP17, _TMP18);
    _v_weight_00 = _pos.y/6.49999976E-01;
    if (_v_weight_00 > 1.00000000E+00) { 
        _v_weight_00 = 1.00000000E+00;
    } 
    _v_weight_00 = 1.00000000E+00 - _v_weight_00*_v_weight_00;
    _v_weight_00 = _v_weight_00*_v_weight_00;
    _color1 = _color1*vec3(_v_weight_00, _v_weight_00, _v_weight_00);
    if (_pos.y > 0.00000000E+00) { 
        _c0093 = TEX0.xy + vec2(float(VARt1.z), float(VARt1.w));
        _TMP9 = COMPAT_TEXTURE(Texture, _c0093);
        _coords10 = _TMP9.xyz;
        _ddy = 1.00000000E+00 - _pos.y;
    } else {
        _c0095 = TEX0.xy - vec2(float(VARt1.z), float(VARt1.w));
        _TMP10 = COMPAT_TEXTURE(Texture, _c0095);
        _coords10 = _TMP10.xyz;
        _ddy = 1.00000000E+00 + _pos.y;
    } 
    _TMP16 = pow(_coords10.x, 2.40000010E+00);
    _TMP17 = pow(_coords10.y, 2.40000010E+00);
    _TMP18 = pow(_coords10.z, 2.40000010E+00);
    _colorNB = vec3(_TMP16, _TMP17, _TMP18);
    _v_weight_10 = _ddy/6.49999976E-01;
    if (_v_weight_10 > 1.00000000E+00) { 
        _v_weight_10 = 1.00000000E+00;
    } 
    _v_weight_10 = 1.00000000E+00 - _v_weight_10*_v_weight_10;
    _v_weight_10 = _v_weight_10*_v_weight_10;
    _color1 = _color1 + _colorNB*vec3(_v_weight_10, _v_weight_10, _v_weight_10);
    _color1 = _color1*vec3( 1.55999994E+00, 1.55999994E+00, 1.55999994E+00);
    _TMP16 = pow(_color1.x, 4.54545438E-01);
    _TMP17 = pow(_color1.y, 4.54545438E-01);
    _TMP18 = pow(_color1.z, 4.54545438E-01);
    _TMP11 = vec3(_TMP16, _TMP17, _TMP18);
    _TMP19 = min(vec3( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00), _TMP11);
    _TMP112 = max(vec3( 0.00000000E+00, 0.00000000E+00, 0.00000000E+00), _TMP19);
    _ret_0 = vec4(_TMP112.x, _TMP112.y, _TMP112.z, 1.00000000E+00);
    FragColor = _ret_0;
    return;
} 
#endif
