TECNOLOGIA
SCHEDA TECNICA
Questo documentario interattivo è stato realizzato fondendo insieme vari linguaggi e tecnologie.
L’ambiente di sviluppo è costruito con tecnologia HTML5 WebGL pensata per la computer grafica 3D sul WEB. Ringraziamo il progetto opensource three.js per il prezioso aiuto in termini di solidità e leggibilità del codice.
Le riprese video volumetriche degli intervistati e degli oggetti sono state effettuate utilizzando il DepthKit, un software capace di combinare il video RGB con le informazioni di profondità registrate dai sensori della Microsoft Kinect.
I modelli delle Ville Medicee e delle Statue che vanno a comporre le infografiche sono stati realizzati attraverso al modellazione 3d, la fotogrammetria e le scansioni laser. Le riprese aeree e la fotogrammetria area sono state effettuate tramite droni.
La texture del Sound Design nasce dalla rielaborazione in chiave elettronica di alcuni brani riprodotti dall’ensemble L’Homme Armé. La realizzazione dei soundscape è avvenuta tramite sintesi analogica, Max MSP e codifiche in ambix per spazializzare i suoni in 3D.
REQUISITI SOFTWARE/HARDWARE
Software
Il webdoc di ville medicee nella sua versione Desktop è ottimizzato per chrome 69, su qualsiasi sistema operativo.
Hardware
Requisiti minimi di prestazione per la fruizione HIGH QUALITY:
- Scheda grafica >= da 1500 a 2000 MB.
- Processore >= 2,4 GHz i7
- RAM >=4GB
- Connessione minima >=150kB/sec.
IDOC COME NUOVA FORMA DEL NARRARE
Ai in my Brain
INTERACTIVE DOCUMENTARY
Loading 0%
For Best Esperience :
Ensure that WebVR is enable on your Browser
Chrome : Navigate to URL
"chrome://flags/#enable-webvr"
Safari : Setting > Safari > Motion & Orientation Access
//SKY SCELTA - FRAGMENT
uniform float time;
uniform float dissolve;
uniform int modesky;
varying vec2 vUv;
#define S(a, b, t) smoothstep(a, b, t)
float N21(vec2 p) {
return fract(sin(p.x*123.+p.y*3456.)*3524.);
}
vec2 N22(vec2 p) {
return vec2(N21(p), N21(p+324.));
}
float L(vec2 p, vec2 a, vec2 b) {
vec2 pa = p-a;
vec2 ba = b-a;
// float t = clamp(dot(pa, ba)/dot(ba, ba), 0., 1.);
float t = 0.;
float d = length(pa - ba*t);
float m = S(.12, .0, d);
d = length(a-b);
float f = S(1., .8, d);
m *= f;
m += m*S(.05, .06, abs(d - .75))*2.;
return m;
}
vec2 GetPos(vec2 p, vec2 o) {
p += o;
vec2 n = N22(p)*time;
p = sin(n)*.4;
return o+p;
}
float G(vec2 uv) {
vec2 id = floor(uv);
uv = fract(uv)-.5;
vec2 g = GetPos(id, vec2(0));
float m = 0.;
for(float y=-1.; y<=1.; y++) {
for(float x=-1.; x<=1.; x++) {
vec2 offs = vec2(x, y);
vec2 p = GetPos(id, offs);
m+=L(uv, g, p);//METTE LE LINEE
vec2 a = p-uv;
//float flash = .003/dot(a, a);
//flash *= pow( sin(N21(id+offs)*6.2831+10.*time)*.4+.6, 10.);//METTE LE STELLINE PULSANTI
//flash *= pow( sin(time)*.5+.5, 3.);
//m += flash;
}
}
//m += L(uv, GetPos(id, vec2(-1, 0)), GetPos(id, vec2(0, -1)));//METTE LE LINEE
//m += L(uv, GetPos(id, vec2(0, -1)), GetPos(id, vec2(1, 0)));//METTE LE LINEE
//m += L(uv, GetPos(id, vec2(1, 0)), GetPos(id, vec2(0, 1)));//METTE LE LINEE
//m += L(uv, GetPos(id, vec2(0, 1)), GetPos(id, vec2(-1, 0)));//METTE LE LINEE
//float d = length(g-uv);//LEVA LE LINEE E METTE CERCHIETTI
//m = S(.1, .08, d);
return m;
}
void main( void ) {
vec2 uv = (0.1*vUv.xy) / 1.;
// vec2 uv = ( gl_FragCoord.xy-.5*varying vec2 vUv.xy*0.001) / 1.*0.001*position.y;
float d = step(uv.y, 0.);
//if(uv.y<0.)
// uv.y = abs(uv.y);
float m = 0.;
m = 0.;
float t = time*.2;
float i=0.;
//for(float i=0.; i<1.; i+=.4) {//da il numero di stelle
float z = fract(i-t);//la t da il movimento e il verso
float s = mix(10., .5, z);//i primi due danno la focale/profondita/zoom
float f = S(0., .4, z)*S(1., .8, z);//regolano la dissolvenza delle linee
m += G(uv*s+10.*i)*f;
//}
t *= 10.;
vec3 base = vec3(0.06 ,0.12 ,0.49);//.5+sin(vec3(1., .56, .76)*t)*.5;//CAMBIA COLORE
vec3 col = base;
col *= m;
col -= uv.y*base;
col *= dissolve*(1.-dot(uv, uv));
//col *= mix(1., .5, d);
//if(col.r<0.1){
gl_FragColor = vec4( col, 1.0 );
//}
}
//SKY SCELTA - VERTEX
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
uniform float dissolve;
uniform int modesky;
varying vec2 vUv;
void main() {
vUv = uv;
vUv = vec2( position.x , position.y );
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
}
//SKY SNOW - FRAGMENT
uniform vec3 color;
uniform float opacity;
uniform int mode;
uniform sampler2D texture0;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;
uniform sampler2D texture4;
uniform sampler2D texture5;
varying vec3 uVu;
void main() {
vec4 texColor;
if(uVu.y<15. || mode==0){
texColor = texture2D( texture0, vec2(gl_PointCoord.x,1.-gl_PointCoord.y) );
}else{
if(mode==1){
texColor = texture2D( texture1, vec2(gl_PointCoord.x,1.-gl_PointCoord.y) );
}else if(mode==2){
texColor = texture2D( texture2, vec2(gl_PointCoord.x,1.-gl_PointCoord.y) );
}else if(mode==3){
texColor = texture2D( texture3, vec2(gl_PointCoord.x,1.-gl_PointCoord.y) );
}else if(mode==4){
texColor = texture2D( texture4, vec2(gl_PointCoord.x,1.-gl_PointCoord.y) );
}else if(mode==5){
texColor = texture2D( texture5, vec2(gl_PointCoord.x,1.-gl_PointCoord.y) );
}
}
gl_FragColor = texColor * vec4( color, opacity );
}
//SKY SNOW - VERTEX
uniform float radiusX;
uniform float radiusZ;
uniform float size;
uniform float scale;
uniform float height;
uniform float time;
uniform float speedH;
uniform float speedV;
varying vec3 uVu;
void main() {
uVu=position;
vec3 pos = position;
pos.x += cos((time + position.z) * 0.25 * speedH) * radiusX;
pos.y = mod(pos.y - time * speedV, height)-height/2.;
pos.z += sin((time + position.x) * 0.25 * speedH) * radiusZ;
vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );
gl_PointSize = size * ( scale / length( mvPosition.xyz ) );
gl_Position = projectionMatrix * mvPosition;
}
//BUTTON ECHO - FRAGMENT
uniform float mousex;
uniform float mousey;
uniform float time;
uniform float dime;
uniform float alph;
uniform sampler2D texture0;
varying vec3 vUv;
void main() {
float t = fract(time+length(vUv)*sin(time)*sin(time));
float t2 = fract(time+length(vUv)*sin(time+0.7)*sin(time+0.7));
float t3 = fract(time+length(vUv)*sin(time+1.55)*sin(time+1.55));
float m0=dime;
float a1=9.;
float a2=6.;
float a3=3.;
float alfa=4.;
float faktor=0.3;
float prosp_y=mousey;
float prosp_x=mousex;
vec3 texColor = vec3(texture2D(texture0,m0*vec2( (vUv.x), (vUv.y) )+0.5).rgb);//**************
vec3 texColor2 = pow(1.-t,alfa)*vec3(texture2D(texture0, m0*vec2(vUv.x*(1.+faktor*t)-prosp_x*t + 1./(a1*4.)*sin(t*10.)*sin(t*10./3.), vUv.y*(1.+faktor*t)-prosp_y*t+1./(a1*4.)*sin(t*10./5.)*sin(t*10./3.) ) + 0.5 ).rgb);//**************
vec3 texColor3 = pow(1.-t2,alfa)*vec3(texture2D(texture0, m0*vec2(vUv.x*(1.+faktor*t2)-prosp_x*t2 + 1./(a2*4.)*sin(t2*10.)*sin(t2*10./3.) , vUv.y*(1.+faktor*t2) -prosp_y*t2+1./(a2*4.)*sin(t2*10.)*sin(t2*10./3.) ) + 0.5 ).rgb);//**************
vec3 texColor4 = pow(1.-t3,alfa)*vec3(texture2D(texture0, m0*vec2(vUv.x*(1.+faktor*t3)-prosp_x*t3 + 1./(a3*4.)*sin(t3*10.)*sin(t3*10./3.) , vUv.y*(1.+faktor*t3) -prosp_y*t3+1./(a3*4.)*sin(t3*10.)*sin(t3*10./3.) ) + 0.5 ).rgb);//**************
texColor=texColor+texColor2+texColor3+texColor4;
gl_FragColor = vec4(texColor,0.5*alph) ;
}
//BUTTON ECHO - VERTEX
uniform float time;
varying vec3 vUv;
void main() {
vUv=position;
vec3 pos = position;
vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );
gl_Position = projectionMatrix * mvPosition;
}
varying vec2 uvu;
varying float vDepth;
uniform int mode;
uniform sampler2D texture;
uniform vec3 lightPos;
void main() {
uvu = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
vec4 mPos = modelMatrix * vec4(position, 1.0);
// Just z
float dist = abs(cameraPosition.z - mPos.z);
vDepth = smoothstep(1.0, 5.0, dist) * smoothstep(35.0, 15.0, dist) ;
}
float random(vec2 co) {
highp float a = 12.9898;
highp float b = 78.233;
highp float c = 43758.5453;
highp float dt= dot(co.xy ,vec2(a,b));
highp float sn= mod(dt,3.14);
return fract(sin(sn) * c);
}
uniform int mode;
uniform sampler2D texture;
uniform vec3 lightPos;
varying vec2 uvu;
varying float vDepth;
void main() {
float r = random(uvu) * 0.2;
float light = length(texture2D(texture, uvu) ) ;
gl_FragColor.rgb = vec3(1.0);
// gl_FragColor.a = light * vDepth;
gl_FragColor.a = light * 0.2 * (vDepth + r);
//gl_FragColor = vec4(uvu, 0.0, 1.0);
//gl_FragColor = vec4(1.0);
}
uniform int mode;
uniform float time;
varying vec3 vUv;
void main( void )
{
float j=0.71-200.*fract(time/400.);//*sin(1.3 + time/12.);
float h=0.81;
float f = 3.0;
float g = 3.0;
// vec2 res = vUv;
// vec2 mou = mouse.xy;
//if (mouse.x < 0.5)
//{
// mou.x = sin(gTime * .3)*sin(gTime * .17) * 1. + sin(gTime * .3);
// mou.y = (1.0-cos(gTime * .632))*sin(gTime * .131)*1.0+cos(gTime * .3);
// mou = (mou+1.0) * res;
//}
vec2 z = 0.1*(vUv.xy);
vec2 p = 0.00001*time*vUv.xy*vUv.y * j;
if(mode==2){
h=(0.8+0.2*sin(time/200.));
j=(0.5-0.2*sin(time/140.));
p = 0.007*time*normalize(vUv.xy)*vUv.y * j;
}else if(mode==3){
z = 0.01*(vUv.xy);
h=(0.2+0.2*sin(time/200.));
j=(0.2-0.2*sin(time/140.));
p = 0.09*time*normalize(vUv.xy)*vUv.y * j;
}else if(mode==0){
z = 0.01*(vUv.xy);
h=(0.2+0.2*sin(time/200.));
j=(0.3-0.2*sin(time/140.));
p = 0.03*time*normalize(vUv.xy)*vUv.y * j;
}
for( int i = 0; i < 25; i++)
{
float d = dot(z,z);
z = (vec2( z.x, -z.y ) / d) + p * h;
z.x = 1.0-abs(z.x);
f = max( f-d, (dot(z-p,z-p) ));
g = min( g*d, sin(dot(z+p,z+p))+1.0);
}
f = abs(-log(f) / 3.5);
g = abs(-log(g) / 8.0);
gl_FragColor = vec4(0.22*min(vec3(g, g*f, f), 1.0),1.);
}
uniform float time;
varying vec3 vUv;
void main() {
vUv=position;
vec3 pos = position;
vec4 mvPosition = modelViewMatrix * vec4( pos, 0.4 );
gl_Position = projectionMatrix * mvPosition;
}
uniform int iFrame;
//uniform sampler2D iChannelB;
//uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
const float sizeGlob = 256.;
const int PNUM = 200;
struct Particle // user defined structure.
{
vec2 pos;
vec2 pos2;
int idx;
};
#define N(v) (v.yx*vec2(1,-1))
int modI(int a,int b) {
float m=float(a)-floor((float(a)+0.5)/float(b))*float(b);
return int(floor(m+0.5));
}
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
vec4 texelFetch(sampler2D tex, ivec2 size, ivec2 coord)
{
return texture2D(tex, vec2((float(coord.x)-0.5) / float(size.x), (float(coord.y)-0.5) / float(size.y)));
}
int particleIdx(vec2 coord, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return int(coord.x)+int(coord.y)*ires.x;
}
vec2 particleCoord(int idx, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return vec2(modI((idx),(ires.x)),idx/ires.x)+.5;
}
vec4 getPixel(vec2 coord, sampler2D s)
{
return texelFetch(s,textureSize(s,0),ivec2(coord));
}
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
Particle readParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=pix.xy;
p.pos2=pix.zw;
p.idx=particleIdx(coord,s);
return p;
}
vec4 getRand(vec2 pos, sampler2D s)//velocity
{
//vec2 rres=vec2(textureSize(s,0));
vec2 rres=vec2(512.,512.);
//return textureLod(s,pos/rres,0.);
return texture2D(s,pos/rres);
}
vec4 getRand(int idx, sampler2D s)//position
{
// ivec2 rres=textureSize(s,0);
ivec2 rres=ivec2(512,512);
idx=int(modI((idx) , (rres.x*rres.y) ) );
return texelFetch(s,rres,ivec2(int(modI((idx),(rres.x))),int(idx/rres.x)));
//return texelFetch(s,textureSize(s,0),ivec2(coord));
}
vec4 getCol(vec2 pos, sampler2D s, vec2 res)
{
// return textureLod(s,pos/res.xy,0.);
return texture2D(s,pos/res.xy);
}
float getVal(vec2 pos, sampler2D s, vec2 res)
{
return dot(getCol(pos,s,res).xyz,vec3(1.)/3.);
}
vec2 getGrad(vec2 pos, float eps, sampler2D s, vec2 res)
{
vec2 d=vec2(eps,0);
return vec2(
getVal(pos+d.xy,s,res)-getVal(pos-d.xy,s,res),
getVal(pos+d.yx,s,res)-getVal(pos-d.yx,s,res)
)/eps/2.;
}
void main(){
vec2 uvy = gl_FragCoord.xy / resolution.xy;
vec2 uv = gl_FragCoord.xy ;
//float velocity=0.01;
Particle p;
//int idx = particleIdx(uv,iChannelB);
//p=readParticle(p,uv,resolution.xy,iChannelB);
vec4 zzz = texture2D(iChannelB, uvy*1.);
//vec3 test = texture2D(iChannelBRAIN, uvy*1.).xyz;
vec3 begin = texture2D(iChannelBRAIN, vec2( zzz.z, zzz.w ) ).xyz;
vec3 end = texture2D(iChannelBRAIN, vec2( zzz.x , zzz.y ) ).xyz;
vec3 www = texture2D(iChannelC,uvy).xyz;
float tx= www.x;
vec3 next = (1.-tx)*begin + tx*end;
gl_FragColor = vec4(next,www.z);
//gl_FragColor = vec4(test,1.);
//gl_FragColor =zzz;
//gl_FragColor = vec4(zzz.xy,0.,1.);
//
//vec4 test = texture2D(iChannel1,gl_FragCoord.xy);
//vec4 test = vec4(1.0, 0.0, 0.0, 1.);
//vec4 test = vec4(1.0,0.0,0.0,1.);
//gl_FragColor = vec4(zzz,1.);
}
uniform int iFrame;
uniform sampler2D iChannelB;
uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
uniform vec2 resolution;
varying vec2 vUv;
const float sizeGlob = 256.;
const int PNUM = 200;
struct Particle // user defined structure.
{
vec2 pos;
vec2 pos2;
int idx;
};
#define N(v) (v.yx*vec2(1,-1))
int modI(int a,int b) {
float m=float(a)-floor((float(a)+0.5)/float(b))*float(b);
return int(floor(m+0.5));
}
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
vec4 texelFetch(sampler2D tex, ivec2 size, ivec2 coord)
{
return texture2D(tex, vec2((float(coord.x)-0.5) / float(size.x), (float(coord.y)-0.5) / float(size.y)));
}
int particleIdx(vec2 coord, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return int(coord.x)+int(coord.y)*ires.x;
}
vec2 particleCoord(int idx, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return vec2(modI((idx),(ires.x)),idx/ires.x)+.5;
}
vec4 getPixel(vec2 coord, sampler2D s)
{
return texelFetch(s,textureSize(s,0),ivec2(coord));
}
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
Particle readParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=pix.xy;
p.pos2=pix.zw;
p.idx=particleIdx(coord,s);
return p;
}
vec4 getRand(vec2 pos, sampler2D s)//velocity
{
//vec2 rres=vec2(textureSize(s,0));
vec2 rres=vec2(512.,512.);
//return textureLod(s,pos/rres,0.);
return texture2D(s,pos/rres);
}
vec4 getRand(int idx, sampler2D s)//position
{
// ivec2 rres=textureSize(s,0);
ivec2 rres=ivec2(512,512);
idx=int(modI((idx) , (rres.x*rres.y) ) );
return texelFetch(s,rres,ivec2(int(modI((idx),(rres.x))),int(idx/rres.x)));
//return texelFetch(s,textureSize(s,0),ivec2(coord));
}
vec4 getCol(vec2 pos, sampler2D s, vec2 res)
{
// return textureLod(s,pos/res.xy,0.);
return texture2D(s,pos/res.xy);
}
float getVal(vec2 pos, sampler2D s, vec2 res)
{
return dot(getCol(pos,s,res).xyz,vec3(1.)/3.);
}
vec2 getGrad(vec2 pos, float eps, sampler2D s, vec2 res)
{
vec2 d=vec2(eps,0);
return vec2(
getVal(pos+d.xy,s,res)-getVal(pos-d.xy,s,res),
getVal(pos+d.yx,s,res)-getVal(pos-d.yx,s,res)
)/eps/2.;
}
void main(){
vec2 uvy = gl_FragCoord.xy/resolution.xy;
vec2 uv = gl_FragCoord.xy ;
//float velocity=0.01;
Particle p;
//int idx = particleIdx(uv,iChannelB);
//p=readParticle(p,uv,resolution.xy,iChannelB);
vec4 zzz = texture2D(iChannelB, uvy*1.);
//vec3 test = texture2D(iChannelBRAIN, uvy*1.).xyz;
vec3 begin = texture2D(iChannelBRAIN, vec2( zzz.z, zzz.w ) ).xyz;
vec3 end = texture2D(iChannelBRAIN, vec2( zzz.x , zzz.y ) ).xyz;
vec3 www = texture2D(iChannelC,uvy).xyz;
float tx= www.x;
vec3 next = (1.-tx)*begin + tx*end;
gl_FragColor = vec4(next,www.z);
//gl_FragColor = vec4(test,1.);
//gl_FragColor =zzz;
//gl_FragColor = vec4(zzz.xy,0.,1.);
//
//vec4 test = texture2D(iChannelB , gl_FragCoord.xy/resolution.xy);
//vec4 test = vec4(1.0, 0.0, 0.0, 1.);
//vec4 test = vec4(1.0,0.0,0.0,1.);
//gl_FragColor = vec4(test.xyz,1.);
}
uniform int iFrame;
//uniform sampler2D iChannelB;
//uniform sampler2D iChannelA;
//uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
uniform sampler2D iChannelVICINI;
uniform sampler2D iChannelVICINI_B;
uniform sampler2D iChannelVICINI_C;
uniform sampler2D iChannelVICINI_D;
const int PNUM = 200;
const float sizeGlob = 256.;
struct Particle // user defined structure.
{
vec2 pos;
vec2 pos2;
int idx;
};
#define N(v) (v.yx*vec2(1,-1))
int modI(int a,int b) {
float m=float(a)-floor((float(a)+0.5)/float(b))*float(b);
return int(floor(m+0.5));
}
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
vec4 texelFetch(sampler2D tex, ivec2 size, ivec2 coord)
{
return texture2D(tex, vec2((float(coord.x)-0.5) / float(size.x), (float(coord.y)-0.5) / float(size.y)));
}
int particleIdx(vec2 coord, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return int(coord.x)+int(coord.y)*ires.x;
}
vec2 particleCoord(int idx, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return vec2(modI(idx,ires.x),idx/ires.x)+.5;
}
vec4 getPixel(vec2 coord, sampler2D s)
{
return texelFetch(s,textureSize(s,0),ivec2(coord));
}
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
Particle readParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=pix.xy;
p.pos2=pix.zw;
p.idx=particleIdx(coord,s);
return p;
}
Particle initParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=vec2(0.,0.);
p.pos2=vec2(155./256., 206./256.);
p.idx=particleIdx(coord,s);
return p;
}
Particle updatePos(Particle p, vec2 coord, vec2 size, sampler2D s,vec2 coord2)
{
vec4 pix=texture2D(s, vec2(((coord2.x)) / (size.x), ((coord2.y)) / (size.y)));
vec2 fp=pix.zw;
p.pos=fp;
p.pos2=coord/(size);
return p;
}
vec4 writeParticle(Particle p, vec2 coord)
{
vec4 col=vec4(0.);
//if ( modI( (particleIdx(coord)), (PNUM) ) == p.idx )
col=vec4(p.pos,p.pos2);
return col;
}
vec4 getRand(vec2 pos, sampler2D s)//velocity
{
//vec2 rres=vec2(textureSize(s,0));
vec2 rres=vec2(512.,512.);
//return textureLod(s,pos/rres,0.);
return texture2D(s,pos/rres);
}
vec4 getRand(int idx, sampler2D s)//position
{
// ivec2 rres=textureSize(s,0);
ivec2 rres=ivec2(512,512);
idx=int(modI((idx) , (rres.x*rres.y) ) );
return texelFetch(s,rres,ivec2(int(modI((idx),(rres.x))),int(idx/rres.x)));
//return texelFetch(s,textureSize(s,0),ivec2(coord));
}
void main(){
vec2 uvy = gl_FragCoord.xy / resolution.xy;
vec2 uv = gl_FragCoord.xy ;
float velocity=0.01;
//int idx = particleIdx(uv,iChannelB);
//p=readParticle(p,uv,resolution,iChannelB);
//vec3 test=vec3(0.);
vec4 CC = texture2D(iChannelC, uvy*1.).xyzw;
float Tlife=CC.x;
vec4 pos2x = texture2D(iChannelB,uvy);
vec2 origin=vec2(120./255.,70./255.);
if (iFrame < 2) pos2x=texture2D(iChannelB,origin);//vec4(pos2x.z*0.8+1./255.,pos2x.w*0.8+1./255.,pos2x.z*0.+1./255.,pos2x.w*0.+1./255.);
//vec4 vicini = texture2D(iChannelVICINI, uvy );
//vec4 vicini_B = texture2D(iChannelVICINI_B, uvy );
//float vx=1.*CC.w;
//float vx2=0.2*CC.w;
float nofp=0.5;
float va=rand(pos2x.xy*0.8+7.13*float(iFrame));
float va2=rand(pos2x.xy*0.2+3.13*float(iFrame));
vec2 zz= step(vec2(1.,1.)*nofp,vec2(va,va2) );
float vx=1.*rand(zz+256.*CC.w);
float vx2=0.2*rand(zz+133.*CC.w);
//float vx2=1.*rand(zz+133.*CC.w);
if(Tlife>=1.) {
Particle p;
vec4 vicini = texture2D(iChannelVICINI, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_B = texture2D(iChannelVICINI_B, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_C = texture2D(iChannelVICINI_C, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_D = texture2D(iChannelVICINI_D, vec2( pos2x.x , pos2x.y ) );
vec2 INDnb=pos2x.xy;
int numofneig=0;
int where=0;
float v1=rand(uv*0.8+7.13*float(iFrame));
float v2=rand(uv*0.7+0.2*float(iFrame));
float v3=rand(uv*0.6+0.3*float(iFrame));
float v4=rand(uv*0.5+0.4*float(iFrame));
float v5=rand(uv*0.4+0.5*float(iFrame));
float v6=rand(uv*0.3+0.6*float(iFrame));
float v7=rand(uv*0.2+0.7*float(iFrame));
float v8=rand(uv*0.1+0.8*float(iFrame));
vec4 dir0 = texture2D(iChannelBRAIN, vec2(vx,vx2));
vec4 dirX = texture2D(iChannelBRAIN, uvy);
vec4 dirA = texture2D(iChannelBRAIN, vicini.xy/255. );
vec4 dirA2 = texture2D(iChannelBRAIN, vicini.zw/255.);
vec4 dirB = texture2D(iChannelBRAIN, vicini_B.xy/255. );
vec4 dirB2 = texture2D(iChannelBRAIN, vicini_B.zw/255. );
vec4 dirC = texture2D(iChannelBRAIN, vicini_C.xy/255. );
vec4 dirC2 = texture2D(iChannelBRAIN, vicini_C.zw/255. );
vec4 dirD = texture2D(iChannelBRAIN, vicini_D.xy/255.);
vec4 dirD2 = texture2D(iChannelBRAIN, vicini_D.zw/255. );
if(CC.z > 0.15 )
dir0=dirX;
//if(CC.z > 0.40 && CC.z < 0.90)
if(false)
dir0.z=dir0.z-300.;
float rfact=0.6;
if(true){
//if(CC.z > 0.15 && CC.z < 0.40 ){
rfact=0.3;
float la= ((1.-rfact)+rfact*rand(dirA.xy+0.43*float(iFrame)) )*length(dirA-dir0);
float la2= ((1.-rfact)+rfact*rand(dirA2.xy+0.43*float(iFrame)) )*length(dirA2-dir0);
float lb=((1.-rfact)+rfact*rand(dirB.xy+0.43*float(iFrame)) )* length(dirB-dir0);
float lb2=((1.-rfact)+rfact*rand(dirB2.xy+0.43*float(iFrame)) )* length(dirB2-dir0);
float lc=((1.-rfact)+rfact*rand(dirC.xy+0.43*float(iFrame)) )* length(dirC-dir0);
float lc2=((1.-rfact)+rfact*rand(dirC2.xy+0.43*float(iFrame)) )* length(dirC2-dir0);
float ld=((1.-rfact)+rfact*rand(dirD.xy+0.43*float(iFrame)) )* length(dirD-dir0);
float ld2=((1.-rfact)+rfact*rand(dirD2.xy+0.43*float(iFrame)) )* length(dirD2-dir0);
//if(CC.z > 0.20 && CC.z < 0.40) {
if(false) {
la= ((1.-rfact)+rfact*rand(dirA.xy+0.43*float(iFrame)) )*length(dirA-vec4(dirA.xyz/10.,1.));
la2= ((1.-rfact)+rfact*rand(dirA2.xy+0.43*float(iFrame)) )*length(dirA2-vec4(dirA2.xyz/10.,1.));
lb=((1.-rfact)+rfact*rand(dirB.xy+0.43*float(iFrame)) )* length(dirB-vec4(dirB.xyz/10.,1.));
lb2=((1.-rfact)+rfact*rand(dirB2.xy+0.43*float(iFrame)) )* length(dirB2-vec4(dirB2.xyz/10.,1.));
lc=((1.-rfact)+rfact*rand(dirC.xy+0.43*float(iFrame)) )* length(dirC-vec4(dirC.xyz/10.,1.));
lc2=((1.-rfact)+rfact*rand(dirC2.xy+0.43*float(iFrame)) )* length(dirC2-vec4(dirC2.xyz/10.,1.));
ld=((1.-rfact)+rfact*rand(dirD.xy+0.43*float(iFrame)) )* length(dirD-vec4(dirD.xyz/10.,1.));
ld2=((1.-rfact)+rfact*rand(dirD2.xy+0.43*float(iFrame)) )* length(dirD2-vec4(dirD2.xyz/10.,1.));
}
float mx = max( max( max(la,la2),max(lb,lb2) ), max( max(lc,lc2),max(ld,ld2) ) );
float minx = min( min( min(la,la2),min(lb,lb2) ), min( min(lc,lc2),min(ld,ld2) ) );
//if(CC.z > 0.15)
if(false)
mx=minx;
if( (mx-la) < 0.01 ){
INDnb=(vicini.xy/255.);
}else if( (mx-la2) < 0.01 ){
INDnb=(vicini.zw/255.);
}else if( (mx-lb) < 0.01 ){
INDnb=(vicini_B.xy/255.);
}else if( (mx-lb2) < 0.01 ){
INDnb=(vicini_B.zw/255.);
}else if( (mx-lc) < 0.01 ){
INDnb=(vicini_C.xy/255.);
}else if( (mx-lc2) < 0.01 ){
INDnb=(vicini_C.zw/255.);
}else if( (mx-ld) < 0.01 ){
INDnb=(vicini_D.xy/255.);
}else if( (mx-ld2) < 0.01 ){
INDnb=(vicini_D.zw/255.);
}
}
// 0 + 10 + 15 + 20 + 40 + 50
//COMPLX + DIVERGE + EXTERNAL + LINE + CONVERGE + DIVERGE
//if(CC.z < 0.1 || ((CC.z > 0.15 && CC.z < 0.40 ) && v1 < 0.5) || ((CC.z > 0.40 && CC.z < 0.90 ) && v1 < 0.5) ){
if(false){
if( (length(vicini.xy-pos2x.zw*255.)> 1.)
&& (length(vicini.xy-pos2x.xy*255.)> 1. )
&& v1 < 0.2
){
numofneig=numofneig+1;
where+=1;
INDnb=(vicini.xy/255.);
}
if( (length(vicini.zw-pos2x.zw*255.)> 1.)
&& (length(vicini.zw-pos2x.xy*255.)> 1.)
&& v2 < 0.3
){
numofneig=numofneig+1;
where+=2;
INDnb=(vicini.zw/255.);
}
if( (length(vicini_B.xy-pos2x.zw*255.) > 1.)
&& (length(vicini_B.xy-pos2x.xy*255.) > 1.)
&& v3 < 0.4
){
numofneig=numofneig+1;
where+=5;
INDnb=(vicini_B.xy/255.);
}
if( (length(vicini_B.zw-pos2x.zw*255.) > 1.)
&& (length(vicini_B.zw-pos2x.xy*255.) > 1.)
&& v4 < 0.5
){
numofneig=numofneig+1;
where+=10;
INDnb=(vicini_B.zw/255.);
}
if( (length(vicini_C.xy-pos2x.zw*255.)> 1.)
&& (length(vicini_C.xy-pos2x.xy*255.)> 1.)
&& v5 < 0.5
){
numofneig=numofneig+1;
where+=20;
INDnb=(vicini_C.xy/255.);
}
if( (length(vicini_C.zw-pos2x.zw*255.)> 1.01)
&& (length(vicini_C.zw-pos2x.xy*255.)> 1.01)
&& v6 < 0.5
){
numofneig=numofneig+1;
where+=50;
INDnb=(vicini_C.zw/255.);
}
if( (length(vicini_D.xy-pos2x.zw*255.)> 1.01)
&& (length(vicini_D.xy-pos2x.xy*255.)> 1.01)
&& v7 < 0.6
){
numofneig=numofneig+1;
where+=100;
INDnb=(vicini_D.xy/255.);
}
if( (length(vicini_D.zw-pos2x.zw*255.)>1.01)
&& (length(vicini_D.zw-pos2x.xy*255.)>1.01)
&& v8 < 0.6
){
numofneig=numofneig+1;
where+=200;
INDnb=(vicini_D.zw/255.);
}
}
if(CC.z<=0.0001){
INDnb=vec2(vx,vx2);
}
p.pos=pos2x.xy;
p.pos2=INDnb;
gl_FragColor=vec4( p.pos2.x , p.pos2.y , p.pos.x , p.pos.y);
}else{
if(CC.z<=0.0001){
pos2x.xy=vec2(vx,vx2);
}
//gl_FragColor=vec4( pos2x.x , pos2x.y , float(ind_prev)/7. , pos2x.w);
gl_FragColor=pos2x;
}
//gl_FragColor=vec4(uvy.x,uvy.y,0.,1.);
//gl_FragColor=vec4(vicini.x/255.,vicini.y/255.,0.,1.);
//vec3 zzz = texture2D(iChannelBRAIN, uv*1.).xyz;
//gl_FragColor=writeParticle(p,uvy);
//gl_FragColor = vec4(vicini);
}
uniform int iFrame;
//uniform sampler2D iChannelB;
//uniform sampler2D iChannelA;
//uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
uniform sampler2D iChannelVICINI;
uniform sampler2D iChannelVICINI_B;
uniform sampler2D iChannelVICINI_C;
uniform sampler2D iChannelVICINI_D;
const int PNUM = 200;
const float sizeGlob = 256.;
struct Particle // user defined structure.
{
vec2 pos;
vec2 pos2;
int idx;
};
#define N(v) (v.yx*vec2(1,-1))
int modI(int a,int b) {
float m=float(a)-floor((float(a)+0.5)/float(b))*float(b);
return int(floor(m+0.5));
}
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
vec4 texelFetch(sampler2D tex, ivec2 size, ivec2 coord)
{
return texture2D(tex, vec2((float(coord.x)-0.5) / float(size.x), (float(coord.y)-0.5) / float(size.y)));
}
int particleIdx(vec2 coord, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return int(coord.x)+int(coord.y)*ires.x;
}
vec2 particleCoord(int idx, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return vec2(modI(idx,ires.x),idx/ires.x)+.5;
}
vec4 getPixel(vec2 coord, sampler2D s)
{
return texelFetch(s,textureSize(s,0),ivec2(coord));
}
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
Particle readParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=pix.xy;
p.pos2=pix.zw;
p.idx=particleIdx(coord,s);
return p;
}
Particle initParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=vec2(0.,0.);
p.pos2=vec2(155./256., 206./256.);
p.idx=particleIdx(coord,s);
return p;
}
Particle updatePos(Particle p, vec2 coord, vec2 size, sampler2D s,vec2 coord2)
{
vec4 pix=texture2D(s, vec2(((coord2.x)) / (size.x), ((coord2.y)) / (size.y)));
vec2 fp=pix.zw;
p.pos=fp;
p.pos2=coord/(size);
return p;
}
vec4 writeParticle(Particle p, vec2 coord)
{
vec4 col=vec4(0.);
//if ( modI( (particleIdx(coord)), (PNUM) ) == p.idx )
col=vec4(p.pos,p.pos2);
return col;
}
void main(){
vec2 uvy = gl_FragCoord.xy / resolution.xy;
vec2 uv = gl_FragCoord.xy ;
float velocity=0.01;
//int idx = particleIdx(uv,iChannelB);
//p=readParticle(p,uv,resolution,iChannelB);
//vec3 test=vec3(0.);
vec4 CC = texture2D(iChannelC, uvy*1.).xyzw;
float Tlife=CC.x;
vec4 pos2x = texture2D(iChannelB,uvy);
vec2 origin=vec2(120./255.,70./255.);
if (iFrame < 2) pos2x=texture2D(iChannelB,origin);//vec4(pos2x.z*0.8+1./255.,pos2x.w*0.8+1./255.,pos2x.z*0.+1./255.,pos2x.w*0.+1./255.);
//vec4 vicini = texture2D(iChannelVICINI, uvy );
//vec4 vicini_B = texture2D(iChannelVICINI_B, uvy );
//float vx=1.*CC.w;
//float vx2=0.2*CC.w;
float nofp=0.5;
float va=rand(pos2x.xy*0.8+7.13*float(iFrame));
float va2=rand(pos2x.xy*0.2+3.13*float(iFrame));
vec2 zz= step(vec2(1.,1.)*nofp,vec2(va,va2) );
float vx=1.*rand(zz+256.*CC.w);
float vx2=0.2*rand(zz+133.*CC.w);
//float vx2=1.*rand(zz+133.*CC.w);
if(Tlife>=1.) {
Particle p;
vec4 vicini = texture2D(iChannelVICINI, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_B = texture2D(iChannelVICINI_B, vec2( pos2x.x , pos2x.y ) );
//vec4 vicini_C = texture2D(iChannelVICINI_C, vec2( pos2x.x , pos2x.y ) );
//vec4 vicini_D = texture2D(iChannelVICINI_D, vec2( pos2x.x , pos2x.y ) );
vec2 INDnb=pos2x.xy;
int numofneig=0;
int where=0;
vec4 dir0 = texture2D(iChannelBRAIN, vec2(vx,vx2));
vec4 dirX = texture2D(iChannelBRAIN, uvy);
vec4 dirA = texture2D(iChannelBRAIN, vicini.xy/255. );
vec4 dirA2 = texture2D(iChannelBRAIN, vicini.zw/255.);
vec4 dirB = texture2D(iChannelBRAIN, vicini_B.xy/255. );
vec4 dirB2 = texture2D(iChannelBRAIN, vicini_B.zw/255. );
//vec4 dirC = texture2D(iChannelBRAIN, vicini_C.xy/255. );
//vec4 dirC2 = texture2D(iChannelBRAIN, vicini_C.zw/255. );
//vec4 dirD = texture2D(iChannelBRAIN, vicini_D.xy/255.);
//vec4 dirD2 = texture2D(iChannelBRAIN, vicini_D.zw/255. );
if(CC.z > 0.15 )
dir0=dirX;
float rfact=0.6;
if(true){
rfact=0.3;
float la= ((1.-rfact)+rfact*rand(dirA.xy+0.43*float(iFrame)) )*length(dirA-dir0);
float la2= ((1.-rfact)+rfact*rand(dirA2.xy+0.43*float(iFrame)) )*length(dirA2-dir0);
float lb=((1.-rfact)+rfact*rand(dirB.xy+0.43*float(iFrame)) )* length(dirB-dir0);
float lb2=((1.-rfact)+rfact*rand(dirB2.xy+0.43*float(iFrame)) )* length(dirB2-dir0);
float mx = max( max(la,la2),max(lb,lb2) ) ;
if( (mx-la) < 0.01 ){
INDnb=(vicini.xy/255.);
}else if( (mx-la2) < 0.01 ){
INDnb=(vicini.zw/255.);
}else if( (mx-lb) < 0.01 ){
INDnb=(vicini_B.xy/255.);
}else if( (mx-lb2) < 0.01 ){
INDnb=(vicini_B.zw/255.);
}
}
if(CC.z<=0.0001){
INDnb=vec2(vx,vx2);
}
p.pos=pos2x.xy;
p.pos2=INDnb;
gl_FragColor=vec4( p.pos2.x , p.pos2.y , p.pos.x , p.pos.y);
}else{
if(CC.z<=0.0001){
pos2x.xy=vec2(vx,vx2);
}
//gl_FragColor=vec4( pos2x.x , pos2x.y , float(ind_prev)/7. , pos2x.w);
gl_FragColor=pos2x;
}
//gl_FragColor=vec4(uvy.x,uvy.y,0.,1.);
//gl_FragColor=vec4(vicini.x/255.,vicini.y/255.,0.,1.);
//vec3 zzz = texture2D(iChannelBRAIN, uv*1.).xyz;
//gl_FragColor=writeParticle(p,uvy);
//gl_FragColor = vec4(vicini);
}
uniform int iFrame;
uniform sampler2D iChannelB;
uniform sampler2D iChannelA;
uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
uniform sampler2D iChannelVICINI;
uniform sampler2D iChannelVICINI_B;
uniform sampler2D iChannelVICINI_C;
uniform sampler2D iChannelVICINI_D;
uniform vec2 resolution;
varying vec2 vUv;
const int PNUM = 200;
const float sizeGlob = 256.;
struct Particle // user defined structure.
{
vec2 pos;
vec2 pos2;
int idx;
};
#define N(v) (v.yx*vec2(1,-1))
int modI(int a,int b) {
float m=float(a)-floor((float(a)+0.5)/float(b))*float(b);
return int(floor(m+0.5));
}
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
vec4 texelFetch(sampler2D tex, ivec2 size, ivec2 coord)
{
return texture2D(tex, vec2((float(coord.x)-0.5) / float(size.x), (float(coord.y)-0.5) / float(size.y)));
}
int particleIdx(vec2 coord, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return int(coord.x)+int(coord.y)*ires.x;
}
vec2 particleCoord(int idx, sampler2D s)
{
ivec2 ires=textureSize(s,0);
return vec2(modI(idx,ires.x),idx/ires.x)+.5;
}
vec4 getPixel(vec2 coord, sampler2D s)
{
return texelFetch(s,textureSize(s,0),ivec2(coord));
}
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
Particle readParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=pix.xy;
p.pos2=pix.zw;
p.idx=particleIdx(coord,s);
return p;
}
Particle initParticle(Particle p, vec2 coord, vec2 size, sampler2D s)
{
vec4 pix=texture2D(s, vec2(((coord.x)) / (size.x), ((coord.y)) / (size.y)));
p.pos=vec2(0.,0.);
p.pos2=vec2(155./256., 206./256.);
p.idx=particleIdx(coord,s);
return p;
}
Particle updatePos(Particle p, vec2 coord, vec2 size, sampler2D s,vec2 coord2)
{
vec4 pix=texture2D(s, vec2(((coord2.x)) / (size.x), ((coord2.y)) / (size.y)));
vec2 fp=pix.zw;
p.pos=fp;
p.pos2=coord/(size);
return p;
}
vec4 writeParticle(Particle p, vec2 coord)
{
vec4 col=vec4(0.);
//if ( modI( (particleIdx(coord)), (PNUM) ) == p.idx )
col=vec4(p.pos,p.pos2);
return col;
}
vec4 getRand(vec2 pos, sampler2D s)//velocity
{
//vec2 rres=vec2(textureSize(s,0));
vec2 rres=vec2(512.,512.);
//return textureLod(s,pos/rres,0.);
return texture2D(s,pos/rres);
}
vec4 getRand(int idx, sampler2D s)//position
{
// ivec2 rres=textureSize(s,0);
ivec2 rres=ivec2(512,512);
idx=int(modI((idx) , (rres.x*rres.y) ) );
return texelFetch(s,rres,ivec2(int(modI((idx),(rres.x))),int(idx/rres.x)));
//return texelFetch(s,textureSize(s,0),ivec2(coord));
}
void main(){
vec2 uvy = gl_FragCoord.xy/resolution.xy;
vec2 uv = gl_FragCoord.xy ;
float velocity=0.01;
//int idx = particleIdx(uv,iChannelB);
//p=readParticle(p,uv,resolution,iChannelB);
//vec3 test=vec3(0.);
vec4 CC = texture2D(iChannelC, uvy*1.).xyzw;
float Tlife=CC.x;
vec4 pos2x = texture2D(iChannelB,uvy);
vec2 origin=vec2(120./255.,70./255.);
if (iFrame < 2) pos2x=texture2D(iChannelB,origin);//vec4(pos2x.z*0.8+1./255.,pos2x.w*0.8+1./255.,pos2x.z*0.+1./255.,pos2x.w*0.+1./255.);
//vec4 vicini = texture2D(iChannelVICINI, uvy );
//vec4 vicini_B = texture2D(iChannelVICINI_B, uvy );
//float vx=1.*CC.w;
//float vx2=0.2*CC.w;
float nofp=0.5;
float va=rand(uv*pos2x.xy*0.8+7.13*float(iFrame));
float va2=rand(uv*pos2x.xy*0.2+3.13*float(iFrame));
vec2 zz= step(vec2(1.,1.)*nofp,vec2(va,va2) );
float vx=1.*rand(uv*zz+256.*va*CC.w);
float vx2=0.2*rand(uv*zz+133.*va2*CC.w);
//float vx2=1.*rand(zz+133.*CC.w);
if(Tlife>=1.) {
Particle p;
vec4 vicini = texture2D(iChannelVICINI, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_B = texture2D(iChannelVICINI_B, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_C = texture2D(iChannelVICINI_C, vec2( pos2x.x , pos2x.y ) );
vec4 vicini_D = texture2D(iChannelVICINI_D, vec2( pos2x.x , pos2x.y ) );
vec2 INDnb=pos2x.xy;
int numofneig=0;
int where=0;
float v1=rand(uv*0.8*7.13*float(iFrame));
float v2=rand(uv*0.7*0.2*float(iFrame));
float v3=rand(uv*0.6*0.3*float(iFrame));
float v4=rand(uv*0.5*0.4*float(iFrame));
float v5=rand(uv*0.4*0.5*float(iFrame));
float v6=rand(uv*0.3*0.6*float(iFrame));
float v7=rand(uv*0.2*0.7*float(iFrame));
float v8=rand(uv*0.1*0.8*float(iFrame));
vec4 dir0 = texture2D(iChannelBRAIN, vec2(vx,vx2));
vec4 dirX = texture2D(iChannelBRAIN, uvy);
vec4 dirA = texture2D(iChannelBRAIN, vicini.xy/255. );
vec4 dirA2 = texture2D(iChannelBRAIN, vicini.zw/255.);
vec4 dirB = texture2D(iChannelBRAIN, vicini_B.xy/255. );
vec4 dirB2 = texture2D(iChannelBRAIN, vicini_B.zw/255. );
vec4 dirC = texture2D(iChannelBRAIN, vicini_C.xy/255. );
vec4 dirC2 = texture2D(iChannelBRAIN, vicini_C.zw/255. );
vec4 dirD = texture2D(iChannelBRAIN, vicini_D.xy/255.);
vec4 dirD2 = texture2D(iChannelBRAIN, vicini_D.zw/255. );
if(CC.z > 0.15 )
dir0=dirX;
//if(CC.z > 0.40 && CC.z < 0.90)
if(false)
dir0.z=dir0.z-300.;
float rfact=0.6;
if(true){
//if(CC.z > 0.15 && CC.z < 0.40 ){
rfact=0.3;
float la= ((1.-rfact)+rfact*rand(dirA.xy+0.43*float(iFrame)) )*length(dirA-dir0);
float la2= ((1.-rfact)+rfact*rand(uv*dirA2.xy+0.43*float(iFrame)) )*length(dirA2-dir0);
float lb=((1.-rfact)+rfact*rand(dirB.xy+0.43*float(iFrame)) )* length(dirB-dir0);
float lb2=((1.-rfact)+rfact*rand(uv*dirB2.xy+0.43*float(iFrame)) )* length(dirB2-dir0);
float lc=((1.-rfact)+rfact*rand(dirC.xy+0.43*float(iFrame)) )* length(dirC-dir0);
float lc2=((1.-rfact)+rfact*rand(uv*dirC2.xy+0.43*float(iFrame)) )* length(dirC2-dir0);
float ld=((1.-rfact)+rfact*rand(dirD.xy+0.43*float(iFrame)) )* length(dirD-dir0);
float ld2=((1.-rfact)+rfact*rand(dirD2.xy+0.43*float(iFrame)) )* length(dirD2-dir0);
//if(CC.z > 0.20 && CC.z < 0.40) {
if(false) {
la= ((1.-rfact)+rfact*rand(dirA.xy+0.43*float(iFrame)) )*length(dirA-vec4(dirA.xyz/10.,1.));
la2= ((1.-rfact)+rfact*rand(uv*dirA2.xy+0.43*float(iFrame)) )*length(dirA2-vec4(dirA2.xyz/10.,1.));
lb=((1.-rfact)+rfact*rand(dirB.xy+0.43*float(iFrame)) )* length(dirB-vec4(dirB.xyz/10.,1.));
lb2=((1.-rfact)+rfact*rand(uv*dirB2.xy+0.43*float(iFrame)) )* length(dirB2-vec4(dirB2.xyz/10.,1.));
lc=((1.-rfact)+rfact*rand(dirC.xy+0.43*float(iFrame)) )* length(dirC-vec4(dirC.xyz/10.,1.));
lc2=((1.-rfact)+rfact*rand(uv*dirC2.xy+0.43*float(iFrame)) )* length(dirC2-vec4(dirC2.xyz/10.,1.));
ld=((1.-rfact)+rfact*rand(dirD.xy+0.43*float(iFrame)) )* length(dirD-vec4(dirD.xyz/10.,1.));
ld2=((1.-rfact)+rfact*rand(dirD2.xy+0.43*float(iFrame)) )* length(dirD2-vec4(dirD2.xyz/10.,1.));
}
float mx = max( max( max(la,la2),max(lb,lb2) ), max( max(lc,lc2),max(ld,ld2) ) );
float minx = min( min( min(la,la2),min(lb,lb2) ), min( min(lc,lc2),min(ld,ld2) ) );
//if(CC.z > 0.15)
if(false)
mx=minx;
if( (mx-la) < 0.01 ){
INDnb=(vicini.xy/255.);
}else if( (mx-la2) < 0.01 ){
INDnb=(vicini.zw/255.);
}else if( (mx-lb) < 0.01 ){
INDnb=(vicini_B.xy/255.);
}else if( (mx-lb2) < 0.01 ){
INDnb=(vicini_B.zw/255.);
}else if( (mx-lc) < 0.01 ){
INDnb=(vicini_C.xy/255.);
}else if( (mx-lc2) < 0.01 ){
INDnb=(vicini_C.zw/255.);
}else if( (mx-ld) < 0.01 ){
INDnb=(vicini_D.xy/255.);
}else if( (mx-ld2) < 0.01 ){
INDnb=(vicini_D.zw/255.);
}
}
// 0 + 10 + 15 + 20 + 40 + 50
//COMPLX + DIVERGE + EXTERNAL + LINE + CONVERGE + DIVERGE
//if(CC.z < 0.1 || ((CC.z > 0.15 && CC.z < 0.40 ) && v1 < 0.5) || ((CC.z > 0.40 && CC.z < 0.90 ) && v1 < 0.5) ){
if(false){
if( (length(vicini.xy-pos2x.zw*255.)> 1.)
&& (length(vicini.xy-pos2x.xy*255.)> 1. )
&& v1 < 0.2
){
numofneig=numofneig+1;
where+=1;
INDnb=(vicini.xy/255.);
}
if( (length(vicini.zw-pos2x.zw*255.)> 1.)
&& (length(vicini.zw-pos2x.xy*255.)> 1.)
&& v2 < 0.3
){
numofneig=numofneig+1;
where+=2;
INDnb=(vicini.zw/255.);
}
if( (length(vicini_B.xy-pos2x.zw*255.) > 1.)
&& (length(vicini_B.xy-pos2x.xy*255.) > 1.)
&& v3 < 0.4
){
numofneig=numofneig+1;
where+=5;
INDnb=(vicini_B.xy/255.);
}
if( (length(vicini_B.zw-pos2x.zw*255.) > 1.)
&& (length(vicini_B.zw-pos2x.xy*255.) > 1.)
&& v4 < 0.5
){
numofneig=numofneig+1;
where+=10;
INDnb=(vicini_B.zw/255.);
}
if( (length(vicini_C.xy-pos2x.zw*255.)> 1.)
&& (length(vicini_C.xy-pos2x.xy*255.)> 1.)
&& v5 < 0.5
){
numofneig=numofneig+1;
where+=20;
INDnb=(vicini_C.xy/255.);
}
if( (length(vicini_C.zw-pos2x.zw*255.)> 1.01)
&& (length(vicini_C.zw-pos2x.xy*255.)> 1.01)
&& v6 < 0.5
){
numofneig=numofneig+1;
where+=50;
INDnb=(vicini_C.zw/255.);
}
if( (length(vicini_D.xy-pos2x.zw*255.)> 1.01)
&& (length(vicini_D.xy-pos2x.xy*255.)> 1.01)
&& v7 < 0.6
){
numofneig=numofneig+1;
where+=100;
INDnb=(vicini_D.xy/255.);
}
if( (length(vicini_D.zw-pos2x.zw*255.)>1.01)
&& (length(vicini_D.zw-pos2x.xy*255.)>1.01)
&& v8 < 0.6
){
numofneig=numofneig+1;
where+=200;
INDnb=(vicini_D.zw/255.);
}
}
if(CC.z<=0.001){
INDnb=vec2(vx,vx2);
}
p.pos=pos2x.xy;
p.pos2=INDnb;
gl_FragColor=vec4( p.pos2.x , p.pos2.y , p.pos.x , p.pos.y);
}else{
if(CC.z<=0.001){
pos2x.xy=vec2(vx,vx2);
}
//gl_FragColor=vec4( pos2x.x , pos2x.y , float(ind_prev)/7. , pos2x.w);
gl_FragColor=pos2x;
}
//gl_FragColor=vec4(uvy.x,uvy.y,0.,1.);
//gl_FragColor=vec4(vicini.x/255.,vicini.y/255.,0.,1.);
//vec3 zzz = texture2D(iChannelBRAIN, uvy*1.).xyz;
//gl_FragColor=writeParticle(p,uvy);
//gl_FragColor = vec4(zzz,1.);
}
uniform int iFrame;
//uniform sampler2D iChannelB;
//uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
const int PNUM = 200;
const float sizeGlob = 256.;
#define N(v) (v.yx*vec2(1,-1))
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
vec4 getRand(vec2 pos, sampler2D s)//velocity
{
//vec2 rres=vec2(textureSize(s,0));
vec2 rres=vec2(512.,512.);
//return textureLod(s,pos/rres,0.);
return texture2D(s,pos/rres);
}
void main(){
vec2 uvy = gl_FragCoord.xy / resolution.xy;
vec2 uv = gl_FragCoord.xy ;
vec4 col = texture2D(iChannelC, uvy*1.).xyzw;
float vx=col.w;
if (iFrame < 2) {
col.y =7.*(0.01);
vx=0.01;
}
col.z=col.z+0.6/254.;
if(col.z>0.999){
col.z=0.;
}
if (col.z < 0.0001 ) {
vx=col.w+0.01;
if(vx>=1.) vx=0.;
}
if(col.x>=1.){
vec2 colB = texture2D(iChannelB, uvy*1.).xy;
col.x=0.;
float v=rand(colB+7.13*float(iFrame));
col.y = 3.*(0.01+0.007*v);
}
col.x=col.x+col.y;
gl_FragColor= vec4( col.xyz, vx );
}
uniform int iFrame;
uniform sampler2D iChannelB;
uniform sampler2D iChannelC;
//uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannelBRAIN;
uniform vec2 resolution;
varying vec2 vUv;
const int PNUM = 200;
const float sizeGlob = 256.;
#define N(v) (v.yx*vec2(1,-1))
float rand(vec2 co){
return fract(sin(dot(co.xy, vec2(12.8273, 67.245))) * 53726.17623);
}
vec4 getRand(vec2 pos, sampler2D s)//velocity
{
//vec2 rres=vec2(textureSize(s,0));
vec2 rres=vec2(512.,512.);
//return textureLod(s,pos/rres,0.);
return texture2D(s,pos/rres);
}
void main(){
vec2 uvy = gl_FragCoord.xy/resolution.xy;
vec2 uv = gl_FragCoord.xy ;
vec4 col = texture2D(iChannelC, uvy*1.).xyzw;
float vx=col.w;
if (iFrame < 2) {
col.y =7.*(0.01);
vx=0.01;
}
col.z=col.z+4./254.;
if(col.z>0.999){
col.z=0.;
}
if (col.z < 0.0001 ) {
vx=col.w+0.01;
if(vx>=1.) vx=0.;
}
if(col.x>=1.){
vec2 colB = texture2D(iChannelB, uvy*1.).xy;
col.x=0.;
float v=rand(uvy*colB*7.13*float(iFrame));
col.y = 3.*(0.01+0.04*v);
}
col.x=col.x+col.y;
gl_FragColor= vec4( col.xyz, vx );
}
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1);
}
const float sizeGlob = 256.;
varying vec2 uvx;
uniform sampler2D map;
uniform sampler2D iChannelA;
uniform sampler2D iChannelC;
uniform sampler2D iChannelBRAIN;
uniform float opacity;
//uniform sampler2D iChannel1;
uniform float flatu;
uniform int mode;
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
void main() {
vec2 uv = gl_FragCoord.xy /256.;
vec3 color = texture2D(iChannelA, uvx).xyz;
vec3 colorC = texture2D(iChannelA, uvx).xyz;
//vec4 test = vec4(1.,0.2+colorC.z,0.+colorC.z,0.065);
vec4 test = vec4(0.96,0.0,0.505,0.065);
// vec4 test = vec4(0.96*0.3,0.0,0.505*0.3,0.95);
if(mode==0)
test = vec4(0.96,0.0,0.505,0.65);
vec4 pngimg=texture2D( map, gl_PointCoord );
if(pngimg.z > 0.5){
gl_FragColor=test;
gl_FragColor = gl_FragColor * pngimg*flatu;;
}
}
uniform sampler2D iChannelA;
uniform sampler2D iChannelC;
attribute vec2 uvu;
uniform sampler2D iChannelBRAIN;
//uniform sampler2D iChannel1;
varying vec2 uvx;
const float sizeGlob = 256.;
uniform float size;
uniform int mode;
uniform int isfloat;
uniform float flatu;
void main() {
uvx=0.5*position.xy-10.;
//vec3 position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
vec3 position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
float xc=1.;
if(isfloat==0){
position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
}else{
if(mode==1){
position = texture2D(iChannelA, uvu).xyz*39.3*0.4-0.2*39.3;
}else{
xc=1.;
position = texture2D(iChannelA, uvu).xyz*199.3*0.4-0.2*199.3;
}
}
// float scalaz;
vec4 mvPosition = modelViewMatrix * vec4(position.x,position.y,position.z,1.);
// if(-mvPosition.z>2.*fade){
if(length(position)>0.01){
gl_PointSize = xc*size/ length( mvPosition.xyz) ;
gl_Position = projectionMatrix * mvPosition;
}
}
const float sizeGlob = 256.;
uniform float flatu;
uniform float size;
uniform int isfloat;
varying vec2 uvx;
uniform sampler2D map;
uniform sampler2D iChannelA;
uniform sampler2D iChannelC;
uniform sampler2D iChannelBRAIN;
uniform float opacity;
//uniform sampler2D iChannel1;
uniform int mode;
ivec2 textureSize(sampler2D s,int lod){
return ivec2(256,256);
}
void main() {
vec2 uv = gl_FragCoord.xy /256.;
vec3 color = texture2D(iChannelA, uvx).xyz;
vec3 color2 = texture2D(iChannelC, uvx).xyz;
vec4 test = vec4(0.96,0.0,0.505,0.02);
if(mode==1)
test = vec4(1.,0.2,0.,0.04);
vec4 pngimg=texture2D( map, gl_PointCoord );
if(pngimg.w > 0.){
gl_FragColor=test;
gl_FragColor = gl_FragColor * pngimg*flatu;;
}
}
uniform sampler2D iChannelA;
uniform sampler2D iChannelC;
attribute vec2 uvu;
uniform sampler2D iChannelBRAIN;
//uniform sampler2D iChannel1;
varying vec2 uvx;
const float sizeGlob = 256.;
uniform float size;
uniform int mode;
uniform int isfloat;
uniform float flatu;
void main() {
uvx=0.5*position.xy-10.;
vec3 position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
float xc=250.;
if(isfloat==0){
position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
if(mode==1)
xc=5.;
}else{
xc=10.;
if(mode==1){
position = texture2D(iChannelA, uvu).xyz*39.3*0.4-0.2*39.3;
}else{
xc=1.;
position = texture2D(iChannelA, uvu).xyz*199.3*0.4-0.2*199.3;
}
}
float scalaz;
vec3 color2 = texture2D(iChannelC, uvx).xyz;
vec4 mvPosition = modelViewMatrix * vec4(position.x,position.y,position.z,1.);
if(length(uvu) < 0.06 ){
gl_PointSize = xc*size/ length( mvPosition.xyz) ;
gl_Position = projectionMatrix * mvPosition;
}
}
uniform sampler2D iChannelA;
uniform sampler2D iChannelC;
attribute vec2 uvu;
uniform sampler2D iChannelBRAIN;
//uniform sampler2D iChannel1;
varying vec2 uvx;
const float sizeGlob = 256.;
uniform float size;
uniform int mode;
uniform int isfloat;
uniform float flatu;
void main() {
uvx=0.5*position.xy-10.;
vec3 position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
float xc=250.;
if(isfloat==0){
position = texture2D(iChannelA, uvu).xyz*0.4-0.2;
if(mode==1)
xc=5.;
}else{
xc=10.;
if(mode==1){
position = texture2D(iChannelA, uvu).xyz*39.3*0.4-0.2*39.3;
}else{
xc=1.;
position = texture2D(iChannelA, uvu).xyz*199.3*0.4-0.2*199.3;
}
}
float scalaz;
vec3 color2 = texture2D(iChannelC, uvx).xyz;
vec4 mvPosition = modelViewMatrix * vec4(position.x,position.y,position.z,1.);
if(length(uvu) < 0.01 ){
gl_PointSize = xc*size/ length( mvPosition.xyz) ;
gl_Position = projectionMatrix * mvPosition;
}
}
const float sizeGlob = 256.;
uniform float flatu;
uniform float time;
varying vec2 uvx;
uniform sampler2D map;
uniform int resolutionx;
uniform int resolutiony;
uniform float ratio;
void main() {
vec2 uv = gl_FragCoord.xy /256.;
vec4 test = vec4(1.0,1.0,1.,0.9);
vec4 test2 = vec4(0.96,0.0,0.505,0.7);
// vec4 test = texture2D(iChannelA, uv.xy);
vec4 pngimg=texture2D( map, gl_PointCoord );
if(pngimg.w > 0.2){
gl_FragColor=test;
if(length(uvx-3.5*(time/100.)) > 2.8){
gl_FragColor=test2;
}
gl_FragColor = gl_FragColor * pngimg * flatu;
}
}
attribute vec2 reference;
attribute vec2 uvu;
uniform int mode;
uniform float time;
uniform float fade;
uniform float flatu;
varying vec2 uvx;
const float sizeGlob = 256.;
void main() {
uvx=position.xy/100.;
float scalaz;
vec3 pos=position;
// if(mode==1){
pos=position*(1.+1.2*time/100.);
// }
vec4 mvPosition = modelViewMatrix * vec4(2.*pos,1.);
// if(-mvPosition.z>2.*fade){
gl_PointSize = 30./ length( mvPosition.xyz) ;
gl_Position = projectionMatrix * mvPosition;
// }
}
const float sizeGlob = 256.;
uniform float flatu;
varying vec2 uvx;
uniform sampler2D map;
uniform sampler2D iChannelA;
uniform sampler2D iChannelBRAIN;
//uniform sampler2D iChannel1;
uniform int resolutionx;
uniform int resolutiony;
uniform float ratio;
void main() {
vec2 uv = gl_FragCoord.xy /256.;
vec4 test = vec4(0.28,0.28,0.85,0.3);
// vec4 test = texture2D(iChannelA, uv.xy);
vec4 pngimg=texture2D( map, gl_PointCoord );
if(pngimg.z > 0.5){
gl_FragColor=test;
gl_FragColor = 0.5*gl_FragColor * pngimg * flatu;
}
}
attribute vec2 reference;
attribute vec2 uvu;
uniform sampler2D iChannelBRAIN;
//uniform sampler2D iChannel1;
uniform int mode;
uniform float fade;
uniform float size ;
uniform int isfloat;
uniform float flatu;
varying vec2 uvx;
const float sizeGlob = 256.;
void main() {
uvx=0.5*position.xy-10.;
vec3 position;
float xc=70.;
if(isfloat==0){
position = texture2D(iChannelBRAIN, uvu).xyz*0.4-0.2;
}else{
if(mode==1){
xc=70.;
position = texture2D(iChannelBRAIN, uvu).xyz*39.3*0.4-0.2*39.3;
}else{
xc=10.;
position = texture2D(iChannelBRAIN, uvu).xyz*199.3*0.4-0.2*199.3;
}
}
//
//
float scalaz;
//float p=length(0.5-position);
// vec4 mvPosition = modelViewMatrix * vec4(position.x+(1.-flatu)*p,position.y+(1.-flatu)*p,position.z+(1.-flatu)*p,1.);
vec4 mvPosition = modelViewMatrix * vec4(position.x,position.y,position.z,1.);
// if(-mvPosition.z>2.*fade){
gl_PointSize =size* xc/ length( mvPosition.xyz) ;
gl_Position = projectionMatrix * mvPosition;
// }
}
varying vec3 vUv;
uniform sampler2D noise;
uniform float flatu;
void main() {
vec4 pngimg=texture2D( noise,vUv.xy );
float grad=1./(1.+8.*vUv.z);
vec4 test = flatu*vec4(pngimg.x*grad*0.18,pngimg.x*grad*0.18,pngimg.x*grad*0.55,grad);
//vec4 test = vec4(0.28,0.28,0.85,1.);
gl_FragColor=test;
}
varying vec3 vUv;
void main() {
vec3 pos=vec3(position.x,position.y,(0.3*(length(position.y-0.5)*length(position.y-0.5))+0.3*(length(position.x-0.5)*length(position.x-0.5))));
vUv = pos;
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos,1);
}