/*{
"IMPORTED": [],
"CATEGORIES": [
"normals",
"mengersponge",
"cuberaymarching",
"Automatically Converted",
"Shadertoy"
],
"DESCRIPTION": "Automatically converted from https://www.shadertoy.com/view/MsfyW4 by abje. a menger sponge",
"INPUTS": []
}
*/vec3box(vec3 p,float s){
p =max(abs(p)-s,0.0);return(p);}floatbox(vec2 p){
p =abs(p);returnmax(p.x,p.y);}vec3middle(vec3 p){float small =min(min(p.x,p.y),p.z);float large =max(max(p.x,p.y),p.z);returnvec3(lessThan(abs(p-(p.x+p.y+p.z-small-large)),vec3(0.000001)));}vec4map(vec3 p){vec3 dists =vec3(0.0);for(float i =1.0; i <5.0; i++){float num =1.0/pow(3.0,i);vec3 p2 = num-abs(mod(p+num*3.0,num*6.0)-num*3.0);
dists =max(dists,middle(p2)*p2);}float len =max(max(dists.x,dists.y),dists.z);returnvec4(dists,len);//return vec4(dists,dists.x);}voidmain(){vec2 uv =(gl_FragCoord.xy *2.0- RENDERSIZE.xy)/ RENDERSIZE.y;vec3 start =vec3(0.0,0.37,TIME*0.1);vec3 p = start;vec3 dir =vec3(uv,1.0)/max(max(abs(uv.x),abs(uv.y)),1.0);float dist =0.0;vec4 len =vec4(0.0);for(int i =0; i <100; i++){
len =map(p);if(len.w <0.001||dist >4.0){break;}
dist += len.w-0.0001;
p = start+dir*dist;}if(len.w <0.001){
gl_FragColor =vec4(vec3(equal(len.xyz,vec3(len.w))),1.0);}}
Upgrade Your Visual Performances
Join and get updates on new plugins and offerings. Your email is encrypted and never shared.