!!ARBfp1.0
OPTION ARB_precision_hint_fastest;

ATTRIB tex = fragment.texcoord[0];      #first set of texture coordinates
ATTRIB tex1 = fragment.texcoord[1];      #first set of texture coordinates
ATTRIB tex2 = fragment.texcoord[2];      #first set of texture coordinates
ATTRIB tex3 = fragment.texcoord[3];      #first set of texture coordinates
ATTRIB col0 = fragment.color.primary;	#diffuse interpolated color
ATTRIB col1 = fragment.color.secondary;	#specular interpolated color
PARAM miscValues  = { 0, 0.5, 1, 2 };
PARAM miscValuesx = { 0.5, 0.05, 5, 4};
OUTPUT outColour = result.color;

TEMP diffuse, glow, base, teamBaseColour, teamStripeColour,bump,tempbump;
TEMP teamBaseAmount, teamStripeAmount, light, spec;
TEMP unFoggedColour, fogColour, temp1, temp2, temp3, glowtemp,temp4,spectemp;

TEX diffuse, tex, texture[0], 2D;       #sample the texture
TEX glow, tex, texture[1], 2D;        	#sample the texture
TEX bump, tex2, texture[1], 2D;





#MUL glowtemp.r, bump.r, miscValuesx.z;
#MUL glowtemp.g, bump.g, miscValuesx.z;
#MUL glowtemp.b, bump.b, miscValuesx.z;


#incease bump contrast
#MUL bump, bump, miscValuesx.z;

#MUL temp1, col1, glowtemp.b;
#MUL temp2, col1, glowtemp.g;
#MUL temp3, col1, glowtemp.r;



#specular base calculation
#MUL spec, col1, glow.b;




#DP3 spec, spec, temp1;
#DP3 spec, spec, temp2;
#DP3 spec, spec, temp3;

#use the next line to preview the normal channel


#accumulate bump values
#ADD tempbump, bump.r, bump.g;
#ADD tempbump, bump.b, tempbump; 
#bump diffuse



#MUL diffuse, diffuse, bump;
#MUL diffuse, diffuse, miscValuesx.z;

#ADD base, base, bump.r;
#ADD base, base, bump.g;
#ADD base, base, bump.b;

#MUL base, base, miscValuesx.y;

#ADD spec, spec, temp1;
#ADD spec, spec, temp2;
#ADD spec, spec, temp3;







##adjust colour underlying base
# make darker
ADD base, diffuse, miscValues.y;
MUL teamBaseColour, base, program.local[0];
MUL teamStripeColour, base, program.local[1];
# make lighter
SUB base, diffuse, miscValues.y;
ADD teamBaseColour, base, teamBaseColour;
ADD teamStripeColour, base, teamStripeColour;

## compute amount of team colour needed
SUB teamBaseAmount, miscValues.z, diffuse.a;
SUB teamStripeAmount, miscValues.z, glow.a;

##avaerge the team colour and base texture
LRP base.rgb, teamBaseAmount, teamBaseColour, diffuse;
LRP base.rgb, teamStripeAmount, teamStripeColour, base;

## lighting
# compute specular

# compute amount of glow
MUL light, miscValues.y, glow.g;
# average glow/level lighting
LRP light, glow.g, light, col0;

# add specular
ADD light, light, spec;

## final colour
MUL unFoggedColour.rgb, base, light;

## fog
MOV fogColour, program.local[2];
MUL fogColour.a, fogColour, col0;
LRP outColour.rgb, fogColour.a, fogColour, unFoggedColour;

##fade away as needed
MOV outColour.a, col0;

END 
