// glslf output by Cg compiler
// cgc version 2.0.0012, build date Jan 30 2008
// command line args: -q -profile glslf -entry fragment_main -DGLOWSRCMRT -po ATI_draw_buffers
// source file: E:/projects/luxiniaprojects/tutorials/gpuprogs/simplelighting.cg
//vendor NVIDIA Corporation
//version 2.0.0.12
//profile glslf
//program fragment_main
//semantic fragment_main.lightambient
//semantic fragment_main.lightdiffuse
//semantic fragment_main.oLightpos
//semantic fragment_main.oCampos
//semantic fragment_main.specularctrl
//semantic fragment_main.diffusemap : TEXUNIT0
//semantic fragment_main.specmap : TEXUNIT1
//semantic fragment_main.illummap : TEXUNIT2
//var float4 lightambient :  : _ZZ3Slightambient : 1 : 1
//var float4 lightdiffuse :  : _ZZ3Slightdiffuse : 2 : 1
//var float4 oLightpos :  : _ZZ3SoLightpos : 3 : 1
//var float4 oCampos :  : _ZZ3SoCampos : 4 : 1
//var float4 specularctrl :  : _ZZ3Sspecularctrl : 5 : 1
//var sampler2D diffusemap : TEXUNIT0 : _ZZ3Sdiffusemap 0 : 6 : 1
//var sampler2D specmap : TEXUNIT1 : _ZZ3Sspecmap 1 : 7 : 1
//var sampler2D illummap : TEXUNIT2 : _ZZ3Sillummap 2 : 8 : 1
//var float2 IN.tex0 : $vin.TEXCOORD0 : TEXCOORD0 : 0 : 1
//var float3 IN.oNormal : $vin.TEXCOORD1 : TEXCOORD1 : 0 : 1
//var float4 IN.oPos : $vin.TEXCOORD2 : TEXCOORD2 : 0 : 1
//var float4 fragment_main.color0 : $vout.COLOR0 : COLOR0 : -1 : 1
//var float4 fragment_main.color1 : $vout.COLOR1 : COLOR1 : -1 : 1

#extension GL_ARB_draw_buffers : enable

struct AppVertex {
    vec3 oNormal;
    vec4 tex0;
};

struct VertexOut {
    vec2 tex0;
    vec3 oNormal;
    vec4 oPos;
};

struct FragOut {
    vec4 color0;
    vec4 color1;
};

FragOut _ZZ3Sret_0;
uniform vec4 _ZZ3Slightambient;
uniform vec4 _ZZ3Slightdiffuse;
uniform vec4 _ZZ3SoLightpos;
uniform vec4 _ZZ3SoCampos;
uniform vec4 _ZZ3Sspecularctrl;
uniform sampler2D _ZZ3Sdiffusemap;
uniform sampler2D _ZZ3Sspecmap;
uniform sampler2D _ZZ3Sillummap;
vec3 _ZZ3SZDtemp18;
float _ZZ3SxZh0023;
vec3 _ZZ3SZDtemp24;
vec3 _ZZ3SvZh0025;
float _ZZ3SxZh0029;
vec3 _ZZ3SZDtemp30;
vec3 _ZZ3SvZh0031;
float _ZZ3SxZh0035;
vec4 _ZZ3SspecularZh0036;
float _ZZ3SxZh0040;
float _ZZ3SZDtemp41;
float _ZZ3SbZh0046;
vec3 _ZZ3SZDtemp47;
vec3 _ZZ3SvZh0048;
float _ZZ3SxZh0052;
float _ZZ3SxZh0056;
float _ZZ3SZDtemp57;
float _ZZ3SbZh0062;

 // main procedure, the original name was fragment_main
void main()
{

    vec4 _ZZ4Stexcolor;
    vec4 _ZZ4Stexspec;
    vec4 _ZZ4Stexillum;
    vec4 _ZZ4Sspecular;
    FragOut _ZZ4SOUT;

    _ZZ4Stexcolor = texture2D(_ZZ3Sdiffusemap, gl_TexCoord[0].xy);
    _ZZ4Stexspec = texture2D(_ZZ3Sspecmap, gl_TexCoord[0].xy);
    _ZZ4Stexillum = texture2D(_ZZ3Sillummap, gl_TexCoord[0].xy);
    _ZZ3SxZh0023 = dot(gl_TexCoord[1].xyz, gl_TexCoord[1].xyz);
    _ZZ3SZDtemp18 = inversesqrt(_ZZ3SxZh0023)*gl_TexCoord[1].xyz;
    _ZZ3SvZh0025 = _ZZ3SoLightpos.xyz - gl_TexCoord[2].xyz;
    _ZZ3SxZh0029 = dot(_ZZ3SvZh0025, _ZZ3SvZh0025);
    _ZZ3SZDtemp24 = inversesqrt(_ZZ3SxZh0029)*_ZZ3SvZh0025;
    _ZZ3SvZh0031 = _ZZ3SoCampos.xyz - gl_TexCoord[2].xyz;
    _ZZ3SxZh0035 = dot(_ZZ3SvZh0031, _ZZ3SvZh0031);
    _ZZ3SZDtemp30 = inversesqrt(_ZZ3SxZh0035)*_ZZ3SvZh0031;
    _ZZ4Sspecular = vec4(_ZZ3Sspecularctrl.x, _ZZ3Sspecularctrl.y, _ZZ3Sspecularctrl.z, 1.00000000E+000);
    _ZZ3SxZh0040 = dot(_ZZ3SZDtemp18, _ZZ3SZDtemp24);
    _ZZ3SbZh0046 = min(1.00000000E+000, _ZZ3SxZh0040);
    _ZZ3SZDtemp41 = max(0.00000000E+000, _ZZ3SbZh0046);
    _ZZ3SvZh0048 = (_ZZ3SZDtemp30 + _ZZ3SZDtemp24)/2.00000000E+000;
    _ZZ3SxZh0052 = dot(_ZZ3SvZh0048, _ZZ3SvZh0048);
    _ZZ3SZDtemp47 = inversesqrt(_ZZ3SxZh0052)*_ZZ3SvZh0048;
    if (_ZZ3SZDtemp41 > 0.00000000E+000) { // if begin
        _ZZ3SxZh0056 = dot(_ZZ3SZDtemp18, _ZZ3SZDtemp47);
        _ZZ3SbZh0062 = min(1.00000000E+000, _ZZ3SxZh0056);
        _ZZ3SZDtemp57 = max(0.00000000E+000, _ZZ3SbZh0062);
        _ZZ3SspecularZh0036 = _ZZ4Sspecular*vec4(pow(_ZZ3SZDtemp57, _ZZ3Sspecularctrl.w), pow(_ZZ3SZDtemp57, _ZZ3Sspecularctrl.w), pow(_ZZ3SZDtemp57, _ZZ3Sspecularctrl.w), pow(_ZZ3SZDtemp57, _ZZ3Sspecularctrl.w));
    } else {
        _ZZ3SspecularZh0036 = vec4( 0.00000000E+000, 0.00000000E+000, 0.00000000E+000, 0.00000000E+000);
    } // end if
    _ZZ4SOUT.color0 = _ZZ4Stexcolor*(_ZZ3SZDtemp41*_ZZ3Slightdiffuse + _ZZ3Slightambient) + _ZZ4Stexspec*_ZZ3SspecularZh0036 + _ZZ4Stexillum;
    _ZZ4SOUT.color1 = _ZZ4Stexspec*_ZZ3SspecularZh0036 + _ZZ4Stexillum;
    _ZZ4SOUT.color1.w = _ZZ4Stexcolor.w;
    _ZZ4SOUT.color0.w = _ZZ4Stexcolor.w;
    _ZZ3Sret_0.color0 = _ZZ4SOUT.color0;
    _ZZ3Sret_0.color1 = _ZZ4SOUT.color1;
    gl_FragData[0] = _ZZ4SOUT.color0;
    gl_FragData[1] = _ZZ4SOUT.color1;
    return;
} // main end
