|
Author |
Topic: Need help blending (Read 1881 times) |
|
Ricard
|
Need help blending
« on: Apr 14th, 2005, 11:20pm » |
|
hola chavalotes!! I'm having a bit of trouble blending to BGraphics into the main pixel buffer. Can anyone help me with this?? I'm guessing that my mistake is when apply the alpha() to the BGraphics, but I tried different things and haven't got the good result. The objective is to see the to boxes in the same screen. Here is the code: Code: float[] clearZ; float fovy, aspect; float elevation, azimuth, distance; BGraphics img, img2; void setup () { size(300, 300); background(255); img = new BGraphics(width,height); img2 = new BGraphics(width,height); img.background(255); img2.background(255); img.noStroke(); img2.noStroke(); fovy = 100.0; aspect = (float) width / (float) height; distance = 200.0; elevation = radians(120); azimuth = radians(0); // make a copy of the virgin z-buffer state clearZ=new float[width*height]; System.arraycopy(g.zbuffer,0,clearZ,0,clearZ.length); } void loop() { // turn off antialiasing noSmooth(); // clear the z-buffer System.arraycopy(clearZ,0,g.zbuffer,0,clearZ.length); // draw semi-transparent background fill(255,100); rect(0,0,width,height); // Set the perspective for the BGraphics2 img.beginCamera(); img.perspective(fovy, aspect, 1.0, 1000.0); img.translate(20.0, 20.0, -distance); img.rotateX(mouseY/100.0); img.rotateZ(mouseX/100.0); img.endCamera(); // Draw background for the BGraphics2, fading img.fill(255,100); img.rect(0,0,width,height); // Draw the box for the BGraphics img.fill(255,255,0,200); img.box(50); // Set the perspective for the BGraphics2 img2.beginCamera(); img2.perspective(fovy, aspect, 1.0, 1000.0); img2.translate(0.0, 0.0, -distance); img2.rotateX(mouseY/100.0); img2.rotateY(mouseX/100.0); img2.endCamera(); // Draw background for the BGraphics2, fading img2.fill(255,150); img2.rect(0,0,width,height); // Draw the box for the BGraphics2 img2.fill(0,0,255,200); img2.box(40); // Set the alpha masks to the BGraphics //smooth(); img.alpha(img); img2.alpha(img2); // Try to blend both BGraphics into the main pixel buffer blend(img,0,0,img.width,img.height,DARKEST); blend(img2,0,0,img2.width,img2.height,DARKEST); // This one works ok, of course //image(img2,0,0,img2.width,img2.height); } |
|
|
|
|
|
|