This browser has no WebGPU, so the sketch cannot run here. The program is below, and it runs in a current Chrome, Edge or Safari.
Sierpinski Sponge
Naive implementation of Sierpinski sponge
// integer grid index 0..26 per axis (UNIT coordDom; see note)
&I = flr( mlt(C, 27) );
// base-3 digit at each level; is it the center (==1)?
// removed at a level if >=2 axes are centered (sum of the vec3's lanes)
&r0 = lrg( sum( eql(mod(&I, 3), 1 )) , 1.5 );
&r1 = lrg( sum( eql(mod(flr(div(&I,3)), 3), 1 )), 1.5 );
&r2 = lrg( sum( eql(mod(flr(div(&I,9)), 3), 1 )), 1.5 );
// keep only if not removed at ANY level
&keep = mlt( sub(1,&r0), sub(1,&r1), sub(1,&r2) );
~sponge{
dim = (27,27,27); // powers of 3! (27, 81, 243) — not 128
shape = CUBE;
pos = (-0.5);
i_scl = mlt(&keep, 1); // 0 => collapsed/hidden
coord_dom = UNIT;
}
{
= (0.5);
= (1);
}