

void main (    float2 oPosition : TEXCOORD0,
	uniform sampler2D decal,			   
	uniform sampler2D decal2,			   
	uniform sampler2D decal3,			   
 uniform float3 alpha,
out float4 oColor1: COLOR0

 ) 
{


	
float2 V=float2 (-0.001,-0.00);
float2 V1=float2 (0.001,-0.00);
float2 V2=float2 (0.0,-0.001);
float2 V3=float2 (0.0,0.001);

float3 Col1=tex2D (decal,oPosition).xyz;


//+tex2D(decal,oPosition+V1)+tex2D(decal,oPosition+V2)+tex2D(decal,oPosition+V3)+tex2D(decal,oPosition+V);
//Col1/=5.0;


float3 Col2=tex2D (decal2,oPosition).xyz;
//+tex2D(decal2,oPosition+V1)+tex2D(decal2,oPosition+V2)+tex2D(decal2,oPosition+V3)+tex2D(decal2,oPosition+V);
//Col1/=5.0;

//Col2/=5.0;

//float mult=1;

if (dot (Col2,Col2)<0.01) {
	//Col2=float3 (0.5,0.2,0.2);
//mult=0;

}
	if (dot (Col1,Col1)<0.01) {
	//Col1=float3 (0.5,0.5,0.5)*0.8;
}
Col1=Col1*2-1;
Col2=Col2*2-1;
//Col2=float4 (1,0,0,1);

//normalize (Col1);
//normalize (Col2);
//float3 Cols= (Col2)-(Col1);
float theta=0;


theta=length(Col1-Col2)*0.3;

theta=max (theta,1*(1-abs(dot(Col1,Col2))));

//theta=saturate (theta);
theta*=1.0;
theta=saturate (theta);

float4 BC=tex2D(decal3,oPosition);
//BC-=float4 (0.5,0.5,0.5,0.5);

oColor1=theta*(0.3+30*BC)+BC;
oColor1*=BC.w;

//oColor1=Col1.xyzz-float4 (1,1,1,1)*0.5;
//oColor1=BC*10;
//oColor1*=BC.w;

//oColor1=1-dot (Col1,Col2);

//oColor1=;
//oColor1=(theta)*(0.1+2*tex2D(decal3,oPosition))+tex2D(decal3,oPosition);
//oColor1=(theta)*1;
//oColor1=Col1.xyzz;
//oColor1=(theta)*(0.0+1*Col1)+tex2D(decal3,oPosition);
//oColor1=(theta)*Col1.xyzz;
//oColor1=Cols.xyzz;
//oColor1=Col1;
//oColor1=tex2D(decal2,oPosition);
//oColor1=tex2D (decal,oPosition);
//oColor1=tex2D(decal2,oPosition);
//oColor1=tex2D(decal,oPosition);
//oColor1=tex2D(decal3,oPosition);
//oColor1=(theta)*te;
//oColor1=pow(tex2D (decal3,oPosition)*0.99999,90000);
//oColor1=1/(10*pow(tex2D (decal3,oPosition).x,8));

//(0.7+tex2D(decal3,oPosition));;
//oColor1=tex2D(decal3,oPosition);;
//oColor1= tex2D (decal,oPosition);
//oColor1=float4 (0,0,1,1);


}









































/* 


  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;




}
*/