-
Notifications
You must be signed in to change notification settings - Fork 0
/
fractal_pyramid.sttf
1 lines (1 loc) · 1.83 KB
/
fractal_pyramid.sttf
1
{"links":[{"end":"RenderOutput","filter":"Linear","slot":0,"start":"Image","wrapMode":"Repeat"}],"metadata":{"Author":"bradjamesgrant","Description":"Creating multiple shapes with one SDF evaluation by repeatedly rotating and folding space","Name":"fractal pyramid","ShaderToyURL":"https://www.shadertoy.com/view/tsXBzS"},"nodes":[{"class":"RenderOutput","name":"RenderOutput"},{"class":"GLSLShader","name":"Image","source":"vec3 palette(float d){\n\treturn mix(vec3(0.2,0.7,0.9),vec3(1.,0.,1.),d);\n}\n\nvec2 rotate(vec2 p,float a){\n\tfloat c = cos(a);\n float s = sin(a);\n return p*mat2(c,s,-s,c);\n}\n\nfloat map(vec3 p){\n for( int i = 0; i<8; ++i){\n float t = iTime*0.2;\n p.xz =rotate(p.xz,t);\n p.xy =rotate(p.xy,t*1.89);\n p.xz = abs(p.xz);\n p.xz-=.5;\n\t}\n\treturn dot(sign(p),p)/5.;\n}\n\nvec4 rm (vec3 ro, vec3 rd){\n float t = 0.;\n vec3 col = vec3(0.);\n float d;\n for(float i =0.; i<64.; i++){\n\t\tvec3 p = ro + rd*t;\n d = map(p)*.5;\n if(d<0.02){\n break;\n }\n if(d>100.){\n \tbreak;\n }\n //col+=vec3(0.6,0.8,0.8)/(400.*(d));\n col+=palette(length(p)*.1)/(400.*(d));\n t+=d;\n }\n return vec4(col,1./(d*100.));\n}\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n vec2 uv = (fragCoord-(iResolution.xy/2.))/iResolution.x;\n\tvec3 ro = vec3(0.,0.,-50.);\n ro.xz = rotate(ro.xz,iTime);\n vec3 cf = normalize(-ro);\n vec3 cs = normalize(cross(cf,vec3(0.,1.,0.)));\n vec3 cu = normalize(cross(cf,cs));\n \n vec3 uuv = ro+cf*3. + uv.x*cs + uv.y*cu;\n \n vec3 rd = normalize(uuv-ro);\n \n vec4 col = rm(ro,rd);\n \n \n fragColor = col;\n}\n\n/** SHADERDATA\n{\n\t\"title\": \"fractal pyramid\",\n\t\"description\": \"\",\n\t\"model\": \"car\"\n}\n*/\n","type":"Image"}]}