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 float3 alpha,
 uniform float3 alpha3,
 uniform float3 alpha4,
 uniform float3 alpha2
 ) 
{


	C2E2f_Output OUT;


	float4 cl;
	float4 cl2;

cl=tex2D (decal,oPosition);


//float ff=0.5*pow ((2.23-oPosition.y),3);
float f=(cl.z-cl.y)*alpha2;


float fft=1+0.1*alpha*tex2D (decal2,oPosition)+f;

//f+=10000+alpha*tex2D (decal2,oPosition)*0.01;
//fft=1000*alpha+0.02*tex2D (decal2,oPosition);
//fft=alpha2;
//oPosition*=1-1*alpha*(tex2D (decal2,oPosition));

float2 oPosition2=round((oPosition)*fft)/fft+20*f;
//float2 oPosition2=oPosition+f;
cl=tex2D(decal,oPosition2+fft);


cl=0.001*pow (cl*5.0,7);


//cl+=tex2D (decal2,oPosition)*0.2;

cl2=tex2D (decal,oPosition);

//OUT.color=cl;
//OUT.color=dot(cl.xyz,cl.xyz)*float4 (0.4,0.8,1.2,1);
OUT.color=dot(cl.xyz,cl.xyz)*float4 (1.4,0.5,0.4,1);


OUT.color=OUT.color+(cl2-OUT.color)*alpha3;


OUT.color=tex2D(decal,oPosition);;

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;




}
*/






/*

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 float3 alpha,
 uniform float3 alpha2
 ) 
{


	C2E2f_Output OUT;


	float4 cl;
	float4 cl2;

cl=tex2D (decal,oPosition);


//cl2=tex2D (decal,oPosition+float2 (0.005,0));
//*float4 (1,0,0,0);
//cl=pow (cl,140-140*oPosition.y);
//cl=pow (cl,(1+oPosition.y*oPosition.y*oPosition.y*1)*1);
float ff=2*(2.3+3.2-8*oPosition.y*oPosition.y);
ff=(3.2+20*oPosition.y*oPosition.y);
ff*=0.5;
ff=(1.3-oPosition.y*oPosition.y*oPosition.y)*2;
ff=0.5*pow ((2.23-oPosition.y),3);

//ff=13-ff;




//float f=ff*66;
float f=((oPosition.y+alpha2)+(oPosition.x+alpha))*cl.z;



f=cl.z*0.4+cl.x*0.4-cl.y*0.8;
//f=1;
//f*=alpha;
//float f=((oPosition.y+alpha2)+(oPosition.x+alpha))*cl.z*0.1;

//200+cl.x*5;
float fft=150+f*80;
//f*=0.0;
//cl=tex2D (decal,oPosition-f);
f*=0.1;
fft=20;
//fft=cl.z*40+10;


cl=tex2D (decal,oPosition);
//cl=tex2D (decal,round((oPosition)*fft)/fft-f);
//f=0;


fft=alpha2+0.5*alpha*tex2D (decal2,oPosition);
//fft=alpha2;

//fft=100+0*tex2D (decal2,oPosition);
///f=0;
f*=4.1;

//oPosition*=1-1*alpha*(tex2D (decal2,oPosition));

cl=tex2D (decal,round((oPosition)*fft)/fft+f);
ff=7.0;

cl=1*0.01*pow (cl*ff,7);
//cl.x=sin(cl.x*1000)*0.5+0.5;
//if (cl.x>0.5) cl=0;
//cl+=(cl-cl2)*1.2;
//(1+oPosition.y*oPosition.y*oPosition.y*1)*1);
OUT.color=cl;


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;




}
*/