#version 130
#define float4 vec4
#define float3 vec3
#define float2 vec2
#define oUV gl_TexCoord[0]
#define tex3D texture3D
#define tex2D texture2D
#define tex1D texture1D
varying vec4 Color;

varying vec3 normal;

				uniform sampler2D texture2d_1;
				uniform sampler2D texture2d_2;
				uniform sampler2D texture2d_blob;
				//uniform sampler2D texture2d_2;

				uniform samplerCube texture2d_cube;

	uniform float PosY;
	uniform float PosY2;
varying vec3 position;
varying vec4 positionProj;
varying vec4 normalB;



void main (void) 
{


//float4 TheNormal=(nnormal.xyzz+float4 (1.0))*0.5;
//TheNormal.w=shadow;

vec3 Normal= (normal);

float dott=dot(normal.xyz,vec3 (1.0,0.0,0.0));
dott=clamp (dott,0.0,1.0);
dott=pow(dott,5.0);
dott=1.0+dott*3.4;




vec4 Norm=(Normal.xyzz+float4 (1.0))*0.5;

vec4 res=vec4 (0.8)*dott*vec4 (0.7,0.6,0.3,0.2);
res=res+ (Norm.xyzz-res)*0.2;
res*=vec4 (0.7,0.8,0.9,1.0)*0.6;


res=vec4 (1.0);
dott=dot(normal.xyz,vec3 (0.0,0.0,1.0));
dott=clamp (dott,0.0,1.0);
dott=pow(dott,5.0);
dott=0.3+dott*13.0;
res*=dott*vec4 (0.5,1.0,1.0,1.0);
if (Color.x<0.25) 
{res=clamp (res,0.0,1.0);res*=0.75;}


dott=dot(normalize (normal.xyz),vec3 (0.0,-1.0,0.0));
dott=clamp (dott,0.0,1.0);
dott=0.2+1.5*pow(dott,1.0);
res+=dott*0.54*vec4 (0.7,0.5,0.4,1.0);



//float ft=texture2D (texture2d_1,position.xz*3.5).x;

res*=0.5;
res*=1.0+0.3*texture (texture2d_cube,normalB.xyz);
res*=0.3+1.1*texture2D (texture2d_1,position.zy*0.38+vec2 (0.5))*texture2D (texture2d_1,position.zy*0.38+vec2 (0.5));
//res=vec4 (0.0);
//res=vec4 (0.2);
float PosL=1.0;

if (PosY2<0.5)
res+=vec4 (0.6,0.8,1.0,1.0)*0.5*tex2D (texture2d_blob,vec2 (0.5,0.5)*PosL+positionProj.st*vec2 (0.15,0.15));
else
{
	res+=vec4 (0.2,0.8,1.0,1.0)*0.25*tex2D (texture2d_blob,vec2 (0.5,0.5)*PosL+positionProj.st*vec2 (0.0025,0.0025));
res*=0.85;
}
res*=1.0+PosY2*0.3;
res*=1.0+PosY2*vec4 (1.0,0.5,0.4,0.2)*0.5;

//res*=1.0+PosY2*vec4 (0.4,0.5,1.0,0.2)*1.0;
//res*=0.8+0.4*texture (texture2d_cube,normalB.xyz);

res*=0.7;
res=res+ (Norm.yxzz-res)*0.08;
res.y*=1.4;
vec4 res2=res;
res=vec4 (res.x);
res*=res*10.0;
res=res+(res2-res)*-0.5;

res+=(Color-vec4 (0.5))*0.09;
//if (Color.x>0.9)  res=vec4 (0.5);
//res=Color;
//res=v;
//res*=0.8;
//res=vec4 (0.3);
gl_FragData[1]=res;

gl_FragData[0]=Norm;
gl_FragData[0].w=1.0;
//Diffuse+float4 (0.5);
//gl_FragData[1]=float4 (0.3,0.3,0.3,0.3);

}














