#version 100
precision highp float;uniform float iGlobalTime;uniform sampler2D tex0;uniform vec2 iResolution;uniform float factorTex;uniform float factorBlend;uniform float alphafactor;varying vec4 col;varying vec3 nrm;
varying vec2 uv;float pn(vec3 p) {vec3 i = floor(p);vec4 a = dot(i, vec3(1., 57., 21.)) + vec4(0., 57., 21., 78.);vec3 f = cos((p-i)*3.141592653589793)*(-.5) + .5;a = mix(sin(cos(a)*a), sin(cos(1.+a)*(1.+a)), f.x);
a.xy = mix(a.xz, a.yw, f.y);   return mix(a.x, a.y, f.z);}vec3 co=vec3(1.);vec2 q;float radius=0.18,dp=6.9,pw=1.;float vr1=1.,vr2=1.,vr3=1.,vr4=1.,vr5=0.8,vr6=1.,vr7=1.,vr8=1.,vr9=1.,vr10=1.;float r (vec2 c,vec2 d) { 
vec2 k=abs(q-c)-0.5*d;return max(k.x,k.y);}float rr(vec2 c,vec2 d){d-=vec2(2.0*radius);return abs(length(max(abs(q-c)-0.5*d,0.0))-radius);}float texfetch(vec2 p){return mix(texture2D(tex0,mod(p,1.0)).g,texture2D(tex0,p+vec2(0.5,0.),1.0).g,cos(iGlobalTime)/2.0+0.5);
}vec3 flx(vec2 p,float ct){float t; vec3 q=vec3(p,p.x-p.y+iGlobalTime*1.3);t=abs(pn(q)); t+=.5*abs(pn(q*2.)); t+=.25*abs(pn(q*4.));t*=0.5;vec3 c=clamp(3.*abs(fract(fract(ct)+vec3(0.,2./3.0,1./3.0))*2.-1.)-1.,0.,1.);return pow(vec3(1.-t),c+1.5);
}float sk(float g){g=abs(g*40.);return cos(g)*pow(1.-clamp(g/11.,0.,1.),2.);}float scv(float t){t=clamp(t,0.,1.);return t*t*(3.0-2.0*t);}void main(void){float a=iGlobalTime*194.24777960;vec2 pa=.15*vec2(sin(a),cos(a));
float asp=iResolution.x/iResolution.y;vec2 p = mod((uv)*vec2(2.0,1.0),1.0);p.y = p.y;p -= 0.5;asp = 1.;vec2 pp=p*2.; float t=iGlobalTime*0.4;p+=0.5;     float ll=texfetch(p);vr4 = 0.4;float lf=ll*vr4-(vr6-1.2);vec3 dir=normalize(vec3(pp*vec2(asp*1.6,-1),-1.5)),q,r=vec3(0.,0.,4.);
float d,ii=1.;float e=0.02;for(float i=0.;i<64.;i++){d=length(r*vec3(0.1,.5,1.))-1.;q=r; q.y-=1.;d+=(pn(q+vec3(.0,iGlobalTime*2.,.0))+pn(q*3.)*.5)*.25*(q.y); d=min(100.-length(q),abs(lf+d))+e; r+=d*dir; if(d<e){ii=i/64.;break;}}gl_FragColor = vec4(0.,0.,0.,1.);
float colmix = r.y*.02+.4;gl_FragColor.rgb += 3.0*vr7*mix(vec3(0.),mix(vec3(1.,.5,.1),vec3(0.1,.5,1),(colmix)),pow(ii*2.,2.2));   float firestren = gl_FragColor.r;gl_FragColor.a = (1.*pow(1.-uv.y,0.95) * firestren) * alphafactor;}