    #version 110 
    #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 ttime;
uniform float fttime;

varying vec4 projection_position;

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

varying vec4 projection_from_camera;
varying vec3 ThePosition;

	uniform float DSP;
	uniform float NoBreak;
varying float WhichTriangle;

void main()
{
mat4 Billboard;



vec4 glVertex= gl_Vertex;
vec2 TheUV;
ThePosition=glVertex.xyz;

// Object transf
/*
if (glVertex.z<PosY)
glVertex.x-=glVertex.z;
else
glVertex.x+=glVertex.z;
*/

glVertex.x+=DSP*0.01*glVertex.y;
//glVertex.y+=DSP*1.02*glVertex.x;


//glVertex.xyz+=PosY*gl_Normal.xyz*sin(glVertex.y*10.0)*0.02;


if (NoBreak<0.5)
if (ttime>186.0)

{
float fl=ttime-252.0;
fl*=0.16;
fl=clamp (fl,0.0,2.0);

	glVertex.xyz+=fl*7.0*gl_Normal.xyz*sin(glVertex.y);
}


if (fttime>186.0)if (fttime<230.0)glVertex.xyz+=0.5*PosY*gl_Normal.xyz*sin(glVertex.y);


//glVertex.xyz+=0.5*PosY*gl_Normal.xyz;
//*sin(glVertex.z*0.01);


glVertex= gl_TextureMatrix[0] * glVertex;
// glVertex.xyz+=PosY*5.0*gl_Normal.xyz;

//glVertex.xyz+=clamp (PosY,-10.0,10.0)*1.0*gl_Normal.xyz;


// interpolant based on vertex
float ffup=PosY-(gl_Vertex.y)*0.2;
ffup=clamp (ffup,0.0,1.0);


// vertex transformations
{ 
	ffup=sin (ttime+glVertex.z*0.2);
vec2 TheUV1=gl_Vertex.yz*0.002;
//+vec2 (PosY)*PosY*0.0001;
//glVertex.x-=abs(ffup*(tex2D (texture2d_1,TheUV1).x-0.41)*15.0);
}


// 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.yz*0.2;
///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;
///}

	vec3 Tnormal=normalize (gl_Normal);
Tnormal=abs (Tnormal);

UVcoordinates=gl_Vertex.zx*0.31;

if ((Tnormal.x>Tnormal.y) && (Tnormal.x>Tnormal.z)) {
	{
		UVcoordinates=gl_Vertex.zy*0.31;
	}

	
	
	}
	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.31;


UVcoordinates*=0.002;
// 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>100) gl_Position.y+=10100.0;

WhichTriangle=float(gl_VertexID);


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

// color pass
Color=gl_Color;


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

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











