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,
                      float3 oEye : TEXCOORD5,
                      float3 oNormal : TEXCOORD3,



                    uniform float3 alpha,  
                    uniform float alpha2,  
                    uniform float3 res,  
                    uniform float resy,  
                   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;

float height=tex2D(texture2,oUV*float2 (0.8,1.4))*tex2D (texture2,oUV*float2 (0.9,1.8)+float2 (alpha2*0.04,alpha2*0.44));
height-=0.5;
height*=0.23;



float3 tanEyeVec = oEye;
oUV+=height*tanEyeVec.xy;

float3 Tnormal=tex2D (texture,oUV*float2 (1.2,2.5)+float2 (alpha2*0.13,alpha2*0.4))+tex2D (texture,oUV*float2 (1.1,1.5)+float2 (-alpha2*0.13,alpha2*0.34));
Tnormal*=0.5;

/*
float mv=tex2D (texture,oUV*1);
oPosition.xy+=height*tanEyeVec.xy*100;
OUT.color=Tnormal.xyzz;
*/

/*
normal=Tnormal.xyz;
normal=(normal-0.5)*2;
mx=1.01*max (0,dot(normal,oHalf));
mx=pow(mx,140);

*/
//heig=pow(Tnormal.y*1+0.5,3);
//float4 afros=(Tnormal.xyzz-0.6)*8*tex2D(texture2,oUV*10);
//OUT.color=
//OUT.color=oHalf.xyzz;

//height+=1;
OUT.color=(tex2Dproj (decal,oPosition*res.xyzz)+float4(0,0,0.2,0));
OUT.color=tex2D(decal,oUV*res.xyzz);
OUT.color=tex2D(texture,oUV);


float3 DistP=oHalf-oPosition;
DistP=normalize (DistP);

float3 normal=Tnormal;
normal-=float3 (0.5,0.5,0.5);

//float3 ref=reflect (normal,oEye);
//ref.xyz+=float3 (0.5,0.5,0.5);

//ref.z*=-1;
OUT.color=oEye.xyzz;
//OUT.color=tex2D(decal,ref.yx*res.yx)+0.1;
oUV.y=1-oUV.y;


oPosition.xy*=res.xy;
oPosition.xy+=normal.xy*9;
OUT.color=tex2Dproj(decal,oPosition)*0.45+0.45*tex2Dproj(light,oPosition)+normal.y;
//OUT.color*=HCOL2;



//OUT.color=mx;

// (texture,oUV)*1;
//OUT.color*=HCOL2;
//oj (light,oPosition)*heig*HCOL2;
//OUT.color=HCOL2*0.5;
//OUT.color=float4 (0.0,0.0,0.0,0)+(HCOL*(OUT.color-float4 (0.0,0.0,0.0,0)));
//OUT.color*=mx;
//OUT.color=texCUBE (cube,oHalf.xyz);
//OUT.color=texCUBE (cube,oHalf.xyz);
//(tex2D (decal,oUV*11))*(cll4+0.5)*(basetexture)*HCOL2;

//OUT.color=(tex2D (decal,oUV*11))*(cll4+0.5)*HCOL2;

//OUT.color=(tex2D (decal,oUV*10))*(cll4+0.5+coll)*(basetexture)*HCOL2;

//OUT.color=*basetexture;
//basetexture*float4 (0.4,0.2,0.2,0.1);



//OUT.color=cll4;


	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;




}
*/