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.
Field Samplers
Different ways of sampling the same source field
////////////////////////////////////////////////////////
// sampler-variations
// Different ways of sampling the same source field.
////////////////////////////////////////////////////////
&dim = (16,16,1);
&spc = 0.55;
&time = mlt(step, 0.06125);
// initialize a source field with random values
#src {
dim = &dim;
set = rand(1,2,3);
}
// sample #src while varying the X lookup coordinate
#A {
dim = &dim;
run = #src(&time, 0);
}
// sample #src while varying the Y lookup coordinate
#B {
dim = &dim;
run = #src(0, &time);
}
// sample #src through a spatial mask (x)
#C {
dim = &dim;
run =
mlt(
#src,
sml(dst(C.x, cos(&time)), 0.125)
);
}
#D {
dim = &dim;
run =
mlt(
#src,
sml(
dst(C.xyz, 0.0),
abs(sin(mlt(step, 0.01)))
)
);
}
// add two fields together
#E{
dim = &dim;
set = #src;
run = add(#C, #D);
}
////////////////////////////////////////
// FORMATIONS
// ~src {
// col = #src;
// pos = (0, &spc, 0);
// scl = (0.25);
// }
~src {
col = #src;
pos = (-&spc, mlt(&spc,.5), 0);
scl = (0.25);
}
~A {
col = #A;
pos = (0, mlt(&spc,.5), 0);
scl = (0.25);
}
~B {
col = #B;
pos = (&spc, mlt(&spc,.5), 0);
scl = (0.25);
}
~C {
col = #C;
pos = (-&spc, mlt(&spc,-.5), 0);
scl = (0.25);
}
~D {
col = #D;
pos = (0, mlt(&spc,-.5), 0);
scl = (0.25);
}
~E {
col = #E;
pos = (&spc, mlt(&spc,-.5), 0);
scl = (0.25);
}