
    #version 120 

    #extension GL_EXT_bindable_uniform : enable 

    #extension GL_EXT_gpu_shader4 : enable 
#define tex2D texture2D



varying vec3 normal;
varying vec3 normalB;
varying vec2 texture_coordinate_1; 
//varying vec3 vertex_to_light_vector;
varying vec4 position;
				uniform float PosY;
				uniform float ttime;
varying vec4 projection_position;

uniform mat4 ProjectionMatrix;

varying vec4 ShadowPosZ;
varying vec4 Color;
				uniform sampler2D texture2d_1;
				uniform sampler2D texture2d_2;
				uniform sampler1D textureDSP;
uniform float particlesize;
uniform float magnifier;
uniform float realttime;
varying float rnd;

varying vec2 TheUV;

void main()
{
rnd=1.0;
vec4 glVertex= gl_Vertex;
vec4 glVertexTemp=gl_Vertex;

float Displacement;


Displacement=0.0+texture2D (texture2d_1,glVertex.xy+vec2 (realttime*0.01,0.0)).x*0.5;
Displacement*=pow(texture2D (texture2d_1,glVertex.xy*0.02+vec2 (realttime*0.004,0.0)).x,6.0)*6.4;



Displacement+=0.08*sin(length (glVertex.xy*14.0)+realttime*2.0);
//*10.2*pow(clamp (1.001*sin(4.0*0.01+4.7*0.2+(1.0/2.5)*ttime*2.0*3.1416),0.0,1.0),18.0);





Displacement=texture2D (texture2d_2,glVertex.xy*1.0).x*10.0;

float T1=5.0-5.0*clamp ((ttime-144.2)*0.03,0.0,1.0);

//glVertex.z+=20.0*pow(pow(T1*texture2D (texture2d_1,glVertex.xy*0.05+vec2 (realttime*0.0,0.0)).x,30.0)+1.85*length (glVertexTemp.xy-vec2 (0.5)),10.0);


float thel=length (glVertexTemp.xy-vec2 (0.5));
float T2=5.0*clamp ((ttime-151.2-thel*5.0)*0.03,0.0,1.0);
if (ttime>170.5)
 T2=5.0*clamp ((ttime-153.2-thel*5.0)*0.024,0.0,1.0);

//theb*0.1;


bool Add=false;
if (Displacement>0.01) Add=true;
//Add=false;
//Displacement=0.0;
//Displacement+=texture2D (texture2d_2,glVertex.xy*0.6+vec2 (ttime*0.05,0.0)).x*1.4;

//Displacement*=1.0+particlesize*10.0*texture1D(textureDSP,1.0/512.0).x;

Color=vec4 (0.0+texture2D (texture2d_1,glVertex.xy*0.3+vec2 (ttime*0.0,0.0)).y);


float Cll=texture2D (texture2d_1,glVertex.xy*1.7+vec2 (realttime*0.008,0.0)).x;
Cll=pow(1.8*Cll,6.0)*1.3+1.3;



float theb=55.0*pow(PosY*clamp ((texture2D (texture2d_1,glVertex.xy*0.03).x-0.4),0.0,1.0),2.0)*50.0;
//glVertex.z+=theb;

//glVertex.z+=5.0*pow(pow(T2*texture2D (texture2d_1,glVertex.xy*1.02+vec2 (realttime*0.0,0.0)).x,25.0)+0.0*length (glVertexTemp.xy-vec2 (0.5)),10.0);
if (theb>0.02)
if (theb<0.5){
//Color=vec4 (1.0,0.4,0.2,1.0);
//Cll*=1.5;
}

//Cll*=1.0+clamp (theb*0.08,0.0,10.0);
glVertex.z=0.0;

glVertex.z=pow(texture2D(texture2d_2,glVertex.xy).x,0.7)*78.0;

if (ttime>204.0)
glVertex.z=0.0;

if (glVertex.z>0.002) 
{
	Color*=vec4 (0.6,1.7,1.2,1.0)*2.8;
//Cll*=0.3*Cll;
//Cll+=0.5;
Add=true;
float za=1.0*texture2D(texture2d_1,glVertex.xy*3.2+0.2*vec2 (ttime)).x;
float zb=0.03*texture2D(texture2d_1,glVertex.xy*1.1+0.4*vec2 (ttime)).x;
glVertex.z+=za;
glVertex.x+=zb;
Cll*=1.2*Cll*0.1;
Cll+=0.2;
//*(1.0+za*4.0);
Color*=1.0+5.0*pow(za*1.3,4.0);

}
else
{
Color*=0.23;
Add=false;
}
glVertex.z=clamp (glVertex.z,-1000.0,1000.0);

Color*=vec4 (0.5,0.7,1.0,1.0)*(0.2+Cll);
if (!Add)
{
	glVertex.z+=8.0*pow(2.4*(length (glVertexTemp.xy-vec2 (0.5))),10.0);
glVertex.z+=0.8*sin(-2.5*ttime+10.0*length(glVertexTemp.xy-vec2 (0.5)));




Cll*=2.0;
}
{
	float T1=5.0*clamp ((ttime-194.2)*0.1,0.0,1.0);
glVertex.z+=20.0*pow(pow(T1*texture2D (texture2d_1,glVertex.xy*0.05+vec2 (realttime*0.0,0.0)).x,30.0)+1.85*length (glVertexTemp.xy-vec2 (0.5)),10.0);
}

rnd=1000.0;

//Color+=vec4 (0.05);
//if (Displacement<0.0001) Displacement=10000000.0;
//Color=vec4 (1.0);

//glVertex.z=Displacement*4.0*magnifier;
Cll*=0.5;
//Add=false;
//if (abs(glVertex.z)<30.0)




//Color=vec4 (1.0);
//Cll=1.0;
//if (ttime>204.0)glVertex.z=0.0;

//glVertex.y+=ttime*0.1;
glVertex.y=mod(glVertex.y,1.0);
glVertex.xy*=40.0; glVertex.xy-=vec2 (20.0);
{
float sff=pow (1.1*texture2D (texture2d_1,vec2(glVertexTemp.xy*1.2)+vec2 (ttime*0.001)).x,1.0)*2.5;
//	glVertex.x+=sff;
}

glVertex.z+=0.0*10.0;
//sin(20.0*ttime);
rnd=10000000.0;
// sphere out


{	
	vec4 glVertex2=glVertexTemp;
float dist=sin(glVertexTemp.y*3.141593)*1.0;
//dist=1.0;
//dist=1.0+PosY;
float fr=glVertexTemp.y*5.0;
glVertex2.x=sin(ttime*0.0+glVertexTemp.x*2.0*3.141593)*1.0*dist;
glVertex2.y=cos(ttime*0.0+glVertexTemp.x*2.0*3.141593)*1.0*dist;
glVertex2.z=(glVertexTemp.y-0.5)*2.0;
//(glVertexTemp.y-0.5)*0.0;
glVertex2.xyz/=length (glVertex2.xyz);
glVertex2.xyz*=13.0;


float sff=pow (1.1*texture2D (texture2d_1,vec2(glVertexTemp.y*0.2,glVertexTemp.x*0.2)+vec2 (ttime*0.001)).x,3.0)*2.5;
float PPosY=1.0-3.0*clamp ((ttime-160.8)*0.05,0.0,1.0);
PPosY=-2.0+PosY*0.4;
//PPosY=PosY;
PPosY=0.0;
if (ttime>170.5){

	float rw=clamp ((ttime-170.5)*0.5,0.0,1.0);
//PPosY=rw*0.055*sin(ttime+20.0*texture2D( texture2d_1,glVertexTemp.xy*0.55+vec2 (0.0*ttime)).x);
	rw=clamp ((ttime-176.5)*0.1,0.0,1.0);
PPosY+=rw*0.055*sin(ttime+20.0*texture2D( texture2d_1,glVertexTemp.xy*0.35+vec2 (0.0*ttime)).x);
}
else
{

	float rw=clamp ((ttime-167.5)*0.75,0.0,1.0);
//PPosY=rw*0.055*sin(ttime+20.0*texture2D( texture2d_1,glVertexTemp.xy*0.55+vec2 (0.0*ttime)).x);

}

if (Add) PPosY=0.0; 
//else PPosY=PosY;

float _PosY=clamp (PPosY*1.0+sff*0.0,-1.0,1.0);
//glVertex=vec4 (0.0);
//_PosY=0.0;
if (abs(glVertex.z)>900.0) _PosY=0.0;
glVertex+=(glVertex2-glVertex)*_PosY;










if (ttime>204.0)
{	
	vec4 glVertex2=glVertexTemp;

	
glVertex2.x+=(ttime-204.0)*(0.08);
glVertex2.x=mod(glVertex2.x,1.0);
	
	glVertex2.xy*=80.0;
glVertex2.xy-=40.0;
glVertex2.z=0.0;

rnd=166.0;

float Displacement=0.0;

	Displacement=0.5+0.5*texture2D (texture2d_1,glVertexTemp.xy*0.7+vec2 (realttime*0.03,0.007)).x*1.9;

Displacement+=1.4*texture2D (texture2d_1,glVertexTemp.xy*vec2 (0.02,0.35)+vec2 (0.0,realttime*0.0015)).x*0.9;
Displacement*=pow(texture2D (texture2d_1,glVertexTemp.xy*vec2 (0.04,0.06)+vec2 (0.0,realttime*0.004)).x,2.0)*0.4;
Displacement+=pow(texture2D (texture2d_1,glVertexTemp.xy*vec2 (0.14,0.66)+vec2 (0.0,realttime*0.014)).x,2.0)*0.04;
Displacement*=1.5;
Displacement+=0.08*sin(length (glVertexTemp.xy*14.0)+realttime*2.0);
Displacement*=2.0;
//Displacement*=5.0;
Displacement+=texture2D (texture2d_2,glVertexTemp.xy).x*0.0;
//PosY;
Color*=vec4 (0.7,0.9,1.0,1.0);

//Color=vec4 (0.1);
glVertex=glVertex2;
glVertex.z=Displacement*10.0;


vec4 glVertex5=glVertexTemp;
glVertex5.x+=(ttime-204.0)*(0.08);
glVertex5.x=mod(glVertex5.x,1.0);
	



glVertex5.xy*=80.0;
glVertex5.xy-=40.0;
glVertex5.z=0.0;
if (texture2D (texture2d_2,glVertexTemp.xy).x<0.001)
{
Displacement=-0.5+1.0*texture2D (texture2d_1,glVertexTemp.xy*vec2 (1.0)+vec2 (0.0,realttime*0.0005)).x;
glVertex5.z=Displacement*200.0;
	//glVertex5.z-=10.0;;
}
bool leth=false;

if (texture2D (texture2d_2,glVertexTemp.xy).x>450.001)
{
leth=true;
	glVertex5=glVertexTemp;
glVertex5.y=glVertexTemp.y;
glVertex5.x=0.0;
glVertex5.z=-glVertexTemp.x;


//glVertex5.x+=(ttime-204.0)*(0.08);
//glVertex5.x=mod(glVertex5.x,1.0);

glVertex5.yz*=80.0;
glVertex5.yz-=40.0;
glVertex5.z+=8.0*10.0;
}


float _Posy=-7.0+(ttime-204.0)*0.55;
_Posy+=5.0*pow(1.3*texture2D (texture2d_1,glVertexTemp.xy*5.0*vec2 (0.25,0.25)+vec2 (0.0,realttime*0.004)).x,4.0);
_Posy+=glVertexTemp.y*5.0;
_Posy=clamp (_Posy,0.0,1.0);
float fc=_Posy;

if (!leth)
glVertex+=(glVertex5-glVertex)*_Posy;



_Posy=-7.0+(ttime-205.0)*0.55;
_Posy+=5.0*pow(1.3*texture2D (texture2d_1,glVertexTemp.xy*5.0*vec2 (0.25,0.25)+vec2 (0.0,realttime*0.004)).x,4.0);
_Posy+=glVertexTemp.y*5.0;
_Posy=clamp (_Posy,0.0,1.0);
if (leth)
glVertex+=(glVertex5-glVertex)*_Posy;



float ft=(ttime-223.0)*0.06;
ft=clamp (ft,0.0,1000.0);
//ft=ft*abs (glVertexTemp.y-0.5);
//if (abs(glVertexTemp.y-0.5)<ft) glVertex.z+=50.0*(abs(abs(glVertexTemp.y-0.5)-ft));

float ffc=glVertexTemp.x+pow (1.5*texture2D (texture2d_1,glVertexTemp.xy).x,4.0);

//if (leth)
if (ft>ffc) 
if (leth)	glVertex.z-=pow(50.0*abs (ft-ffc),2.0);


ft=(ttime-224.0)*0.12;
ft=clamp (ft,0.0,1000.0);
ffc=pow (1.5*texture2D (texture2d_1,glVertexTemp.xy*1.3).x,2.0);

if (ft>ffc) 
if (!leth)		
glVertex.z-=pow(50.0*abs (ft-ffc),2.0);



//glVertex.z+=ft*ft*10.0+10.0*pow(ft,2.0);

//if (texture2D (texture2d_2,glVertexTemp.xy).x>0.001)

{
Cll*=1.0+1.0*fc;
Cll+=1.5*fc;
Color*=1.0+2.0*fc;
if (ttime>209.0)
if (leth)
{
//	glVertex.x+=2.0*texture2D (texture2d_1,glVertexTemp.xy*11.3+vec2 (0.2*ttime*texture2D (texture2d_1,glVertexTemp.xy*1.3).x)).x;
	//glVertex.z+=2.0*texture2D (texture2d_1,glVertexTemp.xy*1.3+vec2 (0.01*ttime)).x;
}
//if (leth) Color*=vec4 (1.5,0.4,0.2,1.0)*fc;

}

}






//glVertex=glVertex2;
//x' = x cos f - y sin f
//y' = y cos f + x sin f	
	
	//Displacement*1.0*sin(ttime*4.0)*pow((1.0-_PosY),8.0);

}
//Cll*=5.0;

//if (Add) glVertex.z+=1000.0;







//glVertex.z+=PosY*100.0;
glVertex= gl_TextureMatrix[0] * glVertex;

gl_Position =  glVertex;

TheUV=gl_MultiTexCoord0.st;
//vec2 TheUV1=gl_Vertex.xy*0.03;
//TheUV1=gl_MultiTexCoord0.st*3.0;
//Color=vec4 (1.0);
gl_Position = gl_ModelViewProjectionMatrix * gl_Position;
//rnd=gl_Color.r;
position=gl_Position;

if (ttime>194.5)
if (ttime<204.0)
if (texture2D (texture2d_1,vec2(glVertexTemp.xy*0.6+vec2 (ttime*0.05))).x>0.5) {
	Color*=vec4 (3.0,0.8,0.4,1.0);
Cll*=1.0;
}



if (ttime>204.0)
if (texture2D (texture2d_1,vec2(glVertexTemp.xy*2.6+vec2 (-ttime*0.05,0.0))).x>0.53) {
	Color*=6.4;
	//vec4 (3.0,0.8,0.4,1.0)*10.0;
Cll*=1.0;
}


if (ttime<204.0)
if (!Add)
if (texture2D (texture2d_1,vec2(glVertexTemp.xy*0.6+vec2 (ttime*0.05))).x>0.4)
Color*=vec4 (2.0,0.9,0.3,1.0);



//float ff=Color.x;Color.x=Color.z;Color.z=ff;
//swap (Color.x,Color.z);
//Cll=2.0;
//	gl_PointSize =1-7.0/gl_Position.w;
	gl_PointSize =Cll*particlesize*125.0/gl_Position.w;
	//gl_PointSize =particlesize*125.0/gl_Position.w;
	///gl_Position.w;

}











