scene.org File Archive

File download

<root>­/­parties­/­2013­/­sundown13­/­shadertoy/1kbnoisething.txt

File size:
1 199 bytes (1.17K)
File date:
2013-09-11 23:06:04
Download count:
all-time: 169

Preview

// Lame 1k shadertoy compofiller
// By Fell ov thee RiFT
// Sundown2013 baby - mad love!

#define f float
#define r return
#define v vec3
#define N normalize

const f m=.00001,F=100.,ms=128.;
f t=iGlobalTime;

f s(v p,f g,f b){
	p*=g;
	v i=floor(p),c;
	vec4 a=dot(i,v(1,57,21))+vec4(0,57,21,78);
	c=-cos((p-i)*3.141)/2.+.5;
	a=mix(sin(cos(a)*a),sin(cos(1.+a)*(1.+a)),c.x);
	a.xy=mix(a.xz,a.yw,c.y);
	r mix(a.x,a.y,c.z)*b;
}

v P(v p,v c){
	r mod(p,c)-c/2.;
}

f h(v p){
	v p2=P(p,v(20.));
	r length(p2)-(5.+5.*sin(t/2.))+5.*s(p,.5,1.);
}

v sk(vec2 u){
	r mix(v(1.,.607,0),v(.349,.922,.882),u.y);
}

void main(){
	vec2 q=-1.+2.*gl_FragCoord.xy/iResolution.xy;
	q.x*=iResolution.x/iResolution.y;
		
	v cp=v(.1*sin(t),.5,6.*t),
	w=N(-cp),u=N(cross(v(cos(t/2.),sin(t/2.),0),w)),
	rd=N(q.x*u+q.y*N(cross(w,u))+w);	
	v p=cp,c;
	f d,E=0.,S=1.;
	for(f k=0.;k<ms;k++){
		d=h(p)-m;
		if(d<m)break;
		p+=N(rd)*d/4.;
		E=length(p-cp);
		if(E>F)break;
	}
	if(d<.8){
		d=0.;
		for(f i=0.;i<9.;i++)
			d+=h(p+v(cos(i),sin(i),-cos(i))/4.);
		c=mix(clamp(min(2.,d*d*h(p+v(.5,.5,0)*.1)*16.)*v(.5,.5,.44)*S,v(0),v(1)),sk(q),pow(E/F,2.));
	}else 
		c=sk(q);

	if(t<5.)c*=t/5.;
	gl_FragColor=vec4(c,abs(2./(E-F/2.)));
}