We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Using a shape to cut an alpha hole in another
Page Index Toggle Pages: 1
Using a shape to cut an alpha hole in another (Read 1267 times)
Using a shape to cut an alpha hole in another
Aug 10th, 2006, 10:15am
 
Hello,

I could really use some advice on the following scenario.
It's basically using shapes as compositing masks.

Idea is that Shape A is drawn to screen.
Shape B is then drawn as an alpha channel to A.  Where ever it  is solid, you reveal the background, textures or other shapes through A.

I searched around for awhile, the closest thing I could find is this discussion but it is still using a texture, not another object as the matte...

http://archives.java.sun.com/cgi-bin/wa?A2=ind0207&L=java3d-interest&P=67305

If anyone had ideas it could be a huge help...

---- processing here ----------

import processing.opengl.*;

void setup() {
 size(200, 200, OPENGL);
}

void draw() {

 background(0, 0, 200);
 
 // OBJECT A which is solid
 fill(255,255,255);
 beginShape();
 vertex(30, 20);
 vertex(85, 20);
 vertex(85, 75);
 vertex(30, 75);
 endShape();
 
 // OBJECT B which shold be a mask revealing the background
 fill(255,0,0);
 beginShape();
 vertex(40, 40);
 vertex(60, 60);
 vertex(40, 60);
 endShape();

}
Re:  Using a shape to cut an alpha hole in an
Reply #1 - Aug 10th, 2006, 12:51pm
 
Hey, just to get my head around your question...

Are you trying to do something like in this video by Zeitguised or done as realtime version in this legendary PC demo: Medium by Einklang.

Here're some reference images of the demo...

...

...
Re:  Using a shape to cut an alpha hole in an
Reply #2 - Aug 10th, 2006, 7:17pm
 
Wow that example is cool.

That one is a bit harder than what I'm trying to do, maybe it's using clipping planes to take out some of the polygons.  

In this case I don't want to punch a hole not with a 3d clipping plane, but just an alpha channel in 2d.  An that alpha is generated using polygons.

http://www.digitalartform.com/archives/2004/10/alpha_channel_a_1.html

http://www.digitalartform.com/assets/fromCG1.jpg

This shows the concept in 2d art:
http://www.luckysquirrel.com/gal_embelshmts/emgal_punc_trees.html

Hope that is more clear,
RoboHaus


Re:  Using a shape to cut an alpha hole in an
Reply #3 - Aug 10th, 2006, 7:37pm
 
Just to be more clear, I do know one way to do this: a custom fill.

Basically cycle through the pixels on the screen and see if the hit Shape A.
Do the same for Shape B.
Then cycle through Apixels, if Bpixels is on, turn Apixels off.

This will work but sucks because it will be super slow and get zero acceleration from OGL.

The ideal situation is an OGL trick to get an alpha pass over the draw.

I guess a comprimise approach would be to draw A with OGL, draw B with a custom fill and pass the alpha somehow to OGL...

Anyways I guess it's tricky...

RoboHaus
Re:  Using a shape to cut an alpha hole in an
Reply #4 - Aug 10th, 2006, 11:59pm
 
The zeitguised stuff is pretty much like what happens when you use the boolean function in 3D packages. I bought a onedotzero book and guessed that that was how he did it. I assumed he took the simple route to making something cool.

What you're suggesting by constantly referring to alpha channels is a mask.

http://processing.org/reference/PImage_mask_.html

To do that you would have to create an offscreen PGraphics object. Draw to it. Then use that PGraphics as a mask for your graphics on screen (g.mask() "g" being the object that holds the graphics being displayed in the applet). Or perhaps do all the drawing in memory and have a PGraphics mask and a PGraphics display. display.mask(). image(mask, 0, 0);

That might slow your work down a shedload.

I've looked for boolean operations on Google but can't find anything. There are numerous threads on creating PGraphics.

just my 2 cents
Re:  Using a shape to cut an alpha hole in an
Reply #5 - Aug 11th, 2006, 12:05am
 
hey toxi,

thanks for sharing that demo! wow that was awesome. not trying to derail this thread or anything, but do you have any other favorites you could share? i visit scene.org from time to time, but find the interface a bit inpenetrable for discovering cool stuff like that.

-aaron
Re:  Using a shape to cut an alpha hole in an
Reply #6 - Aug 11th, 2006, 8:51pm
 
adm, just posted a playlist over here: http://www.toxi.co.uk/blog/2006/08/my-12-favourite-demos.htm
Page Index Toggle Pages: 1