    #version 120 
    #extension GL_EXT_bindable_uniform : enable 
    #extension GL_EXT_gpu_shader4 : enable 
#define tex2D texture2D
uniform mat4 ProjectionMatrix;


varying vec3 normal;
uniform float PosY;
uniform float ttimer1;
uniform float ttimer2;
uniform float ttime;
uniform float randomize;

varying vec4 projection_position;

varying vec4 ShadowPosZ;
varying vec4 Color;
uniform sampler2D texture2d_1;
varying vec2 UVcoordinates;

varying vec4 projection_from_camera;

uniform float isFord;
uniform float isPressable;
uniform float isType2;
void main()
{
mat4 Billboard;



vec4 glVertex= gl_Vertex;
vec2 TheUV;


// Object transf
if (isType2<0.5)
glVertex= gl_TextureMatrix[0] * glVertex;



// interpolant based on vertex
float ffup=(-1.3+4.0*ttimer1)-(gl_Vertex.x)*0.3;
ffup=clamp (ffup,0.0,1.0);

if (randomize>0.5) { 
// vertex transformations
///{ 
vec2 TheUV1=gl_Vertex.xy*0.0012*vec2 (1.0,5.0)+0.003*vec2 (ttime);
//vec2 (PosY)*PosY*0.01;

//float displacement=clamp (abs(ffup*(tex2D (texture2d_1,TheUV1).x-0.11)*131.0),0.0,1.0);
float displacement=clamp ((ffup*(tex2D (texture2d_1,TheUV1).x-0.44)*3.2),-1.0,1.0);
float displacement2=ffup;
displacement=displacement+(displacement2-displacement)*ttimer2;

glVertex.y*=displacement;
glVertex.y+=-(1.0-displacement)*1.9;


 TheUV1=gl_Vertex.xy*0.0012*vec2 (1.0,1.0)+0.003*vec2 (ttime);
 displacement=clamp ((ffup*(tex2D (texture2d_1,TheUV1).x-0.20)*2.5),-1.0,1.0);
displacement2=ffup;
displacement=displacement+(displacement2-displacement)*ttimer2;


glVertex.x*=displacement;
glVertex.x+=-(1.0-displacement)*12.9;
}
else
{


ffup=(-1.3+4.0*ttimer1)-0.021*glVertex.x;
ffup=clamp (ffup,0.0,1.0);
glVertex.y*=ffup;


}


if (isType2>0.5)
glVertex= gl_TextureMatrix[0] * glVertex;


if (isPressable>0.5) {
if (isFord>0.5)
//if (glVertex.x>-2.73*3.0)	
{
	float ff=glVertex.x-(-2.73*3.0-1.1);
float ff3=glVertex.x-(-2.73*3.0-1.1-4.13);
	 ff=1.0-clamp (0.46*ff,0.0,1.0);

	 ff3=1.0-clamp (0.25*(glVertex.x-(-2.73*3.0-1.1-4.13-1.89+1.58)),0.0,1.0);
	 float ff2=sin(3.1415926535*ff3);

//float fff=	 
	 ff2=clamp (ff2,0.0,1.0);

ff2+=6.0*ff3*(tex2D (texture2d_1,gl_Vertex.xz*0.002).x-0.24*1.72);

//ff=1.0-clamp (0.76*ff,0.0,1.0);
ff+=ff2*0.3*clamp ((ttime-57.7)*2.0,0.0,1.0);

glVertex.y-=-1.26;
glVertex.y*=ff;	
glVertex.y+=-1.26;
}
else

{
	float ff=glVertex.x-(-2.73*3.0-1.1+0.5*1.47);
	 ff=1.0-clamp (0.76*ff,0.0,1.0);


glVertex.y-=-1.26;
glVertex.y*=ff;	
glVertex.y+=-1.26;
}

};




///}


// scale / vectorize normals

///	vec3 normalB=normalize (gl_Normal);
///float nx=normalB.x; float ny=normalB.y; float nz=normalB.z;
///for (int r=0;r<4;r++) { 
///if (nx>0.0) nx=nx*nx; else nx=-nx*nx;
///if (ny>0.0) ny=ny*ny; else ny=-ny*ny;
///if (nz>0.0) nz=nz*nz; else nz=-nz*nz ;
///}
///normalB=vec3 (nx,ny,nz);





projection_position=glVertex;
gl_Position =  glVertex;


// texture coordinates
UVcoordinates=gl_Position.xz*0.2;






	vec3 Tnormal=normalize (gl_Normal);
Tnormal=abs (Tnormal);
UVcoordinates=gl_Position.zx*0.11;

if ((Tnormal.x>Tnormal.y) && (Tnormal.x>Tnormal.z)) {
	{
		UVcoordinates=gl_Position.zy*0.61;
	if (isFord>0.5)
		UVcoordinates=gl_Position.xy*0.61;
	}

	
	
	}
	if ((Tnormal.y>Tnormal.z) && (Tnormal.y>Tnormal.x)) UVcoordinates=gl_Vertex.zx*0.31;
if ((Tnormal.z>Tnormal.x) && (Tnormal.z>Tnormal.y)) UVcoordinates=gl_Vertex.xy*0.61;





	//UVcoordinates=gl_Position.xy*0.21;


///UVcoordinates = vec2(gl_MultiTexCoord0);

// discretize vertices
///{ 
//gl_Position.y=float (int (1.7*gl_Position.y))/1.7+gl_Position.y*0.001;
//gl_Position.z=float (int (1.7*gl_Position.z))/1.7+gl_Position.z*0.001;
//gl_Position.x=float (int (1.7*gl_Position.x))/1.7+gl_Position.x*0.001;
///}



// final projection
gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
projection_from_camera=gl_Position;



// instancing
///gl_Position.y+=1.0*gl_InstanceID;

// vertex instancing
///if (gl_VertexID==244) gl_Position.y+=1.0;



// Transforming The Normal To ModelView-Space
normal = gl_NormalMatrix *  gl_Normal; 

// color pass
Color=gl_Color;


ShadowPosZ= ProjectionMatrix *glVertex;
ShadowPosZ=gl_TextureMatrix[2]*glVertex;

// point size
///gl_PointSize =120.0/gl_Position.w;
}











