struct C2E2f_Output { 
	float4 color: COLOR;
};


C2E2f_Output main (    float4 oPosition : TEXCOORD1,
                      float2 oUV : TEXCOORD0,
                      float4 HCOL : COLOR, 
                      
	float4 HCOL2 : COLOR1,
                      
                      float3 oLight : TEXCOORD2,
                      float3 oHalf : TEXCOORD4,
                      float2 uvl : TEXCOORD5,
                      float3 oNormal : TEXCOORD3,



                    uniform float3 alpha,  
                    uniform float alpha2,  
                   uniform sampler2D decal,
				   uniform sampler2D light,
                //   uniform samplerCUBE cube,
				   uniform sampler2D texture,
                   uniform sampler1D oned,
				   uniform sampler2D texture2
//                   uniform samplerCUBE cube
//                   uniform sampler2D cubes
//uniform float3 lightPosition

                   ) 
{



	C2E2f_Output OUT;


    float4 basetexture=tex2D (decal,oUV);
   
//lighttexture=tex2D (lightmap,oUV);
//float3 normals=tex2D (texture,oUV);


float3 normal=((tex2D (texture,oUV)-0.5)*2);

//float maxx=dot(normal,oLight)+pow (dot(normal,oHalf),20);
float maxx=dot(oNormal,oLight);
//maxx*=maxx;
//if (dot(normal,oHalf)>0) maxx=1; else maxx=0;
float mx=max (0,dot(normal,oHalf));
mx=pow(mx,40);
mx*=0.3;

//oPosition.w+=0.003*maxx;
//oPosition+=float4 (maxx,0,0,0);


float4 cll1=tex2D (decal,oPosition.xy);

float4 clr=tex2D (light,oUV);


//oPosition.xyz*=1;
float4 cll4=tex2Dproj (light,oPosition);
//float4 cll4=texCUBE (cube,oHalf);
/*
OUT.color=(HCOL2*basetexture*maxx+mx*cll4);
OUT.color=(maxx*HCOL2*basetexture+HCOL*mx)*(0.5+0.5*cll1);
*/
basetexture=tex2D (texture2,oUV*1
                   );

OUT.color=maxx*((basetexture*HCOL2+HCOL2+0.3*mx))*(0.6+0.4*cll1);

OUT.color=(float4 (alpha2,1.99,2.0,2)-300*HCOL2*basetexture);

OUT.color=HCOL2+HCOL;
//+float4 (0,0,0,tex2D(light,oUV).x);
//*float4 (0,0,0,tex2D(light,oUV).x);

//+float4 (0,0,0,tex2D(light,oUV).x);
//OUT.color=tex2D(light,oUV)*0.1;
//OUT.color=HCOL2;
//OUT.color=float4 (1,0,0,1);
//*float4 (1,1,1,0)+float4 (0,0,0,tex2D(texture2,oUV).x);

//OUT.color=basetexture*0.3;
//)*float4 (1,1,1,0)+float4 (0,0,0,tex2D(texture2,oUV).x);
//OUT.color=HCOL2*(basetexture)*2*float4 (alpha2,3.4,7.8,1);
//OUT.color=(float4 (1.5,0.9,1.7,1)-130*HCOL2*basetexture);
//OUT.color=maxx*((basetexture*HCOL2+HCOL2+0.3*mx));
//OUT.color=HCOL2*maxx;
//OUT.color=float4 (1,1,1,1)*maxx;
//OUT.color=1*((basetexture*HCOL2+HCOL2+0.3*mx));
//OUT.color=basetexture;
//OUT.color=1*((basetexture*HCOL2+HCOL2+0.3*mx))*(cll1*4);
//
//OUT.color=1*((basetexture*HCOL2+HCOL2+0.4*mx));
//OUT.color=1*((basetexture*HCOL2+HCOL2+0.3*mx));
//OUT.color=HCOL2*basetexture+HCOL2*mx;
//OUT.color=HCOL2;
//OUT.color=1*(basetexture*HCOL2+HCOL2);
//OUT.color=0;
//OUT.color.w=0.5;

	return OUT;




}









































/* 


  FRAGMENT ENV MAP 



  struct C2E2f_Output { 
	float4 color: COLOR;
};


C2E2f_Output main (    float2 oPosition : TEXCOORD0,
    float2 oPosition2 : TEXCOORD1,
	uniform sampler2D decal,			   
	uniform sampler2D decal2					   
				   ) 
{



	C2E2f_Output OUT;

//float fc=1;
//fc=position.x;
	//float2 norm;
	//norm.x=oNormal.x;
	//norm.y=oNormal.y;

OUT.color=tex2D (decal2,oPosition);

float dx=ddx(OUT.color.x);
float dy=ddx(OUT.color.x);

oPosition2.x+=dx*1;
oPosition2.y+=dy*1;


  OUT.color=tex2D (decal,oPosition2);




  
  
  //OUT.color.y=0;
//OUT.color.z=0;
//  OUT.color-=tex2D (decal,oPosition2);


	return OUT;




}
*/