struct C2E2f_Output { 
	float3 color: COLOR;
};



C2E2f_Output main (    float2 oPosition : TEXCOORD0,
	uniform sampler2D decal,			   
	uniform sampler2D decal2,			   
//uniform sampler2D decal3,
//float4 cl : COLOR
//float4 HCOL2 : COLOR0
 uniform float ttime,
 uniform float alpha
 ) 
{


	C2E2f_Output OUT;


	float4 cl;

float PI=3.1415926535;
float2 UV=oPosition;

UV-=float2 (0.5,0.5);
UV*=2.0;


float3 DirV =float3 (UV.x,UV.y,0.6);
//normalize (DirV);
float lgn=length (DirV);
DirV/=lgn;
//DirV/=length (DirV);
//UV.x=UV.x+(sin ((UV.x)*PI/2.0)-UV.x)*0.5;
//UV.y=UV.y+(sin ((UV.y)*PI/2.0)-UV.y)*0.5;
//UV.y=sin ((UV.y)*PI/2.0);
//UV.y=sin (UV.y*3.1415926535/2.0);
//UV.x=pow (UV.x,2);
//UV.y=pow (UV.y,2);


float2 VV1=float2 (0.0030,0.0)*UV;
float2 VV2=float2 (0.00,0.0055)*UV;


UV.xy=UV.xy+(DirV.xy-UV.xy)*alpha;
//alpha;



//float r = atan2(sqrt(UV.x*UV.x+y*y),p.z) / pi
//float phi = atan2(y,x) 







UV*=0.5;
UV+=float2 (0.5,0.5);
//UV.xy+=(tex2D (decal2,UV*0.7).xz-float2 (0.5,0.5))*0.03;

//float flx=sin(tex2D (decal2,-UV*0.9).x)*0.0;
//float fly=sin(UV.y*10)*0.03;
 //flx=sin(UV.x*17)*0.03;
//UV.x+=flx;
//UV.y+=fly;

/*
OUT.color=2*tex2D(decal,UV)+
tex2D(decal,UV+VV1)+
tex2D(decal,UV+VV2)+
tex2D(decal,UV-VV1)+
tex2D(decal,UV-VV2);

*/
OUT.color=tex2D(decal,UV)*float4 (1,0,0,1);
OUT.color+=tex2D(decal,UV+VV1)*float4 (0,1,0,1);
OUT.color+=tex2D(decal,UV+VV1*2)*float4 (0,0,1,1);


//saturate(lgn);






float rec=saturate(1-0.4*lgn);
//rec=1;
OUT.color=tex2D(decal2,UV)+(OUT.color-tex2D(decal2,UV))*rec;
VV1*=2;


OUT.color+=tex2D(decal2,UV)*float4 (1,0,0,1);
OUT.color+=tex2D(decal2,UV+VV1)*float4 (0,1,0,1);
OUT.color+=tex2D(decal2,UV+VV1*2)*float4 (0,0,1,1);


//OUT.color+=flx*float4 (0.1,0.2,1,1)*350;
//OUT.color=tex2D (decal,UV).z*float4 (1,1,1,1);
//OUT.color+=pow (tex2D(decal2,UV),8)*float4 (10000,0,0.5,1);

//OUT.color+=float4 (0,0.1,0.2,1)*0.3;
//OUT.color=OUT.color+(2*tex2D(decal2,UV)-OUT.color)*0.5;
//OUT.color=tex2D(decal,UV)*3-tex2D(decal,UV+VV1)*1-tex2D(decal,UV-VV1)*1;
//OUT.color*=saturate(pow(1.5*rec,5));
//*float4 (0,1,0.5,0.5);

//OUT.color=0.4+noise (oPosition.x*1000);

/*
OUT.color.z=cl.x/11.9f;
OUT.color.y=cl.y/11.9f;
OUT.color.x=cl.z/11.9f;

*/


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;




}
*/