#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*1.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,3.0);
dott=0.7-dott*1.0;
res*=dott*vec4 (1.7,1.2,0.3,1.0);


dott=abs(dot(normalize (normalB.xyz),vec3 (0.0,0.0,1.0)));
dott=clamp (dott,0.0,1.0);
dott=0.0-1.5*pow(dott,4.0);
//res*=0.5;
res+=dott*2.64*vec4 (0.5,0.6,0.5,1.0);


dott=abs(dot(normalize (normal.xyz),vec3 (0.0,0.0,1.0)));
dott=clamp (dott,0.0,1.0);
dott=0.0+1.5*pow(dott,3.0);
//res*=0.5;
res+=dott*4.54*vec4 (0.2,0.5,0.5,1.0);

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

res*=0.5;
res*=1.0+1.5*texture (texture2d_cube,normalB.xyz);
res*=0.3+1.7*texture2D (texture2d_1,position.zy*0.08+vec2 (0.5))*texture2D (texture2d_1,position.zy*0.08+vec2 (0.5));
//res=vec4 (0.0);
//res=vec4 (0.2);
float PosL=1.0;
res+=vec4 (0.6,0.8,1.0,1.0)*1.5*tex2D (texture2d_blob,vec2 (0.5,0.5)*PosL+positionProj.st*vec2 (0.035,0.035));
//res*=1.0+PosY2*0.3;
res*=1.0+0.5*vec4 (1.0,0.5,0.4,0.0)*1.0;
res*=0.6;
//*vec4 (1.0,0.8,0.6,1.0);
res+=vec4 (0.2,0.2,0.1,0.0);
res*=0.7;
//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=res+ (normalB.xyzz-res)*0.015;

res+=(Color-vec4 (0.5))*0.39;
//*vec4 (0.3,0.6,2.0,2.0);
//res=v;
//res*=0.8;
//res=vec4 (0.3);
res.w=0.0;
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);

}














