translucent blocks
@author
float W = 800;
float H = 800;
float BOX_WIDTH = 20;
void setup(){
size(500, 500, P3D);
fill(255, 50);
stroke(255, 150);
strokeWeight(2);
}
void draw(){
background(0);
translate(width / 2, height / 3, -200);
rotateX(PI / 5);
rotateZ(PI / 4);
lights();
for(float w = -W; w <= W; w += BOX_WIDTH){
for(float h = -H; h <= H; h += BOX_WIDTH){
pushMatrix();
float boxHeight = map(calcCubic(noise(w * 0.01, h * 0.01 - frameCount * 0.04, frameCount * 0.01)), 0, 1, 0, 150);
translate(w, h, boxHeight / 2);
box(BOX_WIDTH, BOX_WIDTH, boxHeight);
popMatrix();
}
}
}
float calcCubic(float v){
if(v < 0.5){
return 4.0 * v * v * v;
} else {
return 4.0 * (v - 1.0) * (v - 1.0) * (v - 1.0) + 1.0;
}
}