// 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 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;
    vec2 VARt1;
};
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;
 
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;
    _r0006 = VertexCoord.x*MVPMatrix[0];
    _r0006 = _r0006 + VertexCoord.y*MVPMatrix[1];
    _r0006 = _r0006 + VertexCoord.z*MVPMatrix[2];
    _r0006 = _r0006 + VertexCoord.w*MVPMatrix[3];
    _OUT.VARt1 = 1.00000000E+00/TextureSize;
    _ret_0._position1 = _r0006;
    _ret_0._color1 = COLOR;
    _ret_0._texCoord1 = TexCoord.xy;
    VARt1 = _OUT.VARt1;
    gl_Position = _r0006;
    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 VARt1;
COMPAT_VARYING     vec2 _texCoord;
COMPAT_VARYING     vec4 _color;
struct input_dummy {
    vec2 _video_size;
    vec2 _texture_size;
    vec2 _output_dummy_size;
};
struct out_vertex {
    vec4 _color;
    vec2 _texCoord;
    vec2 VARt1;
};
vec3 _TMP15;
float _TMP11;
float _TMP12;
float _TMP14;
float _TMP16;
vec3 _TMP8;
vec3 _TMP9;
vec3 _TMP10;
float _TMP7;
float _TMP5;
float _TMP6;
vec4 _TMP4;
vec4 _TMP3;
vec4 _TMP2;
vec4 _TMP1;
vec4 _TMP0;
out_vertex _VAR1;
uniform sampler2D Texture;
vec2 _c0022;
vec2 _c0024;
vec2 _c0028;
vec2 _c0030;
vec4 _r0032;
float _a0052;
float _TMP53;
float _TMP61;
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()
{
    float _e;
    float _di;
    _c0022 = TEX0.xy + vec2( 0.00000000E+00, -1.00000000E+00)*VARt1;
    _TMP0 = COMPAT_TEXTURE(Texture, _c0022);
    _c0024 = TEX0.xy + vec2( -1.00000000E+00, 0.00000000E+00)*VARt1;
    _TMP1 = COMPAT_TEXTURE(Texture, _c0024);
    _TMP2 = COMPAT_TEXTURE(Texture, TEX0.xy);
    _c0028 = TEX0.xy + vec2( 1.00000000E+00, 0.00000000E+00)*VARt1;
    _TMP3 = COMPAT_TEXTURE(Texture, _c0028);
    _c0030 = TEX0.xy + vec2( 0.00000000E+00, 1.00000000E+00)*VARt1;
    _TMP4 = COMPAT_TEXTURE(Texture, _c0030);
    _r0032.x = dot(_TMP0.xyz, vec3( 2.98999995E-01, 5.87000012E-01, 1.14000000E-01));
    _r0032.y = dot(_TMP1.xyz, vec3( 2.98999995E-01, 5.87000012E-01, 1.14000000E-01));
    _r0032.z = dot(_TMP4.xyz, vec3( 2.98999995E-01, 5.87000012E-01, 1.14000000E-01));
    _r0032.w = dot(_TMP3.xyz, vec3( 2.98999995E-01, 5.87000012E-01, 1.14000000E-01));
    _e = dot(_TMP2.xyz, vec3( 2.98999995E-01, 5.87000012E-01, 1.14000000E-01));
    _TMP5 = max(_r0032.x, _r0032.y);
    _TMP6 = max(_r0032.w, _e);
    _TMP7 = max(_r0032.z, _TMP6);
    _di = max(_TMP5, _TMP7);
    if (_di == _r0032.x) { 
        _TMP8 = _TMP0.xyz;
    } else {
        if (_di == _r0032.y) { 
            _TMP9 = _TMP1.xyz;
        } else {
            if (_di == _r0032.z) { 
                _TMP10 = _TMP4.xyz;
            } else {
                _TMP10 = _TMP3.xyz;
            } 
            _TMP9 = _TMP10;
        } 
        _TMP8 = _TMP9;
    } 
    _a0052 = _e - _di;
    _di = abs(_a0052);
    if (_di <= 0.00000000E+00) { 
        _TMP11 = 0.00000000E+00;
    } else {
        if (_di >= 1.00000000E+00) { 
            _TMP12 = 1.00000000E+00;
        } else {
            _TMP53 = 1.00000000E+00/inversesqrt(_di);
            _TMP16 = min(1.00000000E+00, _TMP53);
            _TMP61 = max(0.00000000E+00, _TMP16);
            _TMP14 = _TMP61*_TMP61*(3.00000000E+00 - 2.00000000E+00*_TMP61);
            _TMP12 = _TMP14;
        } 
        _TMP11 = _TMP12;
    } 
    if (_di == 0.00000000E+00) { 
        _TMP15 = _TMP2.xyz;
    } else {
        _TMP15 = _TMP2.xyz + _TMP11*(_TMP8 - _TMP2.xyz);
    } 
    FragColor.xyz = _TMP15;
    return;
} 
#endif
