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

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 ttime;
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;



//Normal.x*=Normal.x*(Normal.x*Normal.x);
//Normal.y*=Normal.y*(Normal.y*Normal.y);
//Normal.z*=Normal.z*(Normal.z*Normal.z);
Normal=normalize (Normal);
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*3.0;
res*=dott*vec4 (0.5,1.0,1.0,1.0);





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,14.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=vec4 (0.0);
//res=vec4 (0.2);
float PosL=PosY;
//res=res+ (Norm.yzxz-res)*0.07;
//res=vec4(0.3);
//res*=1.0+0.2*texture2D (texture2d_1,position.zy*0.04+vec2 (0.5));
float fff=tex2D (texture2d_1,position.xz*0.0004+ttime*0.003).x;
 fff*=tex2D (texture2d_1,position.xz*0.0010-ttime*0.002).x;

 fff=pow (fff*2.6,13.0);
res*=vec4 (0.5,0.9,1.0,1.0)*5.5*tex2D (texture2d_blob,vec2 (0.95,0.5)*0.49+positionProj.st*vec2 (0.0009,0.0009));
res*=0.7+2.2*vec4 (fff);
//res+=vec4 (0.1);





//res=v;
//res*=0.8;
//res=vec4 (0.5);
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);

}














