// FMS_Cat - This Is My Own Sushi !! // GLSL Graphics for Tokyo Demo Fest 2015 // 2015/02/22 // // Greeting: // gyabo #ifdef GL_ES precision mediump float; #endif uniform float time; uniform vec2 resolution; #define ITER 72 #define SITER 32 #define dance (t*1.) #define t time #define r resolution.xy #define v vec2(0.,1.) #define cl(i) clamp(i,0.,1.) #define PI 3.1415926 float hash(vec2 _v) { return fract(sin(dot(_v,vec2(89.44,19.36)))*229.22); } float iHash(vec2 _v,vec2 _r) { float h00 = hash(vec2(floor(_v*_r+v.xx)/_r)); float h10 = hash(vec2(floor(_v*_r+v.yx)/_r)); float h01 = hash(vec2(floor(_v*_r+v.xy)/_r)); float h11 = hash(vec2(floor(_v*_r+v.yy)/_r)); vec2 ip = vec2(smoothstep(v.xx,v.yy,mod(_v*_r,1.))); return (h00*(1.-ip.x)+h10*ip.x)*(1.-ip.y)+(h01*(1.-ip.x)+h11*ip.x)*ip.y; } float noise(vec2 _v) { float sum = 0.; for(int i=1; i<6; i++) { sum += iHash(_v+vec2(i),vec2(2.*pow(2.,float(i))))/pow(2.,float(i)); } return sum; } float noiseT(vec2 _v) { float sum = 0.; for(int i=1; i<6; i++) { sum += iHash(_v+vec2(i)*t,vec2(2.*pow(2.,float(i))))/pow(2.,float(i)); } return sum; } float smin(float d1, float d2, float k){ float h = exp(-k * d1) + exp(-k * d2); return -log(h) / k; } vec2 rotate(vec2 i,float th) { return mat2(cos(th),-sin(th),sin(th),cos(th))*i; } float sphere(vec3 _p,float _r) { return length(_p)-_r; } float box(vec3 p,vec3 b) { vec3 d=abs(p)-b; return min(max(d.x,max(d.y,d.z)),0.)+length(max(d,0.)); } float box(vec3 p,float b){return box(p,vec3(b));} vec2 geta(vec3 p) { float dis=box(p,vec3(.4,.05,.25)); dis=min(dis,box(p+vec3(.2,.1,.0),vec3(.05,.05,.2))); dis=min(dis,box(p+vec3(-.2,.1,.0),vec3(.05,.05,.2))); return vec2(dis,0.); } vec2 shari(vec3 p) { float dis = sphere(p,.02); float ii = 0.; for( int i=0; i<26; i++ ) { ii += 1.; vec3 pt=vec3(sin(hash(ii*v.yy)*dance),sin(hash(ii*1.13*v.yy)*dance),sin(hash(ii*1.23*v.yy)*dance)); dis = smin( dis, sphere( p-pt*vec3(.17,.06,.09),.02 ), 49. ); } return vec2(dis,1.); } vec2 neta(vec3 p) { p.y+=pow(length(p.xz),2.); p.yz=rotate(p.yz,p.x*10.*sin(dance)); float dis=box(p,vec3(.22,.02,.11)); return vec2(dis,2.); } #define check if(disC.x